Created the Saturday 23 March 2019. Updated 4 months, 3 weeks ago.
This technique leverages the
Transactional NTFS functionality in Windows. This functionality helps maintain data integrity during an unexpected error. For example, when an application needs to write or modify a file, if an error is triggered mid-write, the data can be corrupted. To avoid this kind of behavior, an application can open the file in a transactional mode to perform the modification, then commit the modification, avoiding any corruption. The modification either completes successfully or does not begin.
Process Doppelgänging abuses this functionality to overwrite a legitimate file with a malicious file, resulting in a process injection. The malicious file will be created inside a transaction then committed to the legitimate file, then executed.
Here are the detailed steps to reproduce the Process Doppelgänging technique:
Create a new transaction object using
NtCreateTransactionand store the handle in
Open the target file for the transaction using
CreateFileTransactedand store the handle in
Open the payload file using
CreateFileand store the handle in hFile.
Query the size of the payload file using
GetFileSizeExand store the result in
Allocate a buffer for the payload file using
NtAllocateVirtualMemoryand store the pointer in Buffer.
Read the payload file into the buffer using
Close the handle to the payload file.
Set the size of the target file using
Map the target file into memory using
NtMapViewOfSectionand store the result in
Copy the payload file from the buffer into the mapped memory using
Unmap the target file from memory using
Commit the transaction using
Create a new process using
NtCreateUserProcessand store the handle in
Allocate memory for the process parameters using
NtAllocateVirtualMemoryand store the result in
Set the process parameters using
Create the process using
Start the process using
NtCreateThreadExand store the handle in
Wait for the process to finish execution using
Close the handle to the process and thread.
Featured Windows API's
Below, you will find a list of the most commonly used Windows API's that are currently utilized by malware authors for current evasion technique. This list is meant to provide an overview of the API's that are commonly used for this purpose. If there are any API's that you feel should be included on this list, please do not hesitate to contact us. We will be happy to update the list and provide any additional information or documentation that may be helpful.
The resources provided below are associated links that will give you even more detailed information and research on current evasion technique. It is important to note that, while these resources may be helpful, it is important to exercise caution when following external links. As always, be careful when clicking on links from unknown sources, as they may lead to malicious content.