Skip to main content
Be Bitwise

Dynamic Analysis & Sandboxing

Malware Analysis Fundamentals · Advanced Reverse Engineering track

6 min read

In this module

Watching It Run

Dynamic analysis runs the malware in a controlled environment and watches what happens. Files created, connections opened, processes spawned — the malware tells on itself the moment it executes, no matter how well it's been packed or obfuscated.

Static analysis tells you what the malware could do. Dynamic analysis tells you what it actually does. A packed binary that's silent on disk will happily unpack itself in memory and start misbehaving the moment you let it run.

The Sandbox Environment

A sandbox is an isolated environment designed for safe malware execution. The typical setup:

  • Virtual machine: Run the malware in a VM (VirtualBox, VMware, QEMU) with a clean snapshot. After analysis, revert. Every run should start from the same known-good baseline, otherwise your results aren't reproducible.
  • Isolated network: Don't give the VM real internet. Stand up a fake one with INetSim or FakeNet-NG, simulating DNS, HTTP, SMTP, and the rest. You'll capture the network activity without the malware ever reaching its actual C2.
  • Monitoring tools: These have to be running before the malware starts. Earliest behaviour is often the most revealing, and you only get one shot at it per snapshot.

Wired together, a minimal lab is two VMs on a host-only network. The analysis VM's DNS server and default gateway both point at the INetSim box, so every lookup and connection the sample makes lands on the fake services:

Check the "no uplink" edge for yourself before every session: a NAT adapter left enabled on the analysis VM quietly undoes the whole design.

Common sandbox tools:

  • Cuckoo Sandbox / Cape Sandbox: Automated analysis systems that run malware, record behaviour, and produce detailed reports. Cape is the actively maintained fork of Cuckoo.
  • Any.Run: An interactive online sandbox with visual monitoring that lets you interact with the malware in real time.
  • Joe Sandbox: A commercial automated analysis platform with deep behavioural analysis capabilities.
Key Concept

Dynamic analysis runs malware in a controlled sandbox to observe its runtime behaviour. The sandbox records file operations, registry changes, network traffic, and process activity. Use VM snapshots for clean rollback, isolated networking to prevent real harm, and monitoring tools to capture everything. The goal is to observe the malware's true behaviour in a safe environment.

System Monitoring

While the malware runs, monitor every interaction with the system:

Process Monitor (ProcMon): Records every file system, registry, and process/thread operation in real time. Filter to the malware's process and you'll see every file it opens, every key it touches, every child it spawns. Without ProcMon's filtering, you're drowning in noise from a normal Windows session.

Process Explorer: Running processes, loaded DLLs, handles, memory usage — all in one view. The tree layout shows parent-child relationships at a glance, which is how you spot a benign-looking svchost.exe whose actual parent is some dropper in the user's Temp folder.

Wireshark / TCPdump: Grab everything on the wire. DNS queries hand you the C2 domains. HTTP requests reveal protocols and (if not encrypted) exfiltrated data. Even when traffic is wrapped in TLS, destinations and beacon timing leak plenty.

API monitoring: Tools like API Monitor or Frida hook specific calls and dump arguments and return values. Far more targeted than ProcMon — watching the arguments to CreateProcess shows you exactly which commands the malware runs.

Behavioural Indicators

Common malware behaviours to watch for:

Persistence installation:

  • Writing to registry run keys (HKLM or HKCU \Software\Microsoft\Windows\CurrentVersion\Run)
  • Creating scheduled tasks using schtasks or the Task Scheduler API
  • Dropping files in startup folders
  • Installing services that start automatically
  • Modifying existing DLLs (DLL hijacking) or placing malicious DLLs where legitimate programs will load them

Network activity:

  • DNS queries to unusual or randomly generated domains (domain generation algorithms)
  • HTTP/HTTPS connections to C2 servers, often disguised as normal web traffic
  • DNS tunneling (suspiciously long subdomain queries that encode data)
  • Beaconing patterns (regular, periodic connections that indicate the malware is checking in)

Defence evasion:

  • Disabling antivirus or Windows Defender through registry modifications or service manipulation
  • Clearing event logs to cover tracks
  • Deleting evidence files (its own installer, temporary files)
  • Process injection into legitimate processes to hide malicious activity under a trusted name

Data collection:

  • Reading browser credential stores (Chrome, Firefox saved passwords)
  • Capturing screenshots at intervals
  • Logging keystrokes to capture passwords and sensitive input
  • Scanning for documents, databases, and cryptocurrency wallets

Sandbox Evasion

Sophisticated malware detects sandbox environments and refuses to run (or runs harmlessly):

  • VM detection: Check for VMware tools, QEMU CPUID identifiers, VirtualBox guest additions, or hypervisor-specific CPU instructions
  • Timing checks: Sandboxes may process time differently, and single-step debugging introduces detectable delays
  • User interaction checks: Wait for mouse movement, keyboard input, or specific user actions before activating
  • Environment checks: Check computer name, username, MAC address, installed software, and number of files for sandbox indicators
  • File system checks: Look for analysis tool files, check for realistic user profiles with documents and browsing history

Beating evasion means dressing the room. Stuff the disk with user files, leave browsing history behind, install plausible software, configure hardware that looks lived-in. Some analysts skip VMs entirely and run on bare metal, which is dramatically harder to fingerprint.

Memory Forensics

After the malware has run, analysing the VM's memory can reveal:

  • Unpacked code: If the malware is packed, the unpacked version is in memory after execution
  • Injected code: Code injected into other processes that would not appear on disk
  • Encryption keys: Keys used for C2 communication or data encryption, which must exist in memory during use
  • Network artifacts: URLs, IP addresses, and protocol data that were constructed in memory

Tools like Volatility chew through memory dumps and pull out process lists, loaded modules, network connections, and injected code regions.

Combining Static and Dynamic

Real analysis bounces between both:

  1. Start with static analysis to map capabilities and structure.
  2. Run it dynamically to see what it does and grab unpacked code from memory.
  3. Loop back to static with what you learned — known C2 URLs point straight at the communication code; persistence artefacts point at the installer.
  4. Repeat until you understand the malware's capabilities, infrastructure, and purpose.