Chapter 15 · Reading 3 of 3
Static and dynamic malware examination
CHFI domains 1, 4, 5, 6
The academy now holds three samples from the library case: the JavaScript file the staff member opened, the executable dumped from process 6120’s memory and a PDF that arrived by email the same morning and that another staff member opened. The library wants to know what each one does. Examining malware can go badly wrong if it runs somewhere it can reach the real network, so the work begins with the laboratory, not the sample.
Build an isolated malware-analysis lab
A malware-analysis laboratory (or testbed) is an environment where samples can be examined and run without risk to production systems. Its main features:
- Isolation. Analysis virtual machines on a host-only or physically separate network. Any internet access is deliberate, controlled and logged, or simulated with tools that answer DNS and HTTP requests locally.
- Snapshots. Clean virtual-machine states to revert to after every run.
- Monitoring. Process, file, registry and network monitoring inside the guest, and packet capture outside it.
- Handling rules. Samples stored compressed and password-protected (the convention is the password “infected”), with renamed extensions, and never opened on the examiner’s own workstation.
Static examination first
Static analysis examines a sample without running it. It is safe and repeatable, and it tells the examiner what to watch for in a dynamic run.
| Sample | Tools | Looks for |
|---|---|---|
| Any file | Hashes, file, strings, Detect It Easy, YARA | Identity, known-sample matches, packers, readable indicators such as URLs |
| Office documents | oletools: oleid, olevba, mraptor | VBA macros, auto-run triggers such as AutoOpen, suspicious keywords, external links |
| pdfid, pdf-parser (Didier Stevens) | /JavaScript, /JS, /OpenAction, /AA, /Launch, /EmbeddedFile; extraction of the objects | |
| Windows executables | PE viewers, Detect It Easy, disassemblers | Imports, sections, compile time, signatures, packing |
| .NET assemblies | dnSpy, ILSpy | Decompiled C# that is often close to the original source |
| Scripts (.js, .ps1, .vbs) | A text editor, careful manual deobfuscation, CyberChef | Encoded strings, download URLs, persistence commands |
The PDF from the second staff member’s inbox gives a quick result with pdfid:
PDF Header: %PDF-1.7 obj 14 endobj 14 stream 5 /JS 1 /JavaScript 1 /OpenAction 1 /AA 0 /Launch 0 /EmbeddedFile 0
- The document performs an action when it is opened, and the counts for /JS and /JavaScript suggest the action is a script.
pdf-parser --search /OpenAction then locates the object, and pdf-parser --object 9 --filter --raw extracts the decompressed script. It turns out to open a phishing web page asking for library account credentials, a different threat from the loader, though it arrived the same day.
Controlled dynamic examination
Dynamic analysis runs the sample and watches what it does. In a sandbox, an automated system such as an open-source Cuckoo-style platform or a commercial service, the sample runs in an instrumented virtual machine and a report lists processes started, files and registry keys written, network connections and screenshots. The examiner reads the report as evidence with limits.
- Created a scheduled task with a random name
- Queried DNS for one domain; no answer because the lab was offline
- Checked for the presence of virtualization drivers
- Slept 300 seconds before further activity
- What a live command server would have sent
- Behavior after the 10-minute analysis window ended
- Behavior on a real host where the virtualization check would pass
Separate behavior, indicators and hypotheses
The chapter’s deliverable is a behavior report with three clearly labeled parts. Observed activity is what the examiner saw directly in memory, on disk or in a controlled run, with the source for each item. Contextual indicators are hashes, domains, addresses and file names useful for searching other systems, labeled as indicators rather than proof of activity on those systems. Remaining hypotheses are explanations the evidence does not yet settle, such as whether the loader delivered a second-stage tool, with the evidence that would settle them. That structure stops a report from turning a family name or a threat-intelligence label into a finding.
On the exam, static analysis is safe and comes first, dynamic analysis is run only in isolation, /OpenAction and /JavaScript in a PDF and AutoOpen in a macro mark automatic execution, and a clean sandbox run does not prove a sample is harmless. The next chapter, Mobile devices and cellular records, turns to the phone.
Inspect the three records, then use the evidence to answer the question.
1. /OpenAction
1
2. /JavaScript
1
3. /EmbeddedFile
0
Apply the reading
A sandbox report says a sample made no network connections. Can you conclude that the sample does not communicate?
Compare your reasoning
No. Malware may detect the sandbox, wait before acting, require a specific environment or user action, or have a command server that was offline. A clean sandbox run is one observation under one set of conditions.