# lcdemi/mirage architecture

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

- Interactive diagram: https://gitdiagram.com/lcdemi/mirage
- Repository: https://github.com/lcdemi/mirage

## Overview

#### Purpose and Entry Points
Mirage is a cross-platform red-team operations toolkit for deploying and managing access on Windows, Linux, and FreeBSD web-server targets. Its two primary operator entry points are the interactive Python controller at `mirage.py` and Ansible deployment workflows at `Ansible/playbooks/deploy.yml` and `Ansible/playbooks/undeploy.yml`.

#### Operator Controller
`mirage.py` is the CLI orchestration layer. It delegates interactive actions—single or mass execution, shell handling, callback testing, and connection display—to modular controller code under `Server/`. Runtime target groups and operating parameters originate in `Server/config.json`, loaded through `Server/config_loader.py`; shared runtime state/constants are centralized in `Server/variables.py`.

#### Remote Execution and Shell Flow
The controller’s execution boundary is `Server/execute.py`, which handles command dispatch against selected targets. Shell-oriented workflows are separated into `Server/shell.py`, while concurrency/background execution is represented by `Server/thread.py`. The expected flow is: operator selects a configured host/group → controller validates/builds target work → execution or shell module performs remote action → callback and display modules record/report outcomes.

#### Callback, Visualization, and Integrations
Callback processing and connection testing are handled by `Server/callbacks.py`; presentation/dashboard behavior is in `Server/display.py` and `Server/styles.py`. Optional outbound reporting integrations are isolated in `Server/pwnboard.py` and `Server/discord.py`, configured via logging fields in `Server/config.json`. These form a boundary between local operational state and external Pwnboard/Discord HTTP services.

#### Deployment Automation
Ansible supplies the host provisioning and removal plane. Inventory and connection settings reside in `Ansible/inventory/inventory.yml`, with control defaults in `Ansible/ansible.cfg`. The deploy/undeploy playbooks route work into platform roles: `Ansible/roles/windows/tasks/deploy.yml`, `Ansible/roles/linux/tasks/deploy.yml`, and `Ansible/roles/freebsd/tasks/deploy.yml`. Targets require reachable SSH or WinRM, making Ansible the primary transport and platform-abstraction layer.

#### Hosted Web Surface and Payload Handling
The repository includes themed hosted content for social-engineering or payload-interaction scenarios. Site variants are self-contained under paths such as `Website/EmpireStateHealth/EmpireStateHealth.html`, `Website/IRSEC/IRSEC.html`, and their `web.config` files. Server-side PHP endpoints at `PHP/contact.php` and `PHP/search.php` support hosted handling workflows; associated visual assets live under `Images/`.

#### Optional Extension and Windows Persistence
The Puzzler extension is deployed as a distinct Ansible role, `Ansible/roles/puzzler/tasks/deploy.yml`, backed by Go source and shipped Windows binaries in `Extensions/Puzzler/puzzler.go` and `Extensions/Puzzler/Popup/popup.go`. Windows long-term-access functionality is separately implemented as native service source in `Persistence/Service.cpp` and `Persistence/Persistence.cpp`, with a packaged executable `Persistence/IISManagerService.exe`. This separates optional/user-facing extension behavior and persistence artifacts from the core controller and deployment roles.

#### Runtime and Infrastructure
The control machine needs Python dependencies from `requirements.txt`, Ansible plus collections from `ansible-requirements.yml`, and network access to managed hosts. Managed environments span Windows, Linux, and FreeBSD; Windows workflows depend on WinRM and likely IIS-hosted content, while Unix-like targets use SSH. External integrations are optional and configured rather than hardwired.

Main entry points: [`mirage.py`](https://github.com/lcdemi/mirage/blob/main/mirage.py) (Python Controller), [`Ansible/playbooks/deploy.yml`](https://github.com/lcdemi/mirage/blob/main/Ansible/playbooks/deploy.yml) (Deploy / Undeploy), [`Server/execute.py`](https://github.com/lcdemi/mirage/blob/main/Server/execute.py) (Remote Execution), [`Server/callbacks.py`](https://github.com/lcdemi/mirage/blob/main/Server/callbacks.py) (Callbacks)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_controller["Operator Control"]
  node_cli["Python Controller<br/>CLI orchestrator<br/>[mirage.py]"]
  node_runtime_config["Runtime Config<br/>target configuration<br/>[config.json]"]
  node_config_loader["Config Loader<br/>configuration loader<br/>[config_loader.py]"]
  node_controller_state["Shared State<br/>runtime state<br/>[variables.py]"]
  node_execution["Remote Execution<br/>dispatch boundary<br/>[execute.py]"]
  node_shell["Shell Workflows<br/>interactive shell<br/>[shell.py]"]
  node_background["Background Work<br/>concurrency<br/>[thread.py]"]
  node_callbacks["Callbacks<br/>outcome processing<br/>[callbacks.py]"]
  node_display["Operations Display<br/>presentation<br/>[display.py]"]
  node_integrations{{"Pwnboard &amp; Discord<br/>outbound reporting<br/>[pwnboard.py]"}}
end

subgraph group_automation["Deployment Automation"]
  node_deploy_playbooks["Deploy / Undeploy<br/>Ansible playbooks<br/>[deploy.yml]"]
  node_inventory["Managed Inventory<br/>Ansible inventory<br/>[inventory.yml]"]
  node_platform_roles["Platform Roles<br/>Ansible roles<br/>[deploy.yml]"]
end

subgraph group_hosted["Hosted Content"]
  node_web_sites["Themed Web Sites<br/>hosted content"]
  node_php_handlers["PHP Handlers<br/>server endpoints<br/>[contact.php]"]
end

subgraph group_extensions["Extensions &amp; Persistence"]
  node_puzzler["Puzzler Extension<br/>optional Ansible role<br/>[deploy.yml]"]
  node_persistence{{"Windows Persistence<br/>native service"}}
end

node_operator(("Operator<br/>user"))
node_managed_hosts{{"Managed Targets"}}

node_operator -->|"operates"| node_cli
node_cli -->|"loads targets"| node_config_loader
node_config_loader -->|"reads"| node_runtime_config
node_cli -->|"uses"| node_controller_state
node_cli -->|"dispatches commands"| node_execution
node_cli -->|"opens shells"| node_shell
node_execution -->|"runs concurrently"| node_background
node_execution -->|"records outcomes"| node_callbacks
node_shell -->|"reports status"| node_callbacks
node_callbacks -->|"updates"| node_display
node_callbacks -.->|"optionally reports"| node_integrations
node_runtime_config -.->|"configures"| node_integrations
node_operator -->|"runs"| node_deploy_playbooks
node_deploy_playbooks -->|"uses"| node_inventory
node_deploy_playbooks -->|"routes to"| node_platform_roles
node_platform_roles -->|"provisions via SSH / WinRM"| node_managed_hosts
node_execution -->|"acts on selected targets"| node_managed_hosts
node_deploy_playbooks -.->|"optionally deploys"| node_puzzler
node_puzzler -->|"installs on Windows"| node_managed_hosts
node_deploy_playbooks -.->|"deploys artifact"| node_persistence
node_persistence -->|"persists on Windows"| node_managed_hosts
node_platform_roles -.->|"hosts content"| node_web_sites
node_web_sites -->|"submits to"| node_php_handlers

click node_cli "https://github.com/lcdemi/mirage/blob/main/mirage.py"
click node_runtime_config "https://github.com/lcdemi/mirage/blob/main/Server/config.json"
click node_config_loader "https://github.com/lcdemi/mirage/blob/main/Server/config_loader.py"
click node_controller_state "https://github.com/lcdemi/mirage/blob/main/Server/variables.py"
click node_execution "https://github.com/lcdemi/mirage/blob/main/Server/execute.py"
click node_shell "https://github.com/lcdemi/mirage/blob/main/Server/shell.py"
click node_background "https://github.com/lcdemi/mirage/blob/main/Server/thread.py"
click node_callbacks "https://github.com/lcdemi/mirage/blob/main/Server/callbacks.py"
click node_display "https://github.com/lcdemi/mirage/blob/main/Server/display.py"
click node_integrations "https://github.com/lcdemi/mirage/blob/main/Server/pwnboard.py"
click node_deploy_playbooks "https://github.com/lcdemi/mirage/blob/main/Ansible/playbooks/deploy.yml"
click node_inventory "https://github.com/lcdemi/mirage/blob/main/Ansible/inventory/inventory.yml"
click node_platform_roles "https://github.com/lcdemi/mirage/blob/main/Ansible/roles/windows/tasks/deploy.yml"
click node_web_sites "https://github.com/lcdemi/mirage/blob/main/Website/EmpireStateHealth/EmpireStateHealth.html"
click node_php_handlers "https://github.com/lcdemi/mirage/blob/main/PHP/contact.php"
click node_puzzler "https://github.com/lcdemi/mirage/blob/main/Ansible/roles/puzzler/tasks/deploy.yml"
click node_persistence "https://github.com/lcdemi/mirage/blob/main/Persistence/IISManagerService.exe"

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_cli,node_runtime_config,node_config_loader,node_controller_state,node_execution,node_shell,node_background,node_callbacks,node_display,node_integrations toneBlue
class node_deploy_playbooks,node_inventory,node_platform_roles toneAmber
class node_web_sites,node_php_handlers toneMint
class node_puzzler,node_persistence toneRose
class node_operator,node_managed_hosts toneNeutral
```

## Components

### Operator Control

Interactive local control plane.

- [Python Controller](https://github.com/lcdemi/mirage/blob/main/mirage.py): CLI orchestrator · Interactive execution, shell, callback, and connection commands. · `mirage.py`
- [Runtime Config](https://github.com/lcdemi/mirage/blob/main/Server/config.json): target configuration · Configured hosts, groups, and integration settings. · `Server/config.json`
- [Config Loader](https://github.com/lcdemi/mirage/blob/main/Server/config_loader.py): configuration loader · `Server/config_loader.py`
- [Shared State](https://github.com/lcdemi/mirage/blob/main/Server/variables.py): runtime state · `Server/variables.py`
- [Remote Execution](https://github.com/lcdemi/mirage/blob/main/Server/execute.py): dispatch boundary · Builds and dispatches work to selected targets. · `Server/execute.py`
- [Shell Workflows](https://github.com/lcdemi/mirage/blob/main/Server/shell.py): interactive shell · `Server/shell.py`
- [Background Work](https://github.com/lcdemi/mirage/blob/main/Server/thread.py): concurrency · `Server/thread.py`
- [Callbacks](https://github.com/lcdemi/mirage/blob/main/Server/callbacks.py): outcome processing · Tests connections and processes callback results. · `Server/callbacks.py`
- [Operations Display](https://github.com/lcdemi/mirage/blob/main/Server/display.py): presentation · Reports connection and operational status. · `Server/display.py`
- [Pwnboard & Discord](https://github.com/lcdemi/mirage/blob/main/Server/pwnboard.py): outbound reporting · Optional HTTP reporting integrations. · `Server/pwnboard.py`

### Deployment Automation

Platform provisioning and removal plane.

- [Deploy / Undeploy](https://github.com/lcdemi/mirage/blob/main/Ansible/playbooks/deploy.yml): Ansible playbooks · Primary provisioning and removal workflows. · `Ansible/playbooks/deploy.yml`
- [Managed Inventory](https://github.com/lcdemi/mirage/blob/main/Ansible/inventory/inventory.yml): Ansible inventory · Host connection settings for SSH and WinRM targets. · `Ansible/inventory/inventory.yml`
- [Platform Roles](https://github.com/lcdemi/mirage/blob/main/Ansible/roles/windows/tasks/deploy.yml): Ansible roles · Windows, Linux, and FreeBSD deployment tasks. · `Ansible/roles/windows/tasks/deploy.yml`

### Hosted Content

Web-facing payload and interaction surface.

- [Themed Web Sites](https://github.com/lcdemi/mirage/blob/main/Website/EmpireStateHealth/EmpireStateHealth.html): hosted content · Social-engineering and payload-interaction site variants. · `Website/EmpireStateHealth/EmpireStateHealth.html`
- [PHP Handlers](https://github.com/lcdemi/mirage/blob/main/PHP/contact.php): server endpoints · Hosted contact and search handling workflows. · `PHP/contact.php`

### Extensions & Persistence

Optional Windows capabilities.

- [Puzzler Extension](https://github.com/lcdemi/mirage/blob/main/Ansible/roles/puzzler/tasks/deploy.yml): optional Ansible role · Optional user-facing Windows extension. · `Ansible/roles/puzzler/tasks/deploy.yml`
- [Windows Persistence](https://github.com/lcdemi/mirage/blob/main/Persistence/IISManagerService.exe): native service · Packaged long-term-access service capability. · `Persistence/IISManagerService.exe`

### Other components

- **Operator**: user
- **Managed Targets**: Windows / Linux / FreeBSD · Remote web-server targets reached through WinRM or SSH.

## Connections

- Operator → Python Controller: operates
- Python Controller → Config Loader: loads targets
- Config Loader → Runtime Config: reads
- Python Controller → Shared State: uses
- Python Controller → Remote Execution: dispatches commands
- Python Controller → Shell Workflows: opens shells
- Remote Execution → Background Work: runs concurrently
- Remote Execution → Callbacks: records outcomes
- Shell Workflows → Callbacks: reports status
- Callbacks → Operations Display: updates
- Callbacks → Pwnboard & Discord: optionally reports
- Runtime Config → Pwnboard & Discord: configures
- Operator → Deploy / Undeploy: runs
- Deploy / Undeploy → Managed Inventory: uses
- Deploy / Undeploy → Platform Roles: routes to
- Platform Roles → Managed Targets: provisions via SSH / WinRM
- Remote Execution → Managed Targets: acts on selected targets
- Deploy / Undeploy → Puzzler Extension: optionally deploys
- Puzzler Extension → Managed Targets: installs on Windows
- Deploy / Undeploy → Windows Persistence: deploys artifact
- Windows Persistence → Managed Targets: persists on Windows
- Platform Roles → Themed Web Sites: hosts content
- Themed Web Sites → PHP Handlers: submits to
