Lab Environment Overview
The C2 framework is designed for a VirtualBox lab environment with two VMs on a host-only network:| Host | IP | Role |
|---|---|---|
| Ubuntu VM (c2-server) | 192.168.100.10 | C2 server and Nginx redirector |
| Windows VM (c2-victim) | 192.168.100.20 | Agent victim machine |
| Windows Host (dev) | 192.168.100.1 | Development and git operations |
VirtualBox Network Adapters
Ubuntu VM (c2-server)
| Adapter | Type | Interface | IP | Purpose |
|---|---|---|---|---|
| Adapter 1 | NAT | enp0s3 | 10.0.2.15 (DHCP) | Internet access for apt/pip |
| Adapter 2 | Host-only | enp0s8 | 192.168.100.10/24 (static) | C2 traffic and SSH |
Windows VM (c2-victim)
| Adapter | Type | IP | Purpose |
|---|---|---|---|
| Adapter 1 | NAT | DHCP | Internet access |
| Adapter 2 | Host-only | 192.168.100.20/24 (static) | C2 traffic |
Static IP Configuration
Ubuntu VM Setup
Windows VM Setup
Configure static IP
Open Network Adapter settings for the Host-only adapter:
- IP address:
192.168.100.20 - Subnet mask:
255.255.255.0 - Gateway: (leave blank)
- DNS: (leave blank)
Add hosts file entry
Edit This allows the agent to resolve the C2 server by hostname.
C:\Windows\System32\drivers\etc\hosts as Administrator:DNS Resolution
The agent resolvesc2.lab.internal via the Windows VM hosts file:
In a real deployment, you would use legitimate DNS records or domain fronting. The hosts file approach is only suitable for lab testing.
Port Layout
Bare-Metal Deployment
Docker Compose Deployment
Service Responsibilities
| Component | Port | Protocol | Responsibility |
|---|---|---|---|
| c2-nginx | 443 (host) | HTTPS | TLS termination, UA filtering, traffic routing |
| c2-nginx | 80 (host) | HTTP | Redirect to HTTPS |
| c2-server | 8443 (internal) | HTTP | Beacon handler, session/task management |
Firewall Configuration
Ubuntu VM (UFW)
Windows VM (Windows Firewall)
Windows Firewall typically allows outbound HTTPS by default. No additional configuration is required for the agent to connect to the C2 server. If connection issues occur:Network Traffic Flow
Agent Check-in (Docker Deployment)
- Agent on Windows VM sends
POST /beacontohttps://c2.lab.internal:443 - DNS resolves
c2.lab.internalto192.168.100.10via hosts file - TLS handshake with Nginx on port 443
- Nginx validates User-Agent and Content-Type headers
- If valid, Nginx proxies request to
http://c2-server:8443/beaconover internal network - C2 server processes beacon and returns task list
- Nginx forwards response back to agent
Traffic Filtering
Nginx performs the following checks before proxying to the backend:| Check | Requirement | Action on Failure |
|---|---|---|
| HTTP Method | Must be POST | Return 404 |
| User-Agent | Must contain “Mozilla” | Return 404 |
| Content-Type | Must be “application/octet-stream” | Return 404 |
| Path | Must be exactly /beacon | Return 404 or serve fake site |
Invalid requests never reach the backend — they are filtered at the Nginx layer. This prevents fingerprinting of the C2 server.
Key Network Behaviors
- Agent always connects to port 443 in Docker deployment — never directly to 8443
- Port 8443 is not exposed to the host network in Docker mode
- TLS certificate is mounted into both containers from the host
certs/directory - Database and logs persist outside containers via bind mounts to
logs/ BEHIND_NGINX=1environment variable tells the server to trustX-Real-IPheaders
Testing Network Connectivity
From Windows VM
Test DNS resolution:400 Bad Request (backend rejected invalid protocol)
From Ubuntu VM
Test Nginx is listening:400
Troubleshooting
| Symptom | Cause | Fix |
|---|---|---|
Connection refused from agent | Firewall blocking port 443 | Check UFW rules on Ubuntu VM |
ping c2.lab.internal fails | Hosts file not configured | Add entry to Windows VM hosts file |
502 Bad Gateway | Backend not running | Start c2-server before Nginx |
Name or service not known | DNS resolution failed | Verify hosts file syntax |
| Agent can’t connect | Wrong IP in hosts file | Confirm 192.168.100.10 matches Ubuntu VM IP |
Next Steps
- Configure Docker Deployment for production-ready stack
- Set up Nginx Redirector for advanced traffic filtering
- Generate TLS Certificates for secure communication