How lcdemi/mirage works
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 Python Controller · deploy.yml Deploy / Undeploy · execute.py Remote Execution · callbacks.py Callbacks
Components 19
Operator Control
Interactive local control plane.
- Python Controller · Interactive execution, shell, callback, and connection commands.
mirage.py - Runtime Config · Configured hosts, groups, and integration settings.
Server/config.json - Config Loader
Server/config_loader.py - Shared State
Server/variables.py - Remote Execution · Builds and dispatches work to selected targets.
Server/execute.py - Shell Workflows
Server/shell.py - Background Work
Server/thread.py - Callbacks · Tests connections and processes callback results.
Server/callbacks.py - Operations Display · Reports connection and operational status.
Server/display.py - Pwnboard & Discord · Optional HTTP reporting integrations.
Server/pwnboard.py
Deployment Automation
Platform provisioning and removal plane.
- Deploy / Undeploy · Primary provisioning and removal workflows.
Ansible/playbooks/deploy.yml - Managed Inventory · Host connection settings for SSH and WinRM targets.
Ansible/inventory/inventory.yml - Platform Roles · Windows, Linux, and FreeBSD deployment tasks.
Ansible/roles/windows/tasks/deploy.yml
Hosted Content
Web-facing payload and interaction surface.
- Themed Web Sites · Social-engineering and payload-interaction site variants.
Website/EmpireStateHealth/EmpireStateHealth.html - PHP Handlers · Hosted contact and search handling workflows.
PHP/contact.php
Extensions & Persistence
Optional Windows capabilities.
- Puzzler Extension · Optional user-facing Windows extension.
Ansible/roles/puzzler/tasks/deploy.yml - Windows Persistence · Packaged long-term-access service capability.
Persistence/IISManagerService.exe
Other components
- Operator
- Managed Targets · Remote web-server targets reached through WinRM or SSH.
Connections 23
- 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