1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
| 日志分析技巧: 1、定位有多少IP在爆破主机的root帐号: grep "Failed password for root" /var/log/secure | awk '{print $11}' | sort | uniq -c | sort -nr | more
2、定位有哪些IP在爆破: grep "Failed password" /var/log/secure | grep -E -o "(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)" | uniq -c
3、爆破用户名字典是什么? grep "Failed password" /var/log/secure|perl -e 'while($_=<>){ /for(.*?) from/; print "$1\n";}' | uniq -c | sort -nr
4、登录成功的IP有哪些: grep "Accepted" /var/log/secure | awk '{print $11}' | sort | uniq -c | sort -nr | more
5、登录成功的日期、用户名、IP: grep "Accepted" /var/log/secure | awk '{print $1,$2,$3,$9,$11}' 6、增加用户日志: grep "useradd" /var/log/secure
7、删除用户日志: grep "userdel" /var/log/secure
8、su切换用户 more /var/log/secure | grep 'su:'
|