centos服务器抓马经历

39 篇文章 0 订阅

第一给公司弄服务器没到一个星期就中马了,悲催。不过确实得怪自己没经验,以前一直都是是在本地局域网内玩玩耍耍,也就没太在意安全这些玩意。不扯淡了,进入主题。

一.木马特征:首先申明下的是我们的服务器与公司的其他服务器是并行放一块的。在外面看来,中马后公司放在一块的整个并行网络几乎处于瘫痪状态,这个网络的网速几乎为零,远程用ping命令ping我们的服务器会出现严重的丢包状态,且严重超时。接上显示屏及其他,root登录进人主机系统,打开系统监控,发现网络监控的状态是当前主机正以满带宽的状态向外在发包,cpu占用率也有偏高。尼玛,心想肯定中毒了,我们的主机确实是被攻击了,并且被当肉鸡在攻击其他的网络。噢漏

  

现象:

内网发现经常断网,访问内部服务器非常的卡,基本不能正常访问。

与网管配合,发现是一台linux服务器导致的。

 

# 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)


果断断网,查看系统进行,发现异常进程。(当时只管解决,没截图)

/boot/.IptabLes

/boot/.IptabLex

 

boot下,查看文件,发现几个可疑文件

/boot/IptabLes

/boot/IptabLex

/boot/.IptabLes

/boot/.IptabLex

 

其中有文件指向/etc/rc.d/init.d目录,那就是说开机启动。

查看/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

 

查看.IptabLex .IptabLes文件内容

# cat /boot/.IptabLex 
.IptabLex: sticky ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.6.9, statically linked, not stripped 
# cat /boot/.IptabLes 
.IptabLes: sticky ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.6.9, statically linked, not stripped

 

看不懂,不过基本可以确定是这几个文件引起的,果断删除

rm -f /.mylisthb* 
rm -f /boot/.IptabLex 
rm -f /boot/..IptabLes 
rm -f /etc/rc.d/init.d/IptabLex 
rm -f /etc/rc.d/init.d/IptabLes

 

重启,重新查看,未发现异常。

 

上网查看,也有人有类似问题:

http://bbs.chinaunix.net/thread-4118890-1-1.html

 

目前没有发现有什么建设性的办法,只能写个脚本每隔一段时间检测一次,发现自动删除。

相关脚本:

#!/bin/sh 
######################################################## 
#author:      Asheng Xu 
#             Mail: xjs100200@163.com  
#             QQ: 121854289 
#             blog:http://www.xujiansheng.cn 

#create date: 2014-01-16 


#note: 
#     kill IptabLes and IptabLex virus. 

########################################################


lwc=$(ps -ef | grep IptabL | grep -v grep | wc -l) 
echo "==================" 
date

echo $lwc

if [ $lwc -ne 0 ] ; then

echo "======kill IptabLes IptabLex session======" 
ps -ef | grep IptabL 
ps -ef | grep IptabL | grep -v grep | awk '{print $2}' | xargs kill -9

echo "======kill all IptabLes IptabLex file======" 
find / -name "*IptabL*" -print 
find / -name "*IptabL*" -exec rm -f {} \; 
ls -al /.mylisthb* 
rm -f /.mylisthb*

fi

 

效果:

image

 

2014-01-21

继续研究,查看日志,通常都能发现下面的内容

tail –100 /var/log/secure

image

有公网IP拼命的在尝试root的密码,而且走的是ssh进来的。

当然关闭ssh相信应该是可以的。

我这因为目前公网上还需要用到ssh,所以只能在hosts.deny上进行阻止该公网IP进来。

在/etc/hosts.deny加入如下的内容,有多少个就加多少个:

image

然后在/var/log/secure上可以看到如下的阻止的内容:

image

 

东北大学网络中心有常见的ssh攻击的IP地址,及一个sh脚本:

网址:http://antivirus.neu.edu.cn/scan/ssh.php

 

2014-01-22

发现rc.local下有以下的内容

image

红框为多出来的内容

关闭防火墙。

查看防火墙,果然是关闭的。

 

修改下,将多出的全部屏蔽掉。

开启防火墙

service iptables start

 

安全起见,只开启特定的端口及特定的IP可以访问服务器(服务器上执行)。

iptables -I INPUT -p tcp --dport 3020 -j ACCEPT 
iptables -A OUTPUT -p tcp --sport 3020 -j ACCEPT 
iptables -I INPUT -p tcp --dport 3010 -j ACCEPT 
iptables -A OUTPUT -p tcp --sport 3010 -j ACCEPT 
iptables -I INPUT -p tcp --dport 6080 -j ACCEPT 
iptables -A OUTPUT -p tcp --sport 6080 -j ACCEPT 
iptables -I INPUT -i lo -j ACCEPT 
iptables -I INPUT -p tcp --dport 22 -j DROP 
iptables -I INPUT -s 172.16.91.3 -p tcp --dport 22 -j ACCEPT 
iptables -I INPUT -s 61.154.164.33 -p tcp --dport 22 -j ACCEPT 
iptables -P INPUT DROP

 

保存配置

service iptables save

 

查看状态:

sevice iptables status

image

 

/etc/sysconfig/iptables内容:

image

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值