Divin'n'phishin with executable filetypes on Windows
A hands-on research post that walks through using Windows `assoc`/`ftype` to enumerate file-extension-to-program associations and identify which extensions (.com, .pif, .scr, .bat/.cmd, .vbs/.js, .jar, .chm via hh.exe) execute directly or indirectly on double-click, useful for crafting phishing payloads that evade mail defenses. It includes working PoCs (a .NET binary renamed to .com/.pif/.scr, a VBS script, a Java JAR, and a malicious CHM built with hh.exe per LOLBas), plus credential-theft-relevant extensions like .scf and browser-opening extensions (.html/.svg/.mhtml) for phishing pages, ending with allow-list-based mitigation advice.
What it is
A method for enumerating which Windows file extensions execute directly on double-click (no helper application), useful for identifying phishing payload filetypes that survive mail defenses. The author uses only built-in assoc/ftype commands, so it works on future or constrained Windows environments where the answer isn't already documented.
How it works
Every extension maps to a "File Type" (assoc), and each File Type maps to a launch command (ftype). The tell for direct execution is that the command is the file itself — ="%1" — rather than passing the file as an argument to another binary (e.g. winword.exe /n "%1"). Dumping all associations and grepping for that pattern isolates the directly-executable set:
batfile="%1" %*
cmdfile="%1" %*
comfile="%1" %*
exefile="%1" %*
piffile="%1" %*
scrfile="%1" /SNote scrfile uses /S rather than the bare %1 pattern — so a plain ="%1" grep alone would miss it.
What to do
Reproduce the enumeration on any target Windows build:
C:\>assoc > assoc.txt
$ cut -d '=' -f2 assoc.txt > types.txt
C:\> for /f %l in ('type types.txt') do echo %l >> defs.txt && ftype %l >> defs.txt
$ grep -E '="%1"' defs.txtFor a defender, the inverse is the value: these six File Types (batfile, cmdfile, comfile, exefile, piffile, scrfile → .bat .cmd .com .pif .exe .scr) are the direct-execution set to block or alert on at the mail gateway. Indirect File Types (="%1" absent) can still execute depending on the handler binary, so treat the grep as a floor, not a complete list.
Caveats
- The author states all these filetypes have been documented before; the contribution is the method, not novel extensions.
.piffiles contain no executable code (they lack theMZmagic number), yet Windows runs them through the same pseudo-executable handling — so file-content inspection that keys onMZwill not flag a malicious.pif.- The demonstrated
.compayload is simply a compiled C# binary renamed; the "MS-DOS Application" association executes it regardless of true format.
Organisations named here
- ShellExecute
Technologies named here
- Windows
- assoc
- Microsoft Office Word
- ftype
- Java Runtime Environment, jdk-19
- FileTypesMan
- NirSoft website
- Internet Explorer
- WScript.exe
- Windows explorer
- LOLBas project
- hh.exe
- HTML Help Workshop / hhc.exe
- grep / cut
- LOLBAS
Techniques named here
- Phishing via directly executable filetypes
- COM file phishing payload
- PIF file phishing payload
- SCR file phishing payload
- VBScript-based command execution
- Malicious JAR execution
- LOLBin cross-referencing with file associations
- Malicious CHM creation
- Credential phishing via browser-opening filetypes
- NTLM credential gathering via SCF files
- Rogue OpenSearch provider via OSDX
Related in Offensive Security