PenTest MCP Server
🏗️ 架构
┌──────────────────────────────────────────────────────────┐
│ $ pentest ask --query "scan for SQLi and XSS" \ │
│ --target http://localhost:3000 --consent │
└──────────────────┬───────────────────────────────────────┘
│ Direct Python execution
▼
┌──────────────────────────────────────────────────────────┐
│ GEMINI-POWERED AGENT (Python) │
│ │
│ Phase 1: PLAN → LLM selects tools from query │
│ Phase 2: EXECUTE → Runs tools, collects findings │
│ Phase 3: REPORT → LLM generates professional report │
│ │
│ ┌─────────────┐ ┌──────────────┐ ┌────────────────┐ │
│ │ Session │ │ Scan Mode │ │ Tool │ │
│ │ Manager │ │ Orchestrator│ │ Registry │ │
│ └─────────────┘ └──────┬───────┘ └────────────────┘ │
│ │ │
│ ┌────────────────┼────────────────┐ │
│ ▼ ▼ ▼ │
│ ┌────────────┐ ┌────────────┐ ┌────────────────┐ │
│ │ nmap │ │ sqlmap │ │ ffuf │ │
│ │ nuclei │ │ dalfox │ │ nikto │ │
│ │ sslyze │ │ commix │ │ gobuster │ │
│ │ wafw00f │ │ arjun │ │ subfinder │ │
│ │ ... 30+ │ │ ... │ │ ... │ │
│ └────────────┘ └────────────┘ └────────────────┘ │
│ │ │
│ ▼ │
│ ┌──────────────────────┐ │
│ │ GEMINI API │ │
│ │ (Flash Lite) │ │
│ │ Triage · Analysis │ │
│ │ CVSS · Reporting │ │
│ └──────────────────────┘ │
└──────────────────────────────────────────────────────────┘Related MCP server: Pentest-mcp
✨ 功能
功能 | 描述 |
自然语言接口 | 用简单的英语询问安全问题 — AI 会选择并运行相应的工具 |
3 种扫描模式 | 快速 (5-10 分钟)、中等 (15-30 分钟)、深度 (45 分钟以上) — 每种模式都有不同的深度和 AI 分析 |
30+ 安全工具 | nmap, sqlmap, nuclei, ffuf, dalfox, nikto, wafw00f, subfinder, sslyze 等 |
AI 驱动的分析 | Gemini AI (Flash Lite) 执行漏洞分类、CVSS 评分并生成执行报告 |
自动化工具选择 |
|
会话管理 | 跨多个目标跟踪、暂停和恢复安全评估 |
OWASP Top 10 覆盖 | 映射到 OWASP 2021 类别的系统化扫描 |
智能回退 | 如果未安装专业工具,Python 原生实现将填补空白 |
📋 目录
🚀 快速入门
先决条件
Python 3.11+
uv (Python 包管理器)
Gemini API Key (提供免费层级)
1. 克隆并安装
git clone https://github.com/yourusername/pentest-ai-cli
cd pentest-ai-cli
# Install dependencies
uv sync2. 配置环境
cp .env.example .env编辑 .env 并添加您的 Gemini API 密钥:
GEMINI_API_KEY=your_gemini_api_key_here3. 安装安全工具 (可选)
该服务器支持 Python 原生回退,但为了进行专业级扫描,请安装外部工具:
# macOS (Homebrew)
brew install nmap sqlmap
# Install ffuf (Go-based fuzzer)
go install github.com/ffuf/ffuf/v2@latest
# Install nuclei (vulnerability scanner)
go install github.com/projectdiscovery/nuclei/v3/cmd/nuclei@latest
# Install subfinder (subdomain discovery)
go install github.com/projectdiscovery/subfinder/v2/cmd/subfinder@latest提示: 运行
session_init查看系统检测到了哪些工具。
4. 开始扫描!
pentest ask \
--query "run a quick security scan" \
--target https://example.com \
--consent🎯 扫描模式
快速模式 (5-10 分钟)
用于即时风险评估的快速分类。
测试 | 工具 |
WAF 检测 | wafw00f / 自定义 |
DNS 枚举 | dnsrecon / 自定义 |
端口扫描 (前 20) | nmap / 自定义 |
标头分析 | 自定义 |
TLS/SSL 审计 | sslyze / 自定义 |
技术指纹识别 | whatweb / 自定义 |
敏感文件发现 | ffuf / 自定义 |
中等模式 (15-30 分钟)
涵盖 OWASP Top 10 的标准渗透测试。
测试 | 工具 |
快速模式中的所有内容 | — |
端口扫描 (前 100) | nmap |
XSS 扫描 | dalfox / 自定义 |
SQL 注入 | sqlmap |
目录发现 | ffuf / gobuster |
CORS 配置错误 | corscanner / 自定义 |
路径遍历 | 自定义 |
开放重定向 | 自定义 |
CSRF 检查 | 自定义 |
深度模式 (45 分钟以上)
董事会级别的全面安全评估。
测试 | 工具 |
中等模式中的所有内容 | — |
端口扫描 (前 1000) | nmap / masscan |
子域名枚举 | subfinder / amass |
高级模糊测试 | wfuzz / ffuf |
SSRF 探测 | 自定义 |
密钥扫描 | trufflehog |
Git 暴露 | git-dumper |
JWT 分析 | jwt_tool |
GraphQL 安全 | graphql-cop |
命令注入 | commix |
🔧 支持的工具
该服务器集成了 30 多种安全工具 并具有自动检测功能。如果未安装某个工具,Python 原生回退可确保扫描仍能运行。
工具 | 类别 | 必需 |
nmap | 端口扫描 | 可选 (有回退) |
sqlmap | SQL 注入 | 可选 |
ffuf | 模糊测试 / 文件发现 | 可选 (有回退) |
nuclei | 漏洞扫描 | 可选 |
dalfox | XSS 扫描 | 可选 |
subfinder | 子域名发现 | 可选 |
wafw00f | WAF 检测 | 可选 (有回退) |
sslyze | TLS/SSL 审计 | 可选 (有回退) |
nikto | Web 服务器扫描 | 可选 |
gobuster | 目录暴力破解 | 可选 |
whatweb | 技术指纹识别 | 可选 (有回退) |
wfuzz | 高级模糊测试 | 可选 |
arjun | 隐藏参数发现 | 可选 |
testssl | SSL/TLS 测试 | 可选 |
masscan | 快速端口扫描 | 可选 |
amass | OSINT / 子域名枚举 | 可选 |
dnsrecon | DNS 枚举 | 可选 (有回退) |
theHarvester | 电子邮件/域名 OSINT | 可选 |
retire.js | JS 库 CVE 扫描 | 可选 |
trufflehog | 密钥检测 | 可选 |
git-dumper | Git 仓库暴露 | 可选 |
commix | 命令注入 | 可选 |
corscanner | CORS 配置错误 | 可选 (有回退) |
jwt_tool | JWT 分析 | 可选 |
graphql-cop | GraphQL 安全 | 可选 |
xsstrike | 高级 XSS | 可选 |
hydra | 暴力破解 | 可选 |
shodan | 互联网情报 | 可选 |
enum4linux-ng | SMB 枚举 | 可选 |
💬 使用示例
pentest ask 命令使用 Gemini AI 根据自然语言查询自动规划和执行安全扫描。
快速漏洞扫描
pentest ask \
--query "scan for SQL injection and XSS vulnerabilities" \
--target http://localhost:3000 \
--consent完整的 OWASP Top 10 审计
pentest ask \
--query "perform a comprehensive OWASP Top 10 security audit" \
--target https://example.com \
--consent仅侦察
pentest ask \
--query "enumerate subdomains and check for exposed sensitive files" \
--target example.com \
--consent自定义报告路径
pentest ask \
--query "check security headers and TLS configuration" \
--target https://example.com \
--consent \
--output security-audit-2024.md📁 项目结构
pentest-ai/
├── pentest_mcp/
│ ├── scan_modes.py # Quick/Medium/Extensive scan orchestration
│ ├── agent.py # Standalone CLI orchestrator
│ ├── session.py # Session state management
│ ├── models.py # Pydantic data models
│ ├── config.py # Environment & settings
│ ├── cli.py # CLI interface (includes "ask" command)
│ ├── cli_ui.py # Beautiful CLI UI components
│ ├── tools/
│ │ ├── __init__.py # Python-native security tools
│ │ ├── professional.py # External tool wrappers (nmap, sqlmap, etc.)
│ │ └── tool_registry.py # Tool execution and result processing
│ └── utils/
│ └── sanitizer.py # Input validation & sanitization
├── tests/
│ └── test_system.py # System tests
├── wordlists/ # Fuzzing wordlists for ffuf/gobuster
├── reports/ # Generated scan reports (Markdown)
├── CLI_USAGE_GUIDE.md # Example prompts and detailed usage guide
├── pyproject.toml # Project dependencies & metadata
├── Makefile # Development shortcuts
├── install_tools.sh # Security tool installer script
└── .env.example # Environment variable template⚙️ 配置
环境变量
变量 | 描述 | 默认值 |
| 您的 Gemini API 密钥 | 必需 |
| 用于分析的 LLM 模型 |
|
| 最大响应令牌数 |
|
| LLM 温度 |
|
| 会话存储路径 |
|
| 日志详细程度 |
|
| 每次 |
|
AI 分析流水线
每种扫描模式都使用针对扫描深度校准的 不同 Gemini AI 提示词:
快速:简洁的分类 — 仅关注关键/高严重性发现
中等:OWASP Top 10 分析,具有平衡的风险评估和补救措施
深度:董事会级别的执行摘要,包含详尽的 CVSS 评分发现、合规性映射和战略建议
🔍 故障排除
Read-only file system 错误
报告保存到 <project_root>/reports/。请确保项目目录可写。
Gemini API 错误
验证您的 API 密钥:
echo $GEMINI_API_KEY在 aistudio.google.com 检查速率限制
即使 Gemini 不可用,服务器也会继续扫描 — 原始工具输出仍会返回
未检测到工具
通过 Homebrew 或您的包管理器安装缺失的工具。即使没有外部工具,Python 回退也能涵盖核心功能。
⚠️ 安全声明
此工具仅用于授权的安全测试。
在扫描任何目标之前,请务必获得 明确的书面许可
未经授权的测试违反了 计算机欺诈与滥用法案 (CFAA)、2000/2008 年 IT 法案 以及全球类似的法律
consent_confirmed参数作为道德保障存在 — 切勿绕过它切勿将 API 密钥提交 到版本控制系统
📝 许可证
详情请参阅 LICENSE。
Available Tools
29 toolsamassD
Advanced subdomain enumeration
Inputs: domain (required), session_id (required).
arjunD
HTTP parameter discovery
Inputs: url (required), session_id (required).
commixC
Command injection vulnerability scanner
Inputs: url (required), session_id (required).
corscannerC
CORS misconfiguration scanner
Inputs: url (required), session_id (required).
dalfoxD
XSS vulnerability scanner
Inputs: url (required), session_id (required), params, consent.
dnsreconC
DNS enumeration and reconnaissance
Inputs: domain (required), session_id (required).
extensive_scanA
Comprehensive scan (20-45 min): WAF detection, full recon, top-1000 port scan, tech fingerprinting, TLS audit, directory discovery, XSS, SQLi, CSRF, sensitive file discovery
Inputs: target (required), consent (required).
ffufC
Fast web fuzzer for directory/file discovery
Inputs: url (required), session_id (required), mode, consent.
get_reportC
Generate final security assessment report
Inputs: session_id (required).
git_dumperC
Exposed .git directory dumper
Inputs: url (required), session_id (required).
gobusterC
Directory/file brute forcing
Inputs: url (required), session_id (required), mode.
graphql_copC
GraphQL security scanner
Inputs: url (required), session_id (required).
init_sessionC
Initialize new security assessment session
Inputs: target (required).
jwt_toolC
JWT security testing
Inputs: token (required), session_id (required), url.
masscanC
Fast port scanner
Inputs: target (required), session_id (required), ports.
niktoC
Web server vulnerability scanner
Inputs: url (required), session_id (required), consent.
nmapC
Port scanning and service detection
Inputs: host (required), session_id (required), ports, consent.
nucleiC
Fast vulnerability scanner with templates
Inputs: url (required), session_id (required).
quick_scanB
Fast triage scan (10-15 min): WAF detection, subdomain enum, top-port scan, header analysis, TLS audit, tech fingerprinting, sensitive file discovery, SSRF probe, CSRF check
Inputs: target (required), consent (required).
retireC
JavaScript library vulnerability scanner
Inputs: url (required), session_id (required).
sqlmapC
SQL injection detection and exploitation
Inputs: url (required), session_id (required), params, consent.
sslyzeC
TLS/SSL configuration analyzer
Inputs: host (required), session_id (required), port, consent.
subfinderC
Passive subdomain enumeration
Inputs: domain (required), session_id (required), consent.
testsslC
TLS/SSL security testing
Inputs: host (required), session_id (required), port.
theharvesterD
OSINT gathering from public sources
Inputs: domain (required), session_id (required).
trufflehogC
Secret and credential scanner
Inputs: target (required), session_id (required), scan_type.
wafw00fD
Web Application Firewall detection
Inputs: url (required), session_id (required).
wfuzzC
Web application fuzzer
Inputs: url (required), session_id (required), fuzz_param.
whatwebC
Web technology fingerprinting
Inputs: url (required), session_id (required), consent.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 29 tools
Most tools have distinct purposes (e.g., sqlmap vs nmap), but some overlap exists between masscan and nmap for port scanning, and multiple fuzzing tools like ffuf, wfuzz, and gobuster may cause confusion for an agent. Descriptions help differentiate but are not entirely unambiguous.
Tool names are consistently lowercase with underscores for multi-word names, but they do not follow a strict verb_noun pattern. Some are single words (e.g., amass, nikto) while others are compound (e.g., git_dumper, jwt_tool), which is consistent but not highly patterned.
With 29 tools, the server covers a broad range of penetration testing tasks, which is appropriate for a comprehensive tool set. While on the higher end, the count is justified by the diversity of functionality and does not feel excessive.
The tool set covers most key areas of penetration testing: reconnaissance, scanning, web fuzzing, vulnerability detection, and reporting. However, it lacks network vulnerability scanners (e.g., OpenVAS) and exploitation tools, leaving minor gaps. The inclusion of quick_scan and extensive_scan helps cover comprehensive workflows.
Maintenance
Related MCP Connectors
AI pentesting: run scans, triage vulnerabilities, review PRs, manage schedules and assets.
Governed security assessments, findings and signed reports for your domains, from your AI agent.
Pay-per-call cybersecurity for AI agents: vuln scans, threat intel, compliance, code security.
Security scanner for AI agents and MCP servers: injection, jailbreak, tool abuse.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceAn MCP server that integrates various penetration testing tools, enabling security professionals to perform reconnaissance, vulnerability scanning, and API testing through natural language commands in compatible LLM clients like Claude Desktop.7-
- FlicenseNot gradedqualityDmaintenanceUnified penetration testing MCP server for Claude Desktop providing 34 security tools for reconnaissance, web scanning, code analysis, and authenticated testing.1-
- FlicenseNot gradedqualityDmaintenanceAI-powered Attack Surface Intelligence server that exposes industry-standard penetration testing tools via MCP, enabling AI agents to perform comprehensive security assessments.3-
- AlicenseNot gradedqualityDmaintenanceAI-driven penetration testing MCP server that equips Claude with 13 tools for automated reconnaissance, analysis, vulnerability validation, and exploitation.4GPL 3.0