Jamal Darbo// Security PortfolioPortfolio v1
Portfolio Blog
Back to blog

Malware Analysis

How to create a malware analysis lab

Build a Windows 11 malware analysis VM with Hyper-V, PowerShell and FLARE-VM, then verify the tools and save an offline checkpoint.

A golden bug inside a transparent blue analysis enclosure, with a magnifying glass and an unplugged Ethernet cable

Before investigating a suspicious executable, I want to know where I can inspect it, what that environment can communicate with, and how I can return it to a known state. Building the lab is part of the analysis process: the decisions we make here influence the behaviour we can observe later.

In this article, I will build a Windows 11 virtual machine using Hyper-V and install FLARE-VM, a collection of tools for reverse engineering and malware analysis. Most of the configuration happens through PowerShell, with a few graphical steps where they make the process clearer.

Why Hyper-V? Because it has been the most stable option in my experience. That is a practical preference based on my own systems, rather than a claim that it is the best hypervisor for every situation.

You could run a script that creates and configures everything for you. However, I find that I learn the most by doing each step myself: creating the disk, configuring the network, checking the security settings and interpreting the installation results. We will still use the official FLARE-VM installer for the tools, but we will build and understand the environment around it.

Set aside a few hours. Windows installation, updates, FLARE-VM downloads and automatic reboots take time. Troubleshooting a package or a Windows setting can add more. This is a walkthrough to work through at your own pace.

What we are building

The result is a Windows analysis VM with a local account, a selection of analysis tools and two named checkpoints. Its network adapter is disconnected at the end of this walkthrough. We are not downloading or executing a malware sample yet.

The architecture has two stages. During setup, the VM temporarily uses Hyper-V’s Default Switch to download Windows updates and tools. This is an internal switch with NAT and connectivity to the host, so it is a setup connection, not an isolation boundary. Once setup is complete, we disconnect that adapter and save the offline state.

I also create a Private switch called MalwareLab. It is available for a later lab network, but the final VM in this article is not connected to it. A Private switch allows communication between attached VMs on the same host; it does not create a host network interface or provide internet access on its own. Adding a VM that routes traffic would change that design.

A Hyper-V host containing the Windows 11 FLARE-VM. The setup stage temporarily connects through the Default Switch to the internet. The final baseline has its network adapter disconnected, with a Private MalwareLab switch prepared for future use.
Temporary internet access for setup, followed by a disconnected analysis VM. The Private MalwareLab switch is prepared for a later stage.

Keep the host and guest separate throughout the process. HOST means the physical Windows computer running Hyper-V. VM means Windows inside WIN11-FLARE. The Defender changes later in the article apply only inside the disposable VM.

Use VMConnect’s basic session for this lab and avoid enabling clipboard, drive or folder sharing with the host. Keep personal files and real credentials out of the guest. A checkpoint gives us a recovery point; it does not provide network isolation or replace a backup.

Prepare the host and installation media

This walkthrough assumes Hyper-V and its PowerShell module are already enabled on a supported Windows edition, and hardware virtualization is enabled in the firmware. Microsoft’s Hyper-V installation guide covers that preparation.

I used a Windows 11 Enterprise Evaluation ISO and a local account named Analyst. Obtain the installation media from Microsoft’s Evaluation Center and note the evaluation period. The precise setup screens and Defender behaviour can vary between Windows builds.

These are the resources I chose for the guest. They are practical allocations for this lab, rather than the minimum Windows 11 VM requirements:

SettingConfiguration
VM nameWIN11-FLARE
Generation2
Memory8 GB, with Dynamic Memory disabled
Virtual processors4
OS disk120 GB fixed VHDX
FirmwareSecure Boot using the Microsoft Windows template
TPMVirtual TPM enabled
Initial networkDisconnected

Leave enough RAM and CPU capacity for the host. The fixed disk reserves approximately 120 GB of host storage immediately, and you also need room for the ISO, downloads and growing checkpoint files.

HOST — open PowerShell as administrator. Start by checking the existing VMs and switches:

Get-VM | Select-Object Name, State
Get-VMSwitch | Select-Object Name, SwitchType

Define the paths for this new VM. Adjust the ISO path to match your computer:

$ErrorActionPreference = 'Stop'
$vmName = 'WIN11-FLARE'
$vmRoot = Join-Path $env:USERPROFILE 'Desktop\VMs\WIN11-FLARE'
$isoPath = Join-Path $env:USERPROFILE 'Desktop\VMs\Win11.iso'
$vhdPath = Join-Path $vmRoot 'WIN11-FLARE-fixed.vhdx'

if (-not (Test-Path -LiteralPath $isoPath)) {
    throw 'The Windows installation ISO was not found.'
}

if (Get-VM | Where-Object { $_.Name -eq $vmName }) {
    throw 'A VM with this name already exists.'
}

New-Item -Path $vmRoot -ItemType Directory -Force | Out-Null

Keep this host PowerShell window open for the following configuration steps so the variables remain available.

Create the switch, disk and VM

HOST. Create the Private lab switch if it does not exist. If the name is already in use, check its type rather than silently changing an existing network:

$labSwitch = Get-VMSwitch |
    Where-Object { $_.Name -eq 'MalwareLab' }

if (-not $labSwitch) {
    New-VMSwitch -Name 'MalwareLab' -SwitchType Private
} elseif ($labSwitch.SwitchType -ne 'Private') {
    throw 'MalwareLab exists, but it is not a Private switch.'
}

Next, create the fixed virtual disk and attach it to a new Generation 2 VM:

New-VHD -Path $vhdPath -SizeBytes 120GB -Fixed

New-VM `
    -Name $vmName `
    -Generation 2 `
    -MemoryStartupBytes 8GB `
    -VHDPath $vhdPath `
    -Path $vmRoot

Set-VMMemory -VMName $vmName -DynamicMemoryEnabled $false
Set-VMProcessor -VMName $vmName -Count 4

Set-VM -Name $vmName `
    -AutomaticStartAction Nothing `
    -AutomaticStopAction ShutDown `
    -AutomaticCheckpointsEnabled $false `
    -CheckpointType Standard

No switch is supplied to New-VM, so the VM starts with an unattached network adapter.

I initially created a dynamic disk, then converted it to a fixed VHDX before installing Windows. The commands above create the fixed disk directly, so you can follow the final configuration without repeating that detour. New-VHD supports both types.

I chose a fixed disk to allocate the space upfront and avoid growth allocation during normal use. A dynamic VHDX is also a valid choice and is not automatically slow. It exposes the full capacity to the guest while growing its host file as needed. The trade-off here is predictable allocation versus host storage efficiency. Even with a fixed base disk, checkpoint differencing files can grow.

Check the disk that was created:

Get-VHD -Path $vhdPath |
    Select-Object Path, VhdType,
        @{Name='CapacityGB'; Expression={$_.Size / 1GB}}

Enable Secure Boot and the virtual TPM

HOST — with the new VM still off. Configure the Windows Secure Boot template and create a local key protector for its virtual TPM:

Set-VMFirmware -VMName $vmName `
    -EnableSecureBoot On `
    -SecureBootTemplate MicrosoftWindows

Set-VMKeyProtector -VMName $vmName -NewLocalKeyProtector
Enable-VMTPM -VMName $vmName

The new key protector command belongs to the creation of this fresh VM. It is not a routine command to rerun against an existing TPM-protected guest.

Attach the ISO and place the DVD drive first in the boot order:

$dvd = Add-VMDvdDrive -VMName $vmName `
    -Path $isoPath -Passthru

Set-VMFirmware -VMName $vmName -FirstBootDevice $dvd

Install Windows with a local account

HOST. Temporarily connect the clean VM to the Default Switch, then open its console:

Connect-VMNetworkAdapter -VMName $vmName `
    -SwitchName 'Default Switch'

Start-VM -Name $vmName
vmconnect.exe localhost $vmName

The Default Switch provides connectivity through the host. Treat this as a setup connection, not an isolated malware network.

When Press any key to boot from CD or DVD appears, click inside VMConnect and press Space. I initially missed that prompt and ended up at a network boot attempt and the UEFI boot summary. Using Action → Ctrl+Alt+Delete in VMConnect and pressing Space at the next prompt got the installer started.

Install Windows onto the empty virtual disk. On subsequent installation reboots, allow Windows to boot from the disk rather than pressing a key to start the DVD installer again.

On my Enterprise setup, the work or school sign-in screen offered Sign-in options → Domain join instead. This let me create the local account Analyst without signing in with a personal Microsoft account. Availability depends on the Windows edition and setup flow.

Give the local account a password and keep it available: FLARE-VM uses credentials to resume installation after reboots.

VM. Once the desktop is ready, install Windows updates and complete the required reboots. Then record the actual account and OS version:

whoami

Get-CimInstance Win32_OperatingSystem |
    Select-Object Caption, Version, BuildNumber

The Hyper-V name WIN11-FLARE and the Windows computer name inside the VM are separate. A hostname such as DESKTOP-... inside the guest is expected unless you rename it.

Save a clean Windows checkpoint

Before changing Defender or installing the analysis tools, save a clean return point.

VM — PowerShell as administrator:

Stop-Computer

HOST. Once the VM is off, disconnect its network adapter and eject the ISO:

$vmName = 'WIN11-FLARE'

if ((Get-VM -Name $vmName).State -ne 'Off') {
    throw 'Shut down the guest before continuing.'
}

Disconnect-VMNetworkAdapter -VMName $vmName
Get-VMDvdDrive -VMName $vmName | Set-VMDvdDrive -Path $null

Checkpoint-VM -Name $vmName -SnapshotName '01-Windows11-Clean'

Get-VMNetworkAdapter -VMName $vmName |
    Select-Object Name, SwitchName

Get-VMSnapshot -VMName $vmName |
    Select-Object Name, CreationTime

SwitchName should be empty, and 01-Windows11-Clean should appear in the checkpoint list. This is our Windows baseline before the tool installation.

Prepare the guest for FLARE-VM

FLARE-VM’s requirements include internet access, disabled antivirus and Tamper Protection, and disabled Windows Updates during installation. These are changes to the analysis guest, not the host.

HOST. Reconnect the clean guest for the installation:

Connect-VMNetworkAdapter -VMName 'WIN11-FLARE' `
    -SwitchName 'Default Switch'

Start-VM -Name 'WIN11-FLARE'
vmconnect.exe localhost 'WIN11-FLARE'

VM — built-in Windows PowerShell (powershell.exe) as administrator. Confirm the computer and user before changing security settings:

hostname
whoami

Open Windows Security:

Start-Process 'windowsdefender:'

Go to Virus & threat protection → Manage settings and turn Tamper Protection off. Check the effective state:

Get-MpComputerStatus |
    Format-List IsTamperProtected, RealTimeProtectionEnabled,
        AntivirusEnabled, AMRunningMode

For the installation window, disable automatic updates using the documented Windows Update policy:

$updatePolicy = 'HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU'

New-Item -Path $updatePolicy -Force | Out-Null
New-ItemProperty -Path $updatePolicy -Name NoAutoUpdate `
    -PropertyType DWord -Value 1 -Force | Out-Null

gpupdate.exe /target:computer /force

This setting controls automatic Windows updates; it does not block every software update channel. When maintaining the base image later, deliberately schedule updates while the guest is clean and save a new verified baseline afterwards.

What happened with Defender

This was the part of the setup that took the most troubleshooting. The local Turn off Microsoft Defender Antivirus policy showed Enabled, but Defender continued running and the expected DisableAntiSpyware value was absent. Microsoft documents limitations around this legacy setting, but that alone did not establish why the value was missing in my VM. I checked the effective protection state separately.

The following Set-MpPreference command disabled real-time protection temporarily in my VM:

Set-MpPreference -DisableRealtimeMonitoring $true

However, RealTimeProtectionEnabled returned to True after a reboot. It also did not mean that the WinDefend service had been fully disabled.

I then tried Microsoft Sysinternals Autoruns. In normal Windows, even when running it as administrator, clearing the WinDefend entry failed. The approach that allowed me to change the entry was to run Autoruns in Safe Mode.

These are observations from this installation. Defender and Windows builds change, so check the result on your own VM rather than treating an older guide as a guarantee.

Use Autoruns in Safe Mode

VM. Download Autoruns before entering Safe Mode:

$autorunsFolder = Join-Path `
    ([Environment]::GetFolderPath('Desktop')) 'Autoruns'
$autorunsArchive = Join-Path $env:TEMP 'Autoruns.zip'

Invoke-WebRequest `
    -Uri 'https://download.sysinternals.com/files/Autoruns.zip' `
    -OutFile $autorunsArchive -UseBasicParsing

Expand-Archive -LiteralPath $autorunsArchive `
    -DestinationPath $autorunsFolder -Force

Get-AuthenticodeSignature `
    -LiteralPath (Join-Path $autorunsFolder 'Autoruns64.exe') |
    Select-Object Status,
        @{Name='Signer'; Expression={$_.SignerCertificate.Subject}}

Check for a Valid signature from Microsoft. Keep Tamper Protection off and disable real-time protection before the restart.

If the guest disk uses BitLocker, have its recovery key available locally before using the recovery environment. Check without displaying the recovery key:

Get-BitLockerVolume -MountPoint 'C:' |
    Select-Object MountPoint, VolumeStatus, ProtectionStatus

In my VM, shutdown.exe /r /o /t 0 returned error 87. I checked Windows Recovery Environment directly instead:

reagentc.exe /info

It reported Enabled and a recovery image location. With WinRE enabled, REAgentC’s /boottore option scheduled the next boot into recovery:

reagentc.exe /boottore

Only after Operation Successful, restart:

Restart-Computer

If WinRE is disabled or either command fails, resolve that error before continuing. Do not assume that a reboot will reach the expected menu.

Select Troubleshoot → Advanced options → Startup Settings → Restart, then press 4 for Enable Safe Mode, as described in Microsoft’s Startup Settings instructions. Log in using the local Analyst password.

Start Autoruns as administrator. Under Options, show Windows and Microsoft entries, open Services, and find WinDefend. Clear only the checkbox for Microsoft Defender Antivirus Service. If Autoruns reports an error, the change has not been established.

Restart normally and check the service:

Get-Service -Name WinDefend |
    Select-Object Name, Status, StartType

My result after the normal reboot was:

Name       Status  StartType
----       ------  ---------
WinDefend  Stopped Manual

Stopped describes the current state; Manual describes the start type. Here the antivirus service was not running, but it could still start on demand. I did not treat this as proof of permanent disablement. The FLARE installer used at the time checked whether WinDefend was running; it did not require the start type to be Disabled. Its other checks, including Tamper Protection, still needed review.

Install FLARE-VM

VM — built-in Windows PowerShell as administrator. Follow the official installation instructions and download the installer to the guest desktop:

$ErrorActionPreference = 'Stop'
Set-Location -LiteralPath ([Environment]::GetFolderPath('Desktop'))

Invoke-WebRequest `
    -Uri 'https://raw.githubusercontent.com/mandiant/flare-vm/main/install.ps1' `
    -OutFile '.\install.ps1' -UseBasicParsing

Unblock-File -LiteralPath '.\install.ps1'

Set-ExecutionPolicy -Scope CurrentUser `
    -ExecutionPolicy Unrestricted -Force

.\install.ps1 -noGui

-noGui uses the standard tool selection without the customization interface. The checks remain enabled. The execution policy matches the installer’s documented requirement and persists across the restarts it uses.

Read any preflight warnings. A warning that a Windows build has not been tested is different from a failed administrator or connectivity check. In particular, do not assume Defender is still stopped just because it was stopped earlier.

When prompted for a snapshot, we already have 01-Windows11-Clean. Enter the local Analyst password in the installer’s credential prompt so Boxstarter can resume after reboots. Avoid putting the password directly into a command that will be saved in shell history.

Allow the installer to run and restart the guest as required. Keep an eye on prompts and package failures. Installing a large collection of tools is the stage where the time estimate becomes noticeable.

When it is done, it looks like this

This was my desktop after the installation reached completion:

The installed FLARE-VM desktop with the Tools folder, analysis tool shortcuts and an Internet Enabled indicator
FLARE-VM immediately after installation, while the temporary setup connection was still enabled. The adapter is disconnected before the final checkpoint below.

The desktop is a useful milestone, but the install log tells us more than the wallpaper.

Check what actually installed

VM. FLARE records its installation data under VM_COMMON_DIR, normally C:\ProgramData\_VM. Read the failed-package list and the end of the log:

$flareData = [Environment]::GetEnvironmentVariable('VM_COMMON_DIR', 'Machine')
if ([string]::IsNullOrWhiteSpace($flareData)) {
    $flareData = Join-Path $env:ProgramData '_VM'
}

$failedFile = Join-Path $flareData 'failed_packages.txt'

if (Test-Path -LiteralPath $failedFile) {
    Get-Content -LiteralPath $failedFile
} else {
    'failed_packages.txt is missing; completion is not confirmed.'
}

Get-Content -LiteralPath (Join-Path $flareData 'log.txt') -Tail 60

The package installer creates this file near completion, including when it has no failures to list. A present but empty file means the installer reported no failed packages through that check. A missing file is not equivalent to success. Likewise, Install Complete! can appear even when individual packages failed.

My installation completed with 11 package failures:

angr.vm
js-deobfuscator.vm
ezviewer.vm
js-beautify.vm
regcool.vm
malware-jail.vm
obfuscator-io-deobfuscator.vm
vb-decompiler-lite.vm
recaf.vm
asar.vm
pkg-unpacker.vm

The final summary listed these packages but did not explain the individual causes. For that, the relevant package sections in C:\ProgramData\chocolatey\logs\chocolatey.log and the Boxstarter log would need inspection.

I checked the initial tool selection separately using Chocolatey’s installed-package list:

choco list --limit-output |
    Select-String '^(die|dnspyex|ilspy|sysinternals|wireshark|fakenet-ng|capa|floss)\.vm\|' |
    Select-Object -ExpandProperty Line

All eight were registered:

ToolInitial purpose
Detect It EasyInspect file format and compiler or packer indicators
dnSpyExInspect and debug .NET assemblies when applicable
ILSpyDecompile .NET assemblies when applicable
SysinternalsObserve processes, file activity and other Windows behaviour
WiresharkInspect captured network traffic
FakeNet-NGSimulate network services in a later controlled setup
capaIdentify potential capabilities from file features
FLOSSExtract strings, including supported obfuscated-string forms

Package registration is not a complete functional test. Open Detect It Easy, dnSpyEx or ILSpy, Process Monitor and Wireshark once to check for startup errors, then close them. Run Process Monitor elevated. Network capture and service simulation can be validated when building the controlled network stage; do not start FakeNet-NG just to see whether a window opens.

Check Defender again after the installation’s reboots:

Get-Service -Name WinDefend |
    Select-Object Name, Status, StartType

In my case it still reported Stopped / Manual. The eleven other package failures remained documented rather than being hidden by the successful completion message.

Disconnect the network and save the tools baseline

HOST — PowerShell as administrator. Remove the temporary setup connection:

Disconnect-VMNetworkAdapter -VMName 'WIN11-FLARE' -ErrorAction Stop

Get-VMNetworkAdapter -VMName 'WIN11-FLARE' |
    Select-Object Name, SwitchName

Confirm that every adapter has an empty SwitchName. Check the Hyper-V configuration rather than relying only on a desktop connectivity indicator.

VM. Once the relevant tools open successfully and you have reviewed any installation failures, shut down:

Stop-Computer

HOST. Use Checkpoint-VM to create the named checkpoint only when the VM is off and its adapters are disconnected:

& {
    $ErrorActionPreference = 'Stop'
    $vmName = 'WIN11-FLARE'
    $checkpointName = '02-FLAREVM-Tools-Offline'
    $vm = Get-VM -Name $vmName

    if ($vm.State -ne 'Off') {
        throw 'The guest must be shut down first.'
    }

    $connected = Get-VMNetworkAdapter -VMName $vmName |
        Where-Object { $_.SwitchName }

    if ($connected) {
        throw 'A network adapter is still connected to a switch.'
    }

    if (Get-VMSnapshot -VMName $vmName |
        Where-Object { $_.Name -eq $checkpointName }) {
        throw 'This checkpoint already exists.'
    }

    Checkpoint-VM -VM $vm -SnapshotName $checkpointName

    Get-VMSnapshot -VMName $vmName |
        Select-Object Name, CreationTime
}

The final list should contain both 01-Windows11-Clean and 02-FLAREVM-Tools-Offline. I verified that the second checkpoint was present before moving on.

This gives us two useful return points: Windows before the analysis tools, and the installed tool environment with its network disconnected. Keep the installation logs with the baseline so its known limitations remain clear.

Ready for the next stage

We now have an offline Windows VM, a registered core toolset and a confirmed checkpoint to return to. We also know which packages failed and why checking the actual service state mattered more than a policy checkbox.

The next stage is to select and identify a sample, record its hash and begin with static inspection. Before executing it, we will need a deliberate plan for network simulation and observation. For now, the value of the lab is that its starting state is understood and repeatable. Building it step by step made that understanding possible.

Sources