Overview
The experiments module provides automated pipelines for capturing, parsing, and analyzing beacon traffic across multiple evasion profiles. It orchestrates the full telemetry stack to generate comparative datasets for C2 detection research. Source:experiments/
Available Experiments
1. Beacon Variation Tests
Purpose: Capture beacon traffic for all evasion profiles (baseline, low, medium, high) and extract comparative features. Script:experiments/beacon_variation_tests.py
What It Does:
- For each profile:
- Set active profile in
evasion/profile_config.yaml - Start PCAP capture on specified interface
- Run agent for 3 minutes (generates ~18 beacons at 10s interval)
- Stop capture
- Parse PCAP → flows
- Extract features → CSV and JSON
- Set active profile in
- Generate summary table comparing profiles
- Restore active profile to
medium
2. Entropy Analysis
Purpose: Load captured features and generate detailed statistical comparison with interpretations. Script:experiments/entropy_analysis.py
What It Does:
- Load
.features.csvand.flowsfiles for each profile frompcaps/ - Compute mean and standard deviation for:
- Beacon IAT (from
.flowsbeacon_iats field) - Shannon entropy (from
.features.csv) - Payload length (from
.features.csv)
- Beacon IAT (from
- Generate comparison table
- Write Markdown results summary to
experiments/results_summary.md
experiments/results_summary.md):
Experiment Configuration
Constants (experiments/beacon_variation_tests.py:18-22):
Prerequisites
Infrastructure:- Both VMs running (agent VM + server VM)
- Docker Compose backend services running
- Agent configured and reachable at
SERVER_PORT
- Root/sudo access for tcpdump (or setcap on tcpdump binary)
- Write access to
pcaps/directory
- Python packages: scapy, pyyaml
- System tools: tcpdump
- Host-only network configured (default:
enp0s8on Ubuntu VM) - No firewall blocking traffic between VMs
Pipeline Architecture
Experiment flow for a single profile:Implementation Details
Profile Switching
Theset_active_profile() function uses regex to update profile_config.yaml in-place:
experiments/beacon_variation_tests.py:25-43
Agent Execution
The agent runs inLAB_MODE=1 environment for experiment scenarios:
experiments/beacon_variation_tests.py:46-64
Custom Experiments
Create your own experiment by importing the telemetry modules:Troubleshooting
tcpdump permission denied:- Check if agent successfully connected to server
- Verify BPF filter matches actual traffic (check
SERVER_PORTin config) - Inspect PCAP manually:
tcpdump -r pcaps/baseline.pcap -c 10
- Ensure backend services are running:
docker-compose ps - Check agent can reach server:
nc -zv <server_ip> <server_port> - Review agent logs for connection errors
Experiment Best Practices
Baseline Capture:- Always run baseline profile first to establish ground truth
- Capture for at least 3 minutes (18+ beacons at 10s interval)
- Verify no other network activity during capture
- Use identical capture duration for all profiles
- Run experiments back-to-back to minimize environmental variance
- Capture during low network activity periods
- Check for packet loss:
tcpdump -r capture.pcap | wc -l - Verify beacon count matches expected (duration / interval)
- Inspect first/last packet timestamps for timing drift
Logging
Experiment operations are logged:starting profile run: Logged at start of each profileactive profile set: Logged after updating profile_config.yamlagent started: Logged with PID and durationagent stopped: Logged after terminationprofile run complete: Logged with flow/feature countsprofile run failed: Error if any step failsactive profile restored to medium: Logged after experiment cleanup
Performance Considerations
Total Runtime:- 4 profiles × 3 minutes = 12 minutes capture time
- Add ~30 seconds parsing/extraction per profile
- Total experiment time ≈ 15 minutes
- Typical PCAP: 100-500 KB per profile (compressed traffic)
.flowsfiles: 10-50 KB.features.csv: 5-20 KB- Total per experiment: ~2-3 MB
Next Steps
Analyze Results:- Review
experiments/results_summary.md - Load CSVs into Jupyter notebook for visualization
- Compare feature distributions across profiles
See Also
- Traffic Capture - PCAP capture module
- Flow Analysis - Flow parsing module
- Feature Extraction - Feature computation module
- Evasion Profiles - Configuring evasion settings