Windows Reserved Filenames Exploit & Ghost File Abuse
Written by Aryan Giri
π― Overview
Windows still carries legacy behavior from MS-DOS where certain filenames like con, nul, aux, prn, com1βcom9, and lpt1βlpt9 are treated as device handles instead of normal files.
This creates a strange but powerful edge case:
- Files can be created that cannot be deleted, renamed, or moved normally
- Disk space can be silently consumed using
fsutil - Systems can be disrupted without traditional malware
This is not a classic vulnerabilityβit's a design artifact turned attack primitive.
𧬠Core Concept (Why This Exists)
These names map directly to hardware or system interfaces:
conβ Console input/outputnulβ Null device (blackhole)auxβ Serial deviceprnβ PrintercomXβ Serial portslptXβ Parallel ports
Windows NT still preserves this behavior for backward compatibility.
π When you try to interact with these as files, Windows internally redirects operations to devices.
βοΈ Technique 1: Creating Undeletable Files
π¬ Concept
Windows blocks these names at a high level, but not at the Win32 device namespace level.
By using the special prefix \\.\, we bypass standard checks.
π» Practical Demo
:: Create undeletable file
echo Hello > \\.\D:\con.txt
π§ What Happens
- File is created successfully
- Explorer sees it, but cannot manage it
del,rename, GUI delete β fail
π The system treats it as a device, not a file
βοΈ Technique 2: Ghost File via fsutil
π¬ Concept
fsutil creates files with a defined size without actually writing data (sparse-like behavior perception).
π» Practical Demo
:: Create 10GB ghost file
fsutil file createnew D:\ghost.txt 10737418240
π§ What Happens
- Explorer may show 0 bytes (confusing UI behavior)
- Disk space is actually reserved
- File cannot be opened easily
π Perfect for stealth disk exhaustion
β οΈ Technique 3: Combining Both (Stealth DoS Primitive)
π» Payload
:: Undeletable + 10GB allocation
fsutil file createnew \\.\D:\convirus 10737418240
π§ Impact
- File cannot be deleted normally
- Consumes large disk space
- Appears harmless (0 bytes illusion)
π This becomes a low-noise Denial-of-Service vector
π§ͺ Bulk Exploitation (Automation)
@echo off
for /l %%x in (1,1,100) do (
echo Hello > \\.\C:\Test\con%%x.txt
)
π§ Result
- Hundreds of undeletable files
- Folder becomes unusable
- Cleanup becomes difficult
π This simulates a denial-of-desktop attack
β οΈ Windows Behavior Analysis
Windows 10
- β GUI delete fails
- β
delfails - β Python
os.remove()fails - β Explorer shows incorrect size
Windows 11
- β Improved handling
- Some cases deletable via GUI
π Microsoft partially patched behavior, not the root design
π§Ή Deletion Techniques (Bypassing the Trick)
π οΈ Method 1: UNC Device Path
del \\.\C:\Users\YourUser\Desktop\con.txt
π οΈ Method 2: WSL (Most Reliable)
wsl
rm convirus
π Linux layer ignores Windows device semantics
π οΈ Method 3: Python WinAPI
import win32file
file_path = r'\\.\\C:\\Users\\YourUser\\Desktop\\con.txt'
win32file.DeleteFile(file_path)
π Direct WinAPI bypasses high-level restrictions
π‘οΈ Defensive Strategies
π Awareness
- Never run unknown
.bat,.ps1,.vbs
π§ Monitoring
- Detect abnormal
fsutilusage - Watch sudden disk consumption
βοΈ Controls
- AppLocker / SRP policies
- Restrict script execution in user directories
π§ͺ Detection Idea
- Alert on filenames matching reserved patterns
βοΈ Red Team Use Cases
- Simulate malware without payload execution
- Demonstrate filesystem quirks in workshops
- Create confusion-based persistence techniques
π This is psychological + technical impact, not just exploitation
π§ Ethical Reflection
This technique highlights a deeper reality:
Legacy compatibility often becomes a modern attack surface.
Windows keeps these behaviors for stabilityβbut attackers turn them into primitives.
So the real question:
π Should operating systems prioritize backward compatibility, or security?
π Key Commands Recap
:: Undeletable file
echo Hello > \\.\D:\con.txt
:: 10GB ghost file
fsutil file createnew D:\ghost.txt 10737418240
:: Combined attack
fsutil file createnew \\.\D:\convirus 10737418240
:: Delete via WSL
wsl
rm convirus
𧨠Final Thoughts
This is not "malware" by itself.
But in the hands of an attacker:
- It becomes a stealth DoS tool
- A persistence annoyance
- A user confusion weapon
π The danger is not the techniqueβit's the automation + intent.