⼊侵排查
信息收集
cpu信息 lscpu
[root@hadoop100 ~]# lscpu Architecture: x86_64 CPU op-mode(s): 32-bit, 64-bit Byte Order: Little Endian CPU(s): 2 On-line CPU(s) list: 0,1 Thread(s) per core: 1 Core(s) per socket: 2 座: 1 NUMA 节点: 1 厂商 ID: GenuineIntel CPU 系列: 6 型号: 165 型号名称: Intel(R) Core(TM) i5-10400F CPU @ 2.90GHz 步进: 3 CPU MHz: 2904.001 BogoMIPS: 5808.00 超管理器厂商: VMware 虚拟化类型: 完全 L1d 缓存: 32K L1i 缓存: 32K L2 缓存: 256K L3 缓存: 12288K NUMA 节点0 CPU: 0,1 Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon nopl xtopology tsc_reliable nonstop_tsc eagerfpu pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch invpcid_single ssbd rsb_ctxsw ibrs ibpb stibp ibrs_enhanced fsgsbase tsc_adjust bmi1 avx2 smep bmi2 invpcid rdseed adx smap clflushopt xsaveopt xsavec xgetbv1 arat md_clear spec_ctrl intel_stibp flush_l1d arch_capabilities
操作系统 uname -a
[root@hadoop100 ~]# uname -a Linux hadoop100 3.10.0-1160.108.1.el7.x86_64 #1 SMP Thu Jan 25 16:17:31 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
当前操作系统的版本信息 cat /proc/version
[root@hadoop100 ~]# cat /proc/version Linux version 3.10.0-1160.108.1.el7.x86_64 (mockbuild@kbuilder.bsys.centos.org) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC) ) #1 SMP Thu Jan 25 16:17:31 UTC 2024
模块信息 lsmod
查看所有已载⼊系统的模块细信息。
[root@hadoop100 ~]# lsmod Module Size Used by tcp_lp 12663 0 nls_utf8 12557 1 isofs 43940 1 xt_CHECKSUM 12549 1 iptable_mangle 12695 1 ipt_MASQUERADE 12678 3 nf_nat_masquerade_ipv4 13463 1 ipt_MASQUERADE iptable_nat 12875 1 nf_nat_ipv4 14115 1 iptable_nat nf_nat 26583 2 nf_nat_ipv4,nf_nat_masquerade_ipv4 nf_conntrack_ipv4 19149 2 nf_defrag_ipv4 12729 1 nf_conntrack_ipv4 xt_conntrack 12760 1 nf_conntrack 143411 5 nf_nat,nf_nat_ipv4,xt_conntrack,nf_nat_masquerade_ipv4,nf_conntrack_ipv4 ipt_REJECT 12541 2 nf_reject_ipv4 13373 1 ipt_REJECT tun 40260 1 bridge 155432 0 stp 12976 1 bridge llc 14552 2 stp,bridge ebtable_filter 12827 0 ebtables 35009 1 ebtable_filter ip6table_filter 12815 0 ip6_tables 26912 1 ip6table_filter devlink 60067 0 iptable_filter 12810 1 vmw_vsock_vmci_transport 30620 2 vsock 40463 3 vmw_vsock_vmci_transport sunrpc 366617 1 crc32_pclmul 13133 0 ghash_clmulni_intel 13273 0 aesni_intel 189456 0 lrw 13286 1 aesni_intel gf128mul 15139 1 lrw ppdev 17671 0 glue_helper 13990 1 aesni_intel snd_seq_midi 13565 0 snd_seq_midi_event 14597 1 snd_seq_midi ablk_helper 13597 1 aesni_intel cryptd 21190 3 ghash_clmulni_intel,aesni_intel,ablk_helper vmw_balloon 18094 0 pcspkr 12718 0 joydev 17389 0 parport_pc 28205 0 parport 46395 2 ppdev,parport_pc snd_ens1371 25076 3 snd_rawmidi 31553 2 snd_ens1371,snd_seq_midi snd_ac97_codec 134575 1 snd_ens1371 ac97_bus 12730 1 snd_ac97_codec snd_seq 62774 2 snd_seq_midi_event,snd_seq_midi snd_seq_device 14356 3 snd_seq,snd_rawmidi,snd_seq_midi snd_pcm 109531 2 snd_ac97_codec,snd_ens1371 snd_timer 34110 2 snd_pcm,snd_seq snd 83987 13 snd_ac97_codec,snd_timer,snd_pcm,snd_seq,snd_rawmidi,snd_ens1371,snd_seq_device soundcore 15047 1 snd i2c_piix4 22401 0 sg 40719 0 vmw_vmci 67168 1 vmw_vsock_vmci_transport ip_tables 27126 3 iptable_filter,iptable_mangle,iptable_nat xfs 1014152 2 libcrc32c 12644 3 xfs,nf_nat,nf_conntrack sr_mod 22416 1 cdrom 46696 1 sr_mod sd_mod 46281 3 crc_t10dif 12912 1 sd_mod crct10dif_generic 12647 0 ata_generic 12923 0 pata_acpi 13053 0 nfit 59735 0 libnvdimm 163620 1 nfit vmwgfx 296089 3 drm_kms_helper 186531 1 vmwgfx syscopyarea 12529 1 drm_kms_helper sysfillrect 12701 1 drm_kms_helper crct10dif_pclmul 14307 1 crct10dif_common 12595 3 crct10dif_pclmul,crct10dif_generic,crc_t10dif sysimgblt 12640 1 drm_kms_helper fb_sys_fops 12703 1 drm_kms_helper ttm 100769 1 vmwgfx crc32c_intel 22094 1 ata_piix 35052 1 drm 468454 6 ttm,drm_kms_helper,vmwgfx mptspi 22673 2 e1000 137624 0 serio_raw 13434 0 libata 247190 3 pata_acpi,ata_generic,ata_piix scsi_transport_spi 30732 1 mptspi mptscsih 40150 1 mptspi mptbase 106036 2 mptspi,mptscsih drm_panel_orientation_quirks 17180 1 drm dm_mirror 22326 0 dm_region_hash 20813 1 dm_mirror dm_log 18411 2 dm_region_hash,dm_mirror dm_mod 128595 8 dm_log,dm_mirror fuse 100393 3
⽤户信息
查看系统所有⽤户信息 cat /etc/passwd
[root@hadoop100 ~]# cat /etc/passwd root:x:0:0:root:/root:/bin/bash bin:x:1:1:bin:/bin:/sbin/nologin daemon:x:2:2:daemon:/sbin:/sbin/nologin adm:x:3:4:adm:/var/adm:/sbin/nologin lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin sync:x:5:0:sync:/sbin:/bin/sync shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown halt:x:7:0:halt:/sbin:/sbin/halt mail:x:8:12:mail:/var/spool/mail:/sbin/nologin operator:x:11:0:operator:/root:/sbin/nologin games:x:12:100:games:/usr/games:/sbin/nologin ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin nobody:x:99:99:Nobody:/:/sbin/nologin systemd-network:x:192:192:systemd Network Management:/:/sbin/nologin dbus:x:81:81:System message bus:/:/sbin/nologin polkitd:x:999:998:User for polkitd:/:/sbin/nologin libstoragemgmt:x:998:996:daemon account for libstoragemgmt:/var/run/lsm:/sbin/nologin colord:x:997:995:User for colord:/var/lib/colord:/sbin/nologin rpc:x:32:32:Rpcbind Daemon:/var/lib/rpcbind:/sbin/nologin saned:x:996:994:SANE scanner daemon user:/usr/share/sane:/sbin/nologin saslauth:x:995:76:Saslauthd user:/run/saslauthd:/sbin/nologin abrt:x:173:173::/etc/abrt:/sbin/nologin setroubleshoot:x:994:991::/var/lib/setroubleshoot:/sbin/nologin rtkit:x:172:172:RealtimeKit:/proc:/sbin/nologin pulse:x:171:171:PulseAudio System Daemon:/var/run/pulse:/sbin/nologin radvd:x:75:75:radvd user:/:/sbin/nologin chrony:x:993:988::/var/lib/chrony:/sbin/nologin unbound:x:992:987:Unbound DNS resolver:/etc/unbound:/sbin/nologin qemu:x:107:107:qemu user:/:/sbin/nologin tss:x:59:59:Account used by the trousers package to sandbox the tcsd daemon:/dev/null:/sbin/nologin usbmuxd:x:113:113:usbmuxd user:/:/sbin/nologin geoclue:x:991:985:User for geoclue:/var/lib/geoclue:/sbin/nologin gluster:x:990:984:GlusterFS daemons:/run/gluster:/sbin/nologin gdm:x:42:42::/var/lib/gdm:/sbin/nologin rpcuser:x:29:29:RPC Service User:/var/lib/nfs:/sbin/nologin nfsnobody:x:65534:65534:Anonymous NFS User:/var/lib/nfs:/sbin/nologin gnome-initial-setup:x:989:983::/run/gnome-initial-setup/:/sbin/nologin sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin avahi:x:70:70:Avahi mDNS/DNS-SD Stack:/var/run/avahi-daemon:/sbin/nologin postfix:x:89:89::/var/spool/postfix:/sbin/nologin ntp:x:38:38::/etc/ntp:/sbin/nologin tcpdump:x:72:72::/:/sbin/nologin mk:x:1000:1000:mk:/home/mk:/bin/bash apache:x:48:48:Apache:/usr/share/httpd:/sbin/nologin mysql:x:27:27:MariaDB Server:/var/lib/mysql:/sbin/nologin
Linux操作系统上的⽤户如果需要登录主机,当其输⼊⽤户名和密码之后:
1.⾸先在/etc/passwd⽂件中查找是否有你的账号,如果没有⽆法登录,如果有的话将该⽤户的UID和GID读出来,此外将此⽤户的shell设置也⼀并读出。
2.然后根据UID到/etc/shadow⽂件中去寻找相应⽤户的密码,如果匹配⼀致
3.进⼊shell控制的阶段。
字段之间⽤ :分开.
⽤户名:密码:UID(⽤户ID):GID(组ID):描述性信息:主⽬录:默认Shell
字段 | 含义 |
---|---|
1 | ⽤户名 |
2 | ⽤户的密码原来直接存储在第⼆字段,但是为了安全,最后专⻔有了/etc/shadow⽂件,现在默认⽤x替代 |
3 | ⽤户的uid,⼀般情况下root为0,1-499默认为系统账号,有的更⼤些到1000,500-65535为⽤户的可登录账号,有的系统从1000开始。 |
4 | ⽤户的gid,linux的⽤户都会有两个ID,⼀个是⽤户uid,⼀个是⽤户组id,在我们登录的时候,输⼊⽤户名和密码,其实会先到/etc/passwd查看是否有你输⼊的账号或者⽤户名,有的话将该账号与对应的UID和GID(在/etc/group中)读出来。然后读出主⽂件夹与shell的设置,然后再去检验密码是否正确,正确的话正常登录。 |
5 | ⽤户的账号说明解释 |
6 | ⽤户的家⽬录⽂件夹 |
7 | ⽤户使⽤的shell,如果换成/sbin/nologin/就是默认没有登录环境的。 |
分析超级特权⽤户 awk -F: '{if($3==0)print $1}' /etc/passwd
可以查询登录账号UID为0的账号
[root@hadoop100 ~]# awk -F: '{if($3==0)print $1}' /etc/passwd root
查看可登录的账号 cat /etc/passwd | grep "/bin/bash"
[root@hadoop100 ~]# cat /etc/passwd | grep "/bin/bash" root:x:0:0:root:/root:/bin/bash mk:x:1000:1000:mk:/home/mk:/bin/bash
查看⽤户错误的登录信息 lastb
可查看显示⽤户错误的登录列表 包括错误的登录⽅法 、ip地址 、时间等。
[root@hadoop100 ~]# lastb root ssh:notty 192.168.1.52 Sat Apr 6 17:39 - 17:39 (00:00) root ssh:notty 192.168.1.52 Sat Apr 6 17:39 - 17:39 (00:00) root ssh:notty 192.168.1.52 Sat Apr 6 17:39 - 17:39 (00:00) root ssh:notty 192.168.1.52 Sat Apr 6 17:39 - 17:39 (00:00) root ssh:notty 192.168.1.52 Sat Apr 6 17:39 - 17:39 (00:00) root ssh:notty 192.168.1.52 Sat Apr 6 17:39 - 17:39 (00:00) root ssh:notty 192.168.1.52 Sat Apr 6 17:39 - 17:39 (00:00) root ssh:notty 192.168.1.52 Sat Apr 6 17:39 - 17:39 (00:00) root ssh:notty 192.168.1.52 Sat Apr 6 17:39 - 17:39 (00:00) root ssh:notty 192.168.1.52 Sat Apr 6 17:39 - 17:39 (00:00) root ssh:notty 192.168.1.52 Sat Apr 6 17:39 - 17:39 (00:00) root ssh:notty 192.168.1.52 Sat Apr 6 17:39 - 17:39 (00:00) root ssh:notty 192.168.1.52 Sat Apr 6 17:39 - 17:39 (00:00) root ssh:notty 192.168.1.52 Sat Apr 6 17:39 - 17:39 (00:00) root ssh:notty 192.168.1.52 Sat Apr 6 17:39 - 17:39 (00:00) root ssh:notty 192.168.1.52 Sat Apr 6 17:39 - 17:39 (00:00) root ssh:notty 192.168.1.52 Sat Apr 6 17:39 - 17:39 (00:00)
查看所有最后的登录信息 lastlog
[root@hadoop100 ~]# lastlog 用户名 端口 来自 最后登陆时间 root :0 六 4月 6 17:13:26 +0800 2024 bin **从未登录过** daemon **从未登录过** adm **从未登录过** lp **从未登录过** sync **从未登录过** shutdown **从未登录过** halt **从未登录过** mail **从未登录过** operator **从未登录过** games **从未登录过** ftp **从未登录过** nobody **从未登录过** systemd-network **从未登录过** dbus **从未登录过** polkitd **从未登录过** libstoragemgmt **从未登录过** colord **从未登录过** rpc **从未登录过** saned **从未登录过** saslauth **从未登录过** abrt **从未登录过** setroubleshoot **从未登录过** rtkit **从未登录过** pulse **从未登录过** radvd **从未登录过** chrony **从未登录过** unbound **从未登录过** qemu **从未登录过** tss **从未登录过** usbmuxd **从未登录过** geoclue **从未登录过** gluster **从未登录过** gdm :0 六 4月 6 17:12:48 +0800 2024 rpcuser **从未登录过** nfsnobody **从未登录过** gnome-initial-setup **从未登录过**
查看⽤户最近的登录信息 last
[root@hadoop100 ~]# last root pts/0 :0 Sat Apr 6 17:14 still logged in root :0 :0 Sat Apr 6 17:13 still logged in reboot system boot 3.10.0-1160.108. Sat Apr 6 17:12 - 17:42 (00:29) root pts/1 192.168.1.5 Tue Apr 2 14:49 - 15:55 (01:06) root pts/0 192.168.1.5 Tue Apr 2 14:01 - 15:55 (01:53) reboot system boot 3.10.0-1160.108. Tue Apr 2 13:59 - 17:42 (4+03:42) root pts/3 :0 Mon Apr 1 20:17 - 20:24 (00:06) root pts/2 192.168.1.5 Mon Apr 1 20:09 - 10:44 (14:35) root pts/1 :0 Mon Apr 1 20:09 - 13:09 (17:00) root pts/0 :0 Mon Apr 1 15:07 - 20:09 (05:01) root pts/0 :0 Mon Apr 1 15:01 - 15:05 (00:04) root pts/3 192.168.1.52 Fri Mar 29 20:13 - 16:17 (2+20:03) root pts/1 :0 Fri Mar 29 20:09 - 15:01 (2+18:51) root pts/0 :0 Fri Mar 29 20:09 - 15:01 (2+18:51) root :0 :0 Fri Mar 29 20:08 - down (3+17:00) reboot system boot 3.10.0-1160.108. Fri Mar 29 20:01 - 13:09 (3+17:08) root pts/0 :0 Tue Mar 26 20:59 - crash (2+23:02)
查看当前⽤户的登录情况 who
tty1 本地登录 pts 远程登录
[root@hadoop100 ~]# who root :0 2024-04-06 17:13 (:0) root pts/0 2024-04-06 17:14 (:0) root pts/1 2024-04-06 17:44 (192.168.1.52)
查看是否存在空⼝令账号 【awk -F ":" '($2==""){print $1}' /etc/shadow】
[root@hadoop100 ~]# awk -F ":" '($2==""){print $1}' /etc/shadow
影⼦⽂件 /etc/shadow
【cat /etc/shadow】 查看影⼦⽂件
[root@hadoop100 ~]# cat /etc/shadow root:$6$sNdufgNofDFf.JuY$QubgzUlOtNz3GF9oQjRsKWcy/kb8O2zLIAngfUCPZeMwCRyReJEKlUy9UtucB3EqMYaHogov4e1CXrWvnN/JN.::0:99999:7::: bin:*:18353:0:99999:7::: daemon:*:18353:0:99999:7::: adm:*:18353:0:99999:7::: lp:*:18353:0:99999:7::: sync:*:18353:0:99999:7::: shutdown:*:18353:0:99999:7::: halt:*:18353:0:99999:7::: mail:*:18353:0:99999:7::: operator:*:18353:0:99999:7::: games:*:18353:0:99999:7::: ftp:*:18353:0:99999:7::: nobody:*:18353:0:99999:7::: systemd-network:!!:19759:::::: dbus:!!:19759:::::: polkitd:!!:19759:::::: libstoragemgmt:!!:19759:::::: colord:!!:19759:::::: rpc:!!:19759:0:99999:7::: saned:!!:19759:::::: saslauth:!!:19759:::::: abrt:!!:19759:::::: setroubleshoot:!!:19759:::::: rtkit:!!:19759:::::: pulse:!!:19759:::::: radvd:!!:19759:::::: chrony:!!:19759:::::: unbound:!!:19759:::::: qemu:!!:19759:::::: tss:!!:19759:::::: usbmuxd:!!:19759:::::: geoclue:!!:19759:::::: gluster:!!:19759:::::: gdm:!!:19759:::::: rpcuser:!!:19759:::::: nfsnobody:!!:19759:::::: gnome-initial-setup:!!:19759:::::: sshd:!!:19759:::::: avahi:!!:19759:::::: postfix:!!:19759:::::: ntp:!!:19759:::::: tcpdump:!!:19759:::::: mk:$6$017JiB5XUy9hCmYD$cYmsvKJXKG1esGQo57Rx0kYC6tf6RE4J71AMR2yDUs/JMjyiiLfyMUBci66SMsASA6gaCOCbONhygV6JymnRY/::0:99999:7::: apache:!!:19795:::::: mysql:!!:19795::::::
/etc/shadow ⽂件,⽤于存储 Linux 系统中⽤户的密码信息,⼜称为“影⼦⽂件”。
/etc/shadow ⽂件只有 root ⽤户拥有读权限,其他⽤户没有任何权限,这样就保证了⽤户密码的安全性。
同 /etc/passwd ⽂件⼀样,⽂件中每⾏代表⼀个⽤户,同样使⽤ ":" 作为分隔符,不同之处在于,每⾏⽤户信息被划分为 9 个字段。每个字段的含义如下:
⽤户名:加密密码:最后⼀次修改时间:最⼩修改时间间隔:密码有效期:密码需要变更前的警告天数:密码过期后的宽限时间:账号失效时间:保留字段
计划任务
在linu系统中,计划任务也是维持权限和远程下载恶意软件的⼀种⼿段。⼀般有以下两种⽅法查看计划任务。
【crontab -l】查看当前的计划任务
[root@hadoop100 ~]# crontab -l no crontab for root
【crontab -u root -l 】查看指定⽤户的计划⽤户
[root@hadoop100 ~]# crontab -u root -l no crontab for root
查看etc⽬录下的计划⽂件
⼀般在linux系统中的任务计划⽂件都是以cron开头的。可以使⽤利⽤正则表表达式的*筛选出/etc⽬录下
所有以cron开头的⽂件 【 ls /etc/cron*】
[root@hadoop100 ~]# ls /etc/cron* /etc/cron.deny /etc/crontab /etc/cron.d: 0hourly raid-check sysstat /etc/cron.daily: logrotate man-db.cron mlocate /etc/cron.hourly: 0anacron mcelog.cron /etc/cron.monthly: /etc/cron.weekly:
服务排查
查看运⾏的服务 chkconfig --list
[root@hadoop100 ~]# chkconfig --list 注:该输出结果只显示 SysV 服务,并不包含 原生 systemd 服务。SysV 配置数据 可能被原生 systemd 配置覆盖。 要列出 systemd 服务,请执行 'systemctl list-unit-files'。 查看在具体 target 启用的服务请执行 'systemctl list-dependencies [target]'。 netconsole 0:关 1:关 2:关 3:关 4:关 5:关 6:关 network 0:关 1:关 2:开 3:开 4:开 5:开 6:关 [root@hadoop100 ~]#
0,1,2,3,4,5,6表示的是等级
0.表示 关机
1表示:单⽤户模式
2表示:⽆⽹络连接的多⽤户命令⾏模式
3表示:有⽹络连接的多⽤户命令⾏模式
4表示:不可⽤
5表示:带图形界⾯的多⽤户模式
6表示:重新启动
查看所有服务的状态 【service --status-all】
[root@hadoop100 ~]# service --status-all 未加载 netconsole 模块 已配置设备: lo ens33 当前活跃设备: lo ens33 virbr0
查看⾃启动列表
systemctl list-unit-files以及设置服务⾃启动
[root@hadoop100 ~]# systemctl list-unit-files --type service UNIT FILE STATE abrt-ccpp.service enabled abrt-oops.service enabled abrt-pstoreoops.service disabled abrt-vmcore.service enabled abrt-xorg.service enabled abrtd.service enabled accounts-daemon.service enabled alsa-restore.service static alsa-state.service static anaconda-direct.service static anaconda-nm-config.service static anaconda-noshell.service static anaconda-pre.service static anaconda-shell@.service static anaconda-sshd.service static anaconda-tmux@.service static anaconda.service static arp-ethers.service disabled atd.service enabled auditd.service enabled auth-rpcgss-module.service static autovt@.service enabled avahi-daemon.service enabled blk-availability.service enabled bluetooth.service enabled bolt.service static brandbot.service static brltty.service disabled canberra-system-bootup.service disabled canberra-system-shutdown-reboot.service disabled canberra-system-shutdown.service disabled chrony-dnssrv@.service static chrony-wait.service disabled chronyd.service enabled clean-mount-point@.service static colord.service static configure-printer@.service static console-getty.service disabled console-shell.service disabled container-getty@.service static cpupower.service disabled crond.service enabled cups-browsed.service disabled
enabled:这个daemon将在开机时被执⾏; disabled:这个daemon在开机时不会被执⾏; static:这个daemon不可以⾃⼰启动(enable不可),不过可能会被其他的enabled 的服务来唤 醒(关联属性的服务); mask:这个daemon⽆论如何都⽆法被启动,因为已经被强制注销(⾮删除),可通过systemctlunm ask⽅式改回原本状态;
关闭和启动服务
sudo systemctl stop xxx.service //停⽌服务 sudo systemctl disable xxx.service //禁⽌服务开机启动 sudo systemctl start xxx.service //启动服务 sudo systemctl enable xxx.service //开机启动服务
开机⽂件启动项
[root@hadoop100 ~]# ls -al /etc/rc.local lrwxrwxrwx. 1 root root 13 2月 6 13:39 /etc/rc.local -> rc.d/rc.local
/etc/rc.local 是 /etc/rc.d/rc.local的软连接 有⼀些恶意病毒会把命令放在 这个⽂件内 开机的时候进⾏启动
[root@hadoop100 ~]# cat /etc/rc.d/rc.local #!/bin/bash # THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES # # It is highly advisable to create own systemd services or udev rules # to run scripts during boot instead of using this file. # # In contrast to previous versions due to parallel execution during boot # this script will NOT be run after all other services. # # Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure # that this script will be executed during boot. touch /var/lock/subsys/local
【 ls -alh /etc/init.d/】或【ls -al /etc/rc.d/init.d/】
[root@hadoop100 ~]# ls -alh /etc/init.d/ 总用量 40K drwxr-xr-x. 2 root root 70 2月 6 13:40 . drwxr-xr-x. 10 root root 127 11月 17 2020 .. -rw-r--r--. 1 root root 18K 5月 22 2020 functions -rwxr-xr-x. 1 root root 4.5K 5月 22 2020 netconsole -rwxr-xr-x. 1 root root 7.8K 5月 22 2020 network -rw-r--r--. 1 root root 1.2K 12月 7 22:51 README
ls /etc/rc*.d/
init.d rc0.d rc1.d rc2.d rc3.d rc4.d rc5.d rc6.d rc.local
rc0: 停机(不能使⽤) rc1: 单⽤户模式 rc2: 多⽤户模式,但是没有NFS rc3: 完全多⽤户模式 rc4: 没有使⽤,系统预留 rc5: 图形界⾯模式 rc6: 重启模式(不能使⽤)
敏感⽬录
/tmp⽬录 和命令⽬录 /usr/bin /usr/bin等经常作为恶意软件的下载⽬录及关键⽂件被替换的⽬录
~/.ssh 和 /etc/ssh 也经常作为⼀些后⻔配置的路径,需要重点检测
⽂件排查
通过列出攻击⽇期内变动的⽂件,可发现相关的恶意软件。通过【find】命令可对某⼀时间段新增的⽂件
进⾏查找。
find 指定⽬录下查找⽂件
-type b/d/c/p/l/f 查找块 设备、⽬录、字符设备、管道、符号连接、普通⽂件。
-mtime -n +n 按⽂件更改时间来查找⽂件 -n 指 n天以内 +n指n天前
-atime -n +n 按⽂件访问时间来查找⽂件 -n 指 n天以内 +n 指 n天前
-ctime -n +n 按⽂件的创建时间来查找⽂件 -n 指 n天以内 +n 指 n天前
使⽤命令 【find /tmp -ctime 0 -name "*.txt"】可以查找⼀天内的新增的sh⽂件
[root@hadoop100 ~]# find /tmp -ctime 0 -name "*.txt"
查看指定⽬录 也可以对⽂件时间进⾏排序
【ls -alt | head -n 10】 查看排序后前得10⾏内容
[root@hadoop100 ~]# ls -alt | head -n 10 总用量 12164 -rw-------. 1 root root 3914 4月 6 17:59 .bash_history dr-xr-x---. 17 root root 4096 4月 6 17:13 . -rw-------. 1 root root 1860 4月 6 17:13 .ICEauthority drwxr-xr-x 2 1001 127 79 4月 2 15:55 frp_0.56.0_linux_amd64 -rw------- 1 root root 110 4月 2 14:49 .Xauthority -rw-r--r-- 1 root root 12393840 4月 2 14:16 frp_0.56.0_linux_amd64.tar.gz drwx------. 15 root root 4096 4月 2 08:39 .cache drwxr-xr-x 4 root root 39 4月 2 08:39 .mozilla drwx------ 2 root root 61 3月 29 20:10 .ssh
对⽂件的创建时间、修改时间、访问时间进⾏排查
若修改的时间去应急响应时间的⽇期接近,有线性关联,说明有可能被篡改
使⽤ 【 stat phpinfo.php】查询时间信息
[root@hadoop100 ~]# stat phpinfo.php
特殊⽂件
linux系统中的有的⽂件存在特定的设置,特定的关键词信息等。linux系统中的⼏种特殊⽂件类型可以按照以下⽅法进⾏排查特殊权限⽂件查找 恶意攻击者经常会在tmp⽬录下 上传 下载恶意⽂件 使⽤ 【find /tmp -perm 777】
[root@hadoop100 html]# find /var/www/html -perm 777 /var/www/html/test.php
指定关键字查找内容 ⽹站被攻⼊之后 攻击者会上传⼀些恶意脚本 可以使⽤关键⼦查询 将这些脚本寻找出来。
【find /var/www/html -name "*.php" 】 将查找这个⽬录的php⽂件
对系统命令进⾏排查 【ls】和【ps】 等命令可能被攻击 可以使⽤命令【ls -alt /bin】查看相关命令的修改时间。
[root@hadoop100 html]# ls -alt /bin lrwxrwxrwx. 1 root root 7 2月 6 13:21 /bin -> usr/bin
也可以使⽤【ls -alh】查询⽂件的⼤⼩ 被替换的⽂件⼤⼩⼤多数都是不⼀致。
[root@hadoop100 ~]# ls -alh 总用量 12M dr-xr-x---. 17 root root 4.0K 4月 6 18:11 . dr-xr-xr-x. 17 root root 244 3月 22 15:31 .. -rw-------. 1 root root 1.9K 2月 6 13:27 anaconda-ks.cfg -rw-------. 1 root root 3.9K 4月 6 17:59 .bash_history -rw-r--r--. 1 root root 18 12月 29 2013 .bash_logout -rw-r--r--. 1 root root 176 12月 29 2013 .bash_profile -rw-r--r--. 1 root root 176 12月 29 2013 .bashrc drwx------. 15 root root 4.0K 4月 2 08:39 .cache drwxr-xr-x. 14 root root 261 2月 6 13:30 .config -rw-r--r--. 1 root root 100 12月 29 2013 .cshrc drwx------. 3 root root 25 2月 6 13:28 .dbus -rw-------. 1 root root 16 2月 6 13:29 .esd_auth drwxr-xr-x 2 1001 127 79 4月 2 15:55 frp_0.56.0_linux_amd64 -rw-r--r-- 1 root root 12M 4月 2 14:16 frp_0.56.0_linux_amd64.tar.gz -rw-------. 1 root root 1.9K 4月 6 17:13 .ICEauthority -rw-r--r--. 1 root root 2.0K 2月 6 13:28 initial-setup-ks.cfg drwx------. 3 root root 19 2月 6 13:29 .local drwxr-xr-x 4 root root 39 4月 2 08:39 .mozilla -rw------- 1 root root 81 3月 26 21:00 .mysql_history
排查suid程序 对于⼀些设置了suid权限的程序进程排查 可以使⽤【 find / -type f -perm -04000 -ls-uid 0 2>/dev/null】
[root@hadoop100 ~]# find / -type f -perm -04000 -ls -uid 0 2>/dev/null 50435637 32 -rwsr-xr-x 1 root root 32096 10月 31 2018 /usr/bin/fusermount 50492432 24 -rws--x--x 1 root root 23968 2月 3 2021 /usr/bin/chfn 50492435 24 -rws--x--x 1 root root 23880 2月 3 2021 /usr/bin/chsh 51108965 76 -rwsr-xr-x 1 root root 73888 8月 9 2019 /usr/bin/chage 51108966 80 -rwsr-xr-x 1 root root 78408 8月 9 2019 /usr/bin/gpasswd 51108969 44 -rwsr-xr-x 1 root root 41936 8月 9 2019 /usr/bin/newgrp 51109091 208 ---s--x--- 1 root stapusr 212080 10月 14 2020 /usr/bin/staprun 51072255 28 -rwsr-xr-x 1 root root 27856 4月 1 2020 /usr/bin/passwd 51125995 32 -rwsr-xr-x 1 root root 32128 2月 3 2021 /usr/bin/su 51125980 44 -rwsr-xr-x 1 root root 44264 2月 3 2021 /usr/bin/mount 51125999 32 -rwsr-xr-x 1 root root 31984 2月 3 2021 /usr/bin/umount 51133886 28 -rwsr-xr-x 1 root root 27672 1月 26 2022 /usr/bin/pkexec 51220857 60 -rwsr-xr-x 1 root root 57576 5月 16 2023 /usr/bin/crontab 51309105 2392 -rwsr-xr-x 1 root root 2447256 1月 25 23:56 /usr/bin/Xorg 51797496 52 -rwsr-xr-x 1 root root 52968 5月 18 2022 /usr/bin/at 51427293 148 ---s--x--x 1 root root 151424 1月 26 2023 /usr/bin/sudo 1170819 36 -rwsr-xr-x 1 root root 36272 4月 1 2020 /usr/sbin/unix_chkpwd 1170817 12 -rwsr-xr-x 1 root root 11232 4月 1 2020 /usr/sbin/pam_timestamp_check 1377340 12 -rwsr-xr-x 1 root root 11296 11月 17 2020 /usr/sbin/usernetctl 1526218 40 -rws--x--x 1 root root 40328 8月 9 2019 /usr/sbin/userhelper 1675606 116 -rwsr-xr-x 1 root root 117432 10月 14 2021 /usr/sbin/mount.nfs 51141440 16 -rwsr-xr-x 1 root root 15432 1月 26 2022 /usr/lib/polkit-1/polkit-agent-helper-1 51406810 16 -rwsr-xr-x 1 root root 15360 5月 19 2022 /usr/libexec/qemu-bridge-helper 51133873 60 -rwsr-x--- 1 root dbus 57936 9月 30 2020 /usr/libexec/dbus-1/dbus-daemon-launch-helper 51309054 16 -rwsr-sr-x 1 abrt abrt 15344 10月 2 2020 /usr/libexec/abrt-action-install-debuginfo-to-abrt-cache 51411208 56 -rwsr-xr-x 1 root root 53792 11月 2 2021 /usr/libexec/flatpak-bwrap 17509556 16 -rwsr-xr-x 1 root root 15440 11月 5 2020 /usr/libexec/spice-gtk-x86_64/spice-client-glib-usb-acl-helper
切换⽤户 执⾏命令
[root@hadoop100 ~]# su mk [mk@hadoop100 root]$ find `which find` -exec whoami \; root
隐藏⽂件
攻击者在获取服务器权限后,会通过⼀些技巧来隐藏⾃⼰的踪迹和后⻔⽂件,介绍Linux下的⼏种隐藏技术。
1.创建隐藏⽂件
touch .moon.txt 在⽂件前⾯加上点就是隐藏⽂件 使⽤ ls ⽆法查看 要使⽤ls -al 查看
[root@hadoop100 ~]# touch .moon.txt [root@hadoop100 ~]# ls anaconda-ks.cfg frp_0.56.0_linux_amd64.tar.gz 公共 视频 文档 音乐 frp_0.56.0_linux_amd64 initial-setup-ks.cfg 模板 图片 下载 桌面 [root@hadoop100 ~]# ls -al 总用量 12168 dr-xr-x---. 17 root root 4096 4月 6 18:19 . dr-xr-xr-x. 17 root root 244 3月 22 15:31 .. -rw-------. 1 root root 1938 2月 6 13:27 anaconda-ks.cfg -rw-------. 1 root root 4208 4月 6 18:19 .bash_history -rw-r--r--. 1 root root 18 12月 29 2013 .bash_logout -rw-r--r--. 1 root root 176 12月 29 2013 .bash_profile -rw-r--r--. 1 root root 176 12月 29 2013 .bashrc drwx------. 15 root root 4096 4月 2 08:39 .cache drwxr-xr-x. 14 root root 261 2月 6 13:30 .config -rw-r--r--. 1 root root 100 12月 29 2013 .cshrc drwx------. 3 root root 25 2月 6 13:28 .dbus -rw-------. 1 root root 16 2月 6 13:29 .esd_auth drwxr-xr-x 2 1001 127 79 4月 2 15:55 frp_0.56.0_linux_amd64 -rw-r--r-- 1 root root 12393840 4月 2 14:16 frp_0.56.0_linux_amd64.tar.gz -rw-------. 1 root root 1860 4月 6 17:13 .ICEauthority -rw-r--r--. 1 root root 1986 2月 6 13:28 initial-setup-ks.cfg drwx------. 3 root root 19 2月 6 13:29 .local -rw-r--r-- 1 root root 0 4月 6 18:19 .moon.txt drwxr-xr-x 4 root root 39 4月 2 08:39 .mozilla -rw------- 1 root root 81 3月 26 21:00 .mysql_history
2.隐藏创建时间
Unix 下藏后⻔必须要修改时间,否则很容易被发现,直接利⽤ touch 就可以了
⽐如参考 index.php 的时间,再赋给 webshell.php,结果两个⽂件的时间就⼀样了。
查看时间格式
ls -l --time-style '+%Y/%m/%d %H:%M:%S'
利⽤⽅法
touch -r index.php webshell.php
或者直接将时间戳修改成某年某⽉某⽇。如下 2014 年 01 ⽉ 02 ⽇。
touch -t 1401021042.30 webshell.php
[root@hadoop100 ~]# touch -r index.html webshell.php [root@hadoop100 ~]# ls -al 总用量 68 dr-xr-x---. 16 root root 4096 4月 6 18:25 . dr-xr-xr-x. 17 root root 244 3月 22 15:31 .. -rw-------. 1 root root 1938 2月 6 13:27 anaconda-ks.cfg -rw-------. 1 root root 4208 4月 6 18:19 .bash_history -rw-r--r--. 1 root root 18 12月 29 2013 .bash_logout -rw-r--r--. 1 root root 176 12月 29 2013 .bash_profile -rw-r--r--. 1 root root 176 12月 29 2013 .bashrc drwx------. 15 root root 4096 4月 2 08:39 .cache drwxr-xr-x. 14 root root 261 2月 6 13:30 .config -rw-r--r--. 1 root root 100 12月 29 2013 .cshrc drwx------. 3 root root 25 2月 6 13:28 .dbus -rw-------. 1 root root 16 2月 6 13:29 .esd_auth -rw-------. 1 root root 1860 4月 6 17:13 .ICEauthority -rw-r--r-- 1 root root 6 4月 6 18:24 index.html -rw-r--r--. 1 root root 1986 2月 6 13:28 initial-setup-ks.cfg drwx------. 3 root root 19 2月 6 13:29 .local -rw-r--r-- 1 root root 0 4月 6 18:19 .moon.txt drwxr-xr-x 4 root root 39 4月 2 08:39 .mozilla -rw------- 1 root root 81 3月 26 21:00 .mysql_history drwx------ 2 root root 61 3月 29 20:10 .ssh -rw-r--r--. 1 root root 129 12月 29 2013 .tcshrc -rw------- 1 root root 1661 3月 22 16:58 .viminfo -rw-r--r-- 1 root root 0 4月 6 18:24 webshell.php -rw------- 1 root root 110 4月 6 18:11 .Xauthority
创建⽂件修改时间
touch -t 201812120800.00 webshell.php
可以看到这个参数是按指定时间修改⽂件的访问时间,其他时间没有更新。
[[CC]YY]MMDDhhmm[.ss]
[]代表可有可⽆。
CC是年的前两位:如2021年的 20
YY是年的后两位:如2021年的 21
MM代表⽉份:如 12
DD代表⽇期:如 12
hh代表⼩时:如 08
mm代表分钟:如 00
ss代表秒:如 00
3.隐藏权限
在Linux中,使⽤chattr命令来防⽌root和其他管理⽤户误删除和修改重要⽂件及⽬录,此权限⽤ls -l是
查看不出来的,
从⽽达到隐藏权限的⽬的。
chattr +i webshell.php 锁定⽂件
lsattr webshell.php 属性查看
chattr -i webshell.php 解除锁定
rm -rf 1.webshell.php 删除⽂件
后⻔检测
可以使⽤第三⽅查杀⼯具例如(chkrootkit、rkhunterr)等进⾏查杀
系统资源分析
多个⽤户登录 【uptime】查看连接情况
[root@hadoop100 ~]# uptime 18:34:34 up 1:22, 4 users, load average: 0.00, 0.01, 0.05
查看内存分配【free】
[root@hadoop100 ~]# free total used free shared buff/cache available Mem: 2027680 936296 90696 37720 1000688 865620 Swap: 2097148 520 2096628
检测系统上挂载 情况 【cat /proc/mounts】 是否存在未知挂载
[root@hadoop100 ~]# cat /proc/mounts sysfs /sys sysfs rw,nosuid,nodev,noexec,relatime 0 0 proc /proc proc rw,nosuid,nodev,noexec,relatime 0 0 devtmpfs /dev devtmpfs rw,nosuid,size=996880k,nr_inodes=249220,mode=755 0 0 securityfs /sys/kernel/security securityfs rw,nosuid,nodev,noexec,relatime 0 0 tmpfs /dev/shm tmpfs rw,nosuid,nodev 0 0 devpts /dev/pts devpts rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000 0 0 tmpfs /run tmpfs rw,nosuid,nodev,mode=755 0 0 tmpfs /sys/fs/cgroup tmpfs ro,nosuid,nodev,noexec,mode=755 0 0 cgroup /sys/fs/cgroup/systemd cgroup rw,nosuid,nodev,noexec,relatime,xattr,release_agent=/usr/lib/systemd/systemd-cgroups-agent,name=systemd 0 0 pstore /sys/fs/pstore pstore rw,nosuid,nodev,noexec,relatime 0 0 cgroup /sys/fs/cgroup/net_cls,net_prio cgroup rw,nosuid,nodev,noexec,relatime,net_prio,net_cls 0 0 cgroup /sys/fs/cgroup/cpu,cpuacct cgroup rw,nosuid,nodev,noexec,relatime,cpuacct,cpu 0 0 cgroup /sys/fs/cgroup/pids cgroup rw,nosuid,nodev,noexec,relatime,pids 0 0 cgroup /sys/fs/cgroup/devices cgroup rw,nosuid,nodev,noexec,relatime,devices 0 0 cgroup /sys/fs/cgroup/blkio cgroup rw,nosuid,nodev,noexec,relatime,blkio 0 0 cgroup /sys/fs/cgroup/hugetlb cgroup rw,nosuid,nodev,noexec,relatime,hugetlb 0 0 cgroup /sys/fs/cgroup/perf_event cgroup rw,nosuid,nodev,noexec,relatime,perf_event 0 0 cgroup /sys/fs/cgroup/cpuset cgroup rw,nosuid,nodev,noexec,relatime,cpuset 0 0 cgroup /sys/fs/cgroup/memory cgroup rw,nosuid,nodev,noexec,relatime,memory 0 0 cgroup /sys/fs/cgroup/freezer cgroup rw,nosuid,nodev,noexec,relatime,freezer 0 0 configfs /sys/kernel/config configfs rw,relatime 0 0 /dev/mapper/centos-root / xfs rw,relatime,attr2,inode64,noquota 0 0 systemd-1 /proc/sys/fs/binfmt_misc autofs rw,relatime,fd=32,pgrp=1,timeout=0,minproto=5,maxproto=5,direct,pipe_ino=14541 0 0 debugfs /sys/kernel/debug debugfs rw,relatime 0 0 mqueue /dev/mqueue mqueue rw,relatime 0 0 fusectl /sys/fs/fuse/connections fusectl rw,relatime 0 0 hugetlbfs /dev/hugepages hugetlbfs rw,relatime 0 0 /dev/sda1 /boot xfs rw,relatime,attr2,inode64,noquota 0 0 sunrpc /var/lib/nfs/rpc_pipefs rpc_pipefs rw,relatime 0 0 tmpfs /run/user/0 tmpfs rw,nosuid,nodev,relatime,size=202768k,mode=700 0 0 gvfsd-fuse /run/user/0/gvfs fuse.gvfsd-fuse rw,nosuid,nodev,relatime,user_id=0,group_id=0 0 0 /dev/sr0 /run/media/root/CentOS\0407\040x86_64 iso9660 ro,nosuid,nodev,relatime,uid=0,gid=0,iocharset=utf8,dmode=0500,mode=0400 0 0 binfmt_misc /proc/sys/fs/binfmt_misc binfmt_misc rw,relatime 0 0
进程信息
top命令是linux下常⽤的内存分析管理⼯具,能够实时显示系统中各个进程的资源的占⽤状况,类似于windows的任务管理器
[root@hadoop100 ~]# top top - 18:38:22 up 1:25, 4 users, load average: 0.08, 0.04, 0.05 Tasks: 220 total, 1 running, 219 sleeping, 0 stopped, 0 zombie %Cpu(s): 6.3 us, 2.7 sy, 0.0 ni, 90.8 id, 0.0 wa, 0.0 hi, 0.2 si, 0.0 st KiB Mem : 2027680 total, 89800 free, 936984 used, 1000896 buff/cache KiB Swap: 2097148 total, 2096628 free, 520 used. 864936 avail Mem PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 2301 root 20 0 3540552 218424 70752 S 10.0 10.8 1:22.20 gnome-shell 1620 root 20 0 359184 69404 39036 S 7.3 3.4 0:41.67 X 3550 root 20 0 698928 32884 19152 S 2.7 1.6 0:09.37 gnome-terminal- 728 root 20 0 479628 9532 7084 S 1.0 0.5 0:03.36 NetworkManager 2422 root 20 0 559532 5252 4032 S 0.7 0.3 0:01.45 gsd-sharing 1 root 20 0 191420 4432 2656 S 0.3 0.2 0:02.68 systemd 9 root 20 0 0 0 0 S 0.3 0.0 0:01.92 rcu_sched 506 root 20 0 39444 5248 4600 S 0.3 0.3 0:01.23 systemd-journal 715 dbus 20 0 62720 4184 1884 S 0.3 0.2 0:02.07 dbus-daemon 729 root 20 0 90672 3240 2368 S 0.3 0.2 0:02.63 rngd 753 avahi 20 0 62268 2292 1832 S 0.3 0.1 0:02.05 avahi-daemon 1112 root 20 0 369120 14316 8624 S 0.3 0.7 0:00.59 httpd 2556 root 20 0 608648 25500 18816 S 0.3 1.3 0:07.02 vmtoolsd 5510 root 20 0 162104 2388 1596 R 0.3 0.1 0:00.09 top 2 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kthreadd 4 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kworker/0:0H 5 root 20 0 0 0 0 S 0.0 0.0 0:00.34 kworker/u256:0 6 root 20 0 0 0 0 S 0.0 0.0 0:00.44 ksoftirqd/0 7 root rt 0 0 0 0 S 0.0 0.0 0:00.04 migration/0 8 root 20 0 0 0 0 S 0.0 0.0 0:00.00 rcu_bh 10 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 lru-add-drain 11 root rt 0 0 0 0 S 0.0 0.0 0:00.04 watchdog/0 12 root rt 0 0 0 0 S 0.0 0.0 0:00.03 watchdog/1 13 root rt 0 0 0 0 S 0.0 0.0 0:00.02 migration/1 14 root 20 0 0 0 0 S 0.0 0.0 0:00.23 ksoftirqd/1 16 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kworker/1:0H 18 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kdevtmpfs 19 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 netns 20 root 20 0 0 0 0 S 0.0 0.0 0:00.00 khungtaskd 21 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 writeback 22 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kintegrityd 23 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 bioset 24 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 bioset
PID:进程id USER:进程所有者的⽤户名 PR:优先级 NI:谦让度值。负值表示⾼优先级,正值表示低优先级 VIRT:进程使⽤的虚拟内存总量,单位kb RES:进程使⽤的物理内存⼤⼩,单位kb SHR:共享内存⼤⼩,单位kb S:进程状态 %CPU:上次更新到现在的CPU时间占⽤百分⽐ %MEM:进程使⽤的物理内存百分⽐ TIME+:进程使⽤的CPU时间总计,单位1/100秒
查看进程树
pstree -p
-p 显示进程PID
-u 显示进程的所属⽤户
[root@hadoop100 ~]# pstree -p systemd(1)─┬─ModemManager(740)─┬─{ModemManager}(783) │ └─{ModemManager}(787) ├─NetworkManager(728)─┬─{NetworkManager}(798) │ └─{NetworkManager}(801) ├─VGAuthService(742) ├─abrt-watch-log(747) ├─abrt-watch-log(763) ├─abrtd(746) ├─accounts-daemon(709)─┬─{accounts-daemon}(716) │ └─{accounts-daemon}(726) ├─alsactl(741) ├─at-spi-bus-laun(2265)─┬─dbus-daemon(2270) │ ├─{at-spi-bus-laun}(2266) │ ├─{at-spi-bus-laun}(2267) │ └─{at-spi-bus-laun}(2269) ├─at-spi2-registr(2273)─┬─{at-spi2-registr}(2275) │ └─{at-spi2-registr}(2278) ├─atd(1117) ├─auditd(684)─┬─audispd(686)─┬─sedispatch(688) │ │ └─{audispd}(689) │ └─{auditd}(685) ├─avahi-daemon(753)───avahi-daemon(761) ├─boltd(1941)─┬─{boltd}(1945) │ └─{boltd}(1947) ├─chronyd(777) ├─colord(2025)─┬─{colord}(2029) │ └─{colord}(2031) ├─crond(1118) ├─cupsd(1099) ├─dbus-daemon(2132) ├─dbus-daemon(715) ├─dbus-launch(2131) ├─dconf-service(2349)─┬─{dconf-service}(2350) │ └─{dconf-service}(2351) ├─dnsmasq(1763)───dnsmasq(1764) ├─evolution-addre(2576)─┬─evolution-addre(2588)─┬─{evolution-addre}(2597) │ │ ├─{evolution-addre}(2599) │ │ ├─{evolution-addre}(2600) │ │ ├─{evolution-addre}(2601) │ │ └─{evolution-addre}(2603) │ ├─{evolution-addre}(2577) │ ├─{evolution-addre}(2578) │ ├─{evolution-addre}(2581) │ └─{evolution-addre}(2582) ├─evolution-calen(2529)─┬─evolution-calen(2554)─┬─{evolution-calen}(2561) │ │ ├─{evolution-calen}(2562) │ │ ├─{evolution-calen}(2563) │ │ ├─{evolution-calen}(2565) │ │ ├─{evolution-calen}(2569) │ │ ├─{evolution-calen}(2571) │ │ ├─{evolution-calen}(2572) │ │ └─{evolution-calen}(2575) │ ├─{evolution-calen}(2532) │ ├─{evolution-calen}(2533) │ ├─{evolution-calen}(2545) │ └─{evolution-calen}(2546) ├─evolution-sourc(2367)─┬─{evolution-sourc}(2370) │ ├─{evolution-sourc}(2371) │ └─{evolution-sourc}(2372) ├─fwupd(2709)─┬─{fwupd}(2718) │ ├─{fwupd}(2719) │ ├─{fwupd}(2720) │ └─{fwupd}(2721) ├─gdm(1119)─┬─X(1620)─┬─{X}(1786) │ │ ├─{X}(1787) │ │ └─{X}(1792) │ ├─gdm-session-wor(2087)─┬─gnome-session-b(2122)─┬─abrt-applet(2579)─┬─{abrt+ │ │ │ │ └─{abrt+ │ │ │ ├─gnome-shell(2301)─┬─ibus-+ │ │ │ │ ├─{gnom+ │ │ │ │ ├─{gnom+ │ │ │ │ ├─{gnom+ │ │ │ │ ├─{gnom+ │ │ │ │ ├─{gnom+ │ │ │ │ ├─{gnom+ │ │ │ │ ├─{gnom+ │ │ │ │ ├─{gnom+ │ │ │ │ ├─{gnom+ │ │ │ │ ├─{gnom+ │ │ │ │ ├─{gnom+ │ │ │ │ ├─{gnom+ │ │ │ │ ├─{gnom+ │ │ │ │ └─{gnom+ │ │ │ ├─gnome-software(2580)─┬─{g+ │ │ │ │ ├─{g+ │ │ │ │ └─{g+ │ │ │ ├─gsd-a11y-settin(2454)─┬─{+ │ │ │ │ ├─{+ │ │ │ │ └─{+ │ │ │ ├─gsd-account(2440)─┬─{gsd-+ │ │ │ │ ├─{gsd-+ │ │ │ │ └─{gsd-+ │ │ │ ├─gsd-clipboard(2455)─┬─{gs+ │ │ │ │ └─{gs+ │ │ │ ├─gsd-color(2457)─┬─{gsd-co+ │ │ │ │ ├─{gsd-co+ │ │ │ │ └─{gsd-co+ │ │ │ ├─gsd-datetime(2458)─┬─{gsd+ │ │ │ │ ├─{gsd+ │ │ │ │ └─{gsd+ │ │ │ ├─gsd-disk-utilit(2557)─┬─{+ │ │ │ │ └─{+ │ │ │ ├─gsd-housekeepin(2467)─┬─{+ │ │ │ │ ├─{+ │ │ │ │ └─{+ │ │ │ ├─gsd-keyboard(2471)─┬─{gsd+ │ │ │ │ ├─{gsd+ │ │ │ │ └─{gsd+ │ │ │ ├─gsd-media-keys(2472)─┬─{g+ │ │ │ │ ├─{g+ │ │ │ │ └─{g+ │ │ │ ├─gsd-mouse(2474)─┬─{gsd-mo+ │ │ │ │ ├─{gsd-mo+ │ │ │ │ └─{gsd-mo+ │ │ │ ├─gsd-power(2410)─┬─{gsd-po+ │ │ │ │ ├─{gsd-po+ │ │ │ │ └─{gsd-po+ │ │ │ ├─gsd-print-notif(2411)─┬─{+ │ │ │ │ └─{+ │ │ │ ├─gsd-rfkill(2417)─┬─{gsd-r+ │ │ │ │ └─{gsd-r+ │ │ │ ├─gsd-screensaver(2420)─┬─{+ │ │ │ │ └─{+ │ │ │ ├─gsd-sharing(2422)─┬─{gsd-+ │ │ │ │ ├─{gsd-+ │ │ │ │ └─{gsd-+ │ │ │ ├─gsd-smartcard(2434)─┬─{gs+ │ │ │ │ ├─{gs+ │ │ │ │ ├─{gs+ │ │ │ │ └─{gs+ │ │ │ ├─gsd-sound(2426)─┬─{gsd-so+ │ │ │ │ ├─{gsd-so+ │ │ │ │ └─{gsd-so+ │ │ │ ├─gsd-wacom(2433)─┬─{gsd-wa+ │ │ │ │ └─{gsd-wa+ │ │ │ ├─gsd-xsettings(2427)─┬─{gs+ │ │ │ │ ├─{gs+ │ │ │ │ └─{gs+ │ │ │ ├─nautilus-deskto(2530)─┬─{+ │ │ │ │ ├─{+ │ │ │ │ └─{+ │ │ │ ├─ssh-agent(2250) │ │ │ ├─tracker-extract(2608)─┬─{+ │ │ │ │ ├─{+ │ │ │ │ ├─{+ │ │ │ │ ├─{+ │ │ │ │ ├─{+ │ │ │ │ ├─{+ │ │ │ │ ├─{+ │ │ │ │ ├─{+ │ │ │ │ ├─{+ │ │ │ │ ├─{+ │ │ │ │ ├─{+ │ │ │ │ ├─{+ │ │ │ │ ├─{+ │ │ │ │ ├─{+ │ │ │ │ └─{+ │ │ │ ├─tracker-miner-a(2623)─┬─{+ │ │ │ │ ├─{+ │ │ │ │ └─{+ │ │ │ ├─tracker-miner-f(2636)─┬─{+ │ │ │ │ ├─{+ │ │ │ │ └─{+ │ │ │ ├─tracker-miner-u(2641)─┬─{+ │ │ │ │ ├─{+ │ │ │ │ └─{+ │ │ │ ├─{gnome-session-b}(2272) │ │ │ ├─{gnome-session-b}(2274) │ │ │ └─{gnome-session-b}(2288) │ │ ├─{gdm-session-wor}(2088) │ │ └─{gdm-session-wor}(2089) │ ├─{gdm}(1161) │ ├─{gdm}(1162) │ └─{gdm}(1619) ├─geoclue(2344)─┬─{geoclue}(2345) │ └─{geoclue}(2347) ├─gnome-keyring-d(2096)─┬─{gnome-keyring-d}(2097) │ ├─{gnome-keyring-d}(2098) │ └─{gnome-keyring-d}(2295) ├─gnome-shell-cal(2343)─┬─{gnome-shell-cal}(2363) │ ├─{gnome-shell-cal}(2365) │ ├─{gnome-shell-cal}(2395) │ ├─{gnome-shell-cal}(2396) │ └─{gnome-shell-cal}(2527) ├─gnome-terminal-(3550)─┬─bash(3802)───pstree(5602) │ ├─gnome-pty-helpe(3556) │ ├─{gnome-terminal-}(3551) │ ├─{gnome-terminal-}(3552) │ └─{gnome-terminal-}(3553) ├─goa-daemon(2362)─┬─{goa-daemon}(2397) │ ├─{goa-daemon}(2399) │ └─{goa-daemon}(2400) ├─goa-identity-se(2403)─┬─{goa-identity-se}(2406) │ ├─{goa-identity-se}(2407) │ └─{goa-identity-se}(2408) ├─gsd-printer(2509)─┬─{gsd-printer}(2520) │ └─{gsd-printer}(2521) ├─gssproxy(719)─┬─{gssproxy}(720) │ ├─{gssproxy}(721) │ ├─{gssproxy}(722) │ ├─{gssproxy}(723) │ └─{gssproxy}(724) ├─gvfs-afc-volume(2375)─┬─{gvfs-afc-volume}(2376) │ ├─{gvfs-afc-volume}(2377) │ └─{gvfs-afc-volume}(2379) ├─gvfs-goa-volume(2392)─┬─{gvfs-goa-volume}(2393) │ └─{gvfs-goa-volume}(2394) ├─gvfs-gphoto2-vo(2381)─┬─{gvfs-gphoto2-vo}(2383) │ └─{gvfs-gphoto2-vo}(2385) ├─gvfs-mtp-volume(2387)─┬─{gvfs-mtp-volume}(2388) │ └─{gvfs-mtp-volume}(2390) ├─gvfs-udisks2-vo(2355)─┬─{gvfs-udisks2-vo}(2356) │ └─{gvfs-udisks2-vo}(2357) ├─gvfsd(2164)─┬─gvfsd-burn(2710)─┬─{gvfsd-burn}(2713) │ │ └─{gvfsd-burn}(2714) │ ├─gvfsd-trash(2536)─┬─{gvfsd-trash}(2537) │ │ └─{gvfsd-trash}(2539) │ ├─{gvfsd}(2165) │ └─{gvfsd}(2166) ├─gvfsd-fuse(2169)─┬─{gvfsd-fuse}(2171) │ ├─{gvfsd-fuse}(2172) │ ├─{gvfsd-fuse}(2173) │ ├─{gvfsd-fuse}(2174) │ └─{gvfsd-fuse}(2175) ├─gvfsd-metadata(2708)─┬─{gvfsd-metadata}(2711) │ └─{gvfsd-metadata}(2712) ├─httpd(1112)─┬─httpd(1715) │ ├─httpd(1716) │ ├─httpd(1717) │ ├─httpd(1718) │ └─httpd(1719) ├─ibus-portal(2329)─┬─{ibus-portal}(2330) │ └─{ibus-portal}(2331) ├─ibus-x11(2325)─┬─{ibus-x11}(2333) │ └─{ibus-x11}(2334) ├─imsettings-daem(2160)─┬─{imsettings-daem}(2161) │ ├─{imsettings-daem}(2162) │ └─{imsettings-daem}(2176) ├─irqbalance(710) ├─ksmtuned(790)───sleep(5554) ├─libvirtd(1108)─┬─{libvirtd}(1202) │ ├─{libvirtd}(1203) │ ├─{libvirtd}(1204) │ ├─{libvirtd}(1205) │ ├─{libvirtd}(1206) │ ├─{libvirtd}(1207) │ ├─{libvirtd}(1208) │ ├─{libvirtd}(1209) │ ├─{libvirtd}(1210) │ ├─{libvirtd}(1211) │ ├─{libvirtd}(1461) │ ├─{libvirtd}(1462) │ ├─{libvirtd}(1463) │ ├─{libvirtd}(1464) │ ├─{libvirtd}(1465) │ └─{libvirtd}(1617) ├─lsmd(750) ├─lvmetad(534) ├─master(1419)─┬─pickup(1420) │ └─qmgr(1421) ├─mcelog(771) ├─mission-control(2353)─┬─{mission-control}(2358) │ ├─{mission-control}(2360) │ └─{mission-control}(2368) ├─mysqld_safe(1225)───mysqld(1432)─┬─{mysqld}(1649) │ ├─{mysqld}(1650) │ ├─{mysqld}(1651) │ ├─{mysqld}(1652) │ ├─{mysqld}(1653) │ ├─{mysqld}(1654) │ ├─{mysqld}(1655) │ ├─{mysqld}(1656) │ ├─{mysqld}(1657) │ ├─{mysqld}(1658) │ ├─{mysqld}(1691) │ ├─{mysqld}(1692) │ ├─{mysqld}(1693) │ ├─{mysqld}(1694) │ ├─{mysqld}(1695) │ ├─{mysqld}(1696) │ ├─{mysqld}(1789) │ └─{mysqld}(1790) ├─packagekitd(1940)─┬─{packagekitd}(1957) │ └─{packagekitd}(1960) ├─polkitd(711)─┬─{polkitd}(725) │ ├─{polkitd}(727) │ ├─{polkitd}(731) │ ├─{polkitd}(735) │ ├─{polkitd}(737) │ └─{polkitd}(754) ├─pulseaudio(2453)─┬─{pulseaudio}(2478) │ └─{pulseaudio}(2480) ├─rngd(729) ├─rpcbind(717) ├─rsyslogd(1105)─┬─{rsyslogd}(1149) │ └─{rsyslogd}(1151) ├─rtkit-daemon(732)─┬─{rtkit-daemon}(733) │ └─{rtkit-daemon}(734) ├─smartd(762) ├─sshd(1098)─┬─sshd(3276)───bash(3278) │ └─sshd(3886)───bash(3888) ├─systemd-journal(506) ├─systemd-logind(712) ├─systemd-machine(738) ├─systemd-udevd(545) ├─tracker-store(2651)─┬─{tracker-store}(2652) │ ├─{tracker-store}(2653) │ ├─{tracker-store}(2654) │ ├─{tracker-store}(2655) │ ├─{tracker-store}(2656) │ ├─{tracker-store}(2657) │ └─{tracker-store}(2658) ├─tuned(1095)─┬─{tuned}(1615) │ ├─{tuned}(1616) │ ├─{tuned}(1634) │ └─{tuned}(1635) ├─udisksd(752)─┬─{udisksd}(772) │ ├─{udisksd}(774) │ ├─{udisksd}(797) │ └─{udisksd}(843) ├─upowerd(1864)─┬─{upowerd}(1865) │ └─{upowerd}(1866) ├─vmtoolsd(744)─┬─{vmtoolsd}(809) │ └─{vmtoolsd}(851) ├─vmtoolsd(2556)─┬─{vmtoolsd}(2634) │ ├─{vmtoolsd}(2635) │ └─{vmtoolsd}(2692) ├─wpa_supplicant(1939) └─xdg-permission-(2338)─┬─{xdg-permission-}(2339) └─{xdg-permission-}(2341)
⽹络与进程分析
使⽤命令【netstat -pantl】查看当前系统的tcp连接情况
[root@hadoop100 ~]# netstat -pantl Active Internet connections (servers and established) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 1432/mysqld tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 717/rpcbind tcp 0 0 192.168.122.1:53 0.0.0.0:* LISTEN 1763/dnsmasq tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1098/sshd tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 1099/cupsd tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1419/master tcp 0 0 127.0.0.1:6010 0.0.0.0:* LISTEN 3886/sshd: root@pts tcp 0 0 192.168.1.24:22 192.168.1.5:62396 ESTABLISHED 3886/sshd: root@pts tcp 0 0 192.168.1.24:22 192.168.1.52:56396 ESTABLISHED 3276/sshd: root@pts tcp6 0 0 :::111 :::* LISTEN 717/rpcbind tcp6 0 0 :::80 :::* LISTEN 1112/httpd tcp6 0 0 :::22 :::* LISTEN 1098/sshd tcp6 0 0 ::1:631 :::* LISTEN 1099/cupsd tcp6 0 0 ::1:25 :::* LISTEN 1419/master tcp6 0 0 ::1:6010 :::* LISTEN 3886/sshd: root@pts
关闭未知连接 【kill -9 pid】即可关闭
进程分析
使⽤命令【ps aux】查看所有进程分析
[root@hadoop100 ~]# ps aux USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND root 1 0.0 0.2 191420 4432 ? Ss 17:12 0:02 /usr/lib/systemd/systemd --switch root 2 0.0 0.0 0 0 ? S 17:12 0:00 [kthreadd] root 4 0.0 0.0 0 0 ? S< 17:12 0:00 [kworker/0:0H] root 5 0.0 0.0 0 0 ? S 17:12 0:00 [kworker/u256:0] root 6 0.0 0.0 0 0 ? S 17:12 0:00 [ksoftirqd/0] root 7 0.0 0.0 0 0 ? S 17:12 0:00 [migration/0] root 8 0.0 0.0 0 0 ? S 17:12 0:00 [rcu_bh] root 9 0.0 0.0 0 0 ? S 17:12 0:02 [rcu_sched] root 10 0.0 0.0 0 0 ? S< 17:12 0:00 [lru-add-drain] root 11 0.0 0.0 0 0 ? S 17:12 0:00 [watchdog/0] root 12 0.0 0.0 0 0 ? S 17:12 0:00 [watchdog/1] root 13 0.0 0.0 0 0 ? S 17:12 0:00 [migration/1] root 14 0.0 0.0 0 0 ? S 17:12 0:00 [ksoftirqd/1] root 16 0.0 0.0 0 0 ? S< 17:12 0:00 [kworker/1:0H] root 18 0.0 0.0 0 0 ? S 17:12 0:00 [kdevtmpfs] root 19 0.0 0.0 0 0 ? S< 17:12 0:00 [netns] root 20 0.0 0.0 0 0 ? S 17:12 0:00 [khungtaskd] root 21 0.0 0.0 0 0 ? S< 17:12 0:00 [writeback] root 22 0.0 0.0 0 0 ? S< 17:12 0:00 [kintegrityd] root 23 0.0 0.0 0 0 ? S< 17:12 0:00 [bioset] root 24 0.0 0.0 0 0 ? S< 17:12 0:00 [bioset] root 25 0.0 0.0 0 0 ? S< 17:12 0:00 [bioset] root 26 0.0 0.0 0 0 ? S< 17:12 0:00 [kblockd] root 27 0.0 0.0 0 0 ? S< 17:12 0:00 [md] root 28 0.0 0.0 0 0 ? S< 17:12 0:00 [edac-poller] root 29 0.0 0.0 0 0 ? S< 17:12 0:00 [watchdogd] root 35 0.0 0.0 0 0 ? S 17:12 0:00 [kswapd0] root 36 0.0 0.0 0 0 ? SN 17:12 0:00 [ksmd] root 37 0.0 0.0 0 0 ? SN 17:12 0:00 [khugepaged] root 38 0.0 0.0 0 0 ? S< 17:12 0:00 [crypto] root 46 0.0 0.0 0 0 ? S< 17:12 0:00 [kthrotld] root 49 0.0 0.0 0 0 ? S< 17:12 0:00 [kmpath_rdacd] root 50 0.0 0.0 0 0 ? S< 17:12 0:00 [kaluad] root 51 0.0 0.0 0 0 ? S< 17:12 0:00 [kpsmoused] root 52 0.0 0.0 0 0 ? S 17:12 0:03 [kworker/0:2] root 53 0.0 0.0 0 0 ? S< 17:12 0:00 [ipv6_addrconf] root 66 0.0 0.0 0 0 ? S< 17:12 0:00 [deferwq] root 102 0.0 0.0 0 0 ? S 17:12 0:00 [kauditd] root 285 0.0 0.0 0 0 ? S< 17:12 0:00 [ata_sff] root 286 0.0 0.0 0 0 ? S< 17:12 0:00 [mpt_poll_0] root 287 0.0 0.0 0 0 ? S< 17:12 0:00 [mpt/0] root 291 0.0 0.0 0 0 ? S< 17:12 0:00 [nfit] root 297 0.0 0.0 0 0 ? S 17:12 0:00 [scsi_eh_0] root 298 0.0 0.0 0 0 ? S< 17:12 0:00 [scsi_tmf_0] root 300 0.0 0.0 0 0 ? S 17:12 0:00 [scsi_eh_1] root 301 0.0 0.0 0 0 ? S< 17:12 0:00 [scsi_tmf_1] root 302 0.0 0.0 0 0 ? S 17:12 0:00 [scsi_eh_2] root 303 0.0 0.0 0 0 ? S< 17:12 0:00 [scsi_tmf_2] root 305 0.0 0.0 0 0 ? S 17:12 0:00 [irq/16-vmwgfx] root 306 0.0 0.0 0 0 ? S< 17:12 0:00 [ttm_swap] root 386 0.0 0.0 0 0 ? S< 17:12 0:00 [kdmflush] root 387 0.0 0.0 0 0 ? S< 17:12 0:00 [bioset] root 397 0.0 0.0 0 0 ? S< 17:12 0:00 [kdmflush] root 398 0.0 0.0 0 0 ? S< 17:12 0:00 [bioset] root 411 0.0 0.0 0 0 ? S< 17:12 0:00 [bioset] root 412 0.0 0.0 0 0 ? S< 17:12 0:00 [xfsalloc] root 413 0.0 0.0 0 0 ? S< 17:12 0:00 [xfs_mru_cache] root 414 0.0 0.0 0 0 ? S< 17:12 0:00 [xfs-buf/dm-0] root 415 0.0 0.0 0 0 ? S< 17:12 0:00 [xfs-data/dm-0] root 416 0.0 0.0 0 0 ? S< 17:12 0:00 [xfs-conv/dm-0] root 417 0.0 0.0 0 0 ? S< 17:12 0:00 [xfs-cil/dm-0] root 418 0.0 0.0 0 0 ? S< 17:12 0:00 [xfs-reclaim/dm-] root 419 0.0 0.0 0 0 ? S< 17:12 0:00 [xfs-log/dm-0] root 420 0.0 0.0 0 0 ? S< 17:12 0:00 [xfs-eofblocks/d] root 421 0.0 0.0 0 0 ? S 17:12 0:03 [xfsaild/dm-0] root 422 0.0 0.0 0 0 ? S< 17:12 0:00 [kworker/0:1H] root 506 0.0 0.2 39444 5300 ? Ss 17:12 0:01 /usr/lib/systemd/systemd-journald root 534 0.0 0.0 190376 1360 ? Ss 17:12 0:00 /usr/sbin/lvmetad -f root 545 0.0 0.1 47188 3516 ? Ss 17:12 0:01 /usr/lib/systemd/systemd-udevd root 559 0.0 0.0 0 0 ? S< 17:12 0:00 [kworker/1:1H] root 638 0.0 0.0 0 0 ? S< 17:12 0:00 [xfs-buf/sda1] root 639 0.0 0.0 0 0 ? S< 17:12 0:00 [xfs-data/sda1] root 640 0.0 0.0 0 0 ? S< 17:12 0:00 [xfs-conv/sda1] root 641 0.0 0.0 0 0 ? S< 17:12 0:00 [xfs-cil/sda1] root 642 0.0 0.0 0 0 ? S< 17:12 0:00 [xfs-reclaim/sda] root 643 0.0 0.0 0 0 ? S< 17:12 0:00 [xfs-log/sda1] root 644 0.0 0.0 0 0 ? S< 17:12 0:00 [xfs-eofblocks/s] root 645 0.0 0.0 0 0 ? S 17:12 0:00 [xfsaild/sda1] root 681 0.0 0.0 0 0 ? S< 17:12 0:00 [rpciod] root 682 0.0 0.0 0 0 ? S< 17:12 0:00 [xprtiod] root 684 0.0 0.0 55532 860 ? S<sl 17:12 0:00 /sbin/auditd root 686 0.0 0.0 84556 1004 ? S<sl 17:12 0:00 /sbin/audispd root 688 0.0 0.0 55620 1428 ? S< 17:12 0:00 /usr/sbin/sedispatch root 709 0.0 0.2 396680 4256 ? Ssl 17:12 0:00 /usr/libexec/accounts-daemon root 710 0.0 0.0 21684 1324 ? Ss 17:12 0:01 /usr/sbin/irqbalance --foreground polkitd 711 0.0 0.7 616328 14836 ? Ssl 17:12 0:00 /usr/lib/polkit-1/polkitd --no-de root 712 0.0 0.0 26440 1828 ? Ss 17:12 0:00 /usr/lib/systemd/systemd-logind dbus 715 0.0 0.2 62720 4184 ? Ss 17:12 0:02 /usr/bin/dbus-daemon --system --a rpc 717 0.0 0.0 69256 1004 ? Ss 17:12 0:00 /sbin/rpcbind -w root 719 0.0 0.0 201428 1280 ? Ssl 17:12 0:00 /usr/sbin/gssproxy -D root 728 0.0 0.4 479628 9532 ? Ssl 17:12 0:03 /usr/sbin/NetworkManager --no-dae root 729 0.0 0.1 90672 3240 ? Ss 17:12 0:02 /sbin/rngd -f rtkit 732 0.0 0.0 198784 1812 ? SNsl 17:12 0:00 /usr/libexec/rtkit-daemon root 738 0.0 0.0 22036 1232 ? Ss 17:12 0:00 /usr/lib/systemd/systemd-machined root 740 0.0 0.2 356892 5496 ? Ssl 17:12 0:00 /usr/sbin/ModemManager root 741 0.0 0.0 16900 1392 ? SNs 17:12 0:00 /usr/sbin/alsactl -s -n 19 -c -E root 742 0.0 0.2 168308 5176 ? Ss 17:12 0:00 /usr/bin/VGAuthService -s root 744 0.1 0.2 295564 5308 ? Ssl 17:12 0:07 /usr/bin/vmtoolsd root 746 0.0 0.2 228288 5712 ? Ss 17:12 0:00 /usr/sbin/abrtd -d -s root 747 0.0 0.2 225972 4924 ? Ss 17:12 0:00 /usr/bin/abrt-watch-log -F Backtr libstor+ 750 0.0 0.0 8580 840 ? Ss 17:12 0:00 /usr/bin/lsmd -d root 752 0.0 0.3 451484 6776 ? Ssl 17:12 0:00 /usr/libexec/udisks2/udisksd avahi 753 0.0 0.1 62268 2292 ? Ss 17:12 0:02 avahi-daemon: running [hadoop100. avahi 761 0.0 0.0 62144 400 ? S 17:12 0:00 avahi-daemon: chroot helper root 762 0.0 0.1 52852 2820 ? Ss 17:12 0:00 /usr/sbin/smartd -n -q never root 763 0.0 0.2 225972 4924 ? Ss 17:12 0:00 /usr/bin/abrt-watch-log -F BUG: W root 771 0.0 0.0 6612 300 ? Ss 17:12 0:00 /usr/sbin/mcelog --ignorenodev -- chrony 777 0.0 0.0 120568 1976 ? S 17:12 0:00 /usr/sbin/chronyd root 790 0.0 0.0 115408 956 ? S 17:12 0:00 /bin/bash /usr/sbin/ksmtuned root 1095 0.0 0.8 574288 17480 ? Ssl 17:12 0:00 /usr/bin/python2 -Es /usr/sbin/tu root 1098 0.0 0.2 113004 4380 ? Ss 17:12 0:00 /usr/sbin/sshd -D root 1099 0.0 0.2 198072 4308 ? Ss 17:12 0:00 /usr/sbin/cupsd -f root 1105 0.0 0.4 222740 9096 ? Ssl 17:12 0:00 /usr/sbin/rsyslogd -n root 1108 0.0 0.7 1009244 16136 ? Ssl 17:12 0:00 /usr/sbin/libvirtd root 1112 0.0 0.7 369120 14316 ? Ss 17:12 0:00 /usr/sbin/httpd -DFOREGROUND root 1117 0.0 0.0 25908 956 ? Ss 17:12 0:00 /usr/sbin/atd -f root 1118 0.0 0.0 126384 1632 ? Ss 17:12 0:00 /usr/sbin/crond -n root 1119 0.0 0.2 481564 4800 ? Ssl 17:12 0:00 /usr/sbin/gdm mysql 1225 0.0 0.0 113412 1612 ? Ss 17:12 0:00 /bin/sh /usr/bin/mysqld_safe --ba root 1419 0.0 0.1 91892 2148 ? Ss 17:12 0:00 /usr/libexec/postfix/master -w postfix 1420 0.0 0.2 91996 4116 ? S 17:12 0:00 pickup -l -t unix -u postfix 1421 0.0 0.2 92064 4132 ? S 17:12 0:00 qmgr -l -t unix -u mysql 1432 0.1 4.4 970948 89280 ? Sl 17:12 0:05 /usr/libexec/mysqld --basedir=/us root 1620 0.8 3.4 359184 69404 tty1 Ssl+ 17:12 0:45 /usr/bin/X :0 -background none -n apache 1715 0.0 0.3 371204 7344 ? S 17:12 0:00 /usr/sbin/httpd -DFOREGROUND apache 1716 0.0 0.3 371204 7344 ? S 17:12 0:00 /usr/sbin/httpd -DFOREGROUND apache 1717 0.0 0.3 371204 7344 ? S 17:12 0:00 /usr/sbin/httpd -DFOREGROUND apache 1718 0.0 0.3 371204 7344 ? S 17:12 0:00 /usr/sbin/httpd -DFOREGROUND apache 1719 0.0 0.3 371204 7344 ? S 17:12 0:00 /usr/sbin/httpd -DFOREGROUND nobody 1763 0.0 0.0 56124 1148 ? S 17:12 0:00 /usr/sbin/dnsmasq --conf-file=/va root 1764 0.0 0.0 56096 388 ? S 17:12 0:00 /usr/sbin/dnsmasq --conf-file=/va root 1864 0.0 0.2 430480 5280 ? Ssl 17:12 0:00 /usr/libexec/upowerd root 1939 0.0 0.1 78660 3380 ? Ss 17:12 0:00 /usr/sbin/wpa_supplicant -u -f /v root 1940 0.0 0.3 486300 7640 ? Ssl 17:12 0:00 /usr/libexec/packagekitd root 1941 0.0 0.2 398900 4204 ? Ssl 17:12 0:00 /usr/libexec/boltd colord 2025 0.0 0.3 419688 6388 ? Ssl 17:12 0:00 /usr/libexec/colord root 2087 0.0 0.2 391016 5360 ? Sl 17:13 0:00 gdm-session-worker [pam/gdm-passw root 2096 0.0 0.2 317664 4076 ? Sl 17:13 0:00 /usr/bin/gnome-keyring-daemon --d root 2122 0.0 0.5 745344 11476 ? Ssl 17:13 0:00 /usr/libexec/gnome-session-binary root 2131 0.0 0.0 59016 968 ? S 17:13 0:00 dbus-launch --sh-syntax --exit-wi root 2132 0.0 0.1 61084 2504 ? Ss 17:13 0:00 /usr/bin/dbus-daemon --fork --pri root 2160 0.0 0.2 286120 5976 ? Sl 17:13 0:00 /usr/libexec/imsettings-daemon root 2164 0.0 0.2 388916 4124 ? Sl 17:13 0:00 /usr/libexec/gvfsd root 2169 0.0 0.2 417828 5308 ? Sl 17:13 0:00 /usr/libexec/gvfsd-fuse /run/user root 2250 0.0 0.0 72572 780 ? Ss 17:13 0:00 /usr/bin/ssh-agent /bin/sh -c exe root 2265 0.0 0.2 346772 5684 ? Sl 17:13 0:00 /usr/libexec/at-spi-bus-launcher root 2270 0.0 0.1 60200 2368 ? S 17:13 0:00 /usr/bin/dbus-daemon --config-fil root 2273 0.0 0.2 233104 6000 ? Sl 17:13 0:00 /usr/libexec/at-spi2-registryd -- root 2301 1.6 10.7 3540552 218352 ? Sl 17:13 1:28 /usr/bin/gnome-shell root 2318 0.0 0.2 453320 5544 ? Sl 17:13 0:00 ibus-daemon --xim --panel disable root 2322 0.0 0.1 376184 3740 ? Sl 17:13 0:00 /usr/libexec/ibus-dconf root 2325 0.0 0.6 465124 13912 ? Sl 17:13 0:00 /usr/libexec/ibus-x11 --kill-daem root 2329 0.0 0.1 376152 3452 ? Sl 17:13 0:00 /usr/libexec/ibus-portal root 2338 0.0 0.1 364920 2908 ? Sl 17:13 0:00 /usr/libexec/xdg-permission-store root 2343 0.0 0.6 650116 13788 ? Sl 17:13 0:00 /usr/libexec/gnome-shell-calendar geoclue 2344 0.0 0.7 458596 15324 ? Ssl 17:13 0:00 /usr/libexec/geoclue -t 5 root 2349 0.0 0.2 187400 4932 ? Sl 17:13 0:00 /usr/libexec/dconf-service root 2353 0.0 0.3 485660 7708 ? Sl 17:13 0:00 /usr/libexec/mission-control-5 root 2355 0.0 0.3 563680 7816 ? Sl 17:13 0:00 /usr/libexec/gvfs-udisks2-volume- root 2362 0.0 1.3 903016 27136 ? Sl 17:13 0:00 /usr/libexec/goa-daemon root 2367 0.0 0.8 1051504 16624 ? Sl 17:13 0:00 /usr/libexec/evolution-source-reg root 2375 0.0 0.3 478704 6576 ? Sl 17:13 0:00 /usr/libexec/gvfs-afc-volume-moni root 2381 0.0 0.1 400852 3640 ? Sl 17:13 0:00 /usr/libexec/gvfs-gphoto2-volume- root 2387 0.0 0.1 391760 3388 ? Sl 17:13 0:00 /usr/libexec/gvfs-mtp-volume-moni root 2392 0.0 0.2 371744 5212 ? Sl 17:13 0:00 /usr/libexec/gvfs-goa-volume-moni root 2403 0.0 0.5 527848 10256 ? Sl 17:13 0:00 /usr/libexec/goa-identity-service root 2410 0.0 0.7 640068 15256 ? Sl 17:13 0:00 /usr/libexec/gsd-power root 2411 0.0 0.3 439420 7780 ? Sl 17:13 0:00 /usr/libexec/gsd-print-notificati root 2417 0.0 0.1 539048 3416 ? Sl 17:13 0:00 /usr/libexec/gsd-rfkill root 2420 0.0 0.1 374360 3108 ? Sl 17:13 0:00 /usr/libexec/gsd-screensaver-prox root 2422 0.0 0.2 559532 5252 ? Sl 17:13 0:01 /usr/libexec/gsd-sharing root 2426 0.0 0.2 455200 4904 ? Sl 17:13 0:00 /usr/libexec/gsd-sound root 2427 0.0 0.7 615584 15252 ? Sl 17:13 0:00 /usr/libexec/gsd-xsettings root 2433 0.0 0.7 557800 14704 ? Sl 17:13 0:00 /usr/libexec/gsd-wacom root 2434 0.0 0.3 472720 7272 ? Sl 17:13 0:00 /usr/libexec/gsd-smartcard root 2440 0.0 0.1 457028 3564 ? Sl 17:13 0:00 /usr/libexec/gsd-account root 2453 0.0 0.3 1285532 7340 ? S<l 17:13 0:02 /usr/bin/pulseaudio --start root 2454 0.0 0.1 376700 3412 ? Sl 17:13 0:00 /usr/libexec/gsd-a11y-settings root 2455 0.0 0.6 464784 13716 ? Sl 17:13 0:00 /usr/libexec/gsd-clipboard root 2457 0.0 0.7 779952 15472 ? Sl 17:13 0:00 /usr/libexec/gsd-color root 2458 0.0 0.5 541744 10556 ? Sl 17:13 0:00 /usr/libexec/gsd-datetime root 2467 0.0 0.2 463716 4196 ? Sl 17:13 0:00 /usr/libexec/gsd-housekeeping root 2471 0.0 0.6 614528 13892 ? Sl 17:13 0:00 /usr/libexec/gsd-keyboard root 2472 0.0 0.8 1012340 17700 ? Sl 17:13 0:00 /usr/libexec/gsd-media-keys root 2474 0.0 0.1 376704 3396 ? Sl 17:13 0:00 /usr/libexec/gsd-mouse root 2509 0.0 0.3 608788 7804 ? Sl 17:13 0:00 /usr/libexec/gsd-printer root 2529 0.0 0.9 917012 18628 ? Sl 17:13 0:00 /usr/libexec/evolution-calendar-f root 2530 0.0 1.5 907804 32140 ? Sl 17:13 0:01 nautilus-desktop --force root 2536 0.0 0.2 465032 4704 ? Sl 17:13 0:00 /usr/libexec/gvfsd-trash --spawne root 2549 0.0 0.1 302516 3620 ? Sl 17:13 0:00 /usr/libexec/ibus-engine-simple root 2554 0.0 0.7 1209156 16096 ? Sl 17:13 0:00 /usr/libexec/evolution-calendar-f root 2556 0.1 1.2 608724 25772 ? Sl 17:13 0:07 /usr/bin/vmtoolsd -n vmusr root 2557 0.0 0.1 273068 3232 ? Sl 17:13 0:00 /usr/libexec/gsd-disk-utility-not root 2576 0.0 0.8 903732 18072 ? Sl 17:13 0:00 /usr/libexec/evolution-addressboo root 2579 0.0 0.8 530360 16876 ? Sl 17:13 0:00 abrt-applet root 2580 0.0 3.2 1445820 65360 ? Sl 17:13 0:01 /usr/bin/gnome-software --gapplic root 2588 0.0 1.0 1188352 20904 ? Sl 17:13 0:00 /usr/libexec/evolution-addressboo root 2608 0.0 0.7 812684 15972 ? SNl 17:13 0:00 /usr/libexec/tracker-extract root 2623 0.0 0.5 845788 10932 ? SNl 17:13 0:00 /usr/libexec/tracker-miner-apps root 2636 0.0 0.5 862584 12016 ? SNl 17:13 0:00 /usr/libexec/tracker-miner-fs root 2641 0.0 0.4 562288 10124 ? SNl 17:13 0:00 /usr/libexec/tracker-miner-user-g root 2651 0.0 0.6 526028 14004 ? Sl 17:13 0:00 /usr/libexec/tracker-store root 2708 0.0 0.1 318084 3504 ? Sl 17:13 0:00 /usr/libexec/gvfsd-metadata root 2709 0.0 0.4 586544 8648 ? Ssl 17:13 0:00 /usr/libexec/fwupd/fwupd root 2710 0.0 0.2 536280 4184 ? Sl 17:13 0:00 /usr/libexec/gvfsd-burn --spawner root 3276 0.0 0.3 163856 6456 ? Ss 17:44 0:00 sshd: root@pts/1 root 3278 0.0 0.1 116884 3268 pts/1 Ss+ 17:44 0:00 -bash root 3550 0.4 1.6 700400 33904 ? Rl 17:59 0:10 /usr/libexec/gnome-terminal-serve root 3556 0.0 0.0 8536 736 ? S 17:59 0:00 gnome-pty-helper root 3802 0.0 0.1 116976 3552 pts/2 Ss 18:08 0:00 bash root 3885 0.0 0.0 0 0 ? S 18:11 0:00 [kworker/u256:1] root 3886 0.0 0.3 163856 6160 ? Ss 18:11 0:00 sshd: root@pts/3 root 3888 0.0 0.1 116756 3292 pts/3 Ss+ 18:11 0:00 -bash root 4117 0.0 0.0 0 0 ? S 18:17 0:00 [kworker/0:0] root 4510 0.0 0.0 0 0 ? S 18:22 0:00 [kworker/0:1] root 4782 0.0 0.0 0 0 ? S 18:26 0:00 [kworker/1:1] root 5436 0.0 0.0 0 0 ? R 18:36 0:00 [kworker/1:0] root 5741 0.0 0.0 108052 360 ? S 18:41 0:00 sleep 60 root 5752 0.0 0.0 155448 1884 pts/2 R+ 18:41 0:00 ps aux
使⽤【ps aux|grep pid】 筛选出具体的pid进程的信息
[root@hadoop100 ~]# ps aux|grep 7272 root 2434 0.0 0.3 472720 7272 ? Sl 17:13 0:00 /usr/libexec/gsd-smartcard root 5858 0.0 0.0 112828 984 pts/2 S+ 18:43 0:00 grep --color=auto 7272
也可以使⽤命令 【lsof -i:端⼝号】 也可以实现类似的功能
[root@hadoop100 ~]# lsof -i:3306 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME mysqld 1432 mysql 14u IPv4 30098 0t0 TCP *:mysql (LISTEN)
path环境变量异常 环境变量有可能被修改过
[root@hadoop100 ~]# echo $PATH /usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin:/root/bin
历史命令
history ⽤来查阅输⼊的历史命令
攻击者可以可以通过 history -c 来清除记录
我们可以通过 查看 cat .bash_history 来查阅历史记录
通过设置时间格式更好的查阅命令
设置环境变量
export HISTTIMEFORMAT="%Y-%m-%d %H:%M:%S whoami
"
刷新环境变量
source /etc/profile
history 10 查阅最近10⽇志记录
[root@hadoop100 ~]# history 10 214 free 215 cat /proc/mounts 216 top 217 pstree -p 218 netstat -pantl 219 ps aux 220 ps aux|grep 7272 221 lsof -i:3306 222 echo $PATH 223 history 10
linux⽇志概述
在linux系统中做的操作都会记录到系统⽇志中,对于登录也可以查看⽇志信息查看是否有异常登录。
在linux中 ⽇志存放在 【/var/log】⽬录内
[root@hadoop100 log]# ls -al 总用量 4708 drwxr-xr-x. 20 root root 4096 4月 6 18:30 . drwxr-xr-x. 21 root root 4096 3月 13 19:00 .. drwxr-xr-x. 2 root root 204 2月 6 13:27 anaconda drwx------. 2 root root 23 2月 6 13:28 audit -rw-------. 1 root root 0 4月 6 18:30 boot.log -rw------- 1 root root 79919 4月 1 15:39 boot.log-20240401 -rw------- 1 root root 27458 4月 6 18:30 boot.log-20240406 -rw------- 1 root utmp 26496 4月 6 17:39 btmp -rw-------. 1 root utmp 1536 3月 26 20:53 btmp-20240401 drwxr-xr-x. 2 chrony chrony 6 8月 8 2019 chrony -rw------- 1 root root 7958 4月 6 18:40 cron -rw-------. 1 root root 12489 4月 2 09:29 cron-20240402 drwxr-xr-x. 2 lp sys 84 4月 2 09:29 cups -rw-r--r-- 1 root root 122996 4月 6 17:12 dmesg -rw-r--r-- 1 root root 122923 4月 2 13:59 dmesg.old -rw-r-----. 1 root root 186 2月 6 13:28 firewalld drwx--x--x. 2 root gdm 202 4月 6 17:12 gdm drwxr-xr-x. 2 root root 6 4月 6 2022 glusterfs -rw-------. 1 root root 1367 2月 6 13:43 grubby -rw-r--r--. 1 root root 193 2月 6 13:22 grubby_prune_debug drwx------. 2 root root 94 4月 2 09:29 httpd -rw-r--r--. 1 root root 292292 4月 6 18:17 lastlog drwx------. 3 root root 18 4月 28 2021 libvirt -rw------- 1 root root 396 4月 6 17:12 maillog -rw-------. 1 root root 1188 3月 29 20:01 maillog-20240402 drwxr-x---. 2 mysql mysql 25 3月 13 19:00 mariadb -rw------- 1 root root 1010963 4月 6 18:48 messages -rw-------. 1 root root 1969118 4月 2 09:29 messages-20240402 drwxr-xr-x. 3 root root 18 2月 6 13:22 pluto drwx------. 2 root root 6 2月 28 2020 ppp drwxr-xr-x. 2 root root 6 8月 8 2019 qemu-ga drwxr-xr-x. 2 root root 6 2月 6 13:27 rhsm drwxr-xr-x. 2 root root 90 4月 2 08:40 sa drwx------. 3 root root 17 9月 12 2023 samba -rw------- 1 root root 33346 4月 6 18:22 secure -rw-------. 1 root root 28687 4月 1 20:09 secure-20240402 drwx------. 2 root root 6 6月 10 2014 speech-dispatcher -rw------- 1 root root 0 4月 2 09:29 spooler -rw-------. 1 root root 0 2月 6 13:23 spooler-20240402 drwxr-xr-x. 3 root root 21 2月 6 13:23 swtpm -rw-------. 1 root root 64000 3月 13 19:00 tallylog drwxr-xr-x. 2 root root 23 9月 21 2022 tuned -rw------- 1 root root 1156 4月 2 16:44 vmware-network.1.log -rw------- 1 root root 1456 4月 2 15:55 vmware-network.2.log -rw------- 1 root root 775 4月 2 13:59 vmware-network.3.log -rw------- 1 root root 797 4月 2 13:09 vmware-network.4.log -rw------- 1 root root 1157 4月 2 13:08 vmware-network.5.log -rw------- 1 root root 1457 4月 2 12:02 vmware-network.6.log -rw------- 1 root root 1156 4月 2 08:33 vmware-network.7.log -rw------- 1 root root 1456 4月 1 20:32 vmware-network.8.log -rw------- 1 root root 1156 4月 1 20:07 vmware-network.9.log -rw------- 1 root root 775 4月 6 17:12 vmware-network.log -rw-------. 1 root root 15742 4月 6 17:12 vmware-vgauthsvc.log.0 -rw-------. 1 root root 47660 4月 6 17:12 vmware-vmsvc-root.log -rw-------. 1 root root 5593 4月 6 17:13 vmware-vmtoolsd-root.log -rw-------. 1 root root 12755 4月 6 17:13 vmware-vmusr-root.log -rw-r--r--. 1 root root 320 4月 6 17:12 wpa_supplicant.log -rw-rw-r--. 1 root utmp 24960 4月 6 18:19 wtmp -rw-r--r-- 1 root root 49335 4月 6 18:43 Xorg.0.log -rw-r--r-- 1 root root 32033 4月 2 14:50 Xorg.0.log.old -rw-r--r--. 1 root root 22594 2月 6 13:28 Xorg.9.log -rw-------. 1 root root 21582 3月 13 19:00 yum.log
具体介绍⼀下这上⾯的主要⽇志⽂件:
⽇志⽂件 | 说明 |
---|---|
/var/log/cron | 记录了系统定时任务相关的⽇志。 |
/var/log/cups/ | 记录打印信息的⽇志。(前提你要有打印机或者打印服务器,⼀般不⽤) |
/var/log/dmesg | 记录了系统在开机时内核⾃检的信息。也可以使⽤dmesg命令直接查看内核⾃检信息。 |
/var/log/btmp | 记录错误登录的⽇志。这个⽂件是⼆进制⽂件,不能直接vim查看,⽽要使⽤lastb命令查看。 |
/var/log/lastlog | 记录系统中所有⽤户最后⼀次的登录时间的⽇志。这个⽂件也是⼆进制⽂件,不能直接vim查看,⽽要使⽤lastlog命令查看。 |
/var/log/mailog | 记录邮件信息。 |
/var/log/message | 记录系统重要信息的⽇志。这个⽇志⽂件中会记录Linux系统的绝⼤多数重要信息,如果系统出现问题时,⾸先要检查的就应该是这个⽇志⽂件。 |
/var/log/secure | 记录验证和授权⽅⾯的信息,只要涉及账户和密码的程序都会记录。⽐如说系统的登录,ssh的登录,su切换⽤户,sudo授权,甚⾄添加⽤户和修改⽤户密码都会记录在这个⽇志⽂件中。 |
/var/log/wtmp | 永久记录所有⽤户的登录、注销信息,同时记录系统的启动、重启、关机事件。同样这个⽂件也是⼀个⼆进制⽂件,不能直接vim,⽽需要使⽤last命令来查看。 |
/var/run/utmp | 记录当前已经登录的⽤户的信息。这个⽂件会随着⽤户的登录和注销⽽不断变化,只记录当前登录⽤户的信息。同样这个⽂件不能直接vim,⽽要使⽤w,who,users等命令来查询。 |
为什么有些⽇志⽂件不能使⽤vim编辑器查看?
是因为这些⽇志⽂件中的内容,记录的是重要系统资源的⽇志,与系统安全有关,不能让你修改,要确保数据的准确性,只能通关相关命令来查看。
除了系统默认的⽇志之外,采⽤RPM⽅式安装的系统服务也会默认把⽇志记录在/var/log/⽬录中。
例如:
⽇志⽂件 | 说明 |
---|---|
/var/log/httpd/ | RPM包安装的apache服务的默认⽇志⽬录。 |
/var/log/mail/ | RPM包安装的邮件服务的额外⽇志⽬录。 |
/var/log/samba/ | RPM包安装的samba服务的⽇志⽬录。 |
/var/log/sssd/ | 守护进程安全服务⽬录。 |
重要的⽇志
登录失败记录:/var/log/btmp //lastb 最后⼀次登录:/var/log/lastlog 或者 //lastlog 登录成功记录: /var/log/wtmp //last 登录⽇志记录:/var/log/secure ⽬前登录⽤户信息:/var/run/utmp //w、who、users 历史命令记录:history 仅清理当前⽤户: history -c
查询⾮本地登录的⽇志
[root@hadoop100 log]# last -i | grep -v 0.0.0.0 root pts/3 192.168.1.5 Sat Apr 6 18:11 still logged in root pts/1 192.168.1.52 Sat Apr 6 17:44 still logged in root pts/1 192.168.1.5 Tue Apr 2 14:49 - 15:55 (01:06) root pts/0 192.168.1.5 Tue Apr 2 14:01 - 15:55 (01:53) root pts/2 192.168.1.5 Mon Apr 1 20:09 - 10:44 (14:35) root pts/3 192.168.1.52 Fri Mar 29 20:13 - 16:17 (2+20:03) root pts/1 192.168.1.5 Fri Mar 22 15:33 - down (00:09) wtmp begins Tue Feb 6 13:28:04 2024
w命令 实时登陆查看
[root@hadoop100 log]# w 19:00:29 up 1:48, 4 users, load average: 0.00, 0.01, 0.05 USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT root :0 :0 17:13 ?xdm? 3:25 0.18s /usr/libexec/gnome-session-binary --session gnome-classic root pts/1 192.168.1.52 17:44 1:16m 0.01s 0.01s -bash root pts/2 :0 18:08 5.00s 0.11s 0.00s w root pts/3 192.168.1.5 18:11 38:29 0.03s 0.03s -bash
定位 有多少ip 爆破主机root账号
[root@hadoop100 ~]# grep "Failed password for root" /var/log/secure | awk '{p rint $11}' | sort | uniq -c | sort -nr | more 68 192.168.1.52
定位有那些ip在爆破
[root@hadoop100 ~]# grep "Failed password" /var/log/secure|grep -E -o "(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)"|uniq -c 68 192.168.1.52
爆破⽤户名字典是什么?
[root@hadoop100 ~]# grep "Failed password" /var/log/secure|perl -e 'while($_=<>){ /for(.*?) from/; print "$1\n";}'|uniq -c|sort -nr 68 root
登录成功的ip有那些
[root@hadoop100 ~]# grep "Accepted " /var/log/secure | awk '{print $11}' | sort | uniq -c | sort -nr | more 8 192.168.1.5 2 192.168.1.52
登录成功的⽤户名、ip
[root@hadoop100 ~]# grep "Accepted " /var/log/secure | awk '{print $1,$2,$3,$9,$11}' Apr 2 14:01:54 root 192.168.1.5 Apr 2 14:01:58 root 192.168.1.5 Apr 2 14:16:33 root 192.168.1.5 Apr 2 14:49:00 root 192.168.1.5 Apr 6 17:39:45 root 192.168.1.52 Apr 6 17:44:28 root 192.168.1.52 Apr 6 18:11:18 root 192.168.1.5 Apr 6 18:11:23 root 192.168.1.5 Apr 6 18:11:38 root 192.168.1.5 Apr 6 18:22:06 root 192.168.1.5
查看添加账号信息
[root@hadoop100 ~]# grep "useradd" /var/log/secure [root@hadoop100 ~]#
删除⽤户⽇志
[root@hadoop100 ~]# grep "userdel" /var/log/secure [root@hadoop100 ~]#
-l 显示出⾃⼰(执⾏ sudo 的使⽤者)的权限
[root@hadoop100 ~]# sudo -l 匹配 %2$s 上 %1$s 的默认条目: !visiblepw, always_set_home, match_group_by_gid, always_query_group_plugin, env_reset, env_keep="COLORS DISPLAY HOSTNAME HISTSIZE KDEDIR LS_COLORS", env_keep+="MAIL PS1 PS2 QTDIR USERNAME LANG LC_ADDRESS LC_CTYPE", env_keep+="LC_COLLATE LC_IDENTIFICATION LC_MEASUREMENT LC_MESSAGES", env_keep+="LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER LC_TELEPHONE", env_keep+="LC_TIME LC_ALL LANGUAGE LINGUAS _XKB_CHARSET XAUTHORITY", secure_path=/sbin\:/bin\:/usr/sbin\:/usr/bin 用户 root 可以在 hadoop100 上运行以下命令: (ALL) ALL
cat /etc/sudoers
查看⽂件是否有被修改过 攻击者有可能修改不需要密码就可以执⾏命令
# Adding HOME to env_keep may enable a user to run unrestricted # commands via sudo. # # Defaults env_keep += "HOME" Defaults secure_path = /sbin:/bin:/usr/sbin:/usr/bin ## Next comes the main part: which users can run what software on ## which machines (the sudoers file can be shared between multiple ## systems). ## Syntax: ## ## user MACHINE=COMMANDS ## ## The COMMANDS section may have other options added to it. ## ## Allow root to run any commands anywhere root ALL=(ALL) ALL ## Allows members of the 'sys' group to run networking, software, ## service management apps and more. # %sys ALL = NETWORKING, SOFTWARE, SERVICES, STORAGE, DELEGATING, PROCESSES, LOCATE, DRIVERS ## Allows people in group wheel to run all commands %wheel ALL=(ALL) ALL ## Same thing without a password # %wheel ALL=(ALL) NOPASSWD: ALL ## Allows members of the users group to mount and unmount the ## cdrom as root # %users ALL=/sbin/mount /mnt/cdrom, /sbin/umount /mnt/cdrom ## Allows members of the users group to shutdown this system # %users localhost=/sbin/shutdown -h now ## Read drop-in files from /etc/sudoers.d (the # here does not mean a comment) #includedir /etc/sudoers.d
yum升级⽇志
[root@hadoop100 ~]# more /var/log/yum.log Feb 06 13:39:02 Updated: 1:grub2-common-2.02-0.87.0.2.el7.centos.11.noarch Feb 06 13:39:03 Updated: centos-release-7-9.2009.1.el7.centos.x86_64 Feb 06 13:39:03 Updated: 1:control-center-filesystem-3.28.1-8.el7_9.1.x86_64 Feb 06 13:39:03 Updated: 32:bind-license-9.11.4-26.P2.el7_9.15.noarch Feb 06 13:39:03 Updated: 1:grub2-pc-modules-2.02-0.87.0.2.el7.centos.11.noarch Feb 06 13:39:04 Updated: kbd-misc-1.15.5-16.el7_9.noarch Feb 06 13:39:04 Updated: mesa-filesystem-18.3.4-12.el7_9.x86_64 Feb 06 13:39:05 Updated: tzdata-2023c-1.el7.noarch Feb 06 13:39:06 Updated: bash-4.2.46-35.el7_9.x86_64 Feb 06 13:39:10 Updated: glibc-common-2.17-326.el7_9.x86_64 Feb 06 13:39:10 Updated: nss-softokn-freebl-3.90.0-6.el7_9.x86_64 Feb 06 13:39:23 Updated: glibc-2.17-326.el7_9.x86_64 Feb 06 13:39:23 Updated: nspr-4.35.0-1.el7_9.x86_64 Feb 06 13:39:23 Updated: nss-util-3.90.0-1.el7_9.x86_64 Feb 06 13:39:23 Updated: zlib-1.2.7-21.el7_9.x86_64 Feb 06 13:39:23 Updated: libuuid-2.23.2-65.el7_9.1.x86_64 Feb 06 13:39:23 Updated: xz-libs-5.2.2-2.el7_9.x86_64 Feb 06 13:39:23 Updated: systemd-libs-219-78.el7_9.9.x86_64 Feb 06 13:39:23 Updated: libxml2-2.9.1-6.el7_9.6.x86_64 Feb 06 13:39:24 Updated: freetype-2.8-14.el7_9.1.x86_64 Feb 06 13:39:24 Updated: 4:perl-macros-5.16.3-299.el7_9.x86_64
web⽇志分析
Web访问⽇志记录了Web服务器接收处理请求及运⾏时错误等各种原始信息。通过对WEB⽇志进⾏的安全分析,不仅可 以帮助我们定位攻击者,还可以帮助我们还原攻击路径,找到⽹站存在的安全漏洞并进⾏修复。
apache⽇志⽂件
access.log :记录了所有对Web服务器的访问活动,查找攻击事件时重点看这个
error.log :错误⽇志记录了服务器运⾏期间遇到的各种错误,以及⼀些普通的诊断信息,⽐如服务器何时启动、何时关闭等
我们来看⼀条Apache的访问⽇志
192.168.1.5 - - [06/Apr/2024:20:03:15 +0800] "GET /upload-labs/upload/1.php?=PHPE9568F35-D428-11d2-A769-00AA001ACF42 HTTP/1.1" 200 2146 "http://192.168.1.24/upload-labs/upload/1.php" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:124.0) Gecko/20100101 Firefox/124.0"
⽇志解析
192.168.1.5 代表是谁访问的服务器 [06/Apr/2024:20:03:15 +0800] 表示访问服务器时,服务器的时间。+0800表示服务器所处 时区位于UTC之后的8⼩时 "GET /upload-labs/upload/1.php?=PHPE9568F35-D428-11d2-A769-00AA001ACF42 HTTP/1.1" 请求的⽅法和访问的路径 200 为服务器响应的状态码,此信息⾮常有价值,它揭示了请求是否成功以及失败的 2146 这是响应内容的大小(以字节为单位)。 http://192.168.1.24/upload-labs/upload/1.php 这是引用页或来源页,表示发出此请求的页面URL Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:124.0) Gecko/20100101 Firefox/124.0 这是用户代理字符串,它描述了发出请求的浏览器或客户端的类型和版本
在对WEB⽇志进⾏安全分析时,⼀般可以按照两种思路展开,逐步深⼊,还原整个攻击过程。
第⼀种:确定⼊侵的时间范围,以此为线索,查找这个时间范围内可疑的⽇志,进⼀步排查,最终确定攻击者,还原攻击过程。
第⼆种:攻击者在⼊侵⽹站后,通常会留下后⻔维持权限,以⽅便再次访问,我们可以找到该⽂件,并以此为线索来展开分析。
常⽤分析⼯具:
Window下,推荐⽤ EmEditor 进⾏⽇志分析,⽀持⼤⽂本,搜索效率还不错。
Linux下,使⽤Shell命令组合查询分析。
Shell+Linux命令实现⽇志分析,⼀般结合grep、awk等命令等实现了⼏个常⽤的⽇志分析统计技巧。
Apache⽇志分析技巧:
1、列出当天访问次数最多的IP命令: cut -d- -f 1 access_log|uniq -c | sort -rn | head -20 2、查看当天有多少个IP访问: awk '{print $1}' access_log|sort|uniq|wc -l 3、查看某⼀个⻚⾯被访问的次数: grep "/index.php" access_log | wc -l 4、查看每⼀个IP访问了多少个⻚⾯: awk '{++S[$1]} END {for (a in S) print a,S[a]}' access_log 5、将每个IP访问的⻚⾯数进⾏从⼩到⼤排序: awk '{++S[$1]} END {for (a in S) print S[a],a}' access_log | sort -n 6、查看某⼀个IP访问了哪些⻚⾯: grep ^111.111.111.111 access_log| awk '{print $1,$7}' 7、去掉搜索引擎统计当天的⻚⾯: awk '{print $12,$1}' access_log | grep ^\"Mozilla | awk '{print $2}' |sort | uniq | wc -l 8、查看2023年7⽉2⽇22时这⼀个⼩时内有多少IP访问: awk '{print $4,$1}' access_log | grep 02/Jul/2023:22 | awk '{print $2}'| sort | uniq | wc -l