Documentation Index
Fetch the complete documentation index at: https://mintlify.com/HavocFramework/Havoc/llms.txt
Use this file to discover all available pages before exploring further.
Overview
TheCommand class allows you to define custom commands that operators can execute through your agent in the Havoc client. Each command specifies its parameters, permissions, and generates a task payload for the agent to execute.
Class Definition
Required Attributes
Unique identifier for the command. Should match the command ID in your agent implementation.Example:
0x101 or COMMAND_SHELLCommand name as typed by operators in the Havoc client console.Example:
"shell", "upload", "screenshot"Brief description of what the command does.
Detailed help text displayed when operators run
help [command].Whether the command requires administrator/elevated privileges.
True: Command requires admin rightsFalse: Command works with normal privileges
List of parameters the command accepts. Can be an empty list
[] for commands with no parameters.List of MITRE ATT&CK technique IDs associated with this command.Example:
["T1059.003", "T1106"]CommandParam
Defines a command parameter with validation rules.Parameter name as used in the arguments dictionary.
Whether the parameter expects a file path. When
True, Havoc validates the file exists.Whether the parameter is optional. When
False, the command requires this parameter.Required Methods
job_generate()
Generates the task payload to send to the agent. This method is called when an operator executes the command. Parameters:Dictionary containing parameter values where keys match the parameter names defined in
Params.bytes - The packed task payload to send to the agent
Packer Utility
ThePacker class builds binary task payloads for your agent.
Methods
Adds a 4-byte integer to the buffer.
Adds length-prefixed binary data or string to the buffer.
The final packed binary buffer to return from
job_generate().Command Examples
Registering Commands
Register commands with your agent in the__init__ method:
Command Workflow
-
Operator Input: Operator types command in Havoc client
-
Parameter Validation: Havoc validates parameters against
Paramsdefinition -
Job Generation:
job_generate()is called with parsed arguments -
Task Packing: Command packs task data using
Packer - Transmission: Packed task is sent to agent via Service API
- Agent Execution: Agent receives, unpacks, and executes the task
-
Response: Agent sends results back through the
response()handler
Best Practices
Use Unique Command IDs
Use Unique Command IDs
Ensure each command has a unique
CommandId to avoid conflicts. Consider using a hex range:Validate Input
Validate Input
Validate arguments in
job_generate() before packing:Set Appropriate Permissions
Set Appropriate Permissions
Set
NeedAdmin = True for commands requiring elevated privileges:Include MITRE ATT&CK Tags
Include MITRE ATT&CK Tags
Write Helpful Documentation
Write Helpful Documentation
Provide clear help text with usage examples:
Related Resources
AgentType
Learn about agent implementation and response handling
HavocService
Connect your agent to the Teamserver
