Lab 2.2: Disposable VM for Destructive Testing
Learning Objectives
By the end of this lab, you will be able to:
- Create a Windows VM optimized for testing
- Use snapshots to test without risk
- Perform destructive tests safely
- Understand cloning and linked clones
- Create a reusable lab environment
Estimated Duration
25 minutes
Prerequisites
- VirtualBox or VMware installed
- A functional Windows 10/11 VM
- Minimum 20 GB of free disk space
Professional Context
As a system administrator or security professional, you often need to:
- Test configurations that might break the system
- Check the impact of malware (in an isolated environment)
- Experiment with risky system modifications
- Train users on common errors
Disposable VMs allow:
- Testing ANYTHING without fear
- Instantly rolling back
- Multiplying test environments
- Completely isolating from the host system
Part 1: Understanding Snapshots
Step 1.1: Snapshot Concept
A snapshot captures the EXACT state of a VM at a given moment:
- All files
- All RAM memory
- All configuration
Analogy: It's like a backup that takes 2 seconds and allows you to roll back in 5 seconds.
Step 1.2: Use Cases
Typical scenario:
- Clean and functional VM
- Create snapshot "CLEAN"
- Test something destructive (delete System32, disable services...)
- System broken? No problem!
- Restore snapshot "CLEAN"
- VM like new in 10 seconds
Questions:
- Have you ever broken Windows by testing something?
- How long did it take you to reinstall?
Step 1.3: Create Your First Snapshot
In VirtualBox:
- Select your Windows VM
- Machine → Take Snapshot (or 📸 icon)
- Name: "CLEAN_BASE"
- Description: "Clean Windows, just installed, before any tests"
- Click OK
BOOM! Snapshot created in seconds.
In VMware:
- VM → Snapshot → Take Snapshot
- Same principle
Questions: 3. How long did the snapshot creation take? 4. What is the size of your snapshot file?
Part 2: Destructive Tests - Level 1 (Recoverable)
Step 2.1: Test 1 - Delete System Files
ON YOUR VM (NOT your real computer!):
- Start the VM
- Open File Explorer
- Go to
C:\Windows\System32
WARNING: Normally, NEVER do this on a real system!
-
Try to delete
notepad.exe- Right-click → Delete
- Windows may block (protected file)
-
Try with admin rights:
- Open cmd as admin
takeown /f C:\Windows\System32\notepad.exe
icacls C:\Windows\System32\notepad.exe /grant %username%:F
del C:\Windows\System32\notepad.exe -
Try to launch Notepad
- Windows + R →
notepad - Error! The file no longer exists
- Windows + R →
Observe:
- Windows continues to function
- But notepad is broken
Questions: 5. Did you manage to delete notepad.exe? 6. Is the system still functioning?
Step 2.2: Test 2 - Disable Critical Services
Open services.msc:
services.msc
Find and stop these services:
-
Windows Update (wuauserv)
- Right-click → Stop
- Right-click → Properties → Startup type: Disabled
-
Windows Defender (WinDefend)
- Same procedure
-
Windows Search
- Same procedure
Restart the VM
Observe:
- Some features no longer work
- Windows search broken
- No updates
- No antivirus protection
Questions: 7. Which services did you disable? 8. What immediate impact did you observe?
Step 2.3: Test 3 - Modify the Registry (Dangerous!)
WARNING: On a real system, this can cause a BSOD!
Open regedit:
regedit
Go to:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon
Find the key Shell (normally = explorer.exe)
Change to: cmd.exe
Restart the VM
Result:
- Instead of the normal Windows desktop, you'll just have cmd!
- No explorer, no desktop!
Questions: 9. What did you get after rebooting? 10. Could you still use Windows normally?
Part 3: Snapshot Restoration
Step 3.1: Your VM is Broken!
After all these tests, your VM is probably:
- Notepad deleted
- Critical services disabled
- Registry modified
- Desktop broken
On a real system: Reinstallation = 1-2 hours
With snapshot: Recovery = 10 seconds!
Step 3.2: Restore the Snapshot
In VirtualBox:
- Shut down the VM (or not, you can restore even while running!)
- Right-click on VM → Snapshots
- Select "CLEAN_BASE"
- Right-click → Restore
- Confirm
Wait 5-10 seconds...
MAGIC! Your VM is back to the clean state!
Restart the VM:
- Notepad works
- All services active
- Normal registry
- Normal desktop
Questions: 11. How long did the restoration take? 12. Were all your destructive tests undone?
Step 3.3: Measure the Difference
Time for:
- Reinstalling Windows from scratch: _____ minutes
- Restoring a snapshot: _____ seconds
Ratio: About 100x faster!
Part 4: Multiple Snapshots - Tree Structure
Step 4.1: Create a Snapshot Hierarchy
Snapshots can be organized in a tree structure:
CLEAN_BASE
├── AFTER_INSTALL_CHROME
├── AFTER_INSTALL_PYTHON
│ └── AFTER_CONFIG_PYTHON
└── WITH_BACKDOOR_TEST
Create this structure:
- From CLEAN_BASE, start the VM
- Install Chrome (or other software)
- Create snapshot: "AFTER_INSTALL_CHROME"
- Restore "CLEAN_BASE"
- Install Python
- Create snapshot: "AFTER_INSTALL_PYTHON"
You now have 3 states:
- Clean Windows
- Windows + Chrome
- Windows + Python
Advantage: Test different configurations without reinstalling!
Step 4.2: Navigating Between Snapshots
Exercise:
- Restore "AFTER_INSTALL_CHROME"
- Verify Chrome is there but not Python
- Restore "AFTER_INSTALL_PYTHON"
- Verify Python is there but not Chrome
- Restore "CLEAN_BASE"
- Neither Chrome nor Python
Questions: 13. How many snapshots have you created? 14. Can you freely navigate between them?
Step 4.3: Disk Space Management
Attention: Snapshots take up space!
Check the space:
In VirtualBox:
- Right-click on VM → Settings → Storage
- Look at the file sizes
Each snapshot stores:
- The DIFFERENCES from the parent snapshot
- Not the entire disk each time (delta)
Best practice:
- Keep only necessary snapshots
- Delete old ones
- Merge when possible
Part 5: VM Cloning
Step 5.1: Full Clone vs Linked Clone
Full Clone:
- TOTAL copy of the VM
- Independent of the original
- Takes as much space as the original VM
- Can be moved, shared
Linked Clone:
- Shares the disk with the original VM
- Stores only the DIFFERENCES
- Much faster to create
- Uses much less space
- Perfect for testing!
Step 5.2: Create a Linked Clone
In VirtualBox:
- Right-click on your VM → Clone
- Name: "Windows_TEST_1"
- Clone type: Check "Linked"
- Snapshot: Select "CLEAN_BASE"
- Click Clone
BOOM! Clone created in 10-20 seconds!
Check the space:
- Original VM: ~15-20 GB
- Linked clone: ~500 MB initially!
Step 5.3: Create Multiple Test Clones
Create 3 linked clones:
- "Windows_TEST_MALWARE" (for malware testing)
- "Windows_TEST_DESTRUCTIVE" (for destructive tests)
- "Windows_TEST_NETWORK" (for network tests)
Advantages:
- 3 VMs in a few minutes
- Total space: ~2-3 GB instead of 60 GB
- Each clone can be broken and recreated in 10 seconds
Questions: 15. How many clones have you created? 16. What is the total disk space used?
Part 6: Destructive Tests - Level 2 (More Advanced)
Now that you have disposable VMs, let's test REALLY destructive things!
Step 6.1: Test 1 - Deleting System32
ON A LINKED CLONE only!
Internet Myth: "Deleting System32 speeds up Windows"
Reality: It completely destroys Windows!
Let's test (on clone!):
- Start "Windows_TEST_DESTRUCTIVE"
- cmd as admin:
takeown /f C:\Windows\System32 /r /d y
icacls C:\Windows\System32 /grant %username%:F /t
- DO NOT DO (too long):
rd /s /q C:\Windows\System32 - Instead, just delete an important folder:
rd /s /q C:\Windows\System32\drivers
- Restart
Result: BSOD or boot failure!
Recovery: Delete the clone, create a new one in 10 seconds!
Step 6.2: Test 2 - Test Malware (EICAR)
EICAR = Standard antivirus test file (not a real virus, just a test)
On test clone:
- Disable Windows Defender
- Create a file
test.txt - Paste inside:
X5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*
- Save
- Rename to
test.com - Reactivate Defender
Result: Defender detects and deletes!
Observe:
- Quarantine
- Notifications
- Logs
Questions: 17. Did Defender detect EICAR? 18. How long after reactivation?
Step 6.3: Test 3 - Fork Bomb (DoS)
Fork Bomb = Program that duplicates itself infinitely until the system is saturated
WARNING: This will FREEZE your VM!
Create forkbomb.bat:
:loop
start %0
goto loop
Execute: Double-click on forkbomb.bat
Result in 10 seconds:
- CPU at 100%
- Memory saturated
- VM completely frozen
- Impossible to do anything
Recovery:
- Force shutdown of the VM
- Restore snapshot or recreate clone
- 10 seconds, everything is OK!
Questions:
19. Did your VM freeze?
20. How many cmd.exe processes were created? (Task Manager before freeze)
Part 7: Automation and Scripts
Step 7.1: Automatic Reset Script
Create a script that:
- Deletes the test clone
- Creates a new clean clone
- Starts the new VM
PowerShell Example:
# Stop and delete test VM
VBoxManage controlvm "Windows_TEST_1" poweroff
VBoxManage unregistervm "Windows_TEST_1" --delete
# Recreate linked clone
VBoxManage clonevm "Windows_Original" --name "Windows_TEST_1" --snapshot "CLEAN_BASE" --options link --register
# Start
VBoxManage startvm "Windows_TEST_1"
Step 7.2: Complete Test Environment
Ideal architecture for labs:
VM_BASE (never touched, multiple snapshots)
├── CLEAN_BASE (snapshot)
├── WITH_TOOLS (snapshot - tools installed)
└── HARDENED (snapshot - hardened)
Test clones (recreated at will):
├── TEST_MALWARE_1
├── TEST_MALWARE_2
├── TEST_NETWORK
└── TEST_EXPLOIT
Workflow:
- Break a clone by testing
- Delete it
- Create a new one in 10 sec
- Start again!
Part 8: Security Measures
Step 8.1: Network Isolation
IMPORTANT: Test VMs must be isolated!
Recommended network configuration:
For offensive tests:
- Network: Host-Only or Internal Network
- No Internet!
- Communication only between test VMs
How to configure:
- VM Settings → Network
- Network access mode: Internal Network
- Name: "TestLab"
Check isolation:
- Try to ping google.com (should fail)
- Try to ping another VM on the same internal network (should work)
Step 8.2: Snapshots Before Each Test
Best practice:
Before EACH potentially destructive test:
- Create a snapshot with a descriptive name
- Perform your test
- If it works, merge or delete snapshot
- If it breaks, restore
Example:
- Snapshot: "BEFORE_ROOTKIT_TEST"
- Test the rootkit
- If it crashes: Restore → Analyze why
- Retry with corrections
Step 8.3: Documentation
Document each snapshot:
Good example:
Name: AFTER_INSTALL_METASPLOIT
Description:
- Kali Linux
- Metasploit Framework installed and updated
- PostgreSQL database configured
- Ready for pentest tests
Date: 2024-11-08
Bad example:
Name: test1
Description: (empty)
Deliverables
To submit:
-
Test Document (Word/PDF) containing:
- List of destructive tests performed
- Observed results
- Recovery time via snapshot
- Answers to the 20 questions
-
Screenshots (minimum 6):
- List of your snapshots (tree structure)
- Broken VM (e.g., desktop replaced by cmd)
- Restoration in progress
- Restored and functional VM
- List of created clones
- EICAR test detected by Defender
-
Lab Architecture (diagram):
- Your base VM
- Your snapshots
- Your test clones
- Network configuration
-
PowerShell Script (Step 7.1)
Evaluation Criteria
| Criteria | Points |
|---|---|
| Creation and management of snapshots | 25% |
| Destructive tests performed and documented | 25% |
| Cloning and linked clones | 20% |
| Understanding of isolation and security | 15% |
| Quality of documentation | 10% |
| Automation script | 5% |
VirtualBox Reference Commands
Snapshot Management
# List snapshots
VBoxManage snapshot "VMName" list
# Create a snapshot
VBoxManage snapshot "VMName" take "SnapshotName" --description "Description"
# Restore a snapshot
VBoxManage snapshot "VMName" restore "SnapshotName"
# Delete a snapshot
VBoxManage snapshot "VMName" delete "SnapshotName"
Cloning
# Full clone
VBoxManage clonevm "SourceVM" --name "CloneVM" --register
# Linked clone
VBoxManage clonevm "SourceVM" --name "CloneVM" --snapshot "SnapshotName" --options link --register
VM Management
# Start
VBoxManage startvm "VMName"
# Graceful shutdown
VBoxManage controlvm "VMName" acpipowerbutton
# Force shutdown
VBoxManage controlvm "VMName" poweroff
# Delete
VBoxManage unregistervm "VMName" --delete
Troubleshooting
Problem: Snapshot takes a long time
Solution: If your VM has a lot of RAM (8 GB+), the memory snapshot can be long. Shut down the VM before creating the snapshot.
Problem: Lack of disk space
Solution:
- Delete unnecessary snapshots
- Merge snapshots (right-click → Delete - data is preserved)
- Use linked clones instead of full clones
Problem: Linked clone won't start
Solution: The linked clone depends on the parent VM. If you delete or move the parent VM, the linked clones will no longer work.
Going Further (Optional)
Challenge 1: Multi-VM Lab
Create a lab with:
- 1 Windows VM (target)
- 1 Kali Linux VM (attacker)
- Internal network connecting them
- Coordinated snapshots of both
Challenge 2: Vagrant for Automation
Research Vagrant - VM automation tool.
Create a Vagrantfile that:
- Automatically configures a Windows VM
- Installs tools
- Creates snapshots
- All in one command!
Challenge 3: VM Templates
Create templates for different scenarios:
- "Windows Vulnerable" template (old, unpatched)
- "Windows Hardened" template (maximally hardened)
- "Windows Default" template (basic installation)
Document the differences and use cases.
Conclusion
This lab taught you:
- Use snapshots to test without risk
- Create disposable environments
- Perform destructive tests safely
- Optimize disk space with linked clones
- Create a reusable lab infrastructure
Key lessons:
- Snapshots = Total freedom - Test everything without fear
- Linked clones = Efficiency - Multiple environments, little space
- Network isolation = Security - No impact on real network
- Documentation = Productivity - Know where you stand
- Automation = Speed - Scripts for repetitive tasks
Next step: Lab 2.3 where you will explore BIOS/UEFI security options and firmware-level protection!
Lab developed as part of the Operating Systems course - MODULE 2