#排查异常账号
cat /etc/passwd
cat /etc/shadow
cat /etc/group
cat /etc/gshadow
awk -F: '3==0{print 1}' /etc/passwd ##默认只有root
awk -F: '$3==0{print1}' /etc/passwd
awk -F: 'length(2)==0{print1}' /etc/shadow ##查看空口令
#查看远程登录账号: /bin/shell
awk '/\1\\6/{print $1}' /etc/shadow
#检查sudo权限
more /etc/sudoers | grep -v "^#|^$" | grep "ALL=(ALL)"
##检查禁用账户: /etc/shadow 第二栏为!开头
usermod -L 用户;
userdel -r 用户; 且将/home 下的整个用户目录一起删除;
##who whoami last lastb cat bash_history>>history.txt lastlog
#查看所有 用户链接时间 /var/log/wtmp :ac -dp
#检查当前主机系统负载
w top uptime
#查看异常进程端口;
ss -antlp | less ##分析可疑端口、IP、PID ;如果发现异常,用以下命令查看下PID所对应的进程文件路径
ls -l /proc/PID/exe 或file /proc/PID/exe ##($PID 为对应的PID号)
ps -aux | grep pid
killall -9 可疑进程 ###查杀所有可疑进程
5、启动项配置文件查看是否异常:
more /etc/rc.local /etc/rc.d/rc[0~6].d
ls -l /etc/rc.d/rc3.d ##查看系统启动文件rc.local和/etc/init.d 有无异常脚本文件;
或进去/etc/init.d 删除异常开机文件;
6、查看异常计划任务执行:
crontab -l
crontab -e ##进程删除异常任务
more /etc/cron.daily/* 查看目录下文件
ps aux | grep crond
重点关注以下目录中是否存在恶意脚本:
/var/spool/cron/*
/etc/crontab
/etc/cron.d/*
/etc/cron.daily/*
/etc/cron.hourly/*
/etc/cron.monthly/*
/etc/cron.weekly/*
/etc/anacrontab
/var/spool/anacron/*