courses

Dynamic Analysis

Dynamic analysis means executing a sample and observing its behavior. It is more dangerous than static analysis but reveals things that static analysis cannot — particularly obfuscated or encrypted behavior that only manifests at runtime.

Always analyze in an isolated VM. Always take a snapshot before executing a sample.

Lab Environment Setup

Before running anything:

  1. Revert to your clean baseline snapshot
  2. Disable the VM’s network adapter (or switch to host-only with no internet route)
  3. Take a new “pre-execution” snapshot
  4. Open monitoring tools before launching the sample

System Call Tracing

strace (Linux)

strace intercepts system calls between a process and the kernel. Every file access, network connection, and process creation is a syscall.

$ strace -f -tt -e trace=file,network,process,ipc \
    -o strace_output.txt ./sample

Key flags:

Interesting syscalls to watch for:

Syscall What it means
open/openat file access
connect outbound network connection
execve launching a new process
ptrace debugging or injection
mmap with PROT_EXEC allocating executable memory
unlink deleting files (often self-deletion)

ltrace (Linux)

ltrace intercepts library function calls. It complements strace by showing higher-level behavior:

$ ltrace -o ltrace_output.txt ./sample

Watch for: strcmp, strcpy, malloc, fopen, system, popen, crypto functions.

Network Traffic Analysis

Start Wireshark before running the sample, capturing on all interfaces:

$ sudo wireshark &

Or capture headlessly and analyze afterward:

$ sudo tcpdump -i any -w capture.pcap &
$ ./sample
$ kill %1
$ wireshark capture.pcap

What to Look For

FakeNet-NG / INetSim

These tools simulate network services (DNS, HTTP, SMTP) so that malware “succeeds” in connecting even when no real internet is available. This often causes the malware to proceed past its connectivity checks and reveal more behavior.

$ sudo inetsim

Run FakeNet-NG on a Windows analysis VM to capture simulated responses.

Filesystem and Registry Monitoring

Before-and-After Comparison (Linux)

$ touch /tmp/baseline
# run the sample
$ find / -newer /tmp/baseline -not -path "/proc/*" 2>/dev/null

Process Monitor (Windows)

On Windows analysis VMs, Process Monitor (ProcMon) from Sysinternals records every file, registry, and network event with full context. Filter by process name to focus on your sample.

Sandbox Analysis

Online sandboxes provide automated dynamic analysis with detailed behavioral reports.

Any.run

Any.run is an interactive sandbox: you can click inside the running VM, which helps with samples that wait for user interaction. The free tier supports Windows and Linux analysis.

Hybrid Analysis (Falcon Sandbox)

Hybrid Analysis provides CrowdStrike’s Falcon sandbox results. It maps behavior to MITRE ATT&CK techniques automatically.

Limitations of Sandboxes

Comparing Static and Dynamic Results

A good analysis uses both approaches together:

Observation Method that found it
Import of VirtualAllocEx Static (IAT)
Allocation at 0x140000 during execution Dynamic (strace/debugger)
Encoded string resolved to evil.example.com Static (FLOSS) + Dynamic (DNS query)
Self-deletion after execution Dynamic (strace unlink call)

Discrepancies between static and dynamic findings often indicate anti-analysis evasion.

Useful Resources