• 排查和处理一台被攻击的linux系统及其事后分析


     11:40 2018/3/16 发现最近几天服务器流量异常的大,检查了系统命令发现命令最近的修改时间很近,检查dns配置也发现了异常的dns服务器地址。

    考虑到事态的严重性,铲掉这个系统重新搭建。

    事后分析:
    黑客将管理员常用命令伪装成立系统命令,一旦管理员做巡检,使用掉包后的系统命令来做健康检查的时候,就激活了病毒。
    这些木马程序名字变着花样来,但万变不离其宗,名字都写在/etc/rc.d/init.d/DbSecuritySpt和/etc/rc.d/init.d/selinux里面,而且名字和正常的服务很像。

    有/usr/local/zabbix/sbin/zabbix_AgentD、/usr/bin/bsd-port/getty、/usr/bin/dpkgd/ps、/usr/bin/.dbus-daemon--system、/usr/bin/.sshd、/usr/bin/sshd反正你系统有什么类似的
    http://jerrymin.blog.51cto.com/3002256/1680777
    大神的处理方法如下没(待验证):
    排查过程如下:
    ##检查有无下列文件
    cat /etc/rc.d/init.d/selinux
    cat /etc/rc.d/init.d/DbSecuritySpt
    ls /usr/bin/bsd-port
    ls /usr/bin/dpkgd
    ##查看大小是否正常
    ls -lh /bin/netstat
    ls -lh /bin/ps
    ls -lh /usr/sbin/lsof
    ls -lh /usr/sbin/ss
    ##2,删除如下目录及文件
    rm -rf /usr/bin/dpkgd (ps netstat lsof ss)
    rm -rf /usr/bin/bsd-port (木马程序)
    rm -f /usr/local/zabbix/sbin/zabbix_AgentD (木马程序)
    rm -f /usr/local/zabbix/sbin/conf.n
    rm -f /usr/bin/.sshd
    rm -f /usr/bin/sshd
    rm -f /root/cmd.n
    rm -f /root/conf.n
    rm -f /root/IP
    rm -f /tmp/gates.lod
    rm -f /tmp/moni.lod
    rm -f /tmp/notify.file 程序
    rm -f /tmp/gates.lock 进程号
    rm -f /etc/rc.d/init.d/DbSecuritySpt(启动上述描述的那些木马变种程序)
    rm -f /etc/rc.d/rc1.d/S97DbSecuritySpt
    rm -f /etc/rc.d/rc2.d/S97DbSecuritySpt
    rm -f /etc/rc.d/rc3.d/S97DbSecuritySpt
    rm -f /etc/rc.d/rc4.d/S97DbSecuritySpt
    rm -f /etc/rc.d/rc5.d/S97DbSecuritySpt
    rm -f /etc/rc.d/init.d/selinux(默认是启动/usr/bin/bsd-port/getty)
    rm -f /etc/rc.d/rc1.d/S99selinux
    rm -f /etc/rc.d/rc2.d/S99selinux
    rm -f /etc/rc.d/rc3.d/S99selinux
    rm -f /etc/rc.d/rc4.d/S99selinux
    rm -f /etc/rc.d/rc5.d/S99selinux
    #,找出下列程序进程号并杀死
    top 一眼就看到那个木马cpu利用率特高
    /root/ps aux |grep -i jul29(主要是最近开启的进程)
    /root/ps aux |grep -i jul30
    /root/ps aux |grep -i jul31
    /root/ps aux |grep sshd
    /root/ps aux |grep ps
    /root/ps aux |grep getty
    /root/ps aux |grep netstat
    /root/ps aux |grep lsof
    /root/ps aux |grep ss
    /root/ps aux |grep zabbix_Agetntd
    /root/ps aux |grep .dbus
    #注意如果kill后删除后还会再出现就这样操作(破坏木马程序)
    >/usr/bin/dpkgd/ps && /root/chattr +i /usr/bin/dpkgd/ps
    >/usr/bin/bsd-port/getty && /root/chattr +i /usr/bin/bsd-port/getty
    #删除含木马命令并重新安装(或者把上传的正常程序复制过去也行)
    ps
    /root/chattr -i -a /bin/ps && rm /bin/ps -f
    yum reinstall procps -y

    cp /root/ps /bin

    netstat
    /root/chattr -i -a /bin/netstat && rm /bin/netstat -f
    yum reinstall net-tools -y

    cp /root/netstat /bin

    lsof
    /root/chattr -i -a /bin/lsof && rm /usr/sbin/lsof -f
    yum reinstall lsof -y

    cp /root/lsof /usr/sbin

    chattr && lsattr
    yum -y reinstall e2fsprogs

    ss
    /root/chattr -i -a /usr/sbin/ss && rm /usr/sbin/ss -f
    yum -y reinstall iproute

    cp /root/ss /usr/sbin

    修改下面两个程序的权限,这个是意外发现有的改了这两个程序的权限,让你发现了木马既不能下载正常程序也不能杀进程
    /usr/bin/killall
    /usr/bin/wget

    另外他们还修改了DNS怕我们识别不了有的域名吧,想得很周到哈
    cat /etc/resolv.conf
    nameserver 8.8.8.8
    nameserver 8.8.4.4
    5,工具扫描(实验机验证可行)
    安装杀毒工具
    安装
    yum -y install clamav*
    启动
    service clamd restart
    更新病毒库
    freshclam
    扫描方法
    clamscan -r /etc --max-dir-recursion=5 -l /root/etcclamav.log
    clamscan -r /bin --max-dir-recursion=5 -l /root/binclamav.log
    clamscan -r /usr --max-dir-recursion=5 -l /root/usrclamav.log
    clamscan -r --remove /usr/bin/bsd-port
    clamscan -r --remove /usr/bin/
    clamscan -r --remove /usr/local/zabbix/sbin
    查看日志发现
    /bin/netstat: Linux.Trojan.Agent FOUND为病毒
    grep FOUND /root/usrclamav.log
    /usr/bin/.sshd: Linux.Trojan.Agent FOUND
    /usr/sbin/ss: Linux.Trojan.Agent FOUND
    /usr/sbin/lsof: Linux.Trojan.Agent FOUND

  • 相关阅读:
    静态类、抽象类的笔记
    第一篇
    流复制操作
    速记服务器状态码
    访问修饰符
    jquery对象、js全局变量等tips
    Caching and Indexing
    Using X++ copy the favorites from one user to another
    SID
    Using X++ get Language List from Dynamics AX 2009
  • 原文地址:https://www.cnblogs.com/workherd/p/8580285.html
Copyright © 2020-2023  润新知