一个模型上下文协议(MCP)服务器,连接Claude桌面版与Kali Linux安全工具,实现AI辅助渗透测试。
该项目由两个主要组件组成:
MCP服务器 (mcp_server.py):实现模型上下文协议,连接Claude桌面版与Kali Linux工具API。它提供能力、提示和上下文信息,帮助Claude理解如何有效使用Kali工具。
Kali Linux API服务器 (kali_api_server.py):一个Flask应用程序,提供执行各种Kali Linux安全工具的API端点。它处理实际命令执行并返回结果给MCP服务器。
Claude桌面版 ←→ MCP服务器 ←→ Kali Linux API服务器 ←→ Kali Linux工具
克隆此仓库:
git clone https://github.com/yourusername/kali-mcp-server.git
cd kali-mcp-server
运行设置脚本:
./setup.sh
克隆此仓库:
git clone https://github.com/yourusername/kali-mcp-server.git
cd kali-mcp-server
创建虚拟环境:
python3 -m venv venv
激活虚拟环境:
source venv/bin/activate
安装依赖项:
pip install -r requirements.txt
将脚本设为可执行:
chmod +x mcp_server.py kali_api_server.py run.py
确保相关Kali Linux工具已安装在您的系统上:
sudo apt update
sudo apt install nmap gobuster dirb nikto sqlmap metasploit-framework hydra john wpscan enum4linux
最简单的方法是使用run.py脚本来启动两个服务器:
./run.py
这将在不同的终端中启动API服务器和MCP服务器。
额外选项:
--api-port PORT:指定API服务器端口(默认:5000)--mcp-port PORT:指定MCP服务器端口(默认:8080)--background:在后台运行两个服务器--setup:设置或更新虚拟环境--debug:启用详细日志和诊断端点的调试模式如果您希望手动启动服务器:
启动Kali Linux API服务器:
source venv/bin/activate
python kali_api_server.py
在新的终端中启动MCP服务器:
source venv/bin/activate
python mcp_server.py
http://localhost:8080的MCP服务器如果您使用的是非官方的Claude桌面版Linux构建:
编辑MCP配置文件:
nano ~/.config/Claude/claude_desktop_config.json
添加您的MCP服务器:
{
"mcp_servers": [
{
"name": "Kali Linux工具",
"url": "http://localhost:8080",
"enabled": true
}
]
}
保存文件并重启Claude桌面版
nmap:网络扫描和主机发现
{
"target": "10.10.10.10",
"scan_type": "-sV",
"ports": "80,443,22",
"additional_args": "-T4 --open"
}
gobuster:目录和文件暴力破解
{
"url": "http://10.10.10.10",
"mode": "dir",
"wordlist": "/usr/share/wordlists/dirb/common.txt",
"additional_args": "-x php,txt,html"
}
dirb:Web内容扫描器
{
"url": "http://10.1.1.10",
"wordlist": "/usr/share/wordlists/dirb/common.txt",
"additional_args": "-r -z 10"
}
nikto:Web服务器扫描器
{
"target": "http://10.10.10.10",
"additional_args": "-Tuning 123bx"
}
sqlmap:SQL注入测试
{
"url": "http://10.10.10.10/page.php?id=1",
"data": "username=test&password=test",
"additional_args": "--batch --dbs"
}
metasploit:利用框架
{
"module": "exploit/multi/http/apache_struts2_content_type_rce",
"options": {
"RHOSTS": "10.10.10.10",
"RPORT": "8080",
"TARGETURI": "/struts2-showcase/"
}
}
hydra:密码暴力破解
{
"target": "10.10.10.10",
"service": "ssh",
"username": "admin",
"password_file": "/usr/share/wordlists/rockyou.txt",
"additional_args": "-e nsr"
}
john:密码破解
{
"hash_file": "/path/to/hashes.txt",
"wordlist": "/usr/share/wordlists/rockyou.txt",
"format": "md5crypt",
"additional_args": "--rules=Jumbo"
}
wpscan:WordPress漏洞扫描器
{
"url": "http://10.10.10.10",
"additional_args": "--enumerate u,p,t"
}
enum4linux:Windows/Samba枚举
{
"target": "10.10.10.10",
"additional_args": "-a"
}
初始侦察
发现和服务枚举
探索识别的服务
利用漏洞
后利用
如果您遇到问题,请在调试模式下运行服务器:
./run.py --debug
这将启用:
详细日志:所有操作都被记录到debug.log
调试端点:
http://localhost:8080/debug/status - MCP服务器状态http://localhost:5000/debug/status - API服务器状态http://localhost:8080/debug/config - MCP服务器配置http://localhost:5000/debug/tool-test - 测试工具是否正常工作http://localhost:8080/debug/test-api - 测试MCP-API连接http://localhost:8080/debug/history - 请求历史(最后100个请求)健康检查:
http://localhost:8080/health - 包括API服务器状态的MCP服务器健康检查http://localhost:5000/health - 包括工具可用性的API服务器健康检查命令调试(谨慎使用):
http://localhost:5000/debug/command - 用于故障排除的安全命令执行所有端点都可以通过浏览器或使用如curl等工具访问。
如果您遇到系统包冲突:
--break-system-packages安装包rm -rf venv && ./setup.sh欢迎贡献!请随时提交Pull Request。
本项目根据MIT许可证发布 - 详情见LICENSE文件。