linux主机被爆破入侵的溯源及处置

当出现系统被暴力破解时一般遵循以下处理步骤。

  1. 确认攻击者
  2. 封堵攻击者
  3. 入侵痕迹排查
  4. 加固系统

一:确认攻击者

查看高频攻击IP

[root@localhost ~]#grep -i "Failed password" /var/log/secure | awk '{print $11}' | sort | uniq -c | sort -nr | head -n 10
259 10.44.32.41
114 admin
19  10.28.98.88
...

"259 10.44.32.41"表示该IP有259次登录失败记录

或者使用如下命令

[root@localhost ~]#grep -i "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 | sort -nr
1246 10.32.78.3
22   10.98.2.9
3    10.78.3.20

查看成功登录的IP

[root@localhost ~]#grep -i "accepted " /var/log/secure | awk '{print $11}' | sort | uniq -c | sort -nr | more
12  10.3.33.1
7   10.11.2.98

查看成功登录的日期、用户名、IP

[root@localhost ~]#grep -i "accepted " /var/log/secure | awk '{print $1,$2,$3,$9,$11}'
Jul 2 15:36:41 zhangsan 10.23.35.97
Jul 3 11:24:18 root     10.57.36.5

查看爆破用户名字典

[root@localhost ~]#grep -i "Failed password" /var/log/secure | perl -e 'while($_=<>){ /for(.*?) from/; print "$1\n";}' | uniq -c | sort -nr | more
48 root
36 admin
29 guest

二:封堵攻击者

在确认攻击者的IP后应第一时间进行阻断

防火墙封堵

iptables

[root@localhost ~]#iptables -I INPUT -s <攻击IP> -j DROP
##禁止攻击IP访问本机
[root@localhost ~]#iptables -I OUTPUT -d <攻击IP> -j DROP
##禁止本机访问攻击IP
[root@localhost ~]#service iptables save
##持久化,防止重启后失效
[root@localhost ~]#iptables -L
##查看iptables规则
[root@localhost ~]#systemctl status iptables.service 
##查看iptables运行状态

也可对攻击IP的整个网段进行封堵,如下所示

[root@localhost ~]#iptables -I INPUT -s 10.25.61.0/24 -j DROP
##禁止"10.25.61.0/24"网段IP访问本机
[root@localhost ~]#iptables -I OUTPUT -d 10.25.61.0/24 -j DROP
##禁止本机访问"10.25.61.0/24"网段

firewalld

[root@localhost Desktop]# firewall-cmd --list-all
##查看当前firewall信息
[root@ocalhost Desktop]#firewall-cmd  --zone=public --ad
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值