PPID Spoofing
Parent Process ID (PPID) Spoofing is a technique used to alter the PPID of a process, effectively disguising the relationship between the child process and its true parent process.
Last updated
Parent Process ID (PPID) Spoofing is a technique used to alter the PPID of a process, effectively disguising the relationship between the child process and its true parent process.
Last updated
can make it appear as though a process was spawned by a different legitimate Windows process rather than the true parent process.
NOTE: Security solutions will often look for abnormal parent-child relationships. For example, if Microsoft Word spawns cmd.exe
this is generally an indicator of malicious macros being executed. If cmd.exe
is spawned with a different PPID then it will conceal the true parent process and instead appear as if it was spawned by a different process.
PPID Spoofing requires the use and manipulation of a process's attributes list to modify its PPID.
An attribute list is a data structure that stores a list of attributes associated with a process or thread. Attribute lists can be used to efficiently store and retrieve information about processes and threads, as well as to modify the attributes of a process or thread at runtime. They contain information about state, CPU, and memory.
The steps below sum up the required actions to perform PPID spoofing.
CreateProcessA
is called with the EXTENDED_STARTUPINFO_PRESENT
flag to provide further control over the created process.
The STARTUPINFOEXA
structure is created which contains the attributes list, LPPROC_THREAD_ATTRIBUTE_LIST
.
InitializeProcThreadAttributeList
is called to initialize the attributes list. The function must be called twice, the first time determines the size of the attributes list and the next call is the one that performs the initialization.
UpdateProcThreadAttribute
is used to update the attributes by setting the PROC_THREAD_ATTRIBUTE_PARENT_PROCESS
flag which allow the user to specify the parent process of the thread.
First we create a process witha
flag being set which is used to give further control of the created process. This flag allows us to modify PPID information.
Microsoft's documentation on EXTENDED_STARTUPINFO_PRESENT
states the following:
The process is created with extended startup information; the lpStartupInfo parameter specifies a STARTUPINFOEX structure. (Necessary for EXTENDED_STARTUPINFO_PRESENT)
The STARTUPINFOEXA
data structure is shown below:
StartupInfo
- The only member that needs to be set is cb
to sizeof(STARTUPINFOEX)
.
The InitializeProcThreadAttributeList
function is shown below.
According to Microsoft's documentation, InitializeProcThreadAttributeList
must be called twice:
The first call to InitializeProcThreadAttributeList
should be NULL
for the lpAttributeList
parameter. This call is used to determine the size of the attribute list which will be received from the lpSize
parameter.
The second call to InitializeProcThreadAttributeList
should specify a valid pointer for the lpAttributeList
parameter. The value of lpSize
should be provided as input this time. This call is the one that initializes the attributes list.
dwAttributeCount
will be set to 1 since only one attribute list is needed.
Attribute
- This flag is critical for PPID spoofing and states what should be updated in the attribute list. In this case, it needs to be set to the PROC_THREAD_ATTRIBUTE_PARENT_PROCESS
flag to update the parent process information.
The PROC_THREAD_ATTRIBUTE_PARENT_PROCESS
flag specifies the parent process of the thread. In general, the parent process of a thread is the process that created the thread. If a thread is created using the CreateThread
function, the parent process is the one that called the CreateThread
function. If a thread is created as part of a new process using the CreateProcess
function, the parent process is the new process. Updating the parent process of a thread will also update the parent process of the associated process.
lpValue
- The handle of the parent process.
cbSize
- The size of the attribute value specified by the lpValue
parameter. This will be set to sizeof(HANDLE)
.
lpAttributeList
This is the attribute list. Created with function.
Once the attribute list has been successfully initialized, use the WinAPI to add attributes to the list. The function is shown below.