Forensic Implications and Detection
Fileless Malware and Memory Injection Techniques
This category represents some of the most advanced evasion techniques, where malicious code executes primarily or entirely within the system's volatile memory (RAM), often without writing traditional executable files to the hard drive. This makes detection challenging for standard file-based scanners. These techniques frequently involve injecting code into legitimate processes to hide their presence and leverage existing trust.
Common Fileless/Memory Injection Techniques:
Reflective DLL Injection: Loading a malicious DLL directly from memory into a target process, bypassing standard Windows loading mechanisms and the need for the DLL file on disk at the time of injection.
Process Hollowing: Creating a legitimate process in a suspended state, replacing its code in memory with malicious code, and then resuming it, making the malicious code run under the guise of the legitimate process.
Shellcode Injection: Injecting raw machine code (shellcode) directly into a target process's memory and triggering its execution via various methods (e.g.,
CreateRemoteThread
, thread hijacking).In-Memory .NET Assembly Loading: Using legitimate .NET runtime features (often via PowerShell or loaders) to load and execute malicious .NET assemblies directly from memory.
Detecting Fileless Injection Techniques (Focus on Memory Analysis)
Since these techniques primarily reside in memory, detection requires analyzing the volatile state of the system, focusing heavily on process memory and related artifacts.
Kernel Live Dump Analysis (Best Overall Method):
Rationale: Analyzing a Kernel Live Dump is arguably the most robust and comprehensive approach for detecting artifacts related to fileless execution or injection processes. Even if the malicious payload operates entirely in user-mode memory, the commands, scripts, or loader processes used to initiate the injection or fileless execution often leave persistent traces within the kernel memory buffers captured in the dump. These traces can survive longer than user-mode process memory artifacts, especially if the initial loader process terminates quickly.
Procedure: Create a Kernel Live Dump using tools like System Informer or Task Manager. Note the saved
.dmp
file location (e.g.,%LOCALAPPDATA%\Microsoft\Windows\TaskManager\LiveKernelDumps\
).Analysis with
bstrings
: Usebstrings.exe
(from Eric Zimmerman Tools) to extract and filter strings from the dump file. A command focused on finding indicators of common script-based fileless execution vectors (often used as loaders for memory injection) is:bstrings.exe -f "C:\Path\To\Your\LiveKernelDump.DMP" --lr "(?i)(?:\b(?:powershell|cmd|wscript|cscript)\b|iwr|iex|invoke|encodedcommand|decoded|base64|github|pastebin|\.exe|\.bat|\.vbs)" -o ".\FilelessExecutionEvidence.txt"
(This command searches the kernel dump (case-insensitive) for common script interpreters, PowerShell commands often used for downloading/executing code (
iwr
,iex
,invoke
), indicators of encoded payloads (encodedcommand
,decoded
,base64
), common payload hosting sites (github
,pastebin
), and common executable/script extensions that might appear in launch commands found within the dump. Results are saved toFilelessExecutionEvidence.txt
.)Interpreting Output: Meticulously review the output file for suspicious command lines, script fragments, Base64 blocks (decode these separately), URLs, or paths related to the initiation of the fileless activity or injection. Finding the command used to download and execute a PowerShell script directly in memory, or the command line of a loader executable, provides strong evidence.
Forthcoming Tool: Recognizing the power and utility of this approach, the RedLotus Kernel Live Dump tool is under development (and may be released soon, if not already available). This tool aims to automate and significantly speed up the process of analyzing Kernel Live Dumps specifically for traces of bypasses like fileless script execution and memory injection initiators, providing results in seconds rather than requiring extensive manual string filtering and interpretation.
Event Log Analysis (Using Hayabusa):
While event logs primarily record disk-based activity, certain logs, especially if enhanced logging like PowerShell Script Block Logging (Event IDs 4103/4104) is enabled, can capture the commands or script blocks used to initiate fileless execution or injection.
Tool: Hayabusa is an effective event log parser that utilizes Sigma rules for threat hunting. It can rapidly process numerous
.evtx
files.Analysis: Run Hayabusa against the system's event logs (
C:\Windows\System32\winevt\Logs
). Examine the generated report or CSV output, specifically filtering for rules related to suspicious PowerShell execution, WMI activity, or other Living-off-the-Land techniques. Search for keywords often associated with fetching or executing remote/encoded payloads, such as:iwr
,iex
,invoke-expression
,invoke-webrequest
,encodedcommand
,encode
,decoded
,github
,pastebin
,-nop
,-w hidden
. Finding commands using these keywords, especially complex or obfuscated ones, warrants significant scrutiny.
YARA Rule Scanning (Memory):
Mechanism: Use YARA rules specifically crafted to detect signatures of known shellcode, reflective loader stubs, packed executables in memory, specific cheat modules known to be injected, or common memory evasion artifacts.
Tools:
Volatility Framework: The
yarascan
plugin allows scanning a full memory dump (.mem
,.vmem
,.raw
) using provided YARA rules.Velociraptor: The
yara()
VQL function withaccessor='process'
enables scanning the memory of live running processes directly against YARA rules without requiring a full dump.
Effectiveness: Depends heavily on the quality and specificity of the YARA rules used. Good rules can provide strong hits, but generic rules might produce false positives.
Process Memory Inspection (System Informer/Process Hacker):
Mechanism: Directly examine the memory space of running processes suspected of hosting injected code (e.g., the game process,
explorer.exe
).What to Look For:
Suspicious Memory Regions: Identify regions marked as
Private
(not backed by a file on disk) that haveExecute
permissions (PAGE_EXECUTE_READWRITE
or similar). Analyze the content of these regions (e.g., using the hex viewer or string search). The presence of PE headers (MZ...) or executable code in such regions is a strong indicator of injection.Anomalous Loaded Modules: Check the "Modules" list for unsigned DLLs, DLLs in unexpected locations, or multiple instances of core system DLLs loaded at unusual base addresses. (Note: Reflective injection might hide modules from this list).
String Search: Search for specific strings known to be associated with the cheat, loader, or injection method within the process memory.
Volatility Framework (Memory Dump Analysis):
Mechanism: Analyze a full memory dump acquired using tools like FTK Imager, DumpIt, or Magnet RAM Capture.
Key Plugins:
malfind
: The primary plugin for finding injected code. It specifically looks for memory regions exhibiting characteristics typical of injections (e.g., executable private memory, PE headers).ldrmodules
: Can sometimes identify DLLs hidden from standard enumeration techniques.pstree
/pslist
: Useful for understanding process relationships and identifying potential host processes for injection or anomalies related to hollowing.memdump
: Allows extracting specific memory regions identified as suspicious bymalfind
or other analysis for deeper offline examination (e.g., reverse engineering).vadinfo
: Provides detailed information about Virtual Address Descriptors, helping to understand memory region permissions and types.
Detecting fileless malware and memory injection requires a shift towards analyzing the system's volatile state. While Kernel Live Dump analysis offers broad detection capabilities for the initiation phase, combining it with targeted process memory inspection, advanced tool analysis (Volatility/YARA), and potentially revealing event logs provides the most comprehensive strategy against these advanced evasion techniques.
Last updated