# mythicagents/hannibal architecture

> Architecture diagram of the GitHub repository mythicagents/hannibal, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mythicagents/hannibal
- Repository: https://github.com/mythicagents/hannibal

## Overview

Hannibal is a modular, position-independent Windows Mythic stage-one agent. An operator issues commands through Mythic; the Python translator encodes task messages, the agent’s HTTP profile receives and queues them, and command handlers perform host actions and return results. The profile also handles check-in and chunked file transfer. The repository documents optional HBIN execution, Ekko sleep, and a replaceable HTTP profile. Excerpts establish the task-queue and profile responsibilities, but do not show all runtime dispatch calls; unsampled links are omitted or marked unverified.

Main entry points: [`Payload_Type/hannibal/hannibal/agent_code/Hannibal/src/profile_mythic_http.c`](https://github.com/mythicagents/hannibal/blob/main/Payload_Type/hannibal/hannibal/agent_code/Hannibal/src/profile_mythic_http.c) (HTTP profile), [`Payload_Type/hannibal/hannibal/agent_code/Hannibal/include/hannibal_tasking.h`](https://github.com/mythicagents/hannibal/blob/main/Payload_Type/hannibal/hannibal/agent_code/Hannibal/include/hannibal_tasking.h) (Task queues), [`Payload_Type/hannibal/hannibal/agent_code/Hannibal/src/utility_encryption_AES.c`](https://github.com/mythicagents/hannibal/blob/main/Payload_Type/hannibal/hannibal/agent_code/Hannibal/src/utility_encryption_AES.c) (Encryption and hashing), [`Payload_Type/hannibal/hannibal/agent_code/Hannibal/src/hannibal.c`](https://github.com/mythicagents/hannibal/blob/main/Payload_Type/hannibal/hannibal/agent_code/Hannibal/src/hannibal.c) (Agent entry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_mythic["Mythic integration"]
  node_command_api["Command definitions"]
  node_translator["Message translator<br/>[translator.py]"]
end

subgraph group_agent["Agent runtime"]
  node_agent_entry["Agent entry<br/>[hannibal.c]"]
  node_http_profile["HTTP profile"]
  node_tasking["Task queues<br/>[hannibal_tasking.h]"]
  node_file_transfer["File transfer"]
end

subgraph group_commands["Host capabilities"]
  node_file_commands["File commands"]
  node_process_commands["Process commands"]
  node_host_info["Host information"]
  node_hbin["HBIN execution<br/>[cmd_execute_hbin.c]"]
end

subgraph group_internals["Runtime internals"]
  node_sleep["Ekko sleep"]
  node_crypto["Encryption and hashing"]
  node_serialization["Serialization"]
  node_wininet["WinINet transport"]
  node_api_resolution["API resolution"]
  node_aes_impl["AES implementation"]
  node_sha_impl["SHA-256 implementation"]
  node_hmac_impl["HMAC implementation"]
end

node_operator(("Operator"))
node_mythic_server["Mythic server"]

node_operator -->|"issues tasks"| node_mythic_server
node_mythic_server -.->|"selects command"| node_command_api
node_mythic_server -.->|"sends task data"| node_translator
node_translator -->|"encodes task messages"| node_http_profile
node_http_profile -->|"enqueues tasks"| node_tasking
node_agent_entry -.->|"uses profile"| node_http_profile
node_http_profile -->|"polls and posts"| node_mythic_server
node_http_profile -->|"handles transfers"| node_file_transfer
node_tasking -.->|"dispatches"| node_file_commands
node_tasking -.->|"dispatches"| node_process_commands
node_tasking -.->|"dispatches"| node_host_info
node_tasking -.->|"dispatches"| node_hbin
node_agent_entry -.->|"sleeps with"| node_sleep
node_http_profile -->|"encrypts messages"| node_crypto
node_http_profile -->|"serializes messages"| node_serialization
node_http_profile -->|"uses transport"| node_wininet
node_api_resolution -.->|"resolves APIs"| node_agent_entry
node_crypto -.->|"uses AES"| node_aes_impl
node_crypto -.->|"uses SHA-256"| node_sha_impl
node_crypto -.->|"uses HMAC"| node_hmac_impl

click node_command_api "https://github.com/mythicagents/hannibal/tree/main/Payload_Type/hannibal/hannibal/mythic/agent_functions"
click node_translator "https://github.com/mythicagents/hannibal/blob/main/Payload_Type/python_services/translator/translator.py"
click node_agent_entry "https://github.com/mythicagents/hannibal/blob/main/Payload_Type/hannibal/hannibal/agent_code/Hannibal/src/hannibal.c"
click node_http_profile "https://github.com/mythicagents/hannibal/blob/main/Payload_Type/hannibal/hannibal/agent_code/Hannibal/src/profile_mythic_http.c"
click node_tasking "https://github.com/mythicagents/hannibal/blob/main/Payload_Type/hannibal/hannibal/agent_code/Hannibal/include/hannibal_tasking.h"
click node_file_transfer "https://github.com/mythicagents/hannibal/blob/main/Payload_Type/hannibal/hannibal/agent_code/Hannibal/src/profile_mythic_http.c"
click node_file_commands "https://github.com/mythicagents/hannibal/tree/main/Payload_Type/hannibal/hannibal/agent_code/Hannibal/src"
click node_process_commands "https://github.com/mythicagents/hannibal/tree/main/Payload_Type/hannibal/hannibal/agent_code/Hannibal/src"
click node_host_info "https://github.com/mythicagents/hannibal/tree/main/Payload_Type/hannibal/hannibal/agent_code/Hannibal/src"
click node_hbin "https://github.com/mythicagents/hannibal/blob/main/Payload_Type/hannibal/hannibal/agent_code/Hannibal/src/cmd_execute_hbin.c"
click node_sleep "https://github.com/mythicagents/hannibal/blob/main/Payload_Type/hannibal/hannibal/agent_code/Hannibal/src/utility_sleep_ekko.c"
click node_crypto "https://github.com/mythicagents/hannibal/blob/main/Payload_Type/hannibal/hannibal/agent_code/Hannibal/src/utility_encryption_AES.c"
click node_serialization "https://github.com/mythicagents/hannibal/blob/main/Payload_Type/hannibal/hannibal/agent_code/Hannibal/src/utility_serialization.c"
click node_wininet "https://github.com/mythicagents/hannibal/blob/main/Payload_Type/hannibal/hannibal/agent_code/Hannibal/src/utility_http_wininet.c"
click node_api_resolution "https://github.com/mythicagents/hannibal/blob/main/Payload_Type/hannibal/hannibal/agent_code/Hannibal/src/hannibal_resolve_pointers.c"
click node_aes_impl "https://github.com/mythicagents/hannibal/blob/main/Payload_Type/hannibal/hannibal/agent_code/Hannibal/src/utility_encryption_AES.c"
click node_sha_impl "https://github.com/mythicagents/hannibal/blob/main/Payload_Type/hannibal/hannibal/agent_code/Hannibal/src/utility_hashing_sha256.c"
click node_hmac_impl "https://github.com/mythicagents/hannibal/blob/main/Payload_Type/hannibal/hannibal/agent_code/Hannibal/src/utility_hashing_sha256_hmac.c"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_command_api,node_translator toneBlue
class node_agent_entry,node_http_profile,node_tasking,node_file_transfer toneAmber
class node_file_commands,node_process_commands,node_host_info,node_hbin,node_mythic_server toneMint
class node_sleep,node_crypto,node_serialization,node_wininet,node_api_resolution,node_aes_impl,node_sha_impl,node_hmac_impl toneRose
class node_operator toneIndigo
```

## Components

### Mythic integration

- [Command definitions](https://github.com/mythicagents/hannibal/tree/main/Payload_Type/hannibal/hannibal/mythic/agent_functions): `Payload_Type/hannibal/hannibal/mythic/agent_functions`
- [Message translator](https://github.com/mythicagents/hannibal/blob/main/Payload_Type/python_services/translator/translator.py): `Payload_Type/python_services/translator/translator.py`

### Agent runtime

- [Agent entry](https://github.com/mythicagents/hannibal/blob/main/Payload_Type/hannibal/hannibal/agent_code/Hannibal/src/hannibal.c): `Payload_Type/hannibal/hannibal/agent_code/Hannibal/src/hannibal.c`
- [HTTP profile](https://github.com/mythicagents/hannibal/blob/main/Payload_Type/hannibal/hannibal/agent_code/Hannibal/src/profile_mythic_http.c): `Payload_Type/hannibal/hannibal/agent_code/Hannibal/src/profile_mythic_http.c`
- [Task queues](https://github.com/mythicagents/hannibal/blob/main/Payload_Type/hannibal/hannibal/agent_code/Hannibal/include/hannibal_tasking.h): `Payload_Type/hannibal/hannibal/agent_code/Hannibal/include/hannibal_tasking.h`
- [File transfer](https://github.com/mythicagents/hannibal/blob/main/Payload_Type/hannibal/hannibal/agent_code/Hannibal/src/profile_mythic_http.c): `Payload_Type/hannibal/hannibal/agent_code/Hannibal/src/profile_mythic_http.c`

### Host capabilities

- [File commands](https://github.com/mythicagents/hannibal/tree/main/Payload_Type/hannibal/hannibal/agent_code/Hannibal/src): `Payload_Type/hannibal/hannibal/agent_code/Hannibal/src`
- [Process commands](https://github.com/mythicagents/hannibal/tree/main/Payload_Type/hannibal/hannibal/agent_code/Hannibal/src): `Payload_Type/hannibal/hannibal/agent_code/Hannibal/src`
- [Host information](https://github.com/mythicagents/hannibal/tree/main/Payload_Type/hannibal/hannibal/agent_code/Hannibal/src): `Payload_Type/hannibal/hannibal/agent_code/Hannibal/src`
- [HBIN execution](https://github.com/mythicagents/hannibal/blob/main/Payload_Type/hannibal/hannibal/agent_code/Hannibal/src/cmd_execute_hbin.c): `Payload_Type/hannibal/hannibal/agent_code/Hannibal/src/cmd_execute_hbin.c`

### Runtime internals

- [Ekko sleep](https://github.com/mythicagents/hannibal/blob/main/Payload_Type/hannibal/hannibal/agent_code/Hannibal/src/utility_sleep_ekko.c): `Payload_Type/hannibal/hannibal/agent_code/Hannibal/src/utility_sleep_ekko.c`
- [Encryption and hashing](https://github.com/mythicagents/hannibal/blob/main/Payload_Type/hannibal/hannibal/agent_code/Hannibal/src/utility_encryption_AES.c): `Payload_Type/hannibal/hannibal/agent_code/Hannibal/src/utility_encryption_AES.c`
- [Serialization](https://github.com/mythicagents/hannibal/blob/main/Payload_Type/hannibal/hannibal/agent_code/Hannibal/src/utility_serialization.c): `Payload_Type/hannibal/hannibal/agent_code/Hannibal/src/utility_serialization.c`
- [WinINet transport](https://github.com/mythicagents/hannibal/blob/main/Payload_Type/hannibal/hannibal/agent_code/Hannibal/src/utility_http_wininet.c): `Payload_Type/hannibal/hannibal/agent_code/Hannibal/src/utility_http_wininet.c`
- [API resolution](https://github.com/mythicagents/hannibal/blob/main/Payload_Type/hannibal/hannibal/agent_code/Hannibal/src/hannibal_resolve_pointers.c): `Payload_Type/hannibal/hannibal/agent_code/Hannibal/src/hannibal_resolve_pointers.c`
- [AES implementation](https://github.com/mythicagents/hannibal/blob/main/Payload_Type/hannibal/hannibal/agent_code/Hannibal/src/utility_encryption_AES.c): `Payload_Type/hannibal/hannibal/agent_code/Hannibal/src/utility_encryption_AES.c`
- [SHA-256 implementation](https://github.com/mythicagents/hannibal/blob/main/Payload_Type/hannibal/hannibal/agent_code/Hannibal/src/utility_hashing_sha256.c): `Payload_Type/hannibal/hannibal/agent_code/Hannibal/src/utility_hashing_sha256.c`
- [HMAC implementation](https://github.com/mythicagents/hannibal/blob/main/Payload_Type/hannibal/hannibal/agent_code/Hannibal/src/utility_hashing_sha256_hmac.c): `Payload_Type/hannibal/hannibal/agent_code/Hannibal/src/utility_hashing_sha256_hmac.c`

### Other components

- **Operator**
- **Mythic server**

## Connections

- Operator → Mythic server: issues tasks
- Mythic server → Command definitions: selects command
- Mythic server → Message translator: sends task data
- Message translator → HTTP profile: encodes task messages (evidence: `Payload_Type/hannibal/hannibal/agent_code/Hannibal/src/profile_mythic_http.c`)
- HTTP profile → Task queues: enqueues tasks (evidence: `Payload_Type/hannibal/hannibal/agent_code/Hannibal/src/profile_mythic_http.c`)
- Agent entry → HTTP profile: uses profile
- HTTP profile → Mythic server: polls and posts
- HTTP profile → File transfer: handles transfers (evidence: `Payload_Type/hannibal/hannibal/agent_code/Hannibal/src/profile_mythic_http.c`)
- Task queues → File commands: dispatches (evidence: `Payload_Type/hannibal/hannibal/agent_code/Hannibal/src/cmd_ps.c`)
- Task queues → Process commands: dispatches (evidence: `Payload_Type/hannibal/hannibal/agent_code/Hannibal/src/cmd_ps.c`)
- Task queues → Host information: dispatches (evidence: `Payload_Type/hannibal/hannibal/agent_code/Hannibal/src/cmd_ps.c`)
- Task queues → HBIN execution: dispatches
- Agent entry → Ekko sleep: sleeps with
- HTTP profile → Encryption and hashing: encrypts messages
- HTTP profile → Serialization: serializes messages
- HTTP profile → WinINet transport: uses transport
- API resolution → Agent entry: resolves APIs
- Encryption and hashing → AES implementation: uses AES (evidence: `Payload_Type/hannibal/hannibal/agent_code/Hannibal/src/utility_encryption_AES.c`)
- Encryption and hashing → SHA-256 implementation: uses SHA-256
- Encryption and hashing → HMAC implementation: uses HMAC
