Practice library / Security operations basics
Lab · Hard · 3 hoursFree account
Process Injection & Detection
Detect DLL injection, process hollowing, and reflective injection in EDR logs.
On this page 13 sections
- ·Prerequisites
- ·Background in five lines
- ·Lab Setup
- 1Count the events
- 2Read the access rights in event 10
- Locked: Find DLL injection
- Locked: Find process hollowing
- Locked: Find shellcode injection
- Locked: Write the rules
- Locked: Build the timeline and write the report
- Locked: Defence and Detection
- Locked: Check Your Work
- Locked: Clean-up
Malware hides inside trusted processes to evade antivirus and bypass application control. Cobalt Strike, Emotet and modern ransomware all inject shellcode into svchost or explorer before they run the real payload, and defenders who read the right Sysmon and ETW events catch the pattern even when the sample is new. Study DLL injection, process hollowing and reflective injection, then write three Sigma rules that catch them.
What You'll Learn
- Explain what process injection is and why attackers use it
- Find DLL injection in Sysmon events 10, 8 and 7
- Find process hollowing with Sysmon events 1 and 25
- Find shellcode injection from a thread that starts in unbacked memory
- Match Sysmon events with ETW Threat-Intelligence events by address and process ID
- Write three Sigma rules, run them, and check that normal activity does not match
An attacker who runs upd.exe from a temporary folder is easy to see. An attacker whose code runs inside explorer.exe is not. Process injection puts code into the memory of another process and runs it there. The code then has the name, the privileges and the network access of a trusted program. This lab does not teach how to inject. It teaches what injection looks like in the logs, so that you can find it and write rules for it.
You work as a defender. You only read log files. You never run injection code.
Walk-through. This lab is a guided walk-through of real Sysmon and ETW Threat-Intelligence output. KaliRange gives no sample files. To do the steps yourself, bring Sysmon and ETW Threat-Intelligence event logs of a process-injection incident on a Windows machine of your own lab: run the Atomic Red Team tests for technique T1055 on a Windows VM you own, with Sysmon configured to log events 1, 7, 8, 10 and 25 (the configuration under "Defence and Detection" below) and an EDR product exporting its Threat-Intelligence events. Export the Sysmon log as sysmon.evtx and sysmon.jsonl (evtx_dump -o jsonl sysmon.evtx), and the ETW export as etw-ti.jsonl, in place of this lab's example files, and replace the file names below with your own. The example output shows what such a capture looks like.
Prerequisites
- Windows Event Log Analysis: you must know the Windows log format, event IDs and the channel names.
- YARA & Sigma for Defenders: you must be able to read a Sigma rule.
- Detection Engineering explains why a rule needs a test that must match and a test that must not match. This lab applies it.
For the same technique on Linux, see Linux Process Injection. For the attacker side, see Windows Evasion Techniques.
Background in five lines
- DLL injection. The attacker opens the target process, writes a DLL path into it and starts a thread at
LoadLibraryA. The target loads the DLL from disk. - Process hollowing. The attacker starts a normal program suspended, removes its code from memory, writes new code and resumes it. The process looks like
svchost.exebut runs other code. - Reflective and shellcode injection. The attacker writes code into the target and starts a thread at that address. No file is loaded, so no DLL load event exists.
- Sysmon (System Monitor, from Microsoft Sysinternals) writes these events: 1 process create, 7 image load, 8 CreateRemoteThread, 10 ProcessAccess, 25 ProcessTampering.
- ETW (Event Tracing for Windows) is the kernel event system. The provider
Microsoft-Windows-Threat-Intelligencereports memory operations between processes. Only a protected anti-malware process can subscribe to it, so you see it through an EDR product, not through Event Viewer.
Lab Setup
Use your own Kali machine (a virtual machine is fine). You need these tools:
jqto read JSON lines (packagejq).chainsawto run Sigma rules on.evtxfiles (release of the WithSecure Labs project).- A text editor.
Put your capture in the folder ~/lab/injection/. The example below is data from the fictional workstation WS01 of CORP.LOCAL, user alice, on 12 November 2026:
sysmon.evtxandsysmon.jsonl: Sysmon events. The.jsonlfile is the same data, one JSON object per line. You make it withevtx_dump -o jsonl sysmon.evtx.etw-ti.jsonl: Threat-Intelligence events exported by your EDR.
All times are UTC. The data holds normal activity and three injection patterns.
Analyse only your own captured data. Build it on a Windows VM that you own, with no link to a production network. This lab needs no attack code. The Atomic Red Team test list for technique T1055 can make similar events on your own VM. List a test before you run it, with Invoke-AtomicTest T1055.001 -ShowDetailsBrief.
Step 1: Count the events
Know what is in the data
Before you hunt, learn what you have. Count the events for each ID. A log source with no event 8 or no event 10 cannot show you injection, however good your rules are.
cd ~/lab/injection
wc -l sysmon.jsonl
jq -r '.Event.System.EventID' sysmon.jsonl | sort -n | uniq -cExample output:
299 sysmon.jsonl
212 1
48 7
6 8
31 10
2 25Read the result. Events 1, 7, 8, 10 and 25 are all present. Event 8 has only 6 lines, so you can read them all. Event 10 has 31 lines, so you must filter them.
Print one event 8 to see the field names.
jq 'select(.Event.System.EventID==8) | .Event.EventData' sysmon.jsonl | head -n 14Example output:
{
"UtcTime": "2026-11-12 09:15:12.431",
"SourceProcessId": "5120",
"SourceImage": "C:\\Users\\alice\\AppData\\Local\\Temp\\upd.exe",
"TargetProcessId": "6244",
"TargetImage": "C:\\Windows\\System32\\notepad.exe",
"NewThreadId": "8812",
"StartAddress": "0x00007FFC4A3E5A60",
"StartModule": "C:\\Windows\\System32\\KERNEL32.DLL",
"StartFunction": "LoadLibraryA"
}The source is a program in Temp. The target is notepad.exe. The new thread starts at LoadLibraryA. Step 3 explains why this is a problem.
Step 2: Read the access rights in event 10
Find who opens other processes with write rights
Event 10 (ProcessAccess) records that one process opened another. It also records GrantedAccess, a bit mask of the rights. To inject, the attacker must be able to write to the memory of the target. That needs the bits PROCESS_VM_WRITE and PROCESS_VM_OPERATION.
These are the bits that matter:
| Bit | Name | Meaning |
|---|---|---|
0x0002 | PROCESS_CREATE_THREAD | Start a thread in the target |
0x0008 | PROCESS_VM_OPERATION | Allocate memory and change its protection |
0x0010 | PROCESS_VM_READ | Read memory |
0x0020 | PROCESS_VM_WRITE | Write memory |
0x0400 | PROCESS_QUERY_INFORMATION | Read process data |
0x1000 | PROCESS_QUERY_LIMITED_INFORMATION | Read basic process data |
0x1FFFFF | PROCESS_ALL_ACCESS | Every right |
Add the first six: 0x1000 + 0x0400 + 0x0020 + 0x0010 + 0x0008 + 0x0002 = 0x143A. This value is the common mask for a classic remote-thread injection. A normal program that only reads status uses 0x1410 or 0x1000.
Group the event 10 lines by mask, source and target.
jq -r 'select(.Event.System.EventID==10) | .Event.EventData
| [.GrantedAccess, .SourceImage, .TargetImage] | @tsv' sysmon.jsonl \
| sort | uniq -c | sort -rnExample output:
20 0x1FFFFF C:\Program Files\Windows Defender\MsMpEng.exe C:\Windows\System32\svchost.exe
9 0x1410 C:\Windows\System32\taskmgr.exe C:\Windows\explorer.exe
1 0x1FFFFF C:\Users\alice\AppData\Local\Temp\upd.exe C:\Windows\explorer.exe
1 0x143A C:\Users\alice\AppData\Local\Temp\upd.exe C:\Windows\System32\notepad.exeLook at the four groups.
- Defender uses
0x1FFFFF20 times. A scanner must read everything. This is normal, and a rule must exclude it by the full path of the source. - Task Manager uses
0x1410. This is normal. upd.exeruns fromTempand opensnotepad.exewith0x143A, and opensexplorer.exewith0x1FFFFF. A program in a user folder that opens other programs with write rights is the strongest signal in this step.
Write down both lines for Step 7: the source PID is 5120.
Sign in to continue
8 more sections are for signed-in members. It is free: sign in with Google.
Related
This lab is extra practice for the course Security operations basics. Do the lessons first.Open the course