Process Injection & Hollowing Explained | TryHackMe Abusing Windows Internals P1
We covered process injection and process hollowing. Process injection is the process of injecting an already running process with malicious code or shellcode. Process hollowing is the process of creating a legitimate process in a suspended state and then unmapping the legitimate code from memory and replacing it with the shell code. Both Process injection and hollowing are useful to hide rootkits and shellcodes in innocently-looking processes to maintain access and persistence. This was part of TryHackMe Abusing Windows Internals red team pathway.
Challenge Description
Leverage windows internals components to evade common detection solutions, using modern tool-agnostic approaches.
Video Highlights
Process injection is commonly used as an overarching term to describe injecting malicious code into a process through legitimate functionality or components.
At a high level, shellcode injection can be broken up into four steps:
- Open a target process with all access rights.
- Allocate target process memory for the shellcode.
- Write shellcode to allocated memory in the target process.
- Execute the shellcode using a remote thread.
Process hollowing offers the ability to inject an entire malicious file into a process. This is accomplished by “hollowing” or un-mapping the process and injecting specific PE (Portable Executable) data and sections into the process.
At a high-level process hollowing can be broken up into six steps:
- Create a target process in a suspended state.
- Open a malicious image.
- Un-map legitimate code from process memory.
- Allocate memory locations for malicious code and write each section into the address space.
- Set an entry point for the malicious code.
- Take the target process out of a suspended state.
At a high-level thread (execution) hijacking can be broken up into eleven steps:
- Locate and open a target process to control.
- Allocate memory region for malicious code.
- Write malicious code to allocated memory.
- Identify the thread ID of the target thread to hijack.
- Open the target thread.
- Suspend the target thread.
- Obtain the thread context.
- Update the instruction pointer to the malicious code.
- Rewrite the target thread context.
- Resume the hijacked thread.
Room Answers
Room answers can be found here.