服务器流量异常的解决方案

以下摘自某位老兄的文章,遇到问题一样,不知道是否是新出的病毒IptabLex 大家都知道,互联网每时每刻都会存在攻击的可能性,(系统频繁发包,SYN攻击,等等)安全问题是系统管理员不可忽视的一个问题。当系统出现了问题,我们该如何下手,如何去排查系统问题呢?

正巧,今天公司一台线上的Linux系统出现了入侵的问题。(其实这已经困扰了我快一个月的问题了)(DDOS 系统频繁发包)我把我的处理思路分享给大家,如有哪一点说的不到位,请大家指出,并提出宝贵的意见,谢谢。勿喷。

由于是系统在内网发包,把我们的网络都堵塞了,以至于我不能远程登录到linux系统上,查看cacti流量图都查看不了。ping也全部丢包。这时去机房也不可能,所以,我只好等待发包不频繁的时机,趁此登录系统。功夫不负有心人,终于远程登录上系统了。

由于经历这样的问题不只一次,所以登录系统后,直接奔系统进程查看。查看结果如下:

# ps -ef (只显示可疑进程)
root      2013     1  0 10:01 ?        00:00:00 /boot/.IptabLex
root      5953     1  0 10:01 ?        00:00:00 /boot/.IptabLex
root      6035     1  0 10:01 ?        00:00:00 /boot/.IptabLes
root     24852     1  2 14:31 ?        00:04:29 /boot/.IptabLes
root     27322     1  3 15:08 ?        00:03:50 /boot/.IptabLes

由于程序还在发作,所以只保留唯一一个进程,剩下的进程全部kill掉,以便排查系统的根源在哪里

# kill -9 5953 6035 24852

查看打开的文件,及系统关联的文件都有哪些

# lsof -p 27322 ; lsof -p 2013
COMMAND     PID USER   FD   TYPE DEVICE SIZE/OFF    NODE NAME
.IptabLes 27322 root  cwd    DIR  253,0     4096       2 /
.IptabLes 27322 root  rtd    DIR  253,0     4096       2 /
.IptabLes 27322 root  txt    REG  104,1  1103243    5905 /boot/.IptabLes
.IptabLes 27322 root    0u   REG  253,0        5   98310 /.mylisthbS.pid
.IptabLes 27322 root    1u   REG  253,0        5   98313 /.mylisthb.pid
.IptabLes 27322 root    2u  sock    0,5      0t0 3442424 can't identify protocol
.IptabLes 27322 root    3u   raw             0t0 3445564 00000000:00FF->00000000:0000 st=07
.IptabLes 27322 root    4u   raw             0t0 3445565 00000000:00FF->00000000:0000 st=07
.IptabLes 27322 root    5u   raw             0t0 3445566 00000000:00FF->00000000:0000 st=07
COMMAND    PID USER   FD   TYPE  DEVICE SIZE/OFF  NODE NAME
.IptabLex 2013 root  cwd    DIR   253,0     4096     2 /
.IptabLex 2013 root  rtd    DIR   253,0     4096     2 /
.IptabLex 2013 root  txt    REG   104,1   722580  5906 /boot/.IptabLex
.IptabLex 2013 root    0u   REG   253,0        5 98309 /.mylisthbSx.pid
.IptabLex 2013 root    1uW  REG   253,0        5 98311 /.mylisthbx.pid
.IptabLex 2013 root    2u  IPv4 3479690      0t0   TCP 192.168.116.11:10038-> 59.63.167.168:1001 (ESTABLISHED)

经百度查看59.63.167.168的IP为江西省南昌市 电信

查看Cacti流量图。很遗憾,论坛现在上传图片上传不了。
显示的结果是 Output  300M 跑满了。


查看产生的可疑所有的文件。
# ll -a /   (只显示可疑的文件)
-rw-r--r--   1 root  root      5 Jan 12 17:15 .mylisthb.pid
-rw-r--r--   1 root  root      5 Jan 12 10:01 .mylisthbS.pid
-rw-r--r--   1 root  root      5 Jan 12 10:01 .mylisthbSx.pid
-rw-r--r--   1 root  root      5 Jan 12 16:57 .mylisthbx.pid

查看/boot/分区下
# ll -a /boot/
-rw-r--r--   1 root  root      5 Jan 12 10:01 .IptabLes 
-rw-r--r--   1 root  root      5 Jan 12 10:01 .IptabLex 
-rw-r--r--   1 root  root      5 Jan 12 10:01 IptabLes -> /etc/rc.d/init.d/IptabLes
-rw-r--r--   1 root  root      5 Jan 12 10:01 IptabLex -> /etc/rc.d/init.d/IptabLex


查看/etc/rc.d/init.d/IptabLex和/etc/rc.d/init.d/IptabLes文件内容
# cat /etc/rc.d/init.d/IptabLex 
#!/bin/sh
/boot/.IptabLex
exit 0
# cat /etc/rc.d/init.d/IptabLes
#!/bin/sh
/boot/.IptabLes
exit 0

查看两个文件的文件类型,可知是32位的可执行文件
# file /boot/.IptabLex
.IptabLex: sticky ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.6.9, statically linked, not stripped
# file /boot/.IptabLes
.IptabLes: sticky ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.6.9, statically linked, not stripped


查看message信息
# cat /var/log/message
Jan 12 11:36:24 localhost kernel: .IptabLes[12688]: segfault at 0000000000000000 rip 000000000804e837 rsp 00000000ffeb1fb0 error 4
Jan 12 11:36:39 localhost kernel: .IptabLes[12706]: segfault at 0000000000000000 rip 000000000804e837 rsp 00000000ffeb1fb0 error 4
Jan 12 11:36:54 localhost kernel: .IptabLes[12723]: segfault at 0000000000000000 rip 000000000804e837 rsp 00000000ffeb1fb0 error 4
Jan 12 11:37:10 localhost kernel: .IptabLes[12739]: segfault at 0000000000000000 rip 000000000804e837 rsp 00000000ffeb1fb0 error 4
Jan 12 11:37:46 localhost kernel: .IptabLes[12756]: segfault at 0000000000000000 rip 000000000804e837 rsp 00000000ffeb1fb0 error 4



处理方法,删除关联的文件
# rm -f /.mylisthb*   产生的pid文件
# rm -f /boot/.IptabLex
# rm -f /boot/..IptabLes              编译后的二进制文件
# rm -f /etc/rc.d/init.d/IptabLex
# rm -f /etc/rc.d/init.d/IptabLes


因为这个文件发包基于什么协议,或者基于什么系统命令发包尚未清楚,所以在iptables这无法断定基于什么协议或者基于什么端口进行限制。待大家给一些宝贵的意见。



解决方案:

经过测试,这是因为structs2本身的漏洞造成的,赶紧打补丁,升级structs就可以解决这个问题。

给strusts打补丁吧,http://struts.apache.org/release/2.3.x/docs/s2-016.html 这个现象是被人远程执行命令了 ,然后删掉/tmp 下 /boot 下 /etc/rc.local 里面东西

描述:

目标站点存在命令执行漏洞。
1. 命令执行漏洞是指代码未对用户可控参数做过滤,导致直接带入执行命令的代码中,对恶意构造的语句,可被用来执行任意命令。

2. Struts2(2.3.15.1以前版本)在action、redirect、redirectAction后面的参数未作合理过滤,构造恶意语句会被Struts当做OGNL表达式执行,导致可被用来执行任意命令。(CVE-2013-2251)

危害:

可被攻击者用来执行任意命令,写入后门等,进而完全控***务器,危害巨大。

解决方案:


1. 升级至官方最新版本,可参考:http://struts.apache.org/release/2.3.x/docs/s2-016.html
2. 临时解决方案,添加rewrite规则:
location ~* ^/ {    if ($args ~* "redirect:") {
        return 403;
    }

if ($args ~* "action:") {
        return 403;
    }

if ($args ~* "redirectAction:") {
        return 403;
    }
    proxy_pass http://$host.internal$request_uri;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值