本篇内容介绍了“怎么使用RedShell将命令执行记录在Cobalt Strike团队服务器中”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!
RedShell是一款交互式命令行工具,它可以帮助广大研究人员通过proxychains(一款命令行代理神器)来执行命令,并自动将命令执行日志记录在Cobalt Strike团队服务器之中。
广大研究人员可以使用下列命令将该项目源码克隆至本地:
git clone https://github.com/Verizon/redshell.git
RedShell基于Python 3开发,因此需要在本地主机上安装好Python 3环境。除此之外,RedShell的运行还需要在系统中安装并配置好Cobalt Strike客户端。
安装依赖组件:
pip3 install -r requirements.txt
安装proxychains-ng【传送门】:
apt install proxychains4
给agscript封装器提供可执行权限:
chmod +x agscript.sh
首先,我们需要在Cobalt Strike客户端的Beacon中开启一个socks监听器。
$ python3 redshell.py
____ _______ __ ____
/ __ \___ ____/ / ___// /_ ___ / / /
/ /_/ / _ \/ __ /\__ \/ __ \/ _ \/ / /
/ _, _/ __/ /_/ /___/ / / / / __/ / /
/_/ |_|\___/\__,_//____/_/ /_/\___/_/_/
RedShell>
RedShell> help
Documented commands (use 'help -v' for verbose/'help <topic>' for details):
===========================================================================
beacon_exec connect help pwd shell use_pivot
cd disconnect history quit show_pivots
config exit load_config set status
RedShell> set option VALUE
设置Cobalt Strike连接选项:
RedShell> set cs_host 127.0.0.1
RedShell> set cs_port 50050
RedShell> set cs_user somedude
连接至Cobalt Strike团队服务器(此时需要输入团队服务器的密码):
RedShell> connect
Enter Cobalt Strike password:
Connecting...
╔═══════════════════════╤═══════════════════════════════════════════════════════╗
║ CS team server status │ Connected via somedude_redshell@127.0.0.1:50050 ║
╟───────────────────────┼───────────────────────────────────────────────────────╢
║ Socks port status │ Disconnected ║
╚═══════════════════════╧═══════════════════════════════════════════════════════╝
或者,我们也可以从配置文件中加载配置信息。需要注意的是,团队服务求的密码是无法从配置文件中读取的。在RedShell中输入密码之后,工具将会帮助我们自动跟服务器进行连接:
$ cat config.txt cs_host=127.0.0.1 cs_port=12345 cs_user=somedude
RedShell> load_config config.txt Config applied: ╔════════════════════════════╤═══════════════════════════════════════════════════════╗ ║ Redshell install directory │ /opt/redshell ║ ╟────────────────────────────┼───────────────────────────────────────────────────────╢ ║ Proxychains config │ /opt/redshell/proxychains_redshell.conf ║ ╟────────────────────────────┼───────────────────────────────────────────────────────╢ ║ CS install directory │ /opt/cobaltstrike ║ ╟────────────────────────────┼───────────────────────────────────────────────────────╢ ║ CS team server │ 127.0.0.1 ║ ╟────────────────────────────┼───────────────────────────────────────────────────────╢ ║ CS team server port │ 50050 ║ ╟────────────────────────────┼───────────────────────────────────────────────────────╢ ║ CS user │ somedude_redshell ║ ╟────────────────────────────┼───────────────────────────────────────────────────────╢ ║ Socks port │ ║ ╟────────────────────────────┼───────────────────────────────────────────────────────╢ ║ Beacon PID │ ║ ╟────────────────────────────┼───────────────────────────────────────────────────────╢ ║ Password │ ║ ╚════════════════════════════╧═══════════════════════════════════════════════════════╝
Enter Cobalt Strike password:
╔═══════════════════════╤═══════════════════════════════════════════════════════╗
║ CS team server status │ Connected via somedude_redshell@127.0.0.1:50050 ║
╟───────────────────────┼───────────────────────────────────────────────────────╢
║ Socks port status │ Disconnected ║
╚═══════════════════════╧═══════════════════════════════════════════════════════╝
显示可用代理:
RedShell> show_pivots
╔═════════════════════════════════════════════════════════════════════════════════════════════════════════════╗
║ ID Alive Socks Port PID User Computer Last ║
╠═════════════════════════════════════════════════════════════════════════════════════════════════════════════╣
║ 1 True 22200 8948 Administrator * WS02 16ms ║
╟─────────────────────────────────────────────────────────────────────────────────────────────────────────────╢
║ 2 True 54212 7224 Administrator * WS03 39ms ║
╚═════════════════════════════════════════════════════════════════════════════════════════════════════════════╝
选择一个代理(只有当客户端与团队服务器之间的连接建立成功之后才可以设置该选项):
RedShell> use_pivot 2
╔═══════════════════════╤════════════════════════════════════════════════════════════╗
║ CS team server status │ Connected via somedude_redshell@127.0.0.1:50050 ║
╟───────────────────────┼────────────────────────────────────────────────────────────╢
║ Socks port status │ Connected via socks port 54212 @ beacon PID 7224 ║
╚═══════════════════════╧════════════════════════════════════════════════════════════╝
检查配置信息:
RedShell> config ╔════════════════════════════╤═══════════════════════════════════════════════════════╗ ║ Redshell install directory │ /opt/redshell ║ ╟────────────────────────────┼───────────────────────────────────────────────────────╢ ║ Proxychains config │ /opt/redshell/proxychains_redshell.conf ║ ╟────────────────────────────┼───────────────────────────────────────────────────────╢ ║ CS install directory │ /opt/cobaltstrike ║ ╟────────────────────────────┼───────────────────────────────────────────────────────╢ ║ CS team server │ 127.0.0.1 ║ ╟────────────────────────────┼───────────────────────────────────────────────────────╢ ║ CS team server port │ 50050 ║ ╟────────────────────────────┼───────────────────────────────────────────────────────╢ ║ CS user │ somedude_redshell ║ ╟────────────────────────────┼───────────────────────────────────────────────────────╢ ║ Socks port │ ║ ╟────────────────────────────┼───────────────────────────────────────────────────────╢ ║ Beacon PID │ ║ ╟────────────────────────────┼───────────────────────────────────────────────────────╢ ║ Password │ ║ ╚════════════════════════════╧═══════════════════════════════════════════════════════╝
检测运行状态:
RedShell> status
╔═══════════════════════╤════════════════════════════════════════════════════════════╗
║ CS team server status │ Connected via somedude_redshell@127.0.0.1:50050 ║
╟───────────────────────┼────────────────────────────────────────────────────────────╢
║ Socks port status │ Connected via socks port 54212 @ beacon PID 7224 ║
╚═══════════════════════╧════════════════════════════════════════════════════════════╝
命令是通过Beacon socks代理来执行的,可以使用当前用户权限或sudo来执行。所有的命令都会通过proxychains来执行:
RedShell> beacon_exec -h
usage: beacon_exec [-h] [-t TTP] ...
Execute a command through proxychains/beacon socks proxy and simultaneously log it to the teamserver.
positional arguments:
command Command to execute through the proxy.
optional arguments:
-h, --help show this help message and exit
-t TTP, --ttp TTP MITRE ATT&CK Tactic IDs. Comma delimited to specify multiple.
example:
beacon_exec -t T1003,T1075 cme smb --local-auth -u Administrator -H C713B1D611657D0687A568122193F230 --sam 192.168.1.1
RedShell> beacon_exec cme smb 192.168.1.14
[proxychains] config file found: /etc/proxychains.conf
[proxychains] preloading /usr/lib/x86_64-linux-gnu/libproxychains.so.4
[proxychains] DLL init: proxychains-ng 4.14
[proxychains] Strict chain ... 127.0.0.1:48199 ... 192.168.1.14:445 ... OK
[proxychains] Strict chain ... 127.0.0.1:48199 ... 192.168.1.14:135 ... OK
[proxychains] Strict chain ... 127.0.0.1:48199 ... 192.168.1.14:445 ... OK
SMB 192.168.1.14 445 TESTNET-DC1 [*] Windows Server 2008 R2 Standard 7601 Service Pack 1 x64 (name:TESTNET-DC1) (domain:TESTNET) (signing:True) (SMBv1:True)
需要注意的是,beacon_exec命令所使用的密码中,特殊字符有可能会被解析为shell元字符,这将导致命令执行失败。为了解决这个问题,我们可以设置密码选项,然后使用“$password”来进行调用:
RedShell> set password Test12345
password - was: ''
now: 'Test12345'
RedShell> beacon_exec cme smb --local-auth -u administrator -p $password --shares 192.168.1.14
关于RedShell和CS安装目录选项,脚本需要知道具体的路径,相关配置命令如下:
RedShell> set redshell_directory /opt/redshell
RedShell> set cs_directory /opt/cobaltstrike
RedShell提供了下列命令来帮助研究人员查看文件系统:
RedShell> cd /opt/redshell/
RedShell> pwd
/opt/redshell
我们还可以通过shell命令或”!”短命令来查看其他可用命令:
RedShell> shell date
Mon 29 Jul 2019 05:33:02 PM MDT
RedShell> !date
Mon 29 Jul 2019 05:33:03 PM MDT
追踪命令执行记录,并查看历史记录:
RedShell> history
1 load_config config.txt
2 status
3 help
RedShell还提供了Tab键命令补全,或通过CTRL+ l组合键来清理终端窗口信息。
“怎么使用RedShell将命令执行记录在Cobalt Strike团队服务器中”的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业相关的知识可以关注亿速云网站,小编将为大家输出更多高质量的实用文章!
亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。
原文链接:https://www.freebuf.com/articles/system/257401.html