3MPER0RR/RedAI
GitHub: 3MPER0RR/RedAI
RedAI 是一个基于自然语言的多供应商 AI 代理,专为红队和渗透测试工作流自动串联工具并输出分析报告。
Stars: 0 | Forks: 0
## 安装
```
git clone https://github.com/3MPER0RR/RedAI.git
cd RedAI
python3 -m venv venv
source venv/bin/activate
pip install requests
```
## 函数调用模块
## 简介
RedAI 是一个具备函数调用能力的多供应商 AI 代理,专为红队和渗透测试工作流设计。只需输入自然语言 prompt,它就会自主调用合适的工具,按顺序将它们串联起来,并输出完整的分析结果。
没有硬编码的 pipeline。由模型决定执行何种操作。
## 工作原理
```
prompt (natural language)
↓
RedAI Agent
↓
tool calls (autonomous)
┌─────────────────────┐
│ search_cve │ → NVD live lookup
│ read_file │ → reads any text file
│ save_report │ → saves output to file
│ list_files │ → lists directory contents
│ run_command │ → nmap, whois, dig, curl...
│ fetch_url │ → fetches web content
└─────────────────────┘
↓
final analysis + report
↓
session log (JSON)
```
## 供应商
| 供应商 | 值 | 默认模型 |
|----------|-------|---------------|
| Google Gemini | `google` | `gemini-2.5-flash` |
| Groq | `groq` | `llama-3.3-70b-versatile` |
| OpenRouter | `openrouter` | `mistralai/mistral-7b-instruct` |
### API Keys
```
export GOOGLE_API_KEY="your_key"
export GROQ_API_KEY="your_key"
export OPENROUTER_API_KEY="your_key"
```
## 使用方法
```
python3 fc_module.py --provider --prompt ""
```
### 参数
| 参数 | 必需 | 描述 |
|----------|----------|-------------|
| `--provider` | 是 | `google` / `groq` / `openrouter` |
| `--prompt` | 是 | 自然语言 prompt |
| `--model` | 否 | 覆盖默认模型 |
| `--no-log` | 否 | 禁用会话日志记录 |
## 示例
### CVE 分析
```
python3 fc_module.py --provider google \
--prompt "Search CVE-2021-3156 and give me a detailed analysis"
```
### 对比两个 CVE 并保存报告
```
python3 fc_module.py --provider google \
--prompt "Search CVE-2017-0144 and CVE-2021-3156, compare them and save a report to output/comparison.txt"
```
### 分析文档
```
python3 fc_module.py --provider google \
--prompt "Read data/sample.txt and analyze it from a security perspective"
```
### 读取、分析并保存报告
```
python3 fc_module.py --provider google \
--prompt "Read data/sample.txt, analyze it and save the report to output/report.txt"
```
### 使用 nmap 进行侦察
```
python3 fc_module.py --provider google \
--prompt "Run nmap on 127.0.0.1 and analyze the open ports"
```
### 完整的侦察 pipeline
```
python3 fc_module.py --provider google \
--prompt "Run nmap on 192.168.1.1, analyze open ports, search CVEs for the services found and save a report to output/recon_report.txt"
```
### 覆盖模型
```
python3 fc_module.py --provider groq \
--model "mixtral-8x7b-32768" \
--prompt "Search CVE-2021-3156 and analyze it"
```
### 禁用日志记录
```
python3 fc_module.py --provider google \
--no-log \
--prompt "List files in data/"
```
## 可用工具
| 工具 | 描述 |
|------|-------------|
| `read_file` | 从磁盘读取文本文件 |
| `save_report` | 将输出保存到文件 |
| `list_files` | 列出目录中的文件 |
| `search_cve` | 实时搜索 NVD 获取 CVE 详情和 CVSS 分数 |
| `run_command` | 运行安全的 shell 命令 |
| `fetch_url` | 从 URL 获取内容 |
### `run_command` 允许执行的命令
```
nmap, whois, dig, curl, ping, ls, cat, file, strings
```
## 输出
### 终端
```
=== RedAI - Function Calling Agent ===
[*] Provider : GOOGLE
[*] Model : gemini-2.5-flash
[*] Prompt : Search CVE-2021-3156...
[TOOL] Calling search_cve with args: {'cve_id': 'CVE-2021-3156'}
[RESULT] CVE: CVE-2021-3156 | CVSS: 7.8 ...
=== FINAL RESPONSE ===
[model analysis]
[+] Session logged to logs/session_TIMESTAMP.json
```
### 会话日志(logs/session_TIMESTAMP.json)
```
{
"timestamp": "20260621_122036",
"provider": "google",
"prompt": "Search CVE-2021-3156...",
"tool_calls": [
{
"tool": "search_cve",
"args": {"cve_id": "CVE-2021-3156"},
"result": "CVE: CVE-2021-3156..."
}
],
"response": "final model analysis"
}
```
## 使用场景
- **CVE 研究** — 通过单条命令实现实时 NVD 查询 + AI 分析
- **侦察** — nmap 扫描 + 服务分析 + CVE 关联
- **文档分析** — 渗透测试报告、架构文档、代码
- **威胁情报** — 对比多个 CVE,保存结构化报告
- **红队自动化** — 从单个 prompt 出发自主串联工具
## 注意事项
- 模型会根据 prompt 自主决定调用哪些工具
- 可以在单个 prompt 中按顺序串联多个工具
- 如果工具执行失败,模型会自动重试
- 默认超时时间:300 秒
- 会话日志将带上时间戳保存在 `logs/` 目录中
## DualMindDiff AI 生态系统的一部分
RedAI 是 [DualMindDiffAI](https://github.com/3MPER0RR/DualMindDiffAI) 项目的 agentic 模块 —— 这是一个用于跨模型比较 AI 推理能力的框架。
标签:AI代理, 大模型函数调用, 实时处理, 插件系统, 漏洞查询, 网络安全审计, 逆向工具