<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">

 <title>0xHasi</title>
 <link href="https://lehasas.github.io/atom.xml" rel="self"/>
 <link href="https://lehasas.github.io/"/>
 <updated>2026-03-01T12:06:15+00:00</updated>
 <id>https://lehasas.github.io</id>
 <author>
   <name>Lehasa Seoe</name>
   <email></email>
 </author>

 
 <entry>
   <title>ValleyRAT (Part 1): Static Analysis - From Go Loader to Decrypted Implant</title>
   <link href="https://lehasas.github.io/valleyrat-part-1-static-analysis.html"/>
   <updated>2026-02-28T00:00:00+00:00</updated>
   <id>https://lehasas.github.io/valleyrat-part-1-static-analysis</id>
   <content type="html">&lt;p&gt;This write-up documents my static analysis of the sample &lt;a href=&quot;https://malops.io/challenges/valleyrat&quot;&gt;&lt;em&gt;ValleyRAT&lt;/em&gt;&lt;/a&gt; from MalOps. The goal was to understand what the binary does without leaning on dynamic analysis, packet capture, or full behavioral emulation. I stuck to triage, disassembly, and payload extraction to build a narrative while answering the challenge questions.&lt;/p&gt;

&lt;p&gt;I noticed that the sample used a binary protocol for C2 communication, so this write-up does not cover protocol analysis or network emulation. I will cover that in &lt;strong&gt;Part 2&lt;/strong&gt;.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Safety note: all analysis was done in an isolated lab. Don’t run unknown samples on a host you care about.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2 id=&quot;1-string-analysis--initial-triage&quot;&gt;1. String Analysis / Initial Triage&lt;/h2&gt;

&lt;p&gt;I started with basic triage: &lt;strong&gt;FLOSS + PE Studio&lt;/strong&gt;. The goal was to form hypotheses before touching a disassembler.&lt;/p&gt;

&lt;h3 id=&quot;11-floss-output-go-build-fingerprinting&quot;&gt;1.1 FLOSS Output: Go Build Fingerprinting&lt;/h3&gt;

&lt;p&gt;FLOSS immediately suggested a &lt;strong&gt;Go v1.20-compiled&lt;/strong&gt; binary:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/public/images/2026-02-15-valleyrat-part-1-static-analysis/valley-rat-string-analysis/1-floss-challenge.png&quot; alt=&quot;Running floss against the challenge binary&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Opening the file we dumped the strings to, we then see a Go toolchain fingerprint confirming the above observation:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/public/images/2026-02-15-valleyrat-part-1-static-analysis/valley-rat-string-analysis/2-toolchain-strings.png&quot; alt=&quot;Go compiler toolchain strings&quot; /&gt;&lt;/p&gt;

&lt;p&gt;At this point, my default “Go malware” mental model kicked in: minimal imports and runtime API resolution.&lt;/p&gt;

&lt;h3 id=&quot;12-high-level-capability-hypotheses-from-strings&quot;&gt;1.2 High-level Capability Hypotheses from Strings&lt;/h3&gt;

&lt;p&gt;From raw strings alone, the sample looked like it could do:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Filesystem/ Path Operations&lt;/li&gt;
  &lt;li&gt;Windows Registry Interaction&lt;/li&gt;
  &lt;li&gt;Network Activity Interaction&lt;/li&gt;
  &lt;li&gt;Process/ Thread primitives (to be confirmed)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;img src=&quot;/public/images/2026-02-15-valleyrat-part-1-static-analysis/valley-rat-string-analysis/3-observed-capabilities.png&quot; alt=&quot;Observed capabilities&quot; /&gt;&lt;/p&gt;

&lt;p&gt;One string that stood out is:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;./loader.go&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is not proof by itself, but it is a strong signal that this was built from a Go project with an explicit loader component.&lt;/p&gt;

&lt;h3 id=&quot;13-persistence-indicator&quot;&gt;1.3 Persistence Indicator&lt;/h3&gt;

&lt;p&gt;A very strong persistence indicator appeared directly:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/public/images/2026-02-15-valleyrat-part-1-static-analysis/valley-rat-string-analysis/4-registry-run-persistance.png&quot; alt=&quot;Registry run key&quot; /&gt;&lt;/p&gt;

&lt;p&gt;This indicates Run key persistence&lt;sup id=&quot;fnref:1&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:1&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;1&lt;/a&gt;&lt;/sup&gt;, which immediately becomes a working hypothesis:&lt;/p&gt;
&lt;blockquote&gt;
  &lt;p&gt;The sample persists by adding itself to the Run key.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3 id=&quot;14-imports-minimal-footprint&quot;&gt;1.4 Imports: Minimal Footprint&lt;/h3&gt;

&lt;p&gt;The import footprint was small (just &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Kernel32.dll&lt;/code&gt;), which matches the “resolve everything dynamically” style that shows up in many loader stubs.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/public/images/2026-02-15-valleyrat-part-1-static-analysis/valley-rat-string-analysis/5-library-imports.png&quot; alt=&quot;Library imports&quot; /&gt;&lt;/p&gt;

&lt;p&gt;By the end of triage, the model I wanted to prove was:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Go Loader Stub&lt;/li&gt;
  &lt;li&gt;Persistence via Run key&lt;/li&gt;
  &lt;li&gt;Embedded Encrypted Payload&lt;/li&gt;
  &lt;li&gt;Decrypt -&amp;gt; Allocate -&amp;gt; Execute in-memory Pattern&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;2-disassembly--entrypoint-investigation-go-runtime&quot;&gt;2. Disassembly / Entrypoint Investigation (Go Runtime)&lt;/h2&gt;

&lt;h3 id=&quot;21-cutter-early-crypto-hints&quot;&gt;2.1 Cutter: Early Crypto Hints&lt;/h3&gt;

&lt;p&gt;I like Cutter’s Overview tab, so to start the journey, we’ll look at it first:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/public/images/2026-02-15-valleyrat-part-1-static-analysis/valley-rat-disassembly/1-cutter-overview.png&quot; alt=&quot;Sample&apos;s Cutter Overview&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Initial analysis flagged crypto-relevant code paths, which lined up with the embedded-payload hypothesis.&lt;/p&gt;

&lt;h3 id=&quot;22-ghidra-entrypoint---go-runtime---mainmain&quot;&gt;2.2 Ghidra: Entrypoint -&amp;gt; Go Runtime -&amp;gt; &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;main.main&lt;/code&gt;&lt;/h3&gt;

&lt;p&gt;In Ghidra, following the PE entrypoint landed us in the standard Go startup (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;runtime.rt0_go&lt;/code&gt; and friends). The important part is that the runtime eventually scheduled and called the program logic via &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;main.main&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/public/images/2026-02-15-valleyrat-part-1-static-analysis/valley-rat-disassembly/2-main-main.png&quot; alt=&quot;Sample&apos;s Cutter Overview&quot; /&gt;&lt;/p&gt;

&lt;p&gt;So &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;main.main&lt;/code&gt; is the true behavioral start of this sample, not the raw entrypoint. We can also see the previously noted &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;./loader.go&lt;/code&gt; string, which suggests this address maps to line 67 in the original Go source.&lt;/p&gt;

&lt;h2 id=&quot;3-stage-13---loader-logic-mainmain-call-tree&quot;&gt;3. Stage 1/3 - Loader Logic: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;main.main&lt;/code&gt; Call Tree&lt;/h2&gt;

&lt;p&gt;Once we reach &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;main.main&lt;/code&gt;, the structure was clean and very loader-shaped:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Establish Persistence&lt;/li&gt;
  &lt;li&gt;Perform Payload Decryption&lt;/li&gt;
  &lt;li&gt;Perform Payload Loading (in-memory execution)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This story was clearly evident when we look at the function call tree within the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;main.main&lt;/code&gt; function:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/public/images/2026-02-15-valleyrat-part-1-static-analysis/valley-rat-disassembly/3-ghidra-main-main-call-tree.png&quot; alt=&quot;Main.main function call tree&quot; /&gt;&lt;/p&gt;

&lt;p&gt;We will walk through each of these stages implemented by the functions above to verify the hypotheses.&lt;/p&gt;

&lt;h3 id=&quot;31-persistence-enableautostart&quot;&gt;3.1 Persistence: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;enableAutoStart()&lt;/code&gt;&lt;/h3&gt;

&lt;p&gt;Persistence is implemented via the function &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;enableAutoStart()&lt;/code&gt;, using &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;os.Executable()&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;golang.org/x/sys/windows/registry&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/public/images/2026-02-15-valleyrat-part-1-static-analysis/valley-rat-disassembly/4-enable-auto-start-call.png&quot; alt=&quot;Persistence setup&quot; /&gt;&lt;/p&gt;

&lt;h4 id=&quot;311-locate-the-current-executable-path&quot;&gt;3.1.1 Locate The Current Executable Path&lt;/h4&gt;

&lt;p&gt;The binary calls &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;os.Executable()&lt;/code&gt; and then normalizes it (i.e. &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;filepath.Abs()&lt;/code&gt;), meaning it persists &lt;em&gt;whatever path the binary is currently running from&lt;/em&gt; rather than a hardcoded install location.&lt;/p&gt;

&lt;p&gt;Disassembly fragments I used as anchors:&lt;/p&gt;

&lt;div class=&quot;language-c highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;mo&quot;&gt;0047&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;b969&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;e8&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;52&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;52&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;CALL&lt;/span&gt;       &lt;span class=&quot;n&quot;&gt;os&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;os&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Executable&lt;/span&gt;
&lt;span class=&quot;mo&quot;&gt;0047&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;b978&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;e8&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;23&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;7&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;d&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;CALL&lt;/span&gt;       &lt;span class=&quot;n&quot;&gt;path&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;filepath&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;path&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;filepath&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;abs&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;312-open-the-run-key-hkcu&quot;&gt;3.1.2 Open The Run Key (HKCU)&lt;/h4&gt;

&lt;p&gt;The sample opens:&lt;/p&gt;

&lt;div class=&quot;language-text highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;HKCU\Software\Microsoft\Windows\CurrentVersion\Run
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This matched the string-derived hypothesis exactly.&lt;/p&gt;

&lt;h4 id=&quot;313-set-value-name-calculatorapp_autostart&quot;&gt;3.1.3 Set Value Name: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;CalculatorApp_AutoStart&lt;/code&gt;&lt;/h4&gt;

&lt;p&gt;It writes a string value named:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;CalculatorApp_AutoStart&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;whose data is the absolute path to the current executable.&lt;/p&gt;

&lt;h4 id=&quot;314-cleanup&quot;&gt;3.1.4 Cleanup&lt;/h4&gt;

&lt;p&gt;It closes the registry key via a small closure (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;enableAutoStart.func1&lt;/code&gt;). Nothing fancy, but it’s a useful tell that this is “real” Go code rather than a crude stub.&lt;/p&gt;

&lt;h3 id=&quot;32-payload-decryption-aesdecryptbyecb&quot;&gt;3.2 Payload Decryption: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;AesDecryptByECB()&lt;/code&gt;&lt;/h3&gt;

&lt;p&gt;Next came the payload decryption routine.&lt;/p&gt;

&lt;p&gt;Looking through the disassembly, we can see the preparatory steps for the payload decryption routine below.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/public/images/2026-02-15-valleyrat-part-1-static-analysis/valley-rat-disassembly/5-aes-decrypt-by-ecb-call.png&quot; alt=&quot;Payload Decryption Logic&quot; /&gt;&lt;/p&gt;

&lt;h4 id=&quot;321-encrypted-blob-location-and-size&quot;&gt;3.2.1 Encrypted Blob Location and Size&lt;/h4&gt;

&lt;p&gt;From the above we determine:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;The address of the encrypted blob: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;DAT_004b4fa8&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;The size of the payload: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;0x25660&lt;/code&gt; bytes (153,184 bytes)&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;language-c highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;mo&quot;&gt;0047&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;be4c&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;48&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;d&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;35&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;LEA&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;RSI&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;DAT_004b4fa8&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;mo&quot;&gt;0047&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;be5b&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;bb&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;60&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;56&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;MOV&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;EBX&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mh&quot;&gt;0x25660&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;322-key-material&quot;&gt;3.2.2 Key Material&lt;/h4&gt;

&lt;p&gt;The AES key is hardcoded as a 16-byte string (AES-128 length):&lt;/p&gt;

&lt;div class=&quot;language-c highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;mo&quot;&gt;0047&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;be63&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;48&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;d&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;d&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;LEA&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;RDI&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;s_1ws12uuu11j&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;p5fr_00495639&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;mo&quot;&gt;0047&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;be6a&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;be&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt; &lt;span class=&quot;mo&quot;&gt;00&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;MOV&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;ESI&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mh&quot;&gt;0x10&lt;/span&gt;
&lt;span class=&quot;mo&quot;&gt;0047&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;be6f&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;e8&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;c&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;fc&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;CALL&lt;/span&gt;       &lt;span class=&quot;n&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;AesDecryptByECB&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;More specifically, the key is:&lt;/p&gt;

&lt;div class=&quot;language-text highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;1ws12uuu11j*p5fr
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;There’s also a staging/copy loop before the decrypt call. Effectively, the loader copies the embedded bytes into a buffer and then decrypts in memory using the above key.&lt;/p&gt;

&lt;h4 id=&quot;323-static-payload-extraction&quot;&gt;3.2.3 Static Payload Extraction&lt;/h4&gt;

&lt;p&gt;Given the information above, we can extract the payload without running the sample and dumping memory at runtime. The following script uses the recovered constants directly.&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;pefile&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Crypto.Cipher&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;AES&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;pathlib&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Path&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;PE_PATH&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;challenge&quot;&lt;/span&gt;                   &lt;span class=&quot;c1&quot;&gt;# Sample Name
&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;PAYLOAD_VA&lt;/span&gt;   &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mh&quot;&gt;0x004B4FA8&lt;/span&gt;               &lt;span class=&quot;c1&quot;&gt;# Virtual address of payload
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;PAYLOAD_SIZE&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mh&quot;&gt;0x25660&lt;/span&gt;                  &lt;span class=&quot;c1&quot;&gt;# Size of payload
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;AES_KEY&lt;/span&gt;      &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;sa&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;1ws12uuu11j*p5fr&quot;&lt;/span&gt;      &lt;span class=&quot;c1&quot;&gt;# AES decryption key
&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;OUT_ENC&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;payload.encrypted&quot;&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;OUT_DEC&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;payload.decrypted&quot;&lt;/span&gt;


&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;va_to_file_offset&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;pe&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;va&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;image_base&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pe&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;OPTIONAL_HEADER&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ImageBase&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;rva&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;va&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;image_base&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pe&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;get_offset_from_rva&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;rva&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;extract_decrypted_payload&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;pe&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;offset&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;payload_va&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;payload_size&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;decryption_key&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sa&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;[+] Encrypted Payload Virtual Address: 0x&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;payload_va&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;X&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s&quot;&gt; → At file offset: 0x&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;offset&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;X&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;encrypted&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pe&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;__data__&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;offset&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;offset&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;payload_size&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;

    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;len&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;encrypted&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;payload_size&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;raise&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;RuntimeError&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;[-] Failed to read full payload&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

    &lt;span class=&quot;n&quot;&gt;Path&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;OUT_ENC&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;write_bytes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;encrypted&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;len&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;encrypted&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;16&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;raise&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;RuntimeError&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;[-] Payload not AES block-aligned&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

    &lt;span class=&quot;n&quot;&gt;cipher&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;AES&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;decryption_key&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;AES&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;MODE_ECB&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;decrypted&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cipher&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;decrypt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;encrypted&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

    &lt;span class=&quot;n&quot;&gt;Path&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;OUT_DEC&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;write_bytes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;decrypted&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sa&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;[+] Extracted &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;len&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;decrypted&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s&quot;&gt; decrypted bytes&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sa&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;[+] Final decrypted payload written to file: &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;OUT_DEC&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;


&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;():&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;[*] Starting payload extraction...&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;pe&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pefile&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;PE&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;PE_PATH&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;offset&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;va_to_file_offset&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;pe&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;PAYLOAD_VA&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;extract_decrypted_payload&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;pe&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;offset&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;PAYLOAD_VA&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;PAYLOAD_SIZE&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;AES_KEY&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;[*] Payload extraction completed successfully.&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;__name__&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;__main__&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Running the script successfully extracted and decrypted the payload using the identified key.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/public/images/2026-02-15-valleyrat-part-1-static-analysis/valley-rat-payload-extraction/1-payload-extraction.png&quot; alt=&quot;Payload Decryption and Extraction&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Running the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;file&lt;/code&gt; command on the extracted decrypted payload, we see that it can’t find any recognizable header information to tell us what type of file this is. This will be our next task, to determine what this payload is.&lt;/p&gt;

&lt;h3 id=&quot;33-payload-loading-in-memory-execution-via-kernel32&quot;&gt;3.3 Payload Loading: In-Memory Execution via &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;kernel32&lt;/code&gt;&lt;/h3&gt;

&lt;p&gt;Immediately after decryption, the loader follows the classic sequence:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;load &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;kernel32.dll&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;resolve APIs dynamically&lt;/li&gt;
  &lt;li&gt;allocate RWX (or allocate + change protection)&lt;/li&gt;
  &lt;li&gt;copy decrypted bytes&lt;/li&gt;
  &lt;li&gt;execute via new thread&lt;/li&gt;
  &lt;li&gt;wait&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The resolved API set included:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;VirtualAlloc&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;RtlMoveMemory&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;CreateThread&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;WaitForSingleObject&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In Go this showed up via syscall wrappers like &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;syscall.MustLoadDLL&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;(*DLL).MustFindProc&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;At this point, the stage-0 identity was no longer a hypothesis: this binary is a loader.&lt;/p&gt;

&lt;h2 id=&quot;4-stage-23---decrypted-payload-shellcode-container&quot;&gt;4. Stage 2/3 - Decrypted Payload: Shellcode Container&lt;/h2&gt;

&lt;p&gt;The next question was simple: what is the 153,184-byte decrypted buffer?&lt;/p&gt;

&lt;h3 id=&quot;41-extraction-confirmation&quot;&gt;4.1 Extraction Confirmation&lt;/h3&gt;

&lt;p&gt;Using the loader’s own constants, as proven above, we confirmed the following about the payload:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Virtual Address: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;0x4B4FA8&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;File Offset: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;0xB37A8&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;Size: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;0x25660&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;After extracting and decrypting the embedded payload, I loaded the resulting blob into Cutter expecting something PE-shaped (MZ header, sections, import table, etc.). Instead, Cutter reported:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/public/images/2026-02-15-valleyrat-part-1-static-analysis/valley-rat-payload-extraction/2-cutter-overview.png&quot; alt=&quot;Payload Cutter Overview&quot; /&gt;&lt;/p&gt;

&lt;p&gt;The file format is unknown because it does not start with a recognizable executable container format, which correlates with the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;file&lt;/code&gt; command output. Regardless, a few observations stand out:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Bits: 64&lt;/strong&gt;
Even without a recognized file format, Cutter can still infer architecture from heuristics (instruction patterns, entropy, and typical prologues). It identified this blob as 64-bit code, which is consistent with what we later confirm via DIE.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Base Addr: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;0x00000000&lt;/code&gt;&lt;/strong&gt;
Normal PE binaries embed an ImageBase and relocation information. Shellcode does not. With “Format: N/A”, Cutter has no structural metadata to anchor the blob, so it maps it as a flat buffer and assigns a default base address.&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is one of the first observations that hints to us that we might be dealing with shellcode, i.e. it’s not meant to be loaded by the Windows loader. It’s meant to be copied into memory and executed.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;Mode: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;r-x&lt;/code&gt;&lt;/strong&gt;
Cutter is indicating that it is treating this payload as executable code. Which aligns with a memory execution pipeline (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;VirtualAlloc&lt;/code&gt; -&amp;gt; &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;RtlMoveMemory&lt;/code&gt; -&amp;gt; &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;CreateThread&lt;/code&gt;).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So, even though Cutter couldn’t classify it as a PE, its view is consistent with what the stage-0 Go loader does, which is to decrypt a blob, allocate memory, and then execute it.&lt;/p&gt;

&lt;h3 id=&quot;42-shellcode-characteristics&quot;&gt;4.2 Shellcode Characteristics&lt;/h3&gt;

&lt;p&gt;Next we try to sanity-check the payload with scdbg:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/public/images/2026-02-15-valleyrat-part-1-static-analysis/valley-rat-payload-extraction/3-shellcode-debug-peb-walk.png&quot; alt=&quot;Payload Shellcode Debugger&quot; /&gt;&lt;/p&gt;

&lt;p&gt;At first glance, the line that jumps out is:&lt;/p&gt;

&lt;div class=&quot;language-c highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;mov&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;eax&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mh&quot;&gt;0x30&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;421-why-mov-eax-0x30&quot;&gt;4.2.1 Why &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;mov eax, [0x30]&lt;/code&gt;?&lt;/h4&gt;

&lt;p&gt;I have seen this technique before. It suggests the shellcode is trying to reach the PEB (Process Environment Block) to enumerate loaded modules (kernel32, ntdll, etc.) without relying on imports&lt;sup id=&quot;fnref:3&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:3&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;2&lt;/a&gt;&lt;/sup&gt;.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;On x86, shellcode commonly uses fs:[0x30] to get the PEB pointer.&lt;/li&gt;
  &lt;li&gt;On x64, the analogous approach uses gs:[0x60] for the PEB.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The trace shows &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;mov eax, [0x30]&lt;/code&gt; — not &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;mov eax, fs:[0x30]&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;That detail matters.&lt;/p&gt;

&lt;h4 id=&quot;422-why-scdbg-stopped-wrong-execution-model&quot;&gt;4.2.2 Why &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;scdbg&lt;/code&gt; Stopped: Wrong Execution Model&lt;/h4&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;scdbg&lt;/code&gt; is historically oriented around 32-bit shellcode emulation patterns&lt;sup id=&quot;fnref:4&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:4&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;3&lt;/a&gt;&lt;/sup&gt; and simplified Windows environment emulation. The payload here is &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;AMD64&lt;/code&gt; Donut shellcode, which expects:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;A 64-bit execution context&lt;/li&gt;
  &lt;li&gt;Correct segment register usage (GS access for PEB style lookups)&lt;/li&gt;
  &lt;li&gt;Correct assumptions about memory layout and loader-provided structures&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;scdbg&lt;/code&gt; trying to interpret this blob ends up in a mismatch:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;It hits memory reads that should have been relative to a segment base or runtime-resolved pointer,&lt;/li&gt;
  &lt;li&gt;But instead it tries to read absolute address &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;0x00000000&lt;/code&gt; or &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;0x30&lt;/code&gt; in a flat emulation space,&lt;/li&gt;
  &lt;li&gt;It then dies with error accessing &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;0x00000000&lt;/code&gt; not mapped.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Essentially this tells us that the emulator is the wrong tool for this job.&lt;/p&gt;

&lt;p&gt;So the conclusion from here is:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;This blob behaves like shellcode, but scdbg can’t execute it meaningfully because it’s the wrong architecture/assumption set.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That’s what pushed me to switch tools.&lt;/p&gt;

&lt;h3 id=&quot;43-donut-identification-and-unpacking&quot;&gt;4.3 Donut Identification and Unpacking&lt;/h3&gt;

&lt;p&gt;Since scdbg wasn’t a good fit, I ran the blob through Detect It Easy (DIE). DIE classified it as:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Shellcode: Donut(0.9.2)[AMD64]&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;img src=&quot;/public/images/2026-02-15-valleyrat-part-1-static-analysis/valley-rat-payload-extraction/4-die-donut-detected.png&quot; alt=&quot;Payload DIE Detection&quot; /&gt;&lt;/p&gt;

&lt;p&gt;DIE suggested the payload is &lt;strong&gt;Donut&lt;/strong&gt; shellcode&lt;sup id=&quot;fnref:2&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:2&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;4&lt;/a&gt;&lt;/sup&gt;: a position-independent wrapper commonly used to deliver PE payloads. We know that:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;A PE file is meant to be loaded by the Windows loader (it has headers, sections, imports, relocations).&lt;/li&gt;
  &lt;li&gt;Shellcode is meant to be dropped into memory and executed without the OS loader.&lt;/li&gt;
  &lt;li&gt;Donut bridges the gap by packaging a PE (or other module) into a self-contained shellcode “launcher” that:
    &lt;ul&gt;
      &lt;li&gt;Resolves needed APIs dynamically,&lt;/li&gt;
      &lt;li&gt;Allocates memory,&lt;/li&gt;
      &lt;li&gt;Reconstructs or maps the embedded module,&lt;/li&gt;
      &lt;li&gt;And transfers execution to it.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So in this multi-stage chain:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;Go loader decrypts blob → executes it&lt;/li&gt;
  &lt;li&gt;Blob is Donut shellcode → whose job is to unpack/map an embedded PE&lt;/li&gt;
  &lt;li&gt;That embedded PE is the real implant (the part that actually “does things”)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I used a tool called &lt;a href=&quot;https://github.com/volexity/donut-decryptor&quot;&gt;donut_decryptor&lt;/a&gt;, which can parse the shellcode and extract the embedded &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;DONUT_INSTANCE&lt;/code&gt; structure. Running it against &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;payload.decrypted&lt;/code&gt; produced:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/public/images/2026-02-15-valleyrat-part-1-static-analysis/valley-rat-payload-extraction/5-donut-undonut.png&quot; alt=&quot;Undonut the payload&quot; /&gt;&lt;/p&gt;

&lt;p&gt;The tool does find the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;DONUT_INSTANCE&lt;/code&gt; structure, and recovers the binary and writes it to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;mod_payload.decrypted&lt;/code&gt;, and also produces more information about the instance.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/public/images/2026-02-15-valleyrat-part-1-static-analysis/valley-rat-payload-extraction/6-donut-instance-info.png&quot; alt=&quot;Undonut instance information&quot; /&gt;&lt;/p&gt;

&lt;p&gt;After “undonuting,” we can see that the recovered artifact is a real PE:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/public/images/2026-02-15-valleyrat-part-1-static-analysis/valley-rat-payload-extraction/7-donut-third-stage-payload.png&quot; alt=&quot;Undonut recovered PE&quot; /&gt;&lt;/p&gt;

&lt;p&gt;That’s the transition point where the Go loader stops being interesting and the native implant begins.&lt;/p&gt;

&lt;h2 id=&quot;5-stage-33---deobfuscated-donut-payload-native-x64-pe-implant&quot;&gt;5. Stage 3/3 - Deobfuscated Donut Payload: Native x64 PE Implant&lt;/h2&gt;

&lt;p&gt;Once the Donut wrapper is peeled away, the recovered payload behaves like a conventional native Windows implant. We again load it into cutter to get a general overview of it.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/public/images/2026-02-15-valleyrat-part-1-static-analysis/valley-rat-payload-extraction/8-mod-payload-cutter.png&quot; alt=&quot;Undonut recovered PE&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Analysing it we observe that it enters through the PE entrypoint, runs CRT startup, sets up process-local state, and then transitions into its “real” operational loop.&lt;/p&gt;

&lt;h3 id=&quot;51-crt-startup-and-heap-setup&quot;&gt;5.1 CRT Startup and Heap Setup&lt;/h3&gt;

&lt;p&gt;From the implant entrypoint, execution flows through the usual C/C++ runtime machinery (the CRT).&lt;/p&gt;

&lt;div class=&quot;language-c highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;                        &lt;span class=&quot;n&quot;&gt;entry&lt;/span&gt; 
&lt;span class=&quot;mi&quot;&gt;140009&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;a74&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;48&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;83&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ec&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;28&lt;/span&gt;     &lt;span class=&quot;n&quot;&gt;SUB&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;RSP&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mh&quot;&gt;0x28&lt;/span&gt;
&lt;span class=&quot;mi&quot;&gt;140009&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;a78&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;e8&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;93&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;c&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;CALL&lt;/span&gt;       &lt;span class=&quot;n&quot;&gt;__security_init_cookie&lt;/span&gt;
&lt;span class=&quot;mi&quot;&gt;140009&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;a7d&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;48&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;83&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;c4&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;28&lt;/span&gt;     &lt;span class=&quot;n&quot;&gt;ADD&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;RSP&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mh&quot;&gt;0x28&lt;/span&gt;
&lt;span class=&quot;mi&quot;&gt;140009&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;a81&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;e9&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;76&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;fe&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;JMP&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;__tmainCRTStartup&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;That means it is preparing the process for normal Win32 execution: initializing security cookies, setting up thread-local storage, initializing global constructors (if any), and establishing an allocator strategy.&lt;/p&gt;

&lt;p&gt;A detail that stood out is that the implant did not simply rely on the default process heap forever. Instead, early in initialization it created a &lt;strong&gt;private heap&lt;/strong&gt; using:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;HeapCreate()&lt;/code&gt; - allocates a dedicated heap object owned by the process&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;HeapAlloc()&lt;/code&gt; - uses that heap for subsequent allocations&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This was handled by a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;_heap_init()&lt;/code&gt; call:&lt;/p&gt;

&lt;div class=&quot;language-c highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;mi&quot;&gt;140009950&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;89&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;c&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;24&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;40&lt;/span&gt;     &lt;span class=&quot;n&quot;&gt;MOV&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;dword&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ptr&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;RSP&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;local_res8&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;EBX&lt;/span&gt;
&lt;span class=&quot;mi&quot;&gt;140009954&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;e8&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;f&lt;/span&gt; &lt;span class=&quot;mo&quot;&gt;05&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;CALL&lt;/span&gt;       &lt;span class=&quot;n&quot;&gt;_heap_init&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;In the failure paths of the above operations (calls resembling &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;FUN_14000a30c(0x1c)&lt;/code&gt; / &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;FUN_14000a30c(0x10)&lt;/code&gt;), the behavior matches fail-fast CRT-style enforcement. The implant checks critical initialization results (like heap handle creation). If the handle is null, it does not continue; it aborts through an error routine. This can be seen as early environment checking: if something about the environment is wrong (emulation, restricted sandbox, incompatible runtime), it exits early and avoids noisy crashes later.&lt;/p&gt;

&lt;h3 id=&quot;52-environment-check&quot;&gt;5.2 Environment Check&lt;/h3&gt;

&lt;p&gt;Again, in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;_heap_init()&lt;/code&gt; the implant calls &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;GetVersion()&lt;/code&gt;.&lt;/p&gt;

&lt;div class=&quot;language-c highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;mi&quot;&gt;140009&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;eeb&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;48&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;85&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;c0&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;TEST&lt;/span&gt;       &lt;span class=&quot;n&quot;&gt;RAX&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;RAX&lt;/span&gt;
&lt;span class=&quot;mi&quot;&gt;140009&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;eee&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;74&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;29&lt;/span&gt;           &lt;span class=&quot;n&quot;&gt;JZ&lt;/span&gt;         &lt;span class=&quot;n&quot;&gt;LAB_140009f19&lt;/span&gt;
&lt;span class=&quot;mi&quot;&gt;140009&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ef0&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ff&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;15&lt;/span&gt; &lt;span class=&quot;mo&quot;&gt;02&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;CALL&lt;/span&gt;       &lt;span class=&quot;n&quot;&gt;qword&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ptr&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;KERNEL32&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;DLL&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;GetVersion&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This was interpreted as the implant asking, “what kind of Windows am I on?” It likely does this to support:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;Compatibility gates&lt;/strong&gt;: Avoid executing paths that rely on APIs not present on older systems.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Behavior selection&lt;/strong&gt;: Different injection methods, persistence tactics, or system paths by version.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Profiling&lt;/strong&gt;: OS version becomes part of an environment fingerprint or telemetry report to the operator.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Given the rest of the implant’s behavior (threading, registry usage, dumping via DbgHelp), the most conservative interpretation is that it’s used for &lt;strong&gt;gating and branching&lt;/strong&gt;.&lt;/p&gt;

&lt;h2 id=&quot;6-anti-analysis-and-self-process-dumping&quot;&gt;6. Anti-Analysis and Self-Process Dumping&lt;/h2&gt;

&lt;p&gt;After initial setup, execution reaches &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;FUN_140008580&lt;/code&gt;. This function is best understood as a &lt;strong&gt;runtime staging hub&lt;/strong&gt;: it wires up crash/exception handling, performs stealthy UI behavior, and then kicks off the long-running worker thread that later drives C2 behavior. Specifically, this function does at least four distinct things:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Installs the unhandled exception filter&lt;/li&gt;
  &lt;li&gt;Hides the console window&lt;/li&gt;
  &lt;li&gt;Posts a thread message (likely to pump or unblock something UI/message related)&lt;/li&gt;
  &lt;li&gt;Spawns the worker thread (FUN_1400080e0) and waits on it&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The first important call here is &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;SetUnhandledExceptionFilter&lt;/code&gt;. This registers &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;FUN_140008550&lt;/code&gt; as the process-wide unhandled exception filter. If an exception occurs and nothing catches it, Windows will invoke this handler instead of immediately terminating the process with the default crash UI.&lt;/p&gt;

&lt;div class=&quot;language-c highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;                        &lt;span class=&quot;n&quot;&gt;FUN_140008580&lt;/span&gt;
&lt;span class=&quot;mi&quot;&gt;140008580&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;48&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;83&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ec&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;38&lt;/span&gt;     &lt;span class=&quot;n&quot;&gt;SUB&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;RSP&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mh&quot;&gt;0x38&lt;/span&gt;
&lt;span class=&quot;mi&quot;&gt;140008584&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;48&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;d&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;d&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;LEA&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;RCX&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;FUN_140008550&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;mi&quot;&gt;14000858&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;b&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ff&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;15&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;97&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;CALL&lt;/span&gt;       &lt;span class=&quot;n&quot;&gt;qword&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ptr&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;KERNEL32&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;DLL&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;SetUnhandledExceptionFilter&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;Immediately afterward, the implant calls &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;GetConsoleWindow()&lt;/code&gt; and then &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ShowWindow(hWnd, 0)&lt;/code&gt;. Passing &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;0&lt;/code&gt; corresponds to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;SW_HIDE&lt;/code&gt;&lt;sup id=&quot;fnref:5&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:5&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;5&lt;/a&gt;&lt;/sup&gt;, i.e., it hides its console window if one exists. A console-compiled payload is far noisier if it leaves a visible window on the user desktop.&lt;/p&gt;

&lt;div class=&quot;language-c highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;mi&quot;&gt;140008591&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ff&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;15&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;a9&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;CALL&lt;/span&gt;       &lt;span class=&quot;n&quot;&gt;qword&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ptr&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;KERNEL32&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;DLL&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;GetConsoleWindow&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;mi&quot;&gt;140008597&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;33&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;d2&lt;/span&gt;           &lt;span class=&quot;n&quot;&gt;XOR&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;EDX&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;EDX&lt;/span&gt;
&lt;span class=&quot;mi&quot;&gt;140008599&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;48&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;b&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;c8&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;MOV&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;RCX&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;RAX&lt;/span&gt;
&lt;span class=&quot;mi&quot;&gt;14000859&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;c&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ff&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;15&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;b6&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;CALL&lt;/span&gt;       &lt;span class=&quot;n&quot;&gt;qword&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ptr&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;USER32&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;DLL&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ShowWindow&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;...&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Finally, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;FUN_140008580&lt;/code&gt; spawns the worker thread, so the main thread becomes a supervisor. It creates the operational thread and waits on it.&lt;/p&gt;

&lt;div class=&quot;language-c highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;p&quot;&gt;...&lt;/span&gt;
&lt;span class=&quot;mi&quot;&gt;1400085&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;c6&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;c&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;d&lt;/span&gt; &lt;span class=&quot;mo&quot;&gt;05&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;LEA&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;R8&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;FUN_1400080e0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;mi&quot;&gt;1400085&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;cd&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;45&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;33&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;c9&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;XOR&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;R9D&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;R9D&lt;/span&gt;
&lt;span class=&quot;mi&quot;&gt;1400085&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;d0&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;c&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;89&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;c&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;MOV&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;qword&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ptr&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;RSP&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;local_10&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;R11&lt;/span&gt;
&lt;span class=&quot;mi&quot;&gt;1400085&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;d5&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;33&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;d2&lt;/span&gt;           &lt;span class=&quot;n&quot;&gt;XOR&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;EDX&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;EDX&lt;/span&gt;
&lt;span class=&quot;mi&quot;&gt;1400085&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;d7&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;33&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;c9&lt;/span&gt;           &lt;span class=&quot;n&quot;&gt;XOR&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;ECX&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ECX&lt;/span&gt;
&lt;span class=&quot;mi&quot;&gt;1400085&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;d9&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;44&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;89&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;c&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;MOV&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;dword&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ptr&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;RSP&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;local_18&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;R11D&lt;/span&gt;
&lt;span class=&quot;mi&quot;&gt;1400085&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;de&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ff&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;15&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;c&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;CALL&lt;/span&gt;       &lt;span class=&quot;n&quot;&gt;qword&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ptr&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;KERNEL32&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;DLL&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;CreateThread&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;mf&quot;&gt;1400085e4&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;83&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ca&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ff&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;OR&lt;/span&gt;         &lt;span class=&quot;n&quot;&gt;EDX&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mh&quot;&gt;0xffffffff&lt;/span&gt;
&lt;span class=&quot;mf&quot;&gt;1400085e7&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;48&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;b&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;c8&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;MOV&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;RCX&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;RAX&lt;/span&gt;
&lt;span class=&quot;mi&quot;&gt;1400085&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ea&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;48&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;89&lt;/span&gt; &lt;span class=&quot;mo&quot;&gt;05&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;MOV&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;qword&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ptr&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;DAT_1400234f0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;RAX&lt;/span&gt;
&lt;span class=&quot;mi&quot;&gt;1400085&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;f1&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ff&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;15&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;59&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;CALL&lt;/span&gt;       &lt;span class=&quot;n&quot;&gt;qword&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ptr&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;KERNEL32&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;DLL&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;WaitForSingleObject&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;mi&quot;&gt;1400085&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;f7&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;48&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;b&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;d&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;MOV&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;RCX&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;qword&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ptr&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;DAT_1400234f0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;mi&quot;&gt;1400085&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;fe&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ff&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;15&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;74&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;CALL&lt;/span&gt;       &lt;span class=&quot;n&quot;&gt;qword&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ptr&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;KERNEL32&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;DLL&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;CloseHandle&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;mi&quot;&gt;140008604&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;b9&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;c&lt;/span&gt; &lt;span class=&quot;mo&quot;&gt;01&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;MOV&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;ECX&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mh&quot;&gt;0x12c&lt;/span&gt;
&lt;span class=&quot;mi&quot;&gt;140008609&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ff&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;15&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;51&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;CALL&lt;/span&gt;       &lt;span class=&quot;n&quot;&gt;qword&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ptr&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;KERNEL32&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;DLL&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Sleep&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;61-fun_140008550-exception-filter--debugger-gate&quot;&gt;6.1 FUN_140008550: Exception Filter + Debugger Gate&lt;/h3&gt;

&lt;p&gt;The exception filter itself begins with a debugger check:&lt;/p&gt;

&lt;div class=&quot;language-c highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;                        &lt;span class=&quot;n&quot;&gt;FUN_140008550&lt;/span&gt;
&lt;span class=&quot;mi&quot;&gt;140008550&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;40&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;53&lt;/span&gt;           &lt;span class=&quot;n&quot;&gt;PUSH&lt;/span&gt;       &lt;span class=&quot;n&quot;&gt;RBX&lt;/span&gt;
&lt;span class=&quot;mi&quot;&gt;140008552&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;48&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;83&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ec&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;20&lt;/span&gt;     &lt;span class=&quot;n&quot;&gt;SUB&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;RSP&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mh&quot;&gt;0x20&lt;/span&gt;
&lt;span class=&quot;mi&quot;&gt;140008556&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;48&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;b&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;d9&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;MOV&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;RBX&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;RCX&lt;/span&gt;
&lt;span class=&quot;mi&quot;&gt;140008559&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ff&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;15&lt;/span&gt; &lt;span class=&quot;mo&quot;&gt;01&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;CALL&lt;/span&gt;       &lt;span class=&quot;n&quot;&gt;qword&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ptr&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;KERNEL32&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;DLL&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;IsDebuggerPresent&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;mi&quot;&gt;14000855&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;f&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;85&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;c0&lt;/span&gt;           &lt;span class=&quot;n&quot;&gt;TEST&lt;/span&gt;       &lt;span class=&quot;n&quot;&gt;EAX&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;EAX&lt;/span&gt;
&lt;span class=&quot;mi&quot;&gt;140008561&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;74&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;08&lt;/span&gt;           &lt;span class=&quot;n&quot;&gt;JZ&lt;/span&gt;         &lt;span class=&quot;n&quot;&gt;LAB_14000856b&lt;/span&gt;
&lt;span class=&quot;mi&quot;&gt;140008563&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;33&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;c0&lt;/span&gt;           &lt;span class=&quot;n&quot;&gt;XOR&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;EAX&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;EAX&lt;/span&gt;
&lt;span class=&quot;mi&quot;&gt;140008565&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;48&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;83&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;c4&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;20&lt;/span&gt;     &lt;span class=&quot;n&quot;&gt;ADD&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;RSP&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mh&quot;&gt;0x20&lt;/span&gt;
&lt;span class=&quot;mi&quot;&gt;140008569&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;b&lt;/span&gt;              &lt;span class=&quot;n&quot;&gt;POP&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;RBX&lt;/span&gt;
&lt;span class=&quot;mi&quot;&gt;14000856&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;c3&lt;/span&gt;              &lt;span class=&quot;n&quot;&gt;RET&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Two behaviors stand out immediately:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;If a debugger is detected -&amp;gt; return early (skip the noisy part).&lt;/li&gt;
  &lt;li&gt;Otherwise -&amp;gt; proceed into a second branch that performs a dump routine (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;FUN_140008370&lt;/code&gt;).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;As an unhandled exception filter, Windows calls this function with exception-context-like data. The hypothesis here is that the handler’s purpose is less about “handling” an exception and more about conditionally executing the dump logic.&lt;/p&gt;

&lt;p&gt;The dump routine path includes:&lt;/p&gt;

&lt;div class=&quot;language-c highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;mi&quot;&gt;14000838&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;f&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;48&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;d&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;d&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;LEA&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;RCX&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;u_DbgHelp&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;dll_14001ab68&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;mi&quot;&gt;140008396&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ff&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;15&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;9&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;c&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;CALL&lt;/span&gt;       &lt;span class=&quot;n&quot;&gt;qword&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ptr&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;KERNEL32&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;DLL&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;LoadLibraryW&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;...&lt;/span&gt;
&lt;span class=&quot;mi&quot;&gt;1400083&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ac&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;48&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;d&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;15&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;LEA&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;RDX&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;s_MiniDumpWriteDump_14001ab80&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;mi&quot;&gt;1400083&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;b3&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;48&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;b&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;c8&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;MOV&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;RCX&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;RAX&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;...&lt;/span&gt;
&lt;span class=&quot;mi&quot;&gt;1400083&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;b6&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;48&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;89&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ac&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;MOV&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;qword&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ptr&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;RSP&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;local_res10&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;RBP&lt;/span&gt;
&lt;span class=&quot;mi&quot;&gt;1400083&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;be&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ff&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;15&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;c&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;CALL&lt;/span&gt;       &lt;span class=&quot;n&quot;&gt;qword&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ptr&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;KERNEL32&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;DLL&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;GetProcAddress&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;...&lt;/span&gt;
&lt;span class=&quot;mi&quot;&gt;14000840&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;d&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ff&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;15&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;45&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;CALL&lt;/span&gt;       &lt;span class=&quot;n&quot;&gt;qword&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ptr&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;KERNEL32&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;DLL&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;GetLocalTime&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;...&lt;/span&gt;
&lt;span class=&quot;mi&quot;&gt;14000844&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;c&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;d&lt;/span&gt; &lt;span class=&quot;mo&quot;&gt;05&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;LEA&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;R8&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;u_&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;analyze_&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;v_14001ab98&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;mi&quot;&gt;140008451&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;48&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;d&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;15&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;LEA&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;RDX&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;u_&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;%&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-%&lt;/span&gt;&lt;span class=&quot;mo&quot;&gt;04&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;d&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;%&lt;/span&gt;&lt;span class=&quot;mo&quot;&gt;02&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;d&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;%&lt;/span&gt;&lt;span class=&quot;mo&quot;&gt;02&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;d&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-%&lt;/span&gt;&lt;span class=&quot;mo&quot;&gt;02&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;d&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;%&lt;/span&gt;&lt;span class=&quot;mo&quot;&gt;02&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;d&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;%&lt;/span&gt;&lt;span class=&quot;mo&quot;&gt;02&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;d&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;dmp_14001a&lt;/span&gt;
&lt;span class=&quot;mi&quot;&gt;140008458&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;48&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;d&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;c&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;LEA&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;RCX&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;local_238&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;RSP&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;mh&quot;&gt;0x70&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;mi&quot;&gt;14000845&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;d&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ff&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;15&lt;/span&gt; &lt;span class=&quot;mo&quot;&gt;05&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;CALL&lt;/span&gt;       &lt;span class=&quot;n&quot;&gt;qword&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ptr&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;USER32&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;DLL&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;wsprintfW&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;...&lt;/span&gt;
&lt;span class=&quot;mi&quot;&gt;140008463&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;c&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;89&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;c&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;MOV&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;qword&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ptr&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;RSP&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;local_278&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;R13&lt;/span&gt;
&lt;span class=&quot;mi&quot;&gt;140008468&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;45&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;d&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;45&lt;/span&gt; &lt;span class=&quot;mo&quot;&gt;03&lt;/span&gt;     &lt;span class=&quot;n&quot;&gt;LEA&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;R8D&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;R13&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;mh&quot;&gt;0x3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;mi&quot;&gt;14000846&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;c&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;48&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;d&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;c&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;LEA&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;RCX&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;local_238&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;RSP&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;mh&quot;&gt;0x70&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;mi&quot;&gt;140008471&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;45&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;33&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;c9&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;XOR&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;R9D&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;R9D&lt;/span&gt;
&lt;span class=&quot;mi&quot;&gt;140008474&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ba&lt;/span&gt; &lt;span class=&quot;mo&quot;&gt;00&lt;/span&gt; &lt;span class=&quot;mo&quot;&gt;00&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;MOV&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;EDX&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mh&quot;&gt;0xc0000000&lt;/span&gt;
&lt;span class=&quot;mi&quot;&gt;140008479&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;44&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;89&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;c&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;MOV&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;dword&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ptr&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;RSP&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;local_280&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;R13D&lt;/span&gt;
&lt;span class=&quot;mi&quot;&gt;14000847&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;e&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;c7&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;44&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;24&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;MOV&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;dword&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ptr&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;RSP&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;local_288&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;&lt;span class=&quot;mh&quot;&gt;0x2&lt;/span&gt;
&lt;span class=&quot;mi&quot;&gt;140008486&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ff&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;15&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;bc&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;CALL&lt;/span&gt;       &lt;span class=&quot;n&quot;&gt;qword&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ptr&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;KERNEL32&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;DLL&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;CreateFileW&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;That second branch is especially interesting because creating a minidump of its own process appears deliberate and can capture sensitive runtime state. At this stage, I considered a few plausible motivations:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;Self-debugging:&lt;/strong&gt; Generate a dump that can be pulled later to debug failures on victim systems.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Anti-analysis gating:&lt;/strong&gt; Only produce artifacts when not under a debugger (to avoid handing analysts decrypted state during interactive reversing).&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Noise injection / disruption&lt;/strong&gt;: Dumping can pollute disk with artifacts, trigger alerts, or waste analyst time depending on how it is used operationally.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;62-analysing-the-self-dump-flow-exception-triggered&quot;&gt;6.2 Analysing the Self-dump Flow (Exception-Triggered)&lt;/h3&gt;

&lt;h4 id=&quot;621-loading-dbghelpdll&quot;&gt;6.2.1 Loading &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;DbgHelp.dll&lt;/code&gt;&lt;/h4&gt;

&lt;p&gt;The dump path begins by dynamically loading &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;DbgHelp.dll&lt;/code&gt;:&lt;/p&gt;

&lt;div class=&quot;language-c highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;LEA&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;RCX&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;u_DbgHelp&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;dll&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;CALL&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;KERNEL32&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;LoadLibraryW&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This avoids a static import of DbgHelp in the PE import table. Static imports are analyst-friendly, allowing us to eyeball the IAT and immediately know what the binary wants. Dynamic resolution reduces that visibility and also makes the dumping APIs conditional, as they only appear if/when the branch executes.&lt;/p&gt;

&lt;h4 id=&quot;622-resolving-and-calling-minidumpwritedump&quot;&gt;6.2.2 Resolving and Calling &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;MiniDumpWriteDump&lt;/code&gt;&lt;/h4&gt;

&lt;p&gt;After loading &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;DbgHelp.dll&lt;/code&gt;, the implant resolves &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;MiniDumpWriteDump&lt;/code&gt; by name via &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;GetProcAddress&lt;/code&gt;:&lt;/p&gt;

&lt;div class=&quot;language-c highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;GetProcAddress&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;hDbgHelp&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;MiniDumpWriteDump&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;It then performs a programmatic self-dump of the current process. The typical supporting calls in this pattern are:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;GetCurrentProcessId()&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;GetCurrentProcess()&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;Create/open a file handle for the dump output (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;CreateFileW&lt;/code&gt;)&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;MiniDumpWriteDump(processHandle, pid, fileHandle, dumpType, …)&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The key point is that this is not an OS-generated crash dump created by WerFault. This is an intentional dump created by the implant itself, and it can include:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Decrypted configuration (in memory),&lt;/li&gt;
  &lt;li&gt;Decrypted or unpacked modules that never touch disk,&lt;/li&gt;
  &lt;li&gt;Runtime-resolved function pointers and state,&lt;/li&gt;
  &lt;li&gt;Potentially keys/tokens/parameters used later in execution.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This behavior may help operators debug, but it can also leak the implant’s secrets to defenders if the dump is recovered.&lt;/p&gt;

&lt;h4 id=&quot;623-dump-filename-format&quot;&gt;6.2.3 Dump Filename Format&lt;/h4&gt;

&lt;p&gt;The filename is constructed using &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;GetLocalTime&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;wsprintfW&lt;/code&gt;, with the timestamp format string:&lt;/p&gt;

&lt;div class=&quot;language-text highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&quot;%s-%04d%02d%02d-%02d%02d%02d.dmp&quot;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This produces a timestamped dump name:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;PREFIX-YYYYMMDD-HHMMSS.dmp&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The exact value for &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;%s&lt;/code&gt; depends on what the caller passes at the callsite. In the disassembly we saw a string &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;u&quot;!analyze -v&quot;&lt;/code&gt;, which is suspicious as a prefix candidate and may be a decoy or debug artifact. Regardless, the timestamp structure is clear: it is designed to be unique per run.&lt;/p&gt;

&lt;h2 id=&quot;7-c2-configuration-storage-and-parsing&quot;&gt;7. C2 Configuration Storage and Parsing&lt;/h2&gt;

&lt;p&gt;After initialization and anti-analysis staging, the implant starts to look like an actual C2 client. This logic is reached via &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;FUN_1400073d0&lt;/code&gt; (invoked during setup), which then leads into the main configuration parser &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;FUN_1400073e4&lt;/code&gt;. The parser operates on a compact delimited configuration string, extracts values into runtime globals, and supports a registry-based override to “retask” without patching the binary.&lt;/p&gt;

&lt;h3 id=&quot;71-recovered-config-string&quot;&gt;7.1 Recovered Config String&lt;/h3&gt;

&lt;p&gt;Early in the parser we saw:&lt;/p&gt;

&lt;div class=&quot;language-c highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;mi&quot;&gt;14000740&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;e&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;48&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;b&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cd&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;MOV&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;RCX&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;DAT_14001f440&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;RBP&lt;/span&gt;
&lt;span class=&quot;mi&quot;&gt;140007411&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;e8&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;a6&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;24&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;CALL&lt;/span&gt;       &lt;span class=&quot;n&quot;&gt;_wcsrev&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This tells us that the string at &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;amp;DAT_14001f440&lt;/code&gt; is stored in reverse. Static string extraction sees nonsense, while at runtime, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;_wcsrev&lt;/code&gt; flips it back just before parsing.&lt;/p&gt;

&lt;p&gt;Once reversed, the configuration appears as a delimiter-separated table:&lt;/p&gt;

&lt;div class=&quot;language-text highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;|p1:maaahao.vip|o1:8081|t1:1
|p2:maaahao.vip|o2:8888|t2:1
|p3:maaahao.vip|o3:80|t3:1
|dd:1|cl:1|fz:|bb:1.0|bz:2025.11.7|jp:0|bh:0|ll:0|dl:0|sh:0|kl:0|bd:
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;We can see a structural detail here: the string begins with a leading &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;|&lt;/code&gt;. That makes parsing simpler and safer because every entry is boundary-delimited, reducing the risk of accidental substring matches inside values. Even if the implementation searches for &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;p1:&lt;/code&gt; rather than &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;|p1:&lt;/code&gt;, this layout still reflects a deliberate “flat table” grammar.&lt;/p&gt;

&lt;p&gt;At a glance, the grammar is intentionally minimal:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;Entries are separated by &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;|&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;Each entry is a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;key:value&lt;/code&gt; pair&lt;/li&gt;
  &lt;li&gt;Keys are short (2 chars + optional index), values are either strings or single-digit toggles&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The first cluster (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;p1/o1/t1&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;p2/o2/t2&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;p3/o3/t3&lt;/code&gt;) reads like a list of C2 endpoints with enable flags. The later flags (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;dd&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;cl&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;jp&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;bh&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ll&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;dl&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sh&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;kl&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;bd&lt;/code&gt;) behave like feature toggles, versioning markers, and behavior parameters.&lt;/p&gt;

&lt;p&gt;The intent here is clear: the implant wants a compact, easily replaceable config that can be parsed without heavy dependencies.&lt;/p&gt;

&lt;h3 id=&quot;72-parsing-helper-key-extractor&quot;&gt;7.2 Parsing Helper: Key Extractor&lt;/h3&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;FUN_1400072a0&lt;/code&gt; was determined to be the implant’s mini “config getter.” Its behavior is consistent across repeated calls:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Search the config buffer (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;DAT_14001f440&lt;/code&gt;) for a key prefix like &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;L&quot;p1:&quot;&lt;/code&gt;.&lt;/li&gt;
  &lt;li&gt;Once found, advance past the prefix.&lt;/li&gt;
  &lt;li&gt;Copy characters until the next delimiter &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;|&lt;/code&gt;.&lt;/li&gt;
  &lt;li&gt;Write the extracted value into a destination buffer, or set a boolean if the destination is &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;NULL&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This helper explains why the main parser (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;FUN_1400073d0&lt;/code&gt;) repeatedly calls it for keys:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;p1&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;o1&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;p2&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;o2&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;p3&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;o3&lt;/code&gt; copied into buffers&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;t1&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;t2&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;t3&lt;/code&gt; handled as booleans (or via direct &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;1&lt;/code&gt; checks)&lt;/li&gt;
  &lt;li&gt;Additional keys extracted into other globals&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Once extracted, other code never has to parse the raw string again. It simply reads from the populated runtime globals (e.g., host buffers, port buffers, and enable flags). This is why &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;FUN_1400080e0&lt;/code&gt; looks like it selects between pre-parsed tables rather than interpreting the string directly.&lt;/p&gt;

&lt;h3 id=&quot;73-boolean-toggles&quot;&gt;7.3 Boolean Toggles&lt;/h3&gt;

&lt;p&gt;The toggle logic is consistent: if the character after the colon is &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&apos;1&apos;&lt;/code&gt; (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;0x31&lt;/code&gt;), set a corresponding global to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;1&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;We saw this pattern for:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;t1&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;t2&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;t3&lt;/code&gt; -&amp;gt; endpoint enable flags&lt;/li&gt;
  &lt;li&gt;And this is likely for other switches (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;jp&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;bh&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ll&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;dl&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sh&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;kl&lt;/code&gt;) depending on how the implant uses them later in execution.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;74-config-override-via-hkcuconsoleipdate&quot;&gt;7.4 Config Override via &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;HKCU\Console\IpDate&lt;/code&gt;&lt;/h3&gt;

&lt;p&gt;The most operationally interesting detail is a registry-based override. The parser checks:&lt;/p&gt;

&lt;div class=&quot;language-text highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;HKCU\Console\IpDate
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;It first opens the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Console&lt;/code&gt; key under &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;HKCU&lt;/code&gt;:&lt;/p&gt;

&lt;div class=&quot;language-c highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;mi&quot;&gt;140007&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;d4d&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;48&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;d&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;84&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;LEA&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;RAX&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;local_res18&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;RSP&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;mh&quot;&gt;0x80&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;mi&quot;&gt;140007&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;d55&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;48&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;d&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;15&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;LEA&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;RDX&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;u_Console_14001ab48&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;mi&quot;&gt;140007&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;d5c&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;41&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;b9&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;19&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;MOV&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;R9D&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mh&quot;&gt;0x20019&lt;/span&gt;
&lt;span class=&quot;mi&quot;&gt;140007&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;d62&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;45&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;33&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;c0&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;XOR&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;R8D&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;R8D&lt;/span&gt;
&lt;span class=&quot;mi&quot;&gt;140007&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;d65&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;48&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;c7&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;c1&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;MOV&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;RCX&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mh&quot;&gt;0x7fffffff&lt;/span&gt;
&lt;span class=&quot;mi&quot;&gt;140007&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;d6c&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;c7&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;44&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;24&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;MOV&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;dword&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ptr&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;RSP&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;local_res10&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;&lt;span class=&quot;mh&quot;&gt;0x3&lt;/span&gt;
&lt;span class=&quot;mi&quot;&gt;140007&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;d74&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;48&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;89&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;44&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;MOV&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;qword&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ptr&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;RSP&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;local_48&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;RAX&lt;/span&gt;
&lt;span class=&quot;mi&quot;&gt;140007&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;d79&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;c7&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;44&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;24&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;MOV&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;dword&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ptr&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;RSP&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;local_res8&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;&lt;span class=&quot;mh&quot;&gt;0x0&lt;/span&gt;
&lt;span class=&quot;mi&quot;&gt;140007&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;d81&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ff&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;15&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;81&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;CALL&lt;/span&gt;       &lt;span class=&quot;n&quot;&gt;qword&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ptr&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ADVAPI32&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;DLL&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;RegOpenKeyExW&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Then it queries the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;HKCU\Console\IpDate&lt;/code&gt; value.&lt;/p&gt;

&lt;div class=&quot;language-c highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;mi&quot;&gt;140007&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;d8b&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;48&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;b&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;c&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;MOV&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;RCX&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;qword&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ptr&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;RSP&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;local_res18&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;mi&quot;&gt;140007&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;d93&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;48&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;d&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;44&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;LEA&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;RAX&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;local_res8&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;RSP&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;mh&quot;&gt;0x70&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;mi&quot;&gt;140007&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;d98&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;c&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;d&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;c&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;LEA&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;R9&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;local_res10&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;RSP&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;mh&quot;&gt;0x78&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;mi&quot;&gt;140007&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;d9d&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;48&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;89&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;44&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;MOV&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;qword&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ptr&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;RSP&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;local_40&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;RAX&lt;/span&gt;
&lt;span class=&quot;mi&quot;&gt;140007&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;da2&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;48&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;d&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;15&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;LEA&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;RDX&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;u_IpDate_14001ab58&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;mi&quot;&gt;140007&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;da9&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;45&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;33&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;c0&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;XOR&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;R8D&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;R8D&lt;/span&gt;
&lt;span class=&quot;mi&quot;&gt;140007&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;dac&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;48&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;c7&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;44&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;MOV&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;qword&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ptr&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;RSP&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;local_48&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;&lt;span class=&quot;mh&quot;&gt;0x0&lt;/span&gt;
&lt;span class=&quot;mi&quot;&gt;140007&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;db5&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ff&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;15&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;d&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;CALL&lt;/span&gt;       &lt;span class=&quot;n&quot;&gt;qword&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ptr&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ADVAPI32&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;DLL&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;RegQueryValueExW&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Importantly, it uses the common two-step query pattern:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;Query with a null data pointer to retrieve the required size.&lt;/li&gt;
  &lt;li&gt;If the size passes a sanity check (in this case &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;gt; 10&lt;/code&gt;), clear the config buffer and query again to fetch the actual bytes.&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;language-c highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;mi&quot;&gt;140007&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;dbb&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;83&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;7&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;c&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;24&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;CMP&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;dword&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ptr&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;RSP&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;local_res8&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;&lt;span class=&quot;mh&quot;&gt;0xa&lt;/span&gt;
&lt;span class=&quot;mi&quot;&gt;140007&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;dc0&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;f&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;86&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;e3&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;JBE&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;LAB_1400080a9&lt;/span&gt;
&lt;span class=&quot;mi&quot;&gt;140007&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;dc6&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;33&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;d2&lt;/span&gt;           &lt;span class=&quot;n&quot;&gt;XOR&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;EDX&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;EDX&lt;/span&gt;
&lt;span class=&quot;mi&quot;&gt;140007&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;dc8&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;41&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;b8&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;d0&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;MOV&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;R8D&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mh&quot;&gt;0x7d0&lt;/span&gt;
&lt;span class=&quot;mi&quot;&gt;140007&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;dce&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;48&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;b&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cd&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;MOV&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;RCX&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;DAT_14001f440&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;RBP&lt;/span&gt;
&lt;span class=&quot;mi&quot;&gt;140007&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;dd1&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;e8&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ea&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;39&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;CALL&lt;/span&gt;       &lt;span class=&quot;n&quot;&gt;FUN_14000b7c0&lt;/span&gt;
&lt;span class=&quot;mi&quot;&gt;140007&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;dd6&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;48&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;b&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;c&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;MOV&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;RCX&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;qword&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ptr&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;RSP&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;local_res18&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;mi&quot;&gt;140007&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;dde&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;c&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;d&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;c&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;LEA&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;R11&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;local_res8&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;RSP&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;mh&quot;&gt;0x70&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;mi&quot;&gt;140007&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;de3&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;c&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;89&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;c&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;MOV&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;qword&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ptr&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;RSP&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;local_40&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;R11&lt;/span&gt;
&lt;span class=&quot;mi&quot;&gt;140007&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;de8&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;c&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;d&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;c&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;LEA&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;R9&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;local_res10&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;RSP&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;mh&quot;&gt;0x78&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;mi&quot;&gt;140007&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ded&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;48&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;d&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;15&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;LEA&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;RDX&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;u_IpDate_14001ab58&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;mi&quot;&gt;140007&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;df4&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;45&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;33&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;c0&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;XOR&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;R8D&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;R8D&lt;/span&gt;
&lt;span class=&quot;mi&quot;&gt;140007&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;df7&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;48&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;89&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;c&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;MOV&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;qword&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ptr&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;RSP&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;local_48&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;RBP&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;DAT_14001f440&lt;/span&gt;
&lt;span class=&quot;mi&quot;&gt;140007&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;dfc&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ff&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;15&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;16&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;CALL&lt;/span&gt;       &lt;span class=&quot;n&quot;&gt;qword&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ptr&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ADVAPI32&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;DLL&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;RegQueryValueExW&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;We interpret this as a post-deployment control channel:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Operators can change C2 host/ports and toggles without recompiling.&lt;/li&gt;
  &lt;li&gt;The implant can be “retasked” locally by updating a registry value.&lt;/li&gt;
  &lt;li&gt;The key path is intentionally boring-looking (“Console” settings) which helps it blend in compared to something obviously malicious.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The end result is that configuration is effectively &lt;strong&gt;baked-in but replaceable&lt;/strong&gt;. Static config provides defaults, while the registry override provides agility.&lt;/p&gt;

&lt;h2 id=&quot;8-where-static-analysis-stops-and-part-2-starts&quot;&gt;8. Where Static Analysis Stops (and Part 2 Starts)&lt;/h2&gt;

&lt;p&gt;At the end of static analysis, this is what we know:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;strong&gt;Stage-0 Go loader&lt;/strong&gt;
    &lt;ul&gt;
      &lt;li&gt;Resolves its own path&lt;/li&gt;
      &lt;li&gt;Persists via &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;HKCU\...\Run&lt;/code&gt; as &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;CalculatorApp_AutoStart&lt;/code&gt;&lt;/li&gt;
      &lt;li&gt;Decrypts an embedded blob (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;0x25660&lt;/code&gt; bytes) using AES-ECB with key &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;1ws12uuu11j*p5fr&lt;/code&gt;&lt;/li&gt;
      &lt;li&gt;Executes the decrypted buffer in-memory via &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;VirtualAlloc&lt;/code&gt; / &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;RtlMoveMemory&lt;/code&gt; / &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;CreateThread&lt;/code&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Embedded blob&lt;/strong&gt;
    &lt;ul&gt;
      &lt;li&gt;Donut shellcode container&lt;/li&gt;
      &lt;li&gt;Unwraps into a native &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;x64&lt;/code&gt; PE implant&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Native implant&lt;/strong&gt;
    &lt;ul&gt;
      &lt;li&gt;CRT + heap setup (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;HeapCreate&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;HeapAlloc&lt;/code&gt;)&lt;/li&gt;
      &lt;li&gt;Environment/version checks (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;GetVersion&lt;/code&gt;)&lt;/li&gt;
      &lt;li&gt;Setup hub (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;FUN_140008580&lt;/code&gt;) that installs an exception filter, hides UI, and starts the operational thread&lt;/li&gt;
      &lt;li&gt;Debugger gate + self-process dumping (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;DbgHelp.dll&lt;/code&gt; + &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;MiniDumpWriteDump&lt;/code&gt;) with timestamped &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.dmp&lt;/code&gt; naming&lt;/li&gt;
      &lt;li&gt;Reversed-string config storage + runtime parsing&lt;/li&gt;
      &lt;li&gt;Registry-based config override via &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;HKCU\Console\IpDate&lt;/code&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In Part 2 we’ll treat the C2 configuration as an active protocol, recover message framing, capture and emulate the exchange, and build a minimal server that keeps the implant talking long enough to expose its full behavior.&lt;/p&gt;

&lt;h2 id=&quot;references&quot;&gt;References&lt;/h2&gt;

&lt;div class=&quot;footnotes&quot; role=&quot;doc-endnotes&quot;&gt;
  &lt;ol&gt;
    &lt;li id=&quot;fn:1&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;&lt;a href=&quot;https://attack.mitre.org/techniques/T1547/001/&quot;&gt;MITRE ATT&amp;amp;CK T1547.001 - Registry Run Keys / Startup Folder&lt;/a&gt; &lt;a href=&quot;#fnref:1&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:3&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;&lt;a href=&quot;https://www.ired.team/miscellaneous-reversing-forensics/windows-kernel-internals/exploring-process-environment-block&quot;&gt;Exploring Process Environment Block&lt;/a&gt; &lt;a href=&quot;#fnref:3&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:4&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;&lt;a href=&quot;https://isc.sans.edu/diary/24058&quot;&gt;Using &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;scdbg&lt;/code&gt; to Analyze Shellcode&lt;/a&gt; &lt;a href=&quot;#fnref:4&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:2&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;&lt;a href=&quot;https://www.hackercoolmagazine.com/donut-shellcode-generator-beginners-guide/&quot;&gt;Donut Shellcode Generator: Beginner’s Guide&lt;/a&gt; &lt;a href=&quot;#fnref:2&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:5&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;&lt;a href=&quot;https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-showwindow&quot;&gt;ShowWindow Function (winuser.h)&lt;/a&gt; &lt;a href=&quot;#fnref:5&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
  &lt;/ol&gt;
&lt;/div&gt;
</content>
 </entry>
 
 <entry>
   <title>Understanding the Why</title>
   <link href="https://lehasas.github.io/understanding-the-why.html"/>
   <updated>2025-04-01T00:00:00+00:00</updated>
   <id>https://lehasas.github.io/understanding-the-why</id>
   <content type="html">&lt;p&gt;Security gets sold as certainty: dashboards, metrics, “visibility.” The work that keeps pulling me in is the opposite. It’s the part where you do not get to assume the system is telling the truth, and you have to earn every claim by taking something apart.&lt;/p&gt;

&lt;p&gt;Malware analysis sits right in that gap. It is a forced audit of reality: what the binary actually does, what the network trace actually contains, what the OS actually guarantees, and how quickly a neat theory collapses when a single assumption is wrong.&lt;/p&gt;

&lt;p&gt;I still remember the first time I opened a binary in Ghidra and stared at the decompiler like it was an alien language. What hooked me was not the tool. It was the feeling that there was a coherent story in there, and the only way to get it was to build the model yourself.&lt;/p&gt;

&lt;h2 id=&quot;why-i-study-malware&quot;&gt;Why I Study Malware&lt;/h2&gt;

&lt;p&gt;I am interested in security broadly, but malware analysis is where my curiosity becomes mechanical. You do not get to hand-wave. You either explain an artifact or you do not.&lt;/p&gt;

&lt;p&gt;The part I enjoy most is the transition from vague suspicion to a crisp narrative:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;What is the stage layout?&lt;/li&gt;
  &lt;li&gt;Where is configuration stored, and how is it protected?&lt;/li&gt;
  &lt;li&gt;What does persistence actually change on disk/registry/service state?&lt;/li&gt;
  &lt;li&gt;What is the operator supposed to be able to control after deployment?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And if the answer is “I am not sure yet,” I want to be able to say exactly what would remove the uncertainty.&lt;/p&gt;

&lt;h2 id=&quot;what-drew-me-in&quot;&gt;What Drew Me In&lt;/h2&gt;

&lt;p&gt;There is a kind of poetry in malware, but it is the poetry of constraints. Malware has to execute in hostile environments, operate under partial visibility, and keep functioning when defenders and sandboxes interfere.&lt;/p&gt;

&lt;p&gt;I am drawn less to the destruction and more to the design:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;the weird tradeoffs (noise vs reliability vs stealth)&lt;/li&gt;
  &lt;li&gt;the tiny implementation mistakes that change everything&lt;/li&gt;
  &lt;li&gt;the subtle ways systems fail when their assumptions are stressed&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Malware is a sharp lens for studying how software is built, and how it breaks.&lt;/p&gt;

&lt;h2 id=&quot;how-i-work-and-what-i-show&quot;&gt;How I Work (And What I Show)&lt;/h2&gt;

&lt;p&gt;When I write a post here, I am not trying to produce a perfect tutorial. I am documenting investigation:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;the initial hypotheses from triage&lt;/li&gt;
  &lt;li&gt;how I proved or disproved them&lt;/li&gt;
  &lt;li&gt;where the evidence was solid vs where it was suggestive&lt;/li&gt;
  &lt;li&gt;the dead ends (when they’re instructive)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Some posts will be clean and conclusive. Some will be explicitly marked as work-in-progress. Either way, I want the reader to be able to track the chain of reasoning.&lt;/p&gt;

&lt;h2 id=&quot;what-youll-find-here&quot;&gt;What You’ll Find Here&lt;/h2&gt;

&lt;p&gt;This blog is a long-form notebook. I am optimizing for slow reading and replayable understanding, not for engagement.&lt;/p&gt;

&lt;p&gt;You will find:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;narrative-driven malware write-ups (static, dynamic, and sometimes protocol work)&lt;/li&gt;
  &lt;li&gt;reverse engineering notes (how I recognized patterns, how I named things, what I missed at first)&lt;/li&gt;
  &lt;li&gt;tooling experiments (small scripts, helpers, lab notes)&lt;/li&gt;
  &lt;li&gt;occasional reflective pieces on how security is practiced vs how it is marketed&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If a post is part of a longer investigation, it will be labeled as a series/part so you can follow it end-to-end.&lt;/p&gt;

&lt;h2 id=&quot;the-why-that-keeps-me-going&quot;&gt;The Why That Keeps Me Going&lt;/h2&gt;

&lt;p&gt;I keep coming back to this work for a simple reason: the fastest way to understand a system is to watch it fail and then explain why it failed.&lt;/p&gt;

&lt;p&gt;If you like that kind of thinking, you are in the right place.&lt;/p&gt;
</content>
 </entry>
 

</feed>
