在 CentOS(或其他 Linux 发行版)上排查 exploit(漏洞利用 / 入侵)痕迹,通常遵循“系统状态 → 账号 → 进程 → 网络 → 文件 → 日志 → 持久化”的思路。下面给你一套可操作的排查清单。
⚠️ 若怀疑被入侵,尽量不要重启,以免破坏内存中的攻击痕迹。
uptime
w
last
who
重点关注:
cat /etc/passwd
cat /etc/shadow
awk -F: '$3==0 {print $1}' /etc/passwd # UID=0 的账户
检查:
sudoers 是否被改cat /etc/sudoers
ls -l /etc/sudoers.d/
ps auxf
top
重点看:
/tmp、/dev/shm、/var/tmp进一步:
lsof -p <pid>
ls -l /proc/<pid>/exe
netstat -antup
ss -antup
重点:
netstat + ss 对比)查看连接来源:
netstat -ant | grep ESTABLISHED
rpm -V coreutils
rpm -V bash
find / -mtime -7 -type f
find /var/www -mtime -3
/var/www/html/usr/local/nginx/html搜索可疑内容:
grep -R "eval(" /var/www
grep -R "base64_decode" /var/www
crontab -l
ls -l /etc/cron*
cat /var/spool/cron/*
systemctl list-unit-files | grep enabled
ls -l /etc/init.d/
cat /etc/rc.local
/var/log/secure
/var/log/auth.log
grep "Failed password" /var/log/secure
grep "Accepted" /var/log/secure
cat ~/.bash_history
cat /root/.bash_history
/var/log/nginx/access.log
/var/log/httpd/access_log
/tmp/.ICE-unix、/tmp/.* 隐藏文件ld.so.preload 被修改cat /etc/ld.so.preload
iptables 被清掉ssh 公钥被写入cat ~/.ssh/authorized_keys
rkhunterchkrootkitlynisosquery(企业级)如果你愿意,可以告诉我:
我可以帮你做更针对性的排查步骤。