Lab Topology
The lab consists of three systems on an isolated network:| System | IP Address | Role | OS |
|---|---|---|---|
| Windows Host | 192.168.100.1 | Development, Git operations | Windows 10/11 |
| Ubuntu VM (c2-server) | 192.168.100.10 | C2 server, Nginx redirector | Ubuntu 22.04 LTS |
| Windows VM (c2-victim) | 192.168.100.20 | Agent victim machine | Windows 10 |
Network Architecture
VirtualBox Configuration
Step 1: Create Host-Only Network
Step 2: Configure Ubuntu VM Network
Add Network Adapters
In VirtualBox, select the Ubuntu VM → Settings → Network:Adapter 1 (NAT - Internet Access):
- Enable Network Adapter: ✓
- Attached to: NAT
- Adapter Type:
Intel PRO/1000 MT Desktop
- Enable Network Adapter: ✓
- Attached to: Host-only Adapter
- Name:
vboxnet0 - Adapter Type:
Intel PRO/1000 MT Desktop
Step 3: Configure Windows VM Network
Add Network Adapters
In VirtualBox, select the Windows VM → Settings → Network:Adapter 1 (NAT):
- Enable Network Adapter: ✓
- Attached to: NAT
- Enable Network Adapter: ✓
- Attached to: Host-only Adapter
- Name:
vboxnet0
Configure Static IP
Boot the Windows VM:
- Open Control Panel → Network and Sharing Center
- Click the Host-only Adapter connection
- Click Properties → Internet Protocol Version 4 (TCP/IPv4)
- Select Use the following IP address:
- IP Address:
192.168.100.20 - Subnet Mask:
255.255.255.0 - Default Gateway: (leave blank)
- DNS: (leave blank)
- IP Address:
- Click OK
TLS Certificate Generation
Generate a self-signed certificate on the Ubuntu VM for TLS communication.Generate Certificate and Private Key
-x509: Generate self-signed certificate (not a CSR)-newkey rsa:4096: Create 4096-bit RSA private key-days 365: Certificate valid for 1 year-nodes: No passphrase (required for unattended server startup)-subj: Set Common Name toc2.lab.internal-addext: Add Subject Alternative Names (hostname + IP)
Configuration File Setup
Generate Pre-Shared Key
Generate a secure 32-byte key for encryption:Copy the output (e.g.,
b'\x8a\x3f...') and update the config:Port Configuration
Bare-Metal Deployment
Direct Python execution without Docker:Docker Compose Deployment
Containerized with Nginx reverse proxy:In Docker deployment, port 8443 is not exposed to the host. Only Nginx on port 443 is accessible from the Windows VM.
Verify Lab Setup
Network Connectivity
TLS Certificate Validation
Next Steps
With the lab environment configured:- Quickstart Guide - Launch the server and connect your first agent
- Architecture Overview - Understand the system design
Troubleshooting
Cannot Ping Between VMs
- Verify both VMs are on the same host-only network (
vboxnet0) - Check Windows Firewall: Temporarily disable to test
- Verify static IPs are correctly configured
DNS Resolution Fails
- Ensure
C:\Windows\System32\drivers\etc\hostshas the correct entry - Run
ipconfig /flushdnson Windows VM - Try connecting via IP directly:
https://192.168.100.10:8443
Certificate Errors
- Verify certificate was generated with SAN extension
- Check certificate CN matches hostname:
openssl x509 -in certs/server.crt -text -noout | grep Subject - Ensure
certs/server.crtis copied to Windows VM for agent pinning