渗透测试自动化工具

AI驱动的Web应用安全测试工具,结合CrewAI编排、Google ADK网络爬虫和针对每个域的SAST/DAST工具,适用于渗透测试和漏洞评估。

  • by nlgbao1340
  • Python
  • 本地部署
  • 更新于
在 GitHub 查看 nlgbao1340/Automation-Pentest-Tool-with-MCP

使用说明

Pentest自动化工具

AI驱动的web应用程序安全测试——结合CrewAI编排, 将Google ADK网络爬虫和每个域的SAST/DAST工具整合到一个Flask中

  • React工作流。专为CSE本科论文(NCKH 2026)而建 HCMUT。

它做什么

给定目标URL、HTTP请求示例或侦察跟踪,系统:

  1. 侦察 --谷歌ADK代理驱动无头Chromium(CDP上 :9222) 以映射应用程序的端点曲面。
  2. 黑匣子(测试仪1) --CrewAI编排器+执行器对运行 从14个OWASP派生技能(SQLi, XSS、SSRF、IDOR、JWT等)并产生结构化的发现。
  3. 灰色盒子(测试仪2) --当提供凭据时,ADK代理 通过确定性测试用例(IDOR、中断访问、业务)循环 逻辑)使用种子会话。
  4. SAST v2 --Claude Code风格的自主循环上传 源zip。符号图+AST索引器+过去发现的记忆。
  5. 研究结果 被聚合,CVSS评分,并在React UI中呈现。

根据评估,LLM是提供商可插拔的:Vertex AI(默认),Gemini AI Studio、DeepSeek、MiniMax或任何与Anthropic兼容的代理(TrollLLM)。

堆栈

图层 技术
后端 Python 3.13、Flask 3、SQLAlchemy 2、Alembic、Postgres 16、pydantic 2
AI CrewAI 1.12、谷歌ADK、LiteLLM(与提供商无关)
前端 React 18、TypeScript 5、Webpack 5、React Router 6
工具 ruff(lint+format)、mypy、pytest 9、预提交、复制设置
运行时 Windows主机上的WSL2(Kali Linux);Docker用于测试目标

建筑

看 ARCHITECTURE.md 对于边界图,模块 层和请求流。

当前布局的亮点:

backend/
  app.py                Flask factory (75 LOC)
  api/
    blueprints.py       Declarative blueprint registry
    errors.py           Uniform JSON error handlers
    routes/             15 route modules (health, projects, assessments, ...)
    assessment_manager.py
  cli/
    bootstrap.py        run_bootstrap() — init_db, seed, orphan recovery
  config/
    settings.py         pydantic Settings — single env-var source of truth
  engine/
    llm_config.py       SINGLE LLM factory (enforced via ruff TID251)
    skills/             14-skill package (recon, injection, xss, access, ...)
    assessment_state/   AttackTree + records + state (split package)
  crews/                CrewAI agents wiring (Tester-1 black-box)
  recon/                Google ADK web crawler (vendored)
  tester2_agent/        Gray-box engine (Tester-2)
  sast/                 SAST v2 autonomous loop (vendored)
  models/               SQLAlchemy ORM
  repositories/         Repository pattern
  services/             Domain logic
  schemas/              Pydantic request/response schemas

frontend/
  src/
    App.tsx             Route table
    pages/              11 top-level pages
    components/         Shared UI (Layout, Badge, Card, …)
    services/api.ts     Axios client
    types/index.ts      Shared TypeScript types
    context/            ThemeContext, AssessmentContext

bench/                  XBEN benchmark harness (thesis chapter 4.3)
docs/refactor/          Phase 1-5 refactor history
scripts/dev/            Developer helpers (start_services.sh, ...)
scripts/db/             Database utilities (backup, migrate, ...)
targets/                Test-target source dirs (gitignored)

快速入门(WSL2+Postgres+节点)

# 1. Postgres
sudo service postgresql start
sudo -u postgres psql -c "CREATE USER pentest_user WITH PASSWORD 'pentest_pass';"
sudo -u postgres psql -c "CREATE DATABASE pentest_db OWNER pentest_user;"

# 2. Backend
cd backend
python3 -m venv venv && source venv/bin/activate
pip install -r requirements.txt
cp .env.example .env  # fill VERTEXAI_PROJECT or GEMINI_API_KEY
alembic upgrade heads  # NOTE: 'heads' (plural) during the thesis branch
                       # divergence; switches back to 'head' once thesis
                       # and refactor history converge.
python app.py          # http://localhost:5000

# 3. Frontend (separate terminal)
cd frontend
npm install
npm start            # http://localhost:3000

# 4. (Optional) Recon agent — headless Chromium for crawler
chromium --headless=new --no-sandbox --remote-debugging-port=9222 \
         --user-data-dir=/tmp/chromium-cdp-profile about:blank &

详细设置、Vertex AI身份验证选项、灰盒食谱和OWASP Juice 现场车间测试说明 CLAUDE.md.

发展

# install pre-commit hooks (once)
pip install pre-commit && pre-commit install

# lint / format
ruff check backend/api backend/cli backend/engine backend/services backend/schemas backend/models backend/crews --select F,I,E9
ruff format backend/api backend/cli backend/engine backend/services backend/schemas backend/models backend/crews

# tests
pytest backend/tests
cd frontend && npx tsc --noEmit && npm test

pyproject.toml 配置三个工具(ruff、mypy、pytest)。这 .pre-commit-config.yaml 运行ruff F+I+E9+ruff格式+检测秘密 每一个承诺。

项目结构历史

该代码库经历了多阶段结构重构,详见 docs/refactor/:

阶段 什么着陆了
1 回购+后端根清理,gitignore收紧
4a engine/skills.py 1724 → 10-模块包
4b engine/assessment_state.py 721 → 4-模块包
5 app.py 213 → 75 LOC工厂+ cli/bootstrap.py
T0.1 CORS通过env(无无声通配符)
T0.5 print()→结构化日志记录
T1.1 单次迁移系统(仅限alembic)
T1.5 作为env-var注册表的pydantic设置
T1.8 拉夫TID251强制执行单个LLM工厂
T2.1 pyproject.toml+ruff+mypy
T2.2 使用分层挂钩进行预提交
T2.9 修复4个预先存在的测试失败

剩余工作的完整12周路线图(身份验证、OpenAPI、可观察性、, Docker(代码分割)位于 docs/refactor/PROFESSIONAL_ROADMAP.md.

论文背景

NCKH 2026论文在胡志明市-CSE本科生。XBEN基准 安全带 bench/ 第4.3节评估结果。图表和 中捕获的屏幕截图 docs/figures/.生成的节文本 NCKH-2026-DRAFT-2.docx.

许可证

个人学术项目。未获得重新分发许可 作者的许可。