RedShell - An interactive command prompt that executes commands through proxychains and automatically logs them on a Cobalt Strike team server
2020-11-26 05:30:00 Author: www.blogger.com(查看原文) 阅读量:117 收藏

tag:blogger.com,1999:blog-8317222231133660547.post-10092392997093445682020-11-25T17:30:00.007-03:002020-11-25T17:30:03.516-03:00RedShell - An interactive command prompt that executes commands through proxychains and automatically logs them on a Cobalt Strike team server<div class="separator" style="clear: both; text-align: center;"><a href="https://1.bp.blogspot.com/-wOxsBHy8PcA/X73NEJopNtI/AAAAAAAAUeM/ic70r14XdBUE4mHAfsL_LCeqfxoHgcD-QCNcBGAsYHQ/s872/Cobalt-Strike.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="583" data-original-width="872" height="268" src="https://1.bp.blogspot.com/-wOxsBHy8PcA/X73NEJopNtI/AAAAAAAAUeM/ic70r14XdBUE4mHAfsL_LCeqfxoHgcD-QCNcBGAsYHQ/w400-h268/Cobalt-Strike.jpg" width="400" /></a></div><p><br /></p> <p>An interactive command prompt that executes commands through proxychains and automatically logs them on a <a href="https://www.kitploit.com/search/label/Cobalt%20Strike" target="_blank" title="Cobalt Strike">Cobalt Strike</a> team server.</p><span><a name='more'></a></span><div><br /></div><span style="font-size: x-large;"><b>Installation</b></span><br /> <p>RedShell runs on Python 3. It also requires a Cobalt Strike client installed on the system where it runs.</p> <p>Install dependencies:</p> <pre><code>pip3 install -r requirements.txt<br /></code></pre> <p>Install proxychains-ng (<a href="https://github.com/rofl0r/proxychains-ng" rel="nofollow" target="_blank" title="https://github.com/rofl0r/proxychains-ng">https://github.com/rofl0r/proxychains-ng</a>):</p> <pre><code>apt install proxychains4<br /></code></pre> <p>Make the agscript wrapper executable:</p> <pre><code>chmod +x agscript.sh<br /></code></pre> <br /><span style="font-size: x-large;"><b>Usage</b></span><br /> <p>Start a socks <a href="https://www.kitploit.com/search/label/Listener" target="_blank" title="listener">listener</a> on a beacon in your Cobalt Strike client.</p> <p>Start RedShell:</p> <pre><code>$ python3 redshell.py <br /><br /> ____ _______ __ ____<br /> / __ \___ ____/ / ___// /_ ___ / / /<br /> / /_/ / _ \/ __ /\__ \/ __ \/ _ \/ / / <br /> / _, _/ __/ /_/ /___/ / / / / __/ / / <br /> /_/ |_|\___/\__,_//____/_/ /_/\___/_/_/<br /><br /> <br />RedShell&gt; <br /><br /></code></pre> <p>Display help:</p> <pre><code>RedShell&gt; help<br /><br />Documented commands (use 'help -v' for verbose/'help &lt;topic&gt;' for details):<br />===========================================================================<br />beacon_exec connect help pwd shell use_pivot<br />cd disconnect <a href="https://www.kitploit.com/search/label/History" target="_blank" title="history">history</a> quit show_pivots<br />config exit load_config set status <br /></code></pre> <p>Set options:</p> <pre><code>RedShell&gt; set option VALUE<br /></code></pre> <br /><span style="font-size: large;"><b>Connecting to Cobalt Strike</b></span><br /> <p>Set Cobalt Strike connection options:</p> <pre><code>RedShell&gt; set cs_host 127.0.0.1<br />RedShell&gt; set cs_port 50050<br />RedShell&gt; set cs_user somedude<br /></code></pre> <p>Connect to team server (you will be prompted for the team server password):</p> <pre><code>RedShell&gt; connect <br />Enter Cobalt Strike password:<br />Connecting...<br />╔═══════════════════════╤═══════════════════════════════════════════════════════╗<br />║ CS team server status │ Connected via [email protected]:50050 ║<br />╟───────────────────────┼───────────────────────────────────────────────────────╢<br />║ Socks port status │ Disconnected ║<br />╚═══════════════════════╧═══════════════════════════════════════════════════════╝<br /><br /></code></pre> <p>Or load from a config file. Note: team server <a href="https://www.kitploit.com/search/label/Passwords" target="_blank" title="passwords">passwords</a> are not read from config files. Redshell will prompt for the teamserver password and then automatically connect.</p> <pre><code>$ cat config.txt <br />cs_host=127.0.0.1<br />cs_port=12345<br />cs_user=somedude<br /></code></pre> <pre><code>RedShell&gt; load_config config.txt<br />Config applied: <br />╔════════════════════════════╤═══════════════════════════════════════════════════════╗<br />║ Redshell install directory │ /opt/redshell ║<br />╟────────────────────────────┼───────────────────────────────────────────────────────╢<br />║ Proxychains config │ /opt/redshell/proxychains_redshell.conf ║<br />╟────────────────────────────┼───────────────────────────────────────────────────────╢<br />║ CS install directory │ /opt/cobaltstrike ║<br />╟────────────────────────────┼───────────────────────────────────────────────────────╢<br />║ CS team server │ 127.0.0.1 ║<br />╟────────────────────────────┼───────────────────────────────────────────────────────╢<br />║ CS team server port │ 50050 ║<br />╟────────────────────────────┼───────────────────────────────────────────────────────╢<br />║ CS user │ somedude_redshell ║<br />╟────────────────────────────┼───────────────────────────────────────────────────────╢<br />║ Socks port │ ║<br />╟────────────────────────────┼───────────────────────────────────────────────────────╢<br />║ Beacon PID │ ║<br />╟────────────────────────────┼───────────────────────────────────────────────────────╢<br />║ Password │ ║<br />╚════════════════════════════╧═══════════════════════════════════════════════════════╝<br /><br />Enter Cobalt Strike password: <br /><br />╔═══════════════════════╤═══════════════════════════════════════════════════════╗<br />║ CS team server status │ Connected via [email protected]:50050 ║<br />╟───────────────────────┼───────────────────────────────────────────────────────╢<br />║ Socks port status │ Disconnected ║<br />╚═══════════════════════╧═══════════════════════════════════════════════════════╝<br /></code></pre> <p>Show available proxy pivots:</p> <pre><code>RedShell&gt; show_pivots <br />╔═════════════════════════════════════════════════════════════════════════════════════════════════════════════╗<br />║ ID Alive Socks Port PID User Computer Last ║<br />╠═════════════════════════════════════════════════════════════════════════════════════════════════════════════╣<br />║ 1 True 22200 8948 Administrator * WS02 16ms ║<br />╟─────────────────────────────────────────────────────────────────────────────────────────────────────────────╢<br />║ 2 True 54212 7224 Administrator * WS03 39ms ║<br />╚═════════════════════════════════════════════════════════════════════════════════════════════════════════════╝<br /><br /></code></pre> <p>Select a proxy pivot (note: this can only be set after a connection to the team server has been established):</p> <pre><code>RedShell&gt; use_pivot 2<br /><br />╔═══════════════════════╤════════════════════════════════════════════════════════════╗<br />║ CS team server status │ Connected via [email protected]:50050 ║<br />╟───────────────────────┼────────────────────────────────────────────────────────────╢<br />║ Socks port status │ Connected via socks port 54212 @ beacon PID 7224 ║<br />╚═══════════════════════╧════════════════════════════════════════════════════════════╝<br /></code></pre> <p>Check config</p> <pre><code>RedShell&gt; config <br /><br />╔════════════════════════════╤═══════════════════════════════════════════════════════╗<br />║ Redshell install directory │ /opt/redshell ║<br />╟────────────────────────────┼───────────────────────────────────────────────────────╢<br />║ Proxychains config │ /opt/redshell/proxychains_redshell.conf ║<br />╟────────────────────────────┼───────────────────────────────────────────────────────╢<br />║ CS install directory │ /opt/cobaltstrike ║<br />╟────────────────────────────┼───────────────────────────────────────────────────────╢<br />║ CS team server │ 127.0.0.1 ║<br />╟────────────────────────────┼───────────────────────────────────────────────────────╢<br />║ CS team server port │ 50050 ║<br />╟────────────────────────────┼───────────────────────────────────────────────────────╢<br />║ CS user │ somedude_redshell ║<br />╟────────────────────────────┼───────────────────────────────────────────────────────╢<br />║ Socks port │ ║<br />╟────────────────────────────┼───────────────────────────────────────────────────────╢<br />║ Beacon PID │ ║<br />╟────────────────────────────┼───────────────────────────────────────────────────────╢<br />║ Password │ ║<br />╚════════════════════════════╧═══════════════════════════════════════════════════════╝<br /></code></pre> <p>Check status:</p> <pre><code>RedShell&gt; status<br /><br />╔═══════════════════════╤════════════════════════════════════════════════════════════╗<br />║ CS team server status │ Connected via [email protected]:50050 ║<br />╟───────────────────────┼────────────────────────────────────────────────────────────╢<br />║ Socks port status │ Connected via socks port 54212 @ beacon PID 7224 ║<br />╚═══════════════════════╧════════════════════════════════════════════════════════════╝<br /> <br /></code></pre> <p>Execute commands through the beacon socks proxy. These can be run in the context of the current user or via sudo. Specifying 'proxychains' in the command is optional. Commands are forced through proxychains. MITRE ATT&amp;CK Tactic IDs are optional. Including</p> <pre><code>RedShell&gt; beacon_exec -h<br />usage: beacon_exec [-h] [-t TTP] ...<br /><br />Execute a command through proxychains/beacon socks proxy and simultaneously log it to the teamserver.<br /><br />positional arguments:<br /> command Command to execute through the proxy.<br /><br />optional arguments:<br /> -h, --help show this help message and exit<br /> -t TTP, --ttp TTP MITRE ATT&amp;CK Tactic IDs. Comma delimited to specify multiple.<br /><br />example:<br />beacon_exec -t T1003,T1075 cme smb --local-auth -u Administrator -H C713B1D611657D0687A568122193F230 --sam 192.168.1.1<br /></code></pre> <pre><code>RedShell&gt; beacon_exec cme smb 192.168.1.14<br />[proxychains] config file found: /etc/proxychains.conf<br />[proxychains] preloading /usr/lib/x86_64-linux-gnu/libproxychains.so.4<br />[proxychains] DLL init: proxychains-ng 4.14<br />[proxychains] Strict chain ... 127.0.0.1:48199 ... 192.168.1.14:445 ... OK<br />[proxychains] Strict chain ... 127.0.0.1:48199 ... 192.168.1.14:135 ... OK<br />[proxychains] Strict chain ... 127.0.0.1:48199 ... 192.168.1.14:445 ... OK<br />SMB 192.168.1.14 445 TESTNET-DC1 [*] <a href="https://www.kitploit.com/search/label/Windows" target="_blank" title="Windows">Windows</a> Server 2008 R2 Standard 7601 Service Pack 1 x64 (name:TESTNET-DC1) (domain:TESTNET) (signing:True) (SMBv1:True)<br /><br /></code></pre> <p>Note on passwords used in beacon_exec commands - special characters in passwords may be interpreted as shell meta characters, which could cause commands to fail. To get around this, set the password option and then invoke with '$password'. Example:</p> <pre><code>RedShell&gt; set password Test12345<br />password - was: ''<br />now: 'Test12345'<br />RedShell&gt; beacon_exec cme smb --local-auth -u administrator -p $password --shares 192.168.1.14<br /></code></pre> <p>Note on the Redshell and CS install directory options - the script needs to know where it lives, as well as Cobalt Strike. If stuff blows up, be sure to set the directories accordingly:</p> <pre><code>RedShell&gt; set redshell_directory /opt/redshell<br />RedShell&gt; set cs_directory /opt/cobaltstrike<br /></code></pre> <br /><span style="font-size: large;"><b>General Features</b></span><br /> <p>RedShell includes commands for navigating the file system:</p> <pre><code>RedShell&gt; cd /opt/redshell/<br />RedShell&gt; pwd<br />/opt/redshell<br /></code></pre> <p>Additional commands can be run via the shell command or via the '!' shortcut:</p> <pre><code>RedShell&gt; shell date<br />Mon 29 Jul 2019 05:33:02 PM MDT<br />RedShell&gt; !date<br />Mon 29 Jul 2019 05:33:03 PM MDT<br /></code></pre> <p>Commands are tracked and accessible via the history command:</p> <pre><code>RedShell&gt; history <br /> 1 load_config config.txt<br /> 2 status<br /> 3 help<br /></code></pre> <p>RedShell also includes tab-completion and clearing the terminal window via ctrl + l.</p> <br /><span style="font-size: large;"><b>Maintainers</b></span><br /> <ul> <li><a href="https://github.com/exfiltrata" rel="nofollow" target="_blank" title="exfiltrata">exfiltrata</a></li> </ul> <br /><br /><br /><div style="text-align: center;"><b><span style="font-size: x-large;"><a class="kiploit-download" href="https://github.com/Verizon/redshell" rel="nofollow" target="_blank" title="Download Redshell">Download Redshell</a></span></b></div>Zion3R[email protected]

文章来源: http://www.blogger.com/feeds/8317222231133660547/posts/default/1009239299709344568
如有侵权请联系:admin#unsafe.sh