Masquerading Processes via PEB
In this post, we explain how to show a process with the information from another process by changing the Block Process Environment (abbreviated as PEB)
Overview
The information of a process, such as arguments
, image location
, loaded modules
, etc., is stored in a structure called the process environment block (_PEB)
in memory, which can be accessed through the userland
and whose values can be edited.
Tools like
ProcExplorer
display some process information by looking at the_PEB
.
Scenario
The scenario is that mimikatz.exe
is running. We need to change its path
and command line
value using WinDBG
.
Execution
Let’s first take a look at the _PEB
structure for the mimikatz.exe process:
|
|
At offset 0x020
of the PEB, there is another structure _RTL_USER_PROCESS_PARAMETERS
, which contains information about the mimikatz.exe process. Let’s check it out:
|
|
Offset 0x060
_RTL_USER_PROCESS_PARAMETERS
contains an ImagePathName
member that points to a _UNICODE_STRING
structure that contains a Buffer field that effectively represents the full name/path to our binary mimikatz.exe.
|
|
We know that 0x00000000 00be2348
contains the binary path, let’s write a new string at that memory address. let’s move mimikatz.exe with a path to the notepad.exe binary located in C:\Windows\System32\notepad.exe
:
|
|
We change the commandline
in the same way:
|
|
Now let’s see ProcessParameters
again:
|
|
Let’s look at the mimikatz.exe process again with Process Explorer: