Skip to content
Tutorials Center
My learning

Topics

Lesson 37 of 53 ยท Systems and Post-Exploitation Concepts

Dynamic Analysis and Malware Lab Setup

Learn how to build an isolated malware analysis lab, run suspicious samples under observation with Process Monitor, Regshot and sandboxes, and read the Emotet, TrickBot and Ryuk infection chain.

Static analysis (the previous lesson) tells you what a file contains. Dynamic analysis shows what it does: which files it creates, which registry keys it changes, which processes it starts, which addresses it contacts. Dynamic analysis cuts through obfuscation, because even a packed program must unpack and behave eventually. It also carries risk, because you are really running hostile code. The entire discipline is therefore about containment.

Run suspicious samples only inside an isolated virtual machine on a network with no route to the internet or to your real devices, and only if you are authorized to handle the sample. Malware can detect and escape poorly configured labs, steal shared files and attack neighbors. This lesson shows concepts and invented data. The examples are simulations that never execute anything suspicious.

Build the lab first

The goal: the sample can do whatever it likes inside the lab, and nothing it does can reach anywhere that matters.

flowchart LR
  subgraph Host["Your host computer (clean, patched)"]
    subgraph Net["Isolated virtual network (no internet)"]
      A["Analysis VM<br/>(Windows, snapshot)"]
      B["Fake internet VM<br/>(DNS, HTTP responder)"]
    end
  end
  A <--> B

The analysis VM talks only to a simulated internet inside the isolated network.

Checklist for a sound lab:

  1. Isolated virtual network. Use an internal-only or host-only network, not bridged or NAT. A second VM can act as a "fake internet" that answers DNS and web requests, so the sample believes it is online and you see its network behavior without it reaching the real world.
  2. Disable sharing. No shared folders, no clipboard sharing, no drag-and-drop, no USB passthrough, no guest tools that expose the host unnecessarily.
  3. Clean snapshot. Prepare the VM with typical software, the analysis tools and a realistic look (some documents, a plausible user name and uptime), then snapshot it. Revert after every sample.
  4. Keep the hypervisor patched. Escapes from virtual machines are rare but not impossible.
  5. Handle the sample safely. Keep it in an archive with a password and an unambiguous name, transfer it by a controlled method, and defang indicators in notes.
  6. Document everything, including the time and tool versions, as in the lab setup practice.

Malware often checks whether it is being analyzed (virtual machine drivers, very little uptime, tiny disk, analysis tools running) and stays quiet if it suspects so. Making the VM look like a real, used workstation is part of the craft.

Tools and what they show

  • Process Monitor records file system, registry, network and process activity in real time. You filter by the sample's process name to see the files and keys it touches.
  • Process Explorer / Process Hacker show running processes as a tree, with parent-child relationships, loaded modules, network connections and strings in memory. An office program spawning a command interpreter stands out immediately.
  • Regshot takes a snapshot of the registry and chosen folders before and after, then reports the differences. It is simple and good at revealing persistence.
  • Network capture with Wireshark on the fake-internet side shows DNS lookups, beacon traffic and what is sent out.
  • Autoruns lists everything configured to start automatically, to compare before and after.
  • Automated sandboxes (self-hosted or online services) run the sample for you in an instrumented environment and produce a behavior report. They are fast and scale well, but samples can evade them and uploading to a public service discloses the file, so avoid private files.

What you hope to learn

Behavior falls into a handful of questions that map to indicators you can use for detection:

  • Persistence: run keys, scheduled tasks, services, startup folder entries.
  • Execution chain: which process started which, and with what command line.
  • File activity: files dropped, files modified or encrypted, files deleted.
  • Network: domains and addresses contacted, protocols, beacon timing, data sent.
  • Defense evasion: security tools disabled, logs cleared, processes injected.

These feed detection rules and your incident response plan (Incident Response).

A snapshot-diff stand-in

The stand-in below mimics Regshot: two invented snapshots of "registry keys" and "files", before and after a harmless imaginary sample. The code reports what changed. It does not touch your real registry.

Node.js Compare before and after snapshots

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with node:readline or process.stdin), it gets the next line from this box.

The data is made up, but the technique is the daily work of analysts: compare, then label every difference with a hypothesis.

A typical infection chain: Emotet, TrickBot, Ryuk

Analysts often describe an attack as a chain, because one malware family prepares the way for the next. A well-known historical example, described here at a conceptual level, linked three families:

  1. Initial access: Emotet. A phishing email with a malicious document persuades a user to enable macros. The document runs a script that downloads the loader. Emotet spread by hijacking email threads and acting as a delivery service.
  2. Expansion: TrickBot. Emotet downloaded TrickBot, a modular trojan that stole credentials, mapped the network and moved laterally across the domain (see persistence and lateral movement and AD attacks).
  3. Impact: Ryuk. With domain-wide access, operators deployed the Ryuk ransomware to encrypt servers and backups and demanded payment.
flowchart LR
  A["Phishing email<br/>with document"] --> B["Emotet loader"]
  B --> C["TrickBot<br/>credential theft, mapping"]
  C --> D["Domain access"]
  D --> E["Ryuk ransomware<br/>encrypts servers and backups"]

Each stage hands off to the next. Stopping any link stops the chain.

The defensive lesson is that the first stage is cheap and the last is catastrophic, so there are many chances to interrupt: email filtering and disabling macros from the internet, endpoint detection of unusual child processes, credential hygiene, network segmentation, immutable offline backups and tested recovery plans. Analyzing each stage dynamically tells you which indicators to hunt for across the estate.

Turning behavior into detection

The second stand-in models a tiny detection rule over process events, the same step an analyst takes after the sandbox report: describe the behavior in a way the endpoint tool can match. Here it spots an Office program starting a script interpreter that then touches a Run key.

Node.js A behavior rule from analysis findings

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with node:readline or process.stdin), it gets the next line from this box.

Lab ingredients: hypervisors, analysis OS and monitors

A safe lab uses a hypervisor such as VirtualBox, VMware Workstation or Hyper-V (on Windows Pro and Enterprise), a Windows 10 or 11 guest as the victim, and a Linux analysis machine such as REMnux for network simulation and static tools. Install monitoring tools in the victim: Process Monitor, Process Explorer or Process Hacker (to inspect and, when needed, terminate unresponsive or malicious processes), TCPView (live connections per process), Autoruns and RegShot. Keep the network isolated or routed through a simulator, disable shared folders and clipboard, and take a snapshot before each run so every sample starts clean.

What to observe and how

Automated sandboxes such as Cuckoo Sandbox run a sample and report its behavior. By hand, watch for system modifications: new or changed files (Process Monitor on Windows, inotifywait on Linux for a folder), registry changes (RegShot compares before and after; exporting a key with reg export keeps a backup), new processes and network connections (netstat -ano on Windows, lsof -i on Linux, matched to a process ID), and loaded modules in memory (a memory image can be inspected with Volatility pslist). The autostart extensibility points (ASEPs) such as Run keys, services and tasks reveal persistence; Autoruns lists them all.

Sandboxes and reputation services

Isolation can be done with a full VM or a lightweight sandbox: Sandboxie-Plus on Windows or Firejail on Linux restrict what a program can read and write. They are cost-effective and fast, but weaker than a VM because they share the host kernel. Online services such as VirusTotal and Any.Run analyze a suspicious file with many engines or in an interactive sandbox, but never upload confidential documents, since uploads are visible to others. Combine local hashing with a reputation lookup, then check strategic and tactical threat intelligence for the family.

Emotet, TrickBot and Ryuk: the secondary infection chain

The three names form a well-known chain: Emotet arrives through phishing attachments and acts as a loader; it drops TrickBot (the secondary infection), a banking trojan and credential stealer that maps the network; the access is then sold on and Ryuk ransomware is deployed. Incident response preparedness means: detect the first stage early (macro-laden attachments, strange child processes), isolate hosts quickly, hold offline backups, segment the network, and rehearse the response plan before the day it is needed.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. What is the most important property of a malware analysis lab network?

    Isolation contains the sample. A fake-internet VM inside the isolated network lets you observe network behavior safely.
  2. 2. What does Regshot do?

    Regshot reports differences between two snapshots, which makes persistence changes easy to see.
  3. 3. In the Emotet, TrickBot, Ryuk chain, what is TrickBot's role?

    TrickBot expanded access and stole credentials, giving operators the reach needed to deploy ransomware widely.
  4. 4. Why revert the VM to its clean snapshot after each sample?

    A clean state keeps results trustworthy and prevents malware from lingering.

Summary

  • Dynamic analysis runs a sample under observation to see its real behavior; it needs strong containment.
  • The lab is an isolated virtual network with no sharing, a fake-internet VM, clean snapshots and a patched hypervisor.
  • Process Monitor, Process Explorer or Process Hacker, Regshot, Autoruns, packet capture and sandboxes reveal persistence, execution chains, file and network activity.
  • Malware may detect analysis environments, so the VM should look like a used workstation.
  • Chains such as Emotet to TrickBot to Ryuk show how stages hand off; defenders can break the chain at several points.
  • Convert findings into indicators and detection rules.

Next: Reverse Engineering Basics