解放双手||全链路PHP代码安全审计AIAgent系统

admin 2026-05-11 05:53:20 网络安全文章 来源:ZONE.CI 全球网 0 阅读模式

文章总结: 云梦是一个全链路PHP代码安全审计AIAgent系统,基于ClaudeCodeAgentTeams实现多智能体协作,覆盖环境构建、静态侦察、动态追踪、深度利用、后渗透关联分析及报告生成6阶段自动化审计。该系统支持21种漏洞类型检测,具备攻击记忆、智能研究员、混合调度与质量保障机制,通过145+技能模块与标准化模板提升审计效率与准确性,最终生成包含漏洞详情、攻击链可视化及SARIF导出的专业报告。 综合评分: 85 文章分类: 代码审计,安全工具,应用安全,安全开发,安全运营


辅助工具详解

| 工具 | 用途 | 用法 | 使用阶段 | | — | — | — | — | | audit_db.sh | SQLite 数据库操作(攻击记忆/发现/质检/图记忆) | bash audit_db.sh <command> [args] | 全阶段 | | sink_finder.php | AST Sink 扫描器 | php sink_finder.php <目标目录> | Phase-2 | | trace_filter.php | Xdebug Trace 精简过滤器 | php trace_filter.php <trace_file> [sinks] | Phase-3 | | payload_encoder.php | Payload 编码(URL/Base64/Hex/双重等) | php payload_encoder.php <payload> <type> | Phase-4 | | waf_detector.php | WAF/过滤器指纹识别 | php waf_detector.php <base_url> [cookie] | Phase-4 | | jwt_tester.php | JWT 安全测试 | php jwt_tester.php <token> [pubkey] | Phase-4 | | type_juggling_tester.php | PHP 类型混淆松散比较测试 | php type_juggling_tester.php <url> [param] | Phase-4 | | redirect_checker.php | 开放重定向检测 | php redirect_checker.php <url> [param] | Phase-4 | | vuln_intel.sh | 漏洞情报收集(NVD/GitHub Advisory) | bash vuln_intel.sh <component> <version> | Phase-4 | | audit_monitor.sh | 审计进度实时监控 | bash audit_monitor.sh <WORK_DIR> | 全阶段 | | quality_report_gen.sh | QC 报告汇总生成 | bash quality_report_gen.sh <WORK_DIR> | Phase-5 | | validate_shared.php | shared/ 目录完整性校验 | php validate_shared.php [shared_dir] | 开发/维护 |

audit_db.sh 命令速查

ounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(line# 攻击记忆bash audit_db.sh init-memory &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;# 初始化(自动含图记忆)bash audit_db.sh memory-write&nbsp;'<json>'&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;# 写入攻击经验bash audit_db.sh memory-query&nbsp;'<json>'&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;# 查询匹配经验bash audit_db.sh memory-stats &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;# 记忆库统计bash audit_db.sh memory-maintain &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;# 清理过期记忆
# 图记忆bash audit_db.sh graph-node-write&nbsp;'<json>'&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;# 写入图节点bash audit_db.sh graph-edge-write&nbsp;'<json>'&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;# 写入图边bash audit_db.sh graph-neighbors <node_id> &nbsp; &nbsp; &nbsp; &nbsp;# 查询邻居节点bash audit_db.sh graph-by-data-object <obj> &nbsp; &nbsp; &nbsp;&nbsp;# 按数据对象查询bash audit_db.sh graph-export <WORK_DIR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;# 导出完整图数据
# 发现管理bash audit_db.sh finding-write&nbsp;'<json>'&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;# 写入发现bash audit_db.sh finding-read&nbsp;[sink_id] &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;# 读取发现bash audit_db.sh finding-consume <sink_id> &nbsp; &nbsp; &nbsp; &nbsp;# 消费发现
# 质检bash audit_db.sh qc-write&nbsp;'<json>'&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;# 写入质检记录bash audit_db.sh qc-read&nbsp;[phase] &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;# 读取质检记录

输出产物

审计完成后,$WORK_DIR/ 目录结构:

ounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(line$WORK_DIR/├──&nbsp;报告/│&nbsp; &nbsp;├──&nbsp;审计报告.md &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;←&nbsp;全中文单文件报告(含目录/执行摘要/漏洞详情/Context Pack/Burp/攻击链/覆盖率/风险池/经验总结)│&nbsp; &nbsp;└──&nbsp;audit_report.sarif.json &nbsp;←&nbsp;SARIF&nbsp;2.1.0(可导入&nbsp;GitHub/VS&nbsp;Code)├──&nbsp;PoC脚本/│&nbsp; &nbsp;├──&nbsp;poc_{sink_id}.py &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;←&nbsp;每个漏洞的&nbsp;PoC│&nbsp; &nbsp;└──&nbsp;一键运行.sh &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;←&nbsp;批量执行├──&nbsp;修复补丁/│&nbsp; &nbsp;└──&nbsp;{finding_id}.patch &nbsp; &nbsp; &nbsp;&nbsp;←&nbsp;框架适配修复├──&nbsp;经验沉淀/│&nbsp; &nbsp;├──&nbsp;lessons_learned.md &nbsp; &nbsp; &nbsp;&nbsp;←&nbsp;绕过技巧/失败教训/新模式│&nbsp; &nbsp;└──&nbsp;共享文件更新建议.md├──&nbsp;质量报告/│&nbsp; &nbsp;└──&nbsp;质量报告.md└──&nbsp;原始数据/&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;←&nbsp;中间产物归档&nbsp; &nbsp;&nbsp;├──&nbsp;exploits/, traces/, context_packs/&nbsp; &nbsp;&nbsp;├──&nbsp;attack_graph.json, correlation_report.json&nbsp; &nbsp;&nbsp;└──&nbsp;checkpoint.json

审计报告内容结构

ounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(line审计报告.md├──&nbsp;# 封面(项目元数据&nbsp;+&nbsp;CVSS可视化进度条)├──&nbsp;📖 目录(7章锚点导航)├──&nbsp;执行摘要(整体风险等级&nbsp;+&nbsp;关键发现&nbsp;+&nbsp;审计范围)├──&nbsp;漏洞汇总表(CVSS进度条&nbsp;+&nbsp;AI验证徽章)├──&nbsp;漏洞详情&nbsp;×N│&nbsp; &nbsp;├──&nbsp;📋 漏洞信息卡(等级/类型/路由/Sink/鉴权/优先级)│&nbsp; &nbsp;├──&nbsp;📦 上下文包(入口→调用链→Sink&nbsp;+&nbsp;中间件&nbsp;+&nbsp;过滤器&nbsp;+&nbsp;认证绕过)│&nbsp; &nbsp;├──&nbsp;🔗&nbsp;Mermaid&nbsp;攻击链│&nbsp; &nbsp;├──&nbsp;📊 数据流追踪(Source→Sink&nbsp;+&nbsp;file:line)│&nbsp; &nbsp;├──&nbsp;🔫&nbsp;Burp&nbsp;复现模板(请求&nbsp;+&nbsp;响应)│&nbsp; &nbsp;├──&nbsp;⚔️&nbsp;攻击迭代记录│&nbsp; &nbsp;└──&nbsp;🔧 修复方案(❌修复前 vs&nbsp;✅修复后)├──&nbsp;联合攻击链分析(Mermaid&nbsp;+&nbsp;步骤表)├──&nbsp;审计覆盖率统计(路由/优先级/审计器状态)├──&nbsp;待补证风险池(降级原因&nbsp;+&nbsp;复验建议)├──&nbsp;审计经验总结(框架特征/绕过手法/踩坑/建议)└──&nbsp;📋 页脚(版本&nbsp;+&nbsp;时间&nbsp;+&nbsp;工具)

Gate 门禁与 QC 策略

Gate 强制验收

| Gate | 校验条件 | | — | — | | GATE-1 | environment_status.json 存在 | | GATE-2 | priority_queue.jsoncontext_packs/ 存在 | | GATE-3 | credentials.json 存在 | | GATE-4 | exploits/*.json 存在 | | GATE-4.5 | PoC脚本/*.py 存在 |

QC 降级策略

| 阶段 | 质检不通过处理 | | — | — | | Phase-1 | 发回重做(最多 3 次),自愈循环/用户介入 | | Phase-2 | 定位责任 Agent 补充,标注覆盖率继续 | | Phase-3 | 断链路由退回静态分析,不阻塞 | | Phase-4 | 降级标注,不阻塞报告 |


演示效果

PHP_AUDIT_SKILLS Pipeline

📋 点击展开完整执行流程图(文字版)

完整流程详见 全链路详细流程.md

ounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(line输入: /php-audit-skills <目标路径>&nbsp; ↓前置检查: Docker → 路径验证 → WORK_DIR → 断点续审 → 增量审计&nbsp; ↓Phase 1: env-detective ∥ schema-reconstructor → docker-builder → QC&nbsp; ↓Phase 2: scanners ×7 ∥ route-mapper ∥ auth-auditor ∥ dep-scanner&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;→ context-extractor → risk-classifier → QC → 动态创建 Phase-4 任务&nbsp; ↓Phase 3: auth-simulator → trace-dispatcher → trace-worker×N → QC&nbsp; ↓Phase 4: Step1 并行分析(21 专家) → Step2 串行攻击(8 轮循环 + Pivot)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;→ 攻击记忆写入 → QC(完成一个校验一个)&nbsp; ↓Phase 4.5: attack-graph-builder ∥ correlation-engine&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;→ poc-generator ∥ remediation-generator&nbsp; ↓Phase 5: env-cleaner ∥ report-writer ∥ sarif-exporter → 最终 QC&nbsp; ↓输出: 报告/审计报告.md + 报告/audit_report.sarif.json + PoC脚本/ + 修复补丁/ + 经验沉淀/ + 质量报告/

知识注入架构(Agent Injection Framework)

Agent 启动时按层级注入共享知识:

| 层级 | 注入时机 | 内容 | | — | — | — | | L1(强制) | 所有 Agent 启动 | anti_hallucination.mdevidence_contract.mddata_contracts.mdoutput_standard.md | | L2(角色相关) | Phase-4 专家启动 | sink_definitions.mdpayload_templates.mdattack_memory.mdattack_memory_graph.mdwaf_bypass.md 等 16 个 | | L3(按需) | 运行时触发条件 | lessons_learned.mdmini_researcher.md |


最佳实践

  1. 完整源码审计 — 提供完整项目源码目录,减少漏报
  2. 保留 Docker 环境 — 便于复现验证与物理证据采集
  3. Gate + Schema 校验 — 交付前确认产物完整性
  4. 分级修复 — confirmed 优先修复,suspected 人工复核
  5. 攻击记忆复用 — 保留 /tmp/<项目名>/attack_memory.db,积累跨项目经验

项目统计

| 类别 | 数量 | | — | — | | Skill 文件(skills/) | 121(111 skill + 10 index) | | 漏洞审计员(2-Stage) | 21 types × 2 = 42 files | | Skills 子目录 | 10 | | JSON Schema | 30 个(251 string 字段全约束) | | 共享知识库(shared/) | 28 个 | | 阶段定义 | 7 个 | | 参考文档 | 9 个 | | 辅助工具 | 12 个 | | 环境模板 | 10 个 | | 报告 Chapter Writers | 7 个 | | 可控性约束 | 530+ 项(4 轮深度优化) | | Markdown 文件总计 | 210+ 个 |


许可证

本项目仅供安全研究和学习使用。请在授权范围内对目标系统进行审计。


免责声明:

本文所载程序、技术方法仅面向合法合规的安全研究与教学场景,旨在提升网络安全防护能力,具有明确的技术研究属性。

任何单位或个人未经授权,将本文内容用于攻击、破坏等非法用途的,由此引发的全部法律责任、民事赔偿及连带责任,均由行为人独立承担,本站不承担任何连带责任。

本站内容均为技术交流与知识分享目的发布,若存在版权侵权或其他异议,请通过邮件联系处理,具体联系方式可点击页面上方的联系我

本文转载自:闪石星曜CyberSecurity 云梦 云梦《解放双手 || 全链路 PHP 代码安全审计 AI Agent 系统》

评论:0   参与:  0