一个用于 Web 攻击流量自动研判 的多 Agent 项目模板。
它可以读取 HTTP 请求/响应样本,自动完成:
- HTTP 请求/响应解析
- 攻击类型识别
- 响应证据验证
- CVE / 漏洞特征匹配
- 误报判断
- 结构化 JSON 输出
- 中文安全分析报告生成
- FastAPI 接口调用
- CLI 批量分析
webtrace_sentinel/
├── app/
│ ├── main.py # FastAPI 服务入口
│ ├── cli.py # 命令行入口
│ ├── config.py # 配置读取
│ ├── schemas.py # 数据结构
│ ├── parser/
│ │ └── http_trace_parser.py # HTTP 请求/响应解析器
│ ├── agents/
│ │ ├── base.py # LLM Client + Agent 基类
│ │ ├── traffic_parser_agent.py # 流量解析 Agent
│ │ ├── attack_detector_agent.py # 攻击识别 Agent
│ │ ├── response_validator_agent.py
│ │ ├── cve_matcher_agent.py
│ │ ├── false_positive_agent.py
│ │ └── report_agent.py
│ ├── orchestrator/
│ │ └── pipeline.py # 多 Agent 编排
│ └── rules/
│ └── signatures.py # 本地规则库
├── data/
│ └── sample_trace.txt # 示例 HTTP 流量
├── outputs/
├── requirements.txt
├── .env.example
└── run_demo.py
cd webtrace_sentinel
python -m venv .venv
# Windows
.venv\Scripts\activate
# Linux / macOS
source .venv/bin/activate
pip install -r requirements.txt复制 .env.example 为 .env:
cp .env.example .env如果你使用 OpenAI 兼容接口,例如 OpenClaw / sub2api / One API / New API,可这样配置:
LLM_BASE_URL=https://your-domain.example.com/v1
LLM_API_KEY=sk-xxxx
LLM_MODEL=gpt-4o-mini
LLM_TIMEOUT=60
USE_LLM=true如果你暂时没有模型接口:
USE_LLM=false系统会使用内置规则进行基础研判。
python -m app.cli --input data/sample_trace.txt --output outputs/result.json或者:
python run_demo.pyuvicorn app.main:app --host 0.0.0.0 --port 8000 --reload接口:
curl -X POST http://127.0.0.1:8000/analyze \
-H "Content-Type: application/json" \
-d "{\"raw_trace\":\"GET /public/plugins/alertlist/../../../../../../etc/passwd HTTP/1.1\r\nHost: example.com\r\n\r\nHTTP/1.1 200 OK\r\nContent-Type: text/plain\r\n\r\nroot:x:0:0:root:/root:/bin/bash\"}"{
"false_positive": false,
"attack_success": true,
"risk_level": "high",
"attack_types": ["path_traversal", "arbitrary_file_read"],
"matched_cves": ["CVE-2021-43798"],
"evidence": ["响应体包含 /etc/passwd 特征 root:x:0:0"],
"analysis_info": "...",
"conclusion": "..."
}- 接入 PCAP 解析模块,将 pcap 自动还原为 HTTP trace
- 增加向量知识库,扩展 CVE 匹配能力
- 增加批量分析任务队列
- 接入 Elasticsearch / ClickHouse / Wazuh / SIEM
- 对接企业微信 / Telegram 告警
- 增加攻击链聚合 Agent