“排查 CentOS 是否遭受 exploit(漏洞利用/入侵)”一般分几个阶段来做:确认是否已被入侵 → 找入侵痕迹 → 查利用的漏洞 → 清理与加固。下面给你一套实用排查思路(命令可直接用)。
cat /etc/passwd
cat /etc/shadow
重点看:
awk -F: '$3==0 {print $1}' /etc/passwd
who
w
last
lastlog
异常时间点、异常 IP 要重点关注。
top -c
ps auxf
注意:
[kworker] 但带参数)查看隐藏进程:
ps -eo pid,comm | sort -n > /tmp/ps.txt
ls /proc | grep -E '^[0-9]+$' | sort -n > /tmp/proc.txt
diff /tmp/ps.txt /tmp/proc.txt
netstat -tunlp
ss -tunlp
看是否有:
如果是 Nginx / Apache:
find /var/www -type f -name "*.php" -mtime -7
看最近修改的 PHP / JSP / py 文件。
常见后门特征:
eval($_POSTbase64_decodeassert(/bin/shsystem(grep -R "eval(" /var/www
grep -R "base64_decode" /var/www
uname -a
cat /etc/redhat-release
常见 CentOS 老版本风险:
可用工具:
# 本地漏洞扫描
yum install -y lynis
lynis audit system
find / -perm -4000 -type f 2>/dev/null
异常 SUID 文件可能是提权利用残留。
crontab -l
ls /etc/cron*
cat /etc/rc.local
systemctl list-unit-files | grep enabled
/var/log/secure
/var/log/messages
看:
grep "Failed password" /var/log/secure | wc -l
grep "Accepted password" /var/log/secure
/var/log/nginx/access.log
/var/log/httpd/access_log
找:
GET /?cmd=yum install -y chkrootkit rkhunter
chkrootkit
rkhunter --check
yum install -y clamav
clamscan -r /var/www
如果你已经发现被入侵:
yum update -y
PermitRootLogin no
如果你愿意,可以告诉我:
我可以直接帮你定位是哪种 exploit。