Starting the Console
Start the operator console from the server directory:Console Prompt
The console uses thec2> prompt for all commands:
Available Commands
The console supports six commands:| Command | Purpose | Usage |
|---|---|---|
list | List all sessions | list |
task | Enqueue a task for execution | task <session_id> <cmd> [args...] |
results | View task results for a session | results <session_id> |
kill | Deactivate a session | kill <session_id> |
help | Show available commands | help |
exit | Quit the console | exit |
Command Reference
list
Displays all registered agent sessions in a formatted table:- SESSION ID: Unique UUID for each agent
- HOSTNAME: Computer name from agent
- USERNAME: User running the agent
- OS: Operating system information
- JITTER: Beacon jitter percentage (0-100%)
- ACTIVE: Whether the session is active (YES/NO)
task
Enqueues a command for execution on an agent:<session_id>: UUID of the target session (fromlistcommand)<cmd>: Command to execute[args...]: Optional command arguments (space-separated)
results
Displays all task results for a specific session:- TASK ID: UUID of the task
- EXIT: Exit code (0 = success)
- DURATION: Execution time in milliseconds
- STDOUT: First 60 characters of output
kill
Deactivates an agent session:- No longer receive new tasks
- Will not beacon to the server
- Appear as
ACTIVE: NOin the session list - Remain in the database for historical reference
help
Displays the command reference:exit
Quits the operator console:Ctrl+C or Ctrl+D.
Console Architecture
The console is implemented inserver/api_interface.py and provides:
- Asynchronous REPL: Non-blocking command execution using
asyncio - Session management: Direct integration with
SessionManager - Task queueing: Real-time task submission via
CommandQueue - Database queries: Direct access to task results and session history
Session Restoration
On startup, the console automatically restores active sessions from the database:Error Handling
The console validates all commands and provides clear error messages:Implementation Reference
Key functions inserver/api_interface.py:
run_repl(): Main command loop (line 212)cmd_list(): Session listing (line 126)cmd_task(): Task enqueueing (line 132)cmd_results(): Results display (line 167)cmd_kill(): Session deactivation (line 194)_print_sessions(): Session table formatter (line 46)_print_results(): Results table formatter (line 81)