配置文件排查:
文件属性:stat /etc/rc.local
文件配置:cat /etc/fstab
文件内容:grep -V '#' /etc/bashrc | more
文件目录:ls -last /etc/profile.d/
cron后门排查:
配置文件目录:
/etc/cron.d/
/var/spool/cron/
配置文件:
/etc/crontab
/etc/anacrontab
win换行符:
^M = ctrl+v -> ctrl+m
sed -i 's/^M//g' /var/spool/cron/root
setuid后门排查:
根据文件权限来查找指定文件
find / -perm -4000 2>/dev/null
find / -perm -u=s -type f 2>/dev/null
find / -perm -4000 -o -perm -2000 2>dev/null | xargs ls -lh
ssh后门排查
rpm包完整性校验
rpm -Vf 'type sshd' 'type ssh'
S = 大小 / M = 权限 / 5=MD5 / T=时间 / L=链接
获取sshd进程pid并跟踪系统调用
strace -o out.txt -ff -p pid
获取ssh进程pid传给strace进行监控
ps -ef | grep -vE 'sshd|grep' | grep ssh | awk '{print $2}' |xargs
strace -o out.txt -f -p 2>&1
通过文件操作特征跟踪后门
grep open out.txt* | grep -e APPEND
pam后门排查:
pam配置文件检查
stat /etc/pam.d/sshd
cat /etc/pam.d/sshd
so文件加载排查
ps -ef |grep sshd |grep pts
pmap pid |grep security
sshd进程操作跟踪
strace -o out -ff -p pid
cat out* |grep APPEND
ssh公钥排查
公钥文件配置
grep AuthorizedKeysFile /etc/ssh/sshd_config
公钥文件搜索
find / -name authorized_keys
文件属性及内容
stat authorized_keys
预加载后门排查
系统环境变量检查
echo $LD_PRELOAD
unset LD_PRELOAD
绕过后门hook隐藏
./busybox cat /etc/ld.so.preload
跟踪文件系统调用
./strace -f -e trace=file /bin/cat
acess("/etc/ld.so.preload", R_OK)
后门配置文件清理
lsattr /etc/ld.so.preload
echo > /etc/ld.so.preload
strace后门排查
系统进程筛查
进程名称、命令参数
strace跟踪
strace -o out.txt -ff -p pid
调用内核ptrace特性来实现功能
alias命令排查
module后门排查
中间件配置排查
控制器及模块加载配置
模块文件排查
文件修改时间排序
strings evil.so |grep -e exec
已加载模块确认
pamp -q pid |grep auth
内核后门排查
驱动加载
lsmod / modinfo / modprobe -l
cat /proc/modules
网络层排查
正向: nmap -sV -PN -T4 -p-
反向:tcpdump -i eth0 src host hostname -w send.cap
系统文件排查
linux PE / LiveCD (Porteus)
fdisk -l /mount /dev/mapper/VolGroup
常见目录:
驻留文件及目录
/etc/crontab、/etc/init.d、/etc/rc.local
隐藏文件及目录
/tmp/.evil、/tmp/ ./
可写可执行权限
/tmp、/var/tmp、/dev/shm
常用工具:
Rookit检测
chkrootkit、rkhunter
基于特征检测的脚本文件
静态编译工具
busybox-i686
busybox-x86_64
LiveCD
系统急救恢复、后门分析取证
Tripwire
监控和告警任意系统文件的更改(IDS)