Documentation Index
Fetch the complete documentation index at: https://mintlify.com/Menelaus29/c2-framework/llms.txt
Use this file to discover all available pages before exploring further.
Overview
Theagent_main.py module serves as the primary entry point for the C2 agent. It orchestrates environment validation and beacon loop initialization with comprehensive error handling.
Module Location
Main Entry Point
The module runs as a standalone script and coordinates agent startup.Execution Flow
Startup Sequence
1. Environment Validation
The agent first validates the lab environment:- Verifies
LAB_MODEenvironment variable is set to1 - Confirms server host is in
ALLOWED_HOSTS - Detects debuggers (Windows only)
- Identifies VM indicators
1.
2. Beacon Loop Initialization
After validation, the beacon loop starts:Error Handling
SystemExit Passthrough
The entry point allowsSystemExit exceptions to propagate:
- Environment check failures exit cleanly
MSG_TERMINATEsignals shutdown the agent correctly
Catastrophic Failure Recovery
Unexpected exceptions are logged and result in exit code1:
Exit Codes
| Code | Meaning |
|---|---|
0 | Normal shutdown via MSG_TERMINATE |
1 | Environment check failure or catastrophic error |
Dependencies
Usage Example
Run the agent from the command line:Logging
All logs use theagent logger namespace:
- Exception reason
- Full stack trace
Security Considerations
- Lab Mode Required: Agent refuses to run without
LAB_MODE=1 - Host Allowlist: Only connects to pre-approved C2 servers
- Clean Exit: Ensures all shutdown signals are handled correctly
Related APIs
- environment_checks - Environment validation logic
- BeaconLoop - Beacon loop implementation
- Logger - Logging utilities