Process Injection --Part 1--
This C program performs process injection, specifically remote code injection into a running instance of notepad.exe. Here's a step-by-step breakdown of what the code does:
1 - FindTarget Function (Finds Process ID)
The
FindTargetfunction takes a process name (ProcName) as an argument and searches for a running process with that name.It uses
CreateToolhelp32Snapshotto take a snapshot of all running processes.It iterates through the process list using
Process32Next, checking if the process name matchesProcName(notepad.exein this case).If found, it returns the process ID (PID) of the target process
2 - Injection into Notepad
Open Notepad Process
The
OpenProcessfunction is used to get a handle to thenotepad.exeprocess with full access (PROCESS_ALL_ACCESS)
Allocate Memory in Notepad
VirtualAllocExreserves memory insidenotepad.exewithPAGE_EXECUTE_READWRITEpermissions, allowing the shellcode to be written and executed.
Write the Shellcode into Notepad
WriteProcessMemorywrites the shellcode (payload[]) into the allocated memory space.
Execute the Shellcode in Notepad
CreateRemoteThreadstarts a new thread insidenotepad.exeat the memory location where the shellcode was written, effectively executing it.
Last updated