> For the complete documentation index, see [llms.txt](https://ppn.snovvcra.sh/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ppn.snovvcra.sh/red-team/dev/code-injection/process-hollowing.md). Agents can also search and read this documentation through its [MCP server](https://ppn.snovvcra.sh/~gitbook/mcp).

# Process Hollowing

## Hollow with Shellcode

* <https://github.com/chvancooten/OSEP-Code-Snippets/blob/main/Shellcode%20Process%20Hollowing/Program.cs>
* <https://github.com/S3cur3Th1sSh1t/Creds/blob/master/Csharp/DinvokeProcessHollow.cs>

1\. Create the target process (e. g., `svchost.exe`) in a suspended state.

![](https://1743652255-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MZ5E8Fq0UBQAc7rbfId%2Fuploads%2Fgit-blob-1afd4eff0569f6db9031cee74a3e25567de9ecf3%2F004.png?alt=media\&token=cc444a75-0ed7-4ce0-93c3-bc1f631a1fdc)

2\. Query created process to extract its base address pointer from PEB (**P**rocess **E**nvironment **B**lock).

![](https://1743652255-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MZ5E8Fq0UBQAc7rbfId%2Fuploads%2Fgit-blob-18b73d7a57b0a4c10d3e6c880a815773c314eb77%2F005.png?alt=media\&token=98735902-f3ca-40ef-bd43-1956ec300fec)

3\. Read 8 bytes of memory (for 64-bit architecture) pointed by the image base address *pointer* in order to get the actual value of the image base address.

![](https://1743652255-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MZ5E8Fq0UBQAc7rbfId%2Fuploads%2Fgit-blob-d68c1fef30f46da0496b547ff8cbbc0d3d8fee89%2F006.png?alt=media\&token=8b1929cf-6ec8-4488-aebf-e75d4fc4e9c1)

4\. Read 0x200 bytes of the loaded EXE image and parse PE structure to get the EntryPoint address.

![](https://1743652255-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MZ5E8Fq0UBQAc7rbfId%2Fuploads%2Fgit-blob-361d02e850c5f638837fb348241e39644198ad22%2F007.png?alt=media\&token=e0e527ab-d086-4875-93c0-408cc0bd650f)

5\. Write the shellcode to the EntryPoint address and resume thread execution.

![](https://1743652255-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MZ5E8Fq0UBQAc7rbfId%2Fuploads%2Fgit-blob-b7cde1eb5cfadda607684069acaa748e4f1182e0%2F008.png?alt=media\&token=5c96a4a6-0998-4914-9b08-bc60ae8af4b1)

## Hollow with EXE

* <https://github.com/m0n0ph1/Process-Hollowing>
* <https://gist.github.com/gnh1201/6a3836468c898f7ad3a3656e6f24dce3>
* <https://www.ired.team/offensive-security/code-injection-process-injection/process-hollowing-and-pe-image-relocations>
