Establishing Persistence Using Process Doppelgänging¶
Process Doppelgänging is a stealthy technique that abuses Windows NTFS transactions to execute malicious code disguised as a legitimate process.
Because it avoids directly writing malicious binaries to disk, it often evades detection by traditional antivirus and EDR solutions.
Step 1: Creating a New Transaction¶
-
Verify NTFS is in use
This method only works on NTFS volumes due to its transactional file system features. -
Acquire necessary privileges
Typically, administrative rights are required to create and manipulate transactions. -
Start an NTFS transaction
Use the Windows API to begin a transaction, which allows filesystem changes without committing them:
Step 2: Replacing a Legitimate Executable¶
-
Select a legitimate executable
Pick a commonly run program with sufficient execution privileges. -
Create a transacted file with the same name
Open the file within the transaction context:
-
Write the malicious payload
Load the malicious binary into memory and write it into the transacted file:
Step 3: Executing the Malicious Executable¶
- Run the transacted executable
While the transaction is still active, launch the process. Windows will treat it as the legitimate program:
Step 4: Rolling Back the Transaction¶
- Rollback changes
After execution, rollback the transaction to remove the malicious binary from disk while the process remains running:
Step 5: Cleanup¶
- Close handles and free resources
Always release allocated resources to maintain stability: