一、检测服务器的日志是否有被删除
可以查看日志信息是否还存在或者是否被清空,如下相关命令:
[root@master ~]# ll -h /var/log/*
-rw-------. 1 root root 0 Mar 22 14:09 /var/log/boot.log
-rw------- 1 root root 8.0K Jan 3 15:27 /var/log/boot.log-20230103
-rw------- 1 root root 16K Jan 10 17:23 /var/log/boot.log-20230110
-rw------- 1 root root 7.8K Mar 7 17:36 /var/log/boot.log-20230307
-rw------- 1 root root 7.8K Mar 9 10:48 /var/log/boot.log-20230309
-rw------- 1 root root 9.2K Mar 16 11:48 /var/log/boot.log-20230316
-rw------- 1 root root 17K Mar 18 12:42 /var/log/boot.log-20230318
-rw------- 1 root root 7.9K Mar 22 14:09 /var/log/boot.log-20230322
-rw------- 1 root utmp 1.2K Mar 22 13:34 /var/log/btmp
-rw------- 1 root utmp 0 Jan 1 03:13 /var/log/btmp-20230307
-rw------- 1 root root 816 Mar 22 16:01 /var/log/cron
-rw------- 1 root root 39K Jan 8 03:34 /var/log/cron-20230108
-rw------- 1 root root 18K Mar 7 17:36 /var/log/cron-20230307
-rw------- 1 root root 24K Mar 12 03:25 /var/log/cron-20230312
-rw------- 1 root root 14K Mar 22 14:09 /var/log/cron-20230322
[root@master ~]# du -sh /var/log/*
2.3M /var/log/anaconda
36M /var/log/audit
0 /var/log/boot.log
8.0K /var/log/boot.log-20230103
16K /var/log/boot.log-20230110
8.0K /var/log/boot.log-20230307
8.0K /var/log/boot.log-20230309
12K /var/log/boot.log-20230316
20K /var/log/boot.log-20230318
8.0K /var/log/boot.log-20230322
4.0K /var/log/btmp
0 /var/log/btmp-20230307
二、检测是否有异常的用户名及密码文件
可以查看/etc/passwd及/etc/shadow文件,如下相关命令:
[root@master ~]# ll /etc/pass*
-rw-r--r-- 1 root root 1264 Mar 22 16:31 /etc/passwd
-rw-r--r--. 1 root root 1231 Dec 21 10:05 /etc/passwd-
[root@master ~]# ll /etc/sha*
---------- 1 root root 844 Mar 22 16:31 /etc/shadow
----------. 1 root root 821 Dec 21 10:05 /etc/shadow-
三、检测用户名及密码文件是否被更改
可以查看/etc/passwd及/etc/shadow文件内容进行鉴别,如下相关命令:
[root@master ~]# 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
[root@master ~]# cat /etc/shadow
root:$6$ui65fefoaTcI1Pub$7I2ZxpxiEkTgk5pderGB90C/phUAg84FsPMCxZCcoS1GjJhMK2rA2fI5tlMuKQTqQVBbRHfaNrj6A/Vhj/bBX/::0:99999:7:::
bin:*:17834:0:99999:7:::
daemon:*:17834:0:99999:7:::
adm:*:17834:0:99999:7:::
lp:*:17834:0:99999:7:::
sync:*:17834:0:99999:7:::
shutdown:*:17834:0:99999:7:::
halt:*:17834:0:99999:7:::
mail:*:17834:0:99999:7:::
operator:*:17834:0:99999:7:::
四、查看最近一次服务器登录成功和登录不成功
对应日志“/var/log/lastlog”,如下相关命令:
[root@master ~]# lastlog
Username Port From Latest
root pts/1 192.168.189.1 Wed Mar 22 13:42:39 +0800 2023
bin **Never logged in**
daemon **Never logged in**
adm **Never logged in**
lp **Never logged in**
sync **Never logged in**
五、查看机器当前登录的全部用户
对应日志文件“/var/run/utmp”,如下相关命令:
[root@master ~]# who
root tty1 2023-03-22 13:34
root pts/0 2023-03-22 13:39 (192.168.189.1)
root pts/1 2023-03-22 13:42 (192.168.189.1)
六、查看服务器创建以来登陆过的用户
对应日志文件“/var/log/wtmp”,如下相关命令:
[root@master ~]# last
root pts/1 192.168.189.1 Wed Mar 22 13:42 still logged in
root pts/0 192.168.189.1 Wed Mar 22 13:39 still logged in
root tty1 Wed Mar 22 13:34 still logged in
reboot system boot 3.10.0-1160.76.1 Wed Mar 22 13:33 - 16:47 (03:14)
root pts/0 192.168.189.1 Sat Mar 18 11:27 - crash (4+02:06)
root tty1 Sat Mar 18 11:26 - crash (4+02:06)
reboot system boot 3.10.0-1160.76.1 Sat Mar 18 11:26 - 16:47 (4+05:21)
root pts/0 192.168.189.1 Thu Mar 16 15:58 - crash (1+19:27)
root tty1 Thu Mar 16 15:58 - crash (1+19:28)
七、查看 /var/log/secure日志文件
如果有入侵的话,可以尝试发现入侵者的相关信息,如下相关命令:
[root@master ~]# cat /var/log/secure | grep -i "accepted password"
八、查询异常进程所对应的的执行脚本
可以使用top命令查看异常的进程对应的PID
找到对应的PID之后可以在文件系统目录里面查找该进程的可执行文件