In this section

Detecting Process Injection with Volatility: malfind, VADs, Threads and YARA

Module 0

Introduction

Code that runs from a file leaves the file, and the file can be found, hashed and scanned. Code injected into another process has no file: it is written into the memory of a process that is already running, and it runs as part of that process.

To the process list it looks like nothing at all. Finding it is the core skill of memory forensics, and the subject of Module 2.

Protectionexecutable andwritableandNo fileprivate memory,nothing mappedandA threadstarting insidethe regionandContentsa PE header,tool strings

Four independent lines that converge on one region. Any one alone has innocent explanations; together they are a finding.

This lesson reads the injection in NE-ENG-031-1431, the capture from the last two lessons, where code was put into explorer.exe in the afternoon. It starts from malfind's candidates, sets them against the same host's baseline, and then builds a finding from four independent lines of evidence: the region's protection, the absence of a file behind it, a thread that starts inside it, and its contents.

01

Candidates, Not Verdicts

What malfind reports

Volatility's documentation describes windows.malware.malfind as listing process memory ranges that potentially contain injected code. The word potentially is the important one. Run against explorer.exe:

$ vol --hide-columns Tag CommitCharge "File output" -f NE-ENG-031-1431.raw \
    windows.malware.malfind --pid 1428
Volatility 3 Framework 2.28.2
Progress:  100.00		PDB scanning finished

PID	Process	Start VPN	End VPN	Protection	PrivateMemory	Notes	Hexdump	Disasm

1428	explorer.exe	0x2a10000	0x2a47fff	PAGE_EXECUTE_READWRITE	1	MZ header	
4d 5a 90 00 03 00 00 00 04 00 00 00 ff ff 00 00 MZ..............
b8 00 00 00 00 00 00 00 40 00 00 00 00 00 00 00 ........@.......
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 00 00 00 00 00 f8 00 00 00 ................	
0x2a10000:	pop	r10
0x2a10002:	nop	
0x2a10003:	add	byte ptr [rbx], al
0x2a10005:	add	byte ptr [rax], al
0x2a10007:	add	byte ptr [rax + rax], al
0x2a1000a:	add	byte ptr [rax], al

Each candidate comes with its process and PID, the region's start and end, its protection, whether it is private memory, malfind's notes, and the first bytes as a hexdump and as disassembly. The documentation notes that malfind returns the first 64 bytes of each region and ignores regions that are entirely paged out or zeros, because those would otherwise match its filter and tell you nothing.

This region is executable, writable and private: memory the process allocated itself rather than mapped from a file, with protections that let code both be written into it and run from it. Its first two bytes are 4d 5a, MZ in ASCII, the signature that starts every Windows executable file, and malfind's notes column says so. The disassembly is meaningless, because those bytes are a file header, not instructions.

Read the columns that malfind did not need to show as well.

The region runs from 0x2a10000 to 0x2a47fff, about 224 KB, which is the size of a small program rather than a scrap of data. Its private flag is 1, so the process allocated it; nothing in the file system describes it. Its commit charge is 56 pages, the whole region, so it is not a reservation waiting to be filled: every page holds something.

Those two facts alone say that something put a program-sized block of executable memory into explorer.exe by hand.

A Windows executable's header sitting in private executable memory, inside the process that draws the desktop, is a strong lead. It is also exactly what reflective loading produces, which section 5 confirms from the contents. It is still a lead.

The rest of this lesson tests it. The test is not whether the region looks bad but whether anything else could explain it, and each of the next four sections removes one possible explanation.

malfind has blind spots too, and they are worth knowing before relying on it. It looks at a region's protection and the start of its contents. Code placed in memory that is mapped from a file, as hollowing does, or in a region whose protection was changed back to read-only after the code was written, can pass it by.

Module 2 covers the techniques that aim at those gaps and the plugins that close them. For now, a malfind hit is the start of an inquiry, and a clean malfind result is not the end of one, whatever else the image seems to say.

02

Against the Baseline

Which regions this host has every day

malfind across every process in the image reports five regions, reduced here to process, start, protection, size, private flag and notes:

$ vol -f NE-ENG-031-1431.raw windows.malware.malfind | grep PAGE_EXECUTE \
    | cut -f1-3,6-8,10
Progress:  100.00		PDB scanning finished
1428	explorer.exe	0x2a10000	PAGE_EXECUTE_READWRITE	56	1	MZ header
2104	msedge.exe	0x7a500000	PAGE_EXECUTE_READWRITE	12	1	N/A
2104	msedge.exe	0x7a400000	PAGE_EXECUTE_READWRITE	12	1	N/A
2104	msedge.exe	0x7a480000	PAGE_EXECUTE_READWRITE	12	1	N/A
2104	msedge.exe	0x7a5c0000	PAGE_EXECUTE_READWRITE	12	1	N/A

Four of the five are in msedge.exe, and none of those starts with an MZ header. The same plugin on the baseline capture of the same workstation, taken the day before:

$ vol -f NE-ENG-031-baseline.raw windows.malware.malfind | grep PAGE_EXECUTE \
    | cut -f1-3,6-8,10
Progress:  100.00		PDB scanning finished
5096	msedge.exe	0x7a500000	PAGE_EXECUTE_READWRITE	12	1	N/A
5096	msedge.exe	0x7a400000	PAGE_EXECUTE_READWRITE	12	1	N/A
5096	msedge.exe	0x7a480000	PAGE_EXECUTE_READWRITE	12	1	N/A
5096	msedge.exe	0x7a5c0000	PAGE_EXECUTE_READWRITE	12	1	N/A

The browser has four such regions there too. That is the first and cheapest test of a malfind hit, and it disposes of four of the five:

Why a browser has executable private memory

Expected

What it is

just-in-time compiled script code

Where

browsers, .NET, Java, PowerShell

Looks like

private, executable and writable

Tells it apart

baseline, no PE header, no foreign thread

The trap

A malfind hit is a property, not a verdict. Engines that compile code at run time produce the same property every day, so the first question is whether this host has it on an ordinary day.

Browsers compile JavaScript into machine code as pages run, and the memory that code lives in is private and executable by design. The same is true of .NET, Java and PowerShell. On a workstation with a browser open, malfind will always report something, and an analyst who treats every hit as an injection spends the morning on Edge.

Worse, an analyst who learns to dismiss browser hits by name will one day dismiss an injection into a browser, which is a favorite target precisely because its memory is already noisy.

The baseline is the defense against both errors: it says which regions this process has every day, not which processes usually have regions. Here the baseline shows the same four starting addresses in the browser as on the incident day; a region at a new address in the browser would have been worth the same scrutiny as the one in explorer.exe.

The explorer.exe region is the one that is not in the baseline, that starts with an executable header, and that sits in a process with no compiler in it. Those three differences are why it gets the rest of the lesson, and why the browser regions do not. The browser regions are not ignored; they are explained, and the explanation, ordinary on the baseline day, is written down beside them.

03

The Region and the Image

What a VAD says about where memory came from

Every region of a process's memory is described by a structure the kernel keeps, a virtual address descriptor, or VAD. windows.vadinfo lists them, and the two that matter here are the suspect region and explorer.exe's own executable:

$ vol -f NE-ENG-031-1431.raw windows.vadinfo --pid 1428 \
    | grep -e 0x2a10000 -e Explorer.EXE | cut -f4,5,7,9,11 \
    | sed "s/.Device.HarddiskVolume3//"
Progress:  100.00		PDB scanning finished
0x2a10000	0x2a47fff	PAGE_EXECUTE_READWRITE	1	N/A
0x7ff6f4a90000	0x7ff6f4d55fff	PAGE_EXECUTE_WRITECOPY	0	\Windows\Explorer.EXE

explorer.exe's own code is mapped from a file, Explorer.EXE on the system volume, with a copy-on-write executable protection and the private flag at 0: the kernel knows exactly which file those pages came from, and the file is on disk to compare against. The suspect region has none of that. It is private memory, with no file, and with protection that allows writing and executing at once.

That difference is what makes injected code findable at all. Legitimate code nearly always arrives through the loader, mapped from a file with a path the VAD records. Code that was written into memory directly has no path, because there was never a file.

The exceptions, such as a program that legitimately maps and patches its own code, are rare enough on a workstation that each one is worth a note, and a baseline usually shows them.

The VAD also gives the size and the commit charge, which help when several candidates have to be ranked.

A region of a few pages that holds a small trampoline is read differently from one the size of a program, and both differently from a large allocation that is mostly empty. Here the region is program-sized and largely committed, which fits a full payload rather than a stub that fetches one.

Module 2 reads the VAD tree in full: how the kernel organizes these descriptors, what each field means, and how techniques such as process hollowing and doppelganging try to make injected code look file-backed after all. Those techniques exist precisely because the private-and-executable property is so easy to spot, and the module reads what each one leaves behind instead.

04

A Thread That Starts Inside It

Who is running the code, and since when

Code in memory does nothing until a thread runs it. windows.threads lists each thread with the address its creator asked it to start at:

$ vol --hide-columns Offset StartAddress StartPath -f NE-ENG-031-1431.raw \
    windows.threads | grep -e TID -e 6188
Progress:  100.00		PDB scanning finished
PID	TID	Win32StartAddress	Win32StartPath	CreateTime	ExitTime
1428	6188	0x2a11a40	-	2026-03-15 14:06:57.000000 UTC	N/A

Thread 6188 in explorer.exe was told to start at 0x2a11a40, inside the region at 0x2a10000, and its start path is empty because no module covers that address. It was created at 14:06:57, more than five hours after explorer.exe started at 08:52 and seconds before the connection to 10.5.0.20 that lesson 0.1 found explorer.exe holding.

That is the second independent line.

A region can be private and executable for innocent reasons; a thread created in the afternoon, starting inside a region with no file, in the desktop shell, has far fewer. And the time ties the region to the rest of the case: update.exe, the exited process from lesson 0.2, ran from 14:05 to 14:07, and the session moved into explorer.exe in the middle of that window.

Three records from three plugins, a process scan, a connection table and a thread list, agree on the same two minutes without any of them having been asked to, and none of them can see the others.

Agreement of that kind, between plugins that read different structures, is much harder to fake or to misread than any single time. It is also the start of the timeline that Module 8 builds properly.

Threads are also how injection is usually done. One common pattern writes code into the target's memory and then asks the system to start a thread in the target at that code.

The thread's start address, its creation time and the region it points into are the record of that request, and they survive as long as the thread does. A thread that exits takes most of that record with it, which is one more reason to capture early: a short-lived injection may leave a region and no thread to explain it.

05

What the Region Contains

A rule, a scan and three strings

The last line is the contents. The course's rules folder holds a YARA rule written for its captures, which looks for strings a Meterpreter stage carries in memory and fires when two of them are present:

$ grep -v '^//' rules/meterpreter.yar
rule lab_meterpreter_strings
{
    strings:
        $a = "metsrv" ascii wide nocase
        $b = "ReflectiveLoader" ascii
        $c = "stdapi_sys_process" ascii wide
        $d = "core_channel_open" ascii wide
    condition:
        2 of them
}

windows.vadyarascan runs a YARA rule over every region of a process's memory and reports each match with its address:

$ vol --hide-columns CreateTime PPID SessionId Threads -f NE-ENG-031-1431.raw \
    windows.vadyarascan --pid 1428 --yara-file rules/meterpreter.yar
Volatility 3 Framework 2.28.2
Progress:  100.00		PDB scanning finished

Offset	PID	ImageFileName	Rule	Component	Value

0x2a11200	1428	explorer.exe	lab_meterpreter_strings	$a	
6d 65 74 73 72 76                               metsrv          
0x2a11540	1428	explorer.exe	lab_meterpreter_strings	$b	
52 65 66 6c 65 63 74 69 76 65 4c 6f 61 64 65 72 ReflectiveLoader
0x2a11880	1428	explorer.exe	lab_meterpreter_strings	$c	
73 74 64 61 70 69 5f 73 79 73 5f 70 72 6f 63 65 stdapi_sys_proce
73 73                                           ss              

Three of the rule's four strings match, at addresses inside the region at 0x2a10000: metsrv, ReflectiveLoader and stdapi_sys_process. Those are names a Meterpreter payload's own code carries, and ReflectiveLoader in particular is the routine that loads a DLL from memory without the Windows loader, which is why there is no file.

The match addresses run from 0x2a11200 to 0x2a11880, a few kilobytes into the region and just before the address thread 6188 was told to start at, so the strings, the header and the thread all sit within the first few pages of the same allocation.

The rule's file says in a comment above it that it is a lab triage rule written for the course captures, not a production signature, and a match is a fourth line of evidence rather than the whole case.

Writing rules for a case is ordinary practice: an analyst who recognizes a tool in one region writes a rule for its strings and scans every other process and every other image with it, which is how one finding becomes a scope. Its value is that it is independent of the other three.

A region could be private and executable with a foreign thread and still hold something benign; the strings say what it holds. Strings can be removed or encrypted by a careful author, so their absence would prove little; their presence, in the region the other three lines already pointed at, is what makes them worth having.

The order those four lines were gathered in is the order Module 2 uses on every candidate:

1. Run malfind on every processand list each region it reports2. Set it against a baselineregions that appear every day are usually JIT or the like3. Read the region's VADprotection, private or file-backed, and its size4. Look for a thread that starts in itthreads, by start address and creation time5. Scan or dump the contentsa PE header, strings, a YARA match

Turning a malfind hit into a finding, in the order Module 2 takes it.

Each step is cheap, and each can end the inquiry: a region that is in the baseline, or file-backed, or has no thread and nothing recognizable in it, may still deserve a note, but it does not become a finding. Recording the step at which each candidate was set aside is what lets a reviewer check the elimination rather than trust it.

06

Four Lines, One Finding

Why convergence is the standard

Put together, the four lines describe one region from four directions. The kernel's VAD says it is private, executable and writable with no file. malfind says it begins with an executable header and is absent from the baseline. The thread list says a thread was created inside it at 14:06:57, in the window when update.exe was running. YARA says it holds a Meterpreter stage's strings.

Each of those could have come back clean, and none of them depends on the others. That independence is the standard Module 2 holds an injection finding to: not one plugin's opinion but several lines that converge, each with the plugin and row that shows it, so that a reviewer can check each one and an innocent explanation has to account for all of them at once.

A browser JIT region, by contrast, accounts for the protection and the missing file and nothing else: it has no executable header, no thread created by a foreign process, and no tool's strings.

Written down, the finding is a short record with a line for each piece of evidence:

Finding: injected code in explorer.exe

Observed, four lines

Region

0x2a10000 to 0x2a47fff, PID 1428

VAD

private, PAGE_EXECUTE_READWRITE, no file

Header

MZ at offset 0 (malfind)

Thread

6188, starts 0x2a11a40, created 14:06:57

Contents

three Meterpreter strings (lab rule)

Baseline

region absent on 14 March

The finding is still worded with care. Observed: a region in explorer.exe with these properties, a thread in it, these strings. Inferred, with high confidence: code was injected into explorer.exe at about 14:07 and ran there. Not yet established: how it got there, which Module 2 reconstructs by running the attack itself and watching each step, and what it did, which the next lessons start to answer.

That wording matters to whoever reads the finding next. The endpoint team can act on observed facts immediately: isolate the host, collect the region, search other hosts for the same strings. The inference tells them what the facts add up to, and the open questions tell them what is still worth looking for, so nobody mistakes a strong lead for a closed case.

07

What Module 2 Builds On It

Process injection in depth

Module 2 starts with how Windows gives each process its own memory, the page tables underneath it and the VAD tree that describes it.

It then runs an injection in the course lab, captures the result and reads the injected region through the VAD, covers process hollowing and doppelganging, extracts the injected code from the image, and ends with a hunt across a capture that holds an injection among a browser's JIT regions and a hollowed process.

What Module 2 builds

Module 2

2.1 to 2.3

processes, virtual memory, the VAD tree

2.4 to 2.6

run the injection, capture it, read its VAD

2.7 to 2.8

hollowing and doppelganging; extract the code

2.9

the injection hunt

The module also covers extraction: getting the injected code out of the image as a file that can be hashed, scanned and handed to a malware analyst. That is the step that turns a memory finding into something other teams can use, and it is where the strings section 5 found become a sample.

The habit to carry into it is the one this lesson practiced. Treat a malfind hit as a candidate, set it against a baseline, read its VAD, look for a thread that starts in it and read its contents, and write the finding as the lines that converge on it. Each step is cheap, and skipping any of them is how both false alarms and missed injections happen.

The same order applies when the candidate comes from somewhere else entirely: an EDR alert naming a process, a YARA hit from a scan of every process, a suspicious connection's owner. Wherever the lead starts, the region it points to is read through the same four lines before it becomes a finding.

Module 2's hunt is built around exactly the trap section 2 avoided: a capture where the browser's ordinary regions outnumber the injected one, and where the only way to the right answer is to explain every candidate rather than stopping at the first that looks bad.

It also includes a hollowed process, where the injected code sits in memory that claims to come from a file, so that the method has to be applied with judgment rather than as a checklist that always looks for a missing path.

Do

Practice

Find the injected region
prepared evidence

The prepared evidence below is malfind's five regions in the incident image, its four in the baseline, and what three other plugins show for the explorer.exe region. Decide which region needs explaining, which are ordinary, and what makes the one a finding. Each answer comes with its reasoning, so check it against the rows rather than only the choice.

Compare the two malfind tabs row by row before deciding anything, and use the Evidence tab only for the region that survives the comparison: that order is the method, and the third question is about why it works.

In the range, run malfind on the baseline capture first and then on the incident image, before reading any other output. The habit of looking at the ordinary day first is the one that saves the most time in Module 2's hunt. Then dump the explorer.exe region and run the rule on the dump, and you have taken the first steps of Module 2's extraction lesson yourself.

Keep a note of every command and what it showed; the finding record in section 6 is built from exactly those notes, line by line.

Injected code has no file, so it is found by its properties: malfind lists private executable regions as candidates; a baseline removes the ones a host has every day; the VAD shows whether memory came from a file; a thread that starts inside a region shows something ran it and when; and the contents, read with a rule, say what it holds.

A finding is the lines that converge, each with its plugin and row.

The next lesson follows the injected code to its next target: the credentials held by lsass.exe.