本文给大家收集整理了一些审查Linux系统是否被入侵的方法,这些方法可以添加到你运维例行巡检中。
1. 检查帐户
# less /etc/passwd/p>
p># grep :0: /etc/passwd(检查是否产生了新用户,和UID、GID是0的用户)/p>
p># ls -l /etc/passwd(查看文件修改日期)/p>
p># awk -F: ‘$3= =0 {print $1}’ /etc/passwd(查看是否存在特权用户)/p>
p># awk -F: ‘length($2)= =0 {print $1}’ /etc/shadow(查看是否存在空口令帐户)
2. 检查日志
# last
(查看正常情况下登录到本机的所有用户的历史记录)
注意”entered promiscuous mode”
注意错误信息
注 意Remote Procedure Call (rpc) programs with a log entry that includes a large number (> 20) strange characters(-^PM-^PM-^PM-^PM-^PM-^PM-^PM-^PM)
3. 检查进程
# ps -aux(注意UID是0的)/p>
p># lsof -p pid(察看该进程所打开端口和文件)/p>
p># cat /etc/inetd.conf | grep -v “^#”(检查守护进程)/p>
p>检查隐藏进程/p>
p># ps -ef|awk ‘{print }’|sort -n|uniq >1/p>
p># ls /porc |sort -n|uniq >2/p>
p># diff 1 2
4. 检查文件
# find / -uid 0 –perm -4000 –print/p>
p># find / -size +10000k –print/p>
p># find / -name “…” –print/p>
p># find / -name “.. ” –print/p>
p># find / -name “. ” –print/p>
p># find / -name ” ” –print/p>
p>注意SUID文件,可疑大于10M和空格文件
# find / -name core -exec ls -l {} \
(检查系统中的core文件)/p>
p>检查系统文件完整性/p>
p># rpm –qf /bin/ls/p>
p># rpm -qf /bin/login/p>
p># md5sum –b 文件名/p>
p># md5sum –t 文件名
5. 检查RPM
# rpm –Va
输出格式:/p>
p>S – File size differs/p>
p>M – Mode differs (permissions)/p>
p>5 – MD5 sum differs/p>
p>D – Device number mismatch/p>
p>L – readLink path mismatch/p>
p>U – user ownership differs/p>
p>G – group ownership differs/p>
p>T – modification time differs/p>
p>注意相关的 /sbin, /bin, /usr/sbin, and /usr/bin
6. 检查网络
# ip link | grep PROMISC(正常网卡不该在promisc模式,可能存在sniffer)/p>
p># lsof –i/p>
p># netstat –nap(察看不正常打开的TCP/UDP端口)/p>
p># arp –a
7. 检查计划任务
注意root和UID是0的schedule/p>
p># crontab –u root –l/p>
p># cat /etc/crontab/p>
p># ls /etc/cron.*
8. 检查后门
# cat /etc/crontab/p>
p># ls /var/spool/cron//p>
p># cat /etc/rc.d/rc.local/p>
p># ls /etc/rc.d/p>
p># ls /etc/rc3.d/p>
p># find / -type f -perm 4000
9. 检查内核模块
# lsmod
10. 检查系统服务
# chkconfig/p>
p># rpcinfo -p(查看RPC服务)
11. 检查rootkit
# rkhunter -c/p>
p># chkrootkit -q