Skip to content
Tutorials Center
My learning

Topics

Lesson 6 of 37 ยท Concepts and Safe Lab

Building a Safe Analysis Lab

Design an isolated malware analysis lab with virtual machines, host-only networking, snapshots and a simulated internet, and learn the mistakes that cause lab escapes.

A malware analysis lab is a controlled environment where you can open, run and observe suspicious software without putting real systems at risk. A good lab is cheap, disposable and boring: you can break it, restore it in a minute and repeat. This lesson covers the design principles. It does not tell you to buy specific products, and nothing here requires running a sample: the labs in this course are simulations.

Never execute real malware on a machine that holds personal data, stays logged in to accounts or shares a network with other computers, unless it is the properly isolated lab described below. If you cannot guarantee isolation, do static analysis only.

The core idea: containment

Everything in a lab design serves one aim: whatever the sample does stays inside the lab. That requires containing three things.

  1. The code: it runs in a virtual machine, not directly on your host.
  2. The network: it cannot reach the real internet or your home or office network, except in carefully chosen, monitored ways.
  3. The data: nothing valuable lives in the lab, and nothing leaves it by accident (clipboard, shared folders, USB).
flowchart TB
    subgraph Host["Host computer (clean, updated)"]
        H["Hypervisor"]
        subgraph Net["Isolated virtual network"]
            W["Analysis VM (Windows)"]
            L["Helper VM (Linux): fake DNS and web"]
        end
        H --- Net
    end
    W <--> L
    Net -. "no route" .- X["Real network and internet"]

The analysis VM and a helper VM talk only to each other on an isolated virtual network. There is no route to the outside.

Building blocks

Hypervisor

A hypervisor such as VirtualBox, VMware Workstation or Hyper-V runs virtual machines. Choose one you can keep updated. Hypervisor escape vulnerabilities are rare but real, which is another reason the host should hold nothing precious. Some analysts prefer a dedicated physical machine for the lab so a mistake never touches their main computer.

Analysis VM

Install a clean, representative operating system (usually Windows, since most samples target it), then install your analysis tools. Keep the VM unactivated or generic, free of real accounts and real documents. A few believable files (documents, browser history of a fictional user) make some samples behave as they would on a real victim and discourage sandbox detection.

Snapshots

A snapshot records the VM's exact state. After setting everything up, take a snapshot called "clean-baseline". Run the sample, collect evidence, then revert. That guarantees every analysis starts from the same state and removes infections instantly. Name snapshots clearly and note which tools were running.

Network design

Choose one of these modes and know exactly which you are in:

Mode Behaviour Use
Disconnected No network adapter at all Safest. Static work and samples that need nothing
Host-only / isolated VMs see each other but not the outside Standard for dynamic analysis
Simulated internet A helper VM pretends to be DNS and web servers, logs every request Lets malware show its network behaviour safely
Controlled internet Traffic goes out through a VPN or filtered gateway Risky; only for experts, with legal approval

The "simulated internet" idea is key. Tools such as INetSim or FakeNet-NG (read-only mentions here, as they are outside the browser) answer DNS and HTTP requests with fake responses, so malware believes it is online while you capture its requests. Network behaviour analysis uses this idea.

Helper tools

Install your toolset inside the analysis VM and a monitoring or logging VM next to it. Ideas for categories (not shopping lists): hex editor, string extractor, PE viewer, process monitor, registry diff tool, packet capture, debugger and disassembler. The analyst toolkit lesson goes through them.

Disable the escape and leak paths

Out-of-the-box VM conveniences are the usual ways a lab leaks:

  • Shared clipboard and drag-and-drop between host and guest
  • Shared folders
  • Guest additions or integration features you do not need
  • USB passthrough
  • Bridged networking (which puts the VM on your real network)
  • Saved credentials, cloud sync clients and password managers inside the VM

Turn them off, and keep a written configuration sheet.

A lab design checker

The next example validates a lab configuration, stored as plain data, against the rules above. It is a teaching aid: the same idea appears in real "lab linting" scripts.

Python Lint a lab configuration

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 input()), it gets the next line from this box.

Change the values (for example set network_mode to host-only and clear the lists) and run it again to watch the verdict change.

Faking the internet: the idea in miniature

You will not run real malware in this course, but you can see how a fake server works with a few lines of Python that simulate DNS answers. This model keeps a table of names and fake addresses from the documentation range, and logs every lookup: exactly the evidence an analyst wants.

Python A pretend DNS responder with a log

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 input()), it gets the next line from this box.

The odd-looking name xk3j9a.example.test is the kind of thing analysts hunt for: random-looking domains hint at generated names. Chapter 4 returns to it.

Maintenance habits

  • Update the host and hypervisor, but not the analysis VM on a whim: update it, snapshot, and test.
  • Never reuse a VM after a run without reverting.
  • Keep samples on a separate, labelled storage area, not in the shared Downloads folder.
  • Document the configuration so a colleague can rebuild it.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. What is the main purpose of a VM snapshot in a malware lab?

    Reverting to a clean snapshot removes the infection and guarantees each analysis starts from the same baseline.
  2. 2. Which network mode is least appropriate for running an unknown sample?

    Bridged mode puts the VM on your real network, so the sample could reach or infect real machines.
  3. 3. Why use a simulated internet such as a fake DNS and web server?

    Many samples do nothing without network responses. A simulated internet reveals their behaviour without contacting real servers.
  4. 4. Which VM feature should normally be disabled?

    Clipboard and shared folders are leak and escape paths between guest and host.

Summary

  • A lab contains code, network access and data so a sample cannot affect real systems.
  • Use a hypervisor, a clean analysis VM, snapshots, and an isolated virtual network.
  • A simulated internet lets malware show its network behaviour while you log it.
  • Disable shared folders, clipboard sharing, drag and drop, USB and bridged networking.
  • If isolation cannot be guaranteed, do static analysis only.

Next: Handling Samples Safely