RamiBotAI/rami-kali-MCP

GitHub: RamiBotAI/rami-kali-MCP

基于 MCP 协议的 Kali Linux 渗透测试工具封装,使 LLM 智能体能够通过标准化接口调用 60 多款安全工具完成自动化渗透评估。

Stars: 0 | Forks: 0

# Rami-Kali MCP 服务器 Rami-Kali MCP (Model Context Protocol) server,封装了 Kali Linux 渗透测试工具,用于授权的安全评估。设计为通过 LM Studio 由本地 LLM 驱动。 ## 快速开始 ``` git clone rami-kali cd rami-kali docker compose up ``` 就是这么简单。无需手动安装依赖。 ## 架构 ``` ┌─────────────┐ JSON-RPC ┌──────────────────┐ exec ┌────────────┐ │ LM Studio │ ◄──── stdin/out ──►│ MCP Server │ ◄────────────► │ Kali Tools │ │ (local LLM)│ │ (Python 3) │ │ 60+ tools │ └─────────────┘ │ │ │ nmap, msf, │ │ knowledge/ │ │ bettercap..│ │ (tactical KB) │ └────────────┘ └───────┬──────────┘ │ ┌──────▼──────┐ │ SQLite DB │ │ + Reports │ └─────────────┘ ``` ## Docker 设置 ### 前置条件 - Docker Engine 20.10+ - Docker Compose v2+ - 至少 8 GB RAM(仅 Metasploit 就需要约 2 GB) ### 构建与运行 ``` # 构建并启动 docker compose up # 构建并在后台启动 docker compose up -d # 代码更改后重新构建 docker compose build && docker compose up # 查看日志 docker compose logs -f # 在容器内打开 shell(用于调试) docker compose exec mcp-server zsh # 停止 docker compose down ``` ### 环境变量 无需修改 `config.yaml` 即可覆盖任何设置: | Variable | Default | Description | |---|---|---| | `MCP_LOG_LEVEL` | `INFO` | 日志级别 (`DEBUG`, `INFO`, `WARNING`, `ERROR`) | | `MCP_DATABASE` | `/opt/rami-kali/data/scan_results.db` | SQLite 数据库路径 | | `MCP_AUDIT_LOG` | `/opt/rami-kali/data/audit.log` | 审计跟踪文件路径 | | `MCP_REPORT_DIR` | `/opt/rami-kali/reports` | 生成报告的目录 | | `MCP_CONFIG_PATH` | `/opt/rami-kali/config.yaml` | YAML 配置文件路径 | 带覆盖设置的示例: ``` MCP_LOG_LEVEL=DEBUG docker compose up ``` 或者添加到项目根目录下的 `.env` 文件中: ``` MCP_LOG_LEVEL=DEBUG ``` ### 持久化数据 两个 Docker 卷用于在容器重启后保留数据: | Volume | Container Path | Contents | |---|---|---| | `mcp-data` | `/opt/rami-kali/data/` | SQLite 扫描数据库,审计日志 | | `mcp-reports` | `/opt/rami-kali/reports/` | 生成的 markdown 报告 | 备份数据: ``` # 从容器中复制数据库 docker compose cp mcp-server:/opt/rami-kali/data/scan_results.db ./backup.db # 复制报告 docker compose cp mcp-server:/opt/rami-kali/reports/ ./reports-backup/ ``` 清除所有数据并重新开始: ``` docker compose down -v ``` ### 配置 `config.yaml` 文件以只读方式绑定挂载到容器中。在主机上编辑它并重启: ``` # 编辑配置 vim config.yaml # 重启以应用更改 docker compose restart ``` 关键配置部分: ``` security: allowed_scope: # CIDR ranges the server is allowed to scan - "192.168.0.0/16" - "10.0.0.0/8" - "172.16.0.0/12" require_scope_check: true rate_limit: global_max_concurrent: 3 per_tool_max_concurrent: 1 ``` ### 网络 默认情况下,容器使用 `network_mode: host` 运行,以便扫描本地网络。如果您只扫描远程目标或想要隔离,请在 `docker-compose.yml` 中更改为桥接模式: ``` services: mcp-server: # network_mode: host # comment out ports: - "8080:8080" # if you add an HTTP transport later ``` ### Metasploit 数据库(可选) Metasploit 开箱即用,使用其内置数据库。对于专用的 PostgreSQL 实例,请取消注释 `docker-compose.yml` 中的 `msf-db` 服务: ``` # 编辑 docker-compose.yml — 取消 msf-db 服务和 depends_on 的注释 vim docker-compose.yml docker compose up ``` ## 已安装工具(约 80 个可安装) 容器包含这些 Kali 工具(启动时自动检测): | 类别 | 工具 | |---|---| | **Recon** | nmap, masscan, whatweb, whois, dig, theHarvester, amass, subfinder, dnsx, searchsploit | | **CVE Intelligence** | cve_lookup (NVD API — CVSS、描述、CPE、任何 CVE ID 或关键词的参考) | | **Web Scanning** | gobuster, ffuf, nuclei, nikto, dirb, wfuzz, wpscan, joomscan, zap-cli, droopescan | | **Exploitation** | sqlmap, metasploit (msfconsole, msfvenom) | | **Credential Attacks** | hydra, medusa, ncrack, patator, hashcat, john, crunch, cewl | | **SMB / AD** | enum4linux, smbclient, smbmap, rpcclient, crackmapexec, evil-winrm, bloodhound, impacket (psexec.py, wmiexec.py, smbexec.py, secretsdump.py) | | **MITM** | bettercap, ettercap, responder, mitmproxy, arpspoof, dnsspoof, sslstrip, yersinia | | **Wireless** | aircrack-ng, reaver, bully, wifite, kismet, mdk4, pixiewps, cowpatty | | **C2 / Social Engineering** | armitage, veil, beef-xss, setoolkit | | **Proxy Routing** | proxychains4 (Burp 配置文件 `/etc/proxychains4.conf` + Tor 配置文件 `/etc/proxychains4-tor.conf`) | | **Network** | tshark, tcpdump, ngrep, hping3, fragrouter, macchanger, netcat, socat | | **Wordlists** | rockyou.txt, SecLists, dirb lists | 未安装的工具会自动从 MCP 工具列表中隐藏。 ### Docker 中不可用的工具 注册表中的以下工具**无法**在 Docker 容器中运行,并会自动隐藏: | Tool | Reason | |---|---| | `mimikatz` | 仅限 Windows 二进制文件 | | `cobaltstrike` | 需要商业许可证 | | `burpsuite` | 在 Windows 主机上单独运行;其 MCP server 在 RamiBot 中作为独立服务器添加 — 不是 rami-kali 的一部分 | | `powersploit` | PowerShell 模块,非 Linux 二进制文件 | | `empire` | 已弃用 / 安装复杂 | | `shellter` | Windows PE 注入器(依赖 Wine) | | `xhydra` | GTK GUI,无头模式下无用 | | `pyrit`, `ewsa` | 已弃用 / 仓库中不可用 | | `wifiphisher`, `fluxion`, `airgeddon`, `wifi-honey`, `ghost-phisher`, `fern-wifi-cracker` | 不在 Kali 仓库中或需要 GUI | ### Shell 环境 容器默认运行 **zsh** shell,具备: - **`zsh-syntax-highlighting`**:命令在有效时变绿,无效时变红 — 按下 Enter 键前的实时反馈 - **`zsh-autosuggestions`**:根据历史记录建议命令;按 Tab 或 → 接受 当 RamiBot 的 Docker Terminal 打开会话时,它会按以下顺序检测 shell:**zsh → bash → sh**。 ``` # 打开交互式 zsh 会话 docker exec -it rami-kali zsh ``` ### 代理路由 (proxychains4) 安装了两个现成的配置文件,用于在不修改工具配置的情况下路由工具流量: | Profile | Path | Target | |---------|------|--------| | Burp | `/etc/proxychains4.conf` | `127.0.0.1:8080` (Windows 主机 Burp 代理) | | Tor | `/etc/proxychains4-tor.conf` | `127.0.0.1:9050` (容器内 Tor SOCKS) | **用法:** ``` # 通过 Burp 路由以进行流量分析 proxychains nmap -sV 10.10.10.1 # 通过 Tor 路由以实现匿名 proxychains -f /etc/proxychains4-tor.conf curl https://example.com # 链式工具 → Burp → Tor(先配置 Burp SOCKS 上游) # 在 Burp 中:Settings → Network → Connections → SOCKS proxy → 127.0.0.1:9050 proxychains nmap -sV 10.10.10.1 ``` `gobuster_dir` MCP 工具接受 `proxy` 参数,可直接通过代理路由目录暴力破解(例如,`http://127.0.0.1:8080` 用于 Burp 或 `socks5://127.0.0.1:9050` 用于 Tor) — 该工具不需要 proxychains。 因为容器使用 `network_mode: host`,容器内的 `127.0.0.1` 会解析到 Windows/Linux 主机,因此在主机上运行的 Burp 可以通过 `127.0.0.1:8080` 访问。 ### 无线工具注意事项 无线工具(aircrack-ng, reaver, wifite 等)已**安装**,但需要 USB WiFi 适配器直通才能运行。在 `docker-compose.yml` 中取消以下内容的注释: ``` privileged: true devices: - /dev/bus/usb:/dev/bus/usb ``` 如果没有直通物理适配器,无线工具可以启动,但没有可操作的接口。 ## 知识库 `knowledge/` 目录包含用于 LLM 的战术推理系统: ``` knowledge/ core_principles.md — Decision axioms engagement_rules.md — Scope & risk rules pivot_map.md — "If X found → do Y" decision trees tools/*.md — Per-tool tactical memory interpretation/*.md — Result parsing guides tactics/*.md — Phase-by-phase methodology ``` `tools/cve_lookup.md` 文件为 LLM 提供了 NVD 查询策略、CVSS 严重级别区间、特定于 CVE 数据的证据规则以及链接工作流(nmap version → cve_lookup → searchsploit)。 有关完整结构和集成指南,请参阅 `knowledge/README.md`。 ## LM Studio 集成 1. 启动 LM Studio 并加载模型(例如 Qwen 2.5 7B, Mistral 7B) 2. 在 LM Studio 的工具设置中启用 MCP server 3. 将其指向 MCP server 的 stdin/stdout 接口 4. LLM 现在可以通过 MCP 协议调用渗透测试工具 ## 项目结构 ``` rami-kali/ ├── Dockerfile ← Kali-based container image (60+ tools) ├── docker-compose.yml ← One-command startup + optional PostgreSQL ├── docker-entrypoint.sh ← Startup checks & tool verification ├── .dockerignore ← Build context exclusions ├── config.yaml ← Server configuration ├── requirements.txt ← Python dependencies ├── mcp_server.py ← MCP server (2800+ lines, 45 registered tools) ├── knowledge/ ← Tactical knowledge base (27 files) │ ├── core_principles.md │ ├── pivot_map.md │ ├── tools/ │ ├── interpretation/ │ └── tactics/ └── README.md ← This file ``` ## 安全 - **范围强制执行**:每次工具调用都会根据配置中的 `allowed_scope` 进行检查 - **主机名解析**:域在进行范围检查之前解析为 IP(防止绕过) - **输入清洗**:所有输入中的 Shell 元字符均被剥离 - **速率限制**:并发工具执行设有上限(全局 + 单工具) - **审计日志**:每次工具调用都会记录时间戳和参数 - **风险等级**:高风险工具(hydra, sqlmap, metasploit, bettercap 等)通过 stderr 发出警告 - **二进制可用性**:只有容器中实际安装的工具才会通过 MCP 暴露
标签:CVE利用, DLL 劫持, Docker, FTP漏洞扫描, JSON-RPC, LIDS, LLM Agent, LM Studio, MCP Server, Nmap, Python, 中间人攻击, 大语言模型, 威胁模拟, 安全工具集成, 安全编排, 安全防御评估, 密码管理, 插件系统, 攻击框架, 无后门, 本地大模型, 模型上下文协议, 结构化查询, 网络安全, 自动化安全, 虚拟驱动器, 请求拦截, 隐私保护