d3v-sh/d3m0n-agent
GitHub: d3v-sh/d3m0n-agent
d3m0n-agent:基于Go的AI网络安全代理,自动化执行渗透测试工具。
Stars: 1 | Forks: 0
```
██████╗ ██████╗ ███╗ ███╗ ██████╗ ███╗ ██╗
██╔══██╗╚════██╗████╗ ████║██╔═████╗████╗ ██║
██║ ██║ █████╔╝██╔████╔██║██║██╔██║██╔██╗ ██║
██║ ██║ ╚═══██╗██║╚██╔╝██║████╔╝██║██║╚██╗██║
██████╔╝██████╔╝██║ ╚═╝ ██║╚██████╔╝██║ ╚████║
╚═════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═══╝
[ AI-Powered Cybersecurity Agent ]
[ by d3v-sh | v1.0.0 ]
```





## 预览
**一个使用 Go 构建的、完全自主的 AI 驱动的网络安全 agent。**
运行真实的工具。返回真实的结果。不模拟任何输出。
## 什么是 d3m0n?
d3m0n 是一个用于攻击性安全工作的 AI agent。你只需用自然语言描述一个任务——agent 会决定调用哪些工具,在你的系统上执行它们,对真实的输出进行推理,并持续工作直到任务完成。
它不是一个伪造工具输出的包装器。当你要求它扫描目标时,它会实际运行 `nmap`。当你要求它枚举子域名时,它会实际运行 `amass`。每一次工具调用都会连同完整的参数和输出记录到 SQLite 中。
使用 Go 构建——可编译为单个二进制文件,无运行时依赖。
## 功能
- **自主 agent 循环** — 模型调用工具,对真实输出进行推理,自动链接多个工具
- **22 种集成安全工具** — 涵盖从侦察到利用再到报告的全流程
- **CVE 查询** — 在 NVD 数据库中搜索已发现服务中的漏洞
- **目标记忆** — agent 可以跨会话保存和调用有关目标的信息
- **专业报告生成** — 根据对话记录生成 Markdown 和暗色主题的 HTML 渗透测试报告
- **会话记录** — 每次工具调用都会连同完整的参数和输出存储在 SQLite 中
- **配置驱动** — 模型、超时、安全模式、允许的路径等均在 `config.yaml` 中设置
- **本地 LLM 支持** — 兼容 Ollama、LM Studio 或任何兼容 OpenAI 的 endpoint
- **安全模式** — 提供路径遍历保护,将文件操作限制在已配置的目录中
- **流式输出** — 响应内容以 token 为单位流式传输,并使用 glamour markdown 重新渲染
- **精美的 CLI** — 采用 lipgloss 风格化的 UI、加载动画、渲染后的 markdown 以及 slash 命令
## 环境要求
- Go 1.22+
- Linux(推荐使用 Kali 以获得完整的工具可用性)
- [OpenRouter](https://openrouter.ai) 的 API key,**或者**一个本地 LLM 服务器(Ollama、LM Studio)
**安全工具**(安装以获取完整功能):
```
# Kali / Debian
sudo apt install nmap whois curl gobuster ffuf amass nikto sqlmap sslscan gitleaks
# Python 工具
pip install theHarvester sherlock-project spiderfoot
# 其他
# EyeWitness: https://github.com/RedSiege/EyeWitness
# testssl.sh: https://github.com/drwetter/testssl.sh
# recon-ng: https://github.com/lanmaster53/recon-ng
# dradis: https://dradisframework.com
```
## 安装说明
```
# 克隆
git clone https://github.com/d3v-sh/d3m0n.git
cd d3m0n
# 配置
cp config.yaml.example config.yaml
# 编辑 config.yaml 并添加你的 API key
# 构建
make build
# 运行
./d3m0n
# 或直接运行
make run
```
## 配置说明
将 `config.yaml.example` 复制为 `config.yaml`:
```
# LLM
model: "anthropic/claude-3.5-haiku" # any OpenRouter model
base_url: "https://openrouter.ai/api/v1"
api_key: "your-api-key-here" # or set OPENROUTER_API_KEY env var
# Agent
max_history: 20 # messages kept in context window
timeout: 300 # seconds per request before timeout
# 安全
safe_mode: true # restrict file ops to allowed_paths only
allowed_paths:
- .
- ./output
- /tmp
# Prompt
system_prompt: "You are a professional cybersecurity red team expert."
```
`config.yaml` 已被 gitignored —— 你的密钥将保留在本地。
### 本地 LLM
```
# Ollama
model: "llama3.2"
base_url: "http://localhost:11434/v1"
api_key: "ollama"
# LM Studio
model: "local-model"
base_url: "http://localhost:1234/v1"
api_key: "lm-studio"
```
## 用法
```
./d3m0n
```
用纯英文描述任务:
```
❯ perform a full recon on example.com
❯ scan 192.168.1.1 for open ports and look up CVEs for discovered services
❯ find all subdomains of target.com
❯ check ssl/tls configuration of example.com:443
❯ search for secrets in /path/to/repo
❯ run a whois on vulnweb.com then save results to output/vulnweb.txt
```
### Slash 命令
| 命令 | 描述 |
|---------|-------------|
| `/help` | 显示可用命令 |
| `/tools` | 列出所有集成的工具 |
| `/report` | 根据对话生成渗透测试报告 |
| `/history` | 显示数据库中最近 10 次会话 |
| `/targets` | 显示所有已记忆的目标 |
| `/session` | 显示当前会话信息 |
| `/config` | 显示当前活动的配置 |
| `clear` | 清除屏幕并重置对话历史 |
| `exit` | 退出 d3m0n |
### 报告生成
在侦察会话结束后,运行 `/report` 以生成专业的渗透测试报告:
```
❯ perform recon on vulnweb.com
⚙ calling → run_whois
✓ run_whois completed
⚙ calling → run_amass
✓ run_amass completed
⚙ calling → run_curl
✓ run_curl completed
│ Assistant
[summary of findings]
❯ /report
⏳ Generating report...
✓ Reports saved:
MD: output/report-20260601-143022.md
HTML: output/report-20260601-143022.html
```
HTML 报告是一个暗色主题、格式完整的文档,包含漏洞发现表、证据以及修复建议。
## 集成工具
| 工具 | 用途 |
|------|---------|
| `run_nmap` | 端口扫描与服务/版本检测 |
| `run_whois` | 域名和 IP 注册信息查询 |
| `run_curl` | HTTP 探测、头部检查及内容抓取 |
| `run_gobuster` | 目录、DNS 和 vhost 暴力破解 |
| `run_ffuf` | 支持 FUZZ 关键字的快速 Web 模糊测试 |
| `run_amass` | 子域名枚举与 DNS 情报收集 |
| `run_recon-ng` | 模块化 Web 侦察框架 |
| `run_theharvester` | 从公开来源收集邮箱、子域名和姓名的 OSINT |
| `run_sherlock` | 跨 300 多个社交平台搜索用户名 |
| `run_spiderfoot` | 跨多个模块的自动化 OSINT 收集 |
| `run_eyewitness` | Web 服务截图捕获 |
| `run_sslscan` | SSL/TLS 配置和加密套件测试 |
| `run_testssl` | 深入的 SSL/TLS 漏洞分析 |
| `run_gitleaks` | git 仓库中的密钥和凭证检测 |
| `run_sqlmap` | 自动化 SQL 注入检测与利用 |
| `run_crtsh` | 针对子域名的证书透明度日志查询 |
| `run_dradis` | 将扫描结果导入 Dradis 报告框架 |
| `search_cve` | 针对产品和版本的 NVD CVE 数据库查询 |
| `read_file` | 从磁盘读取文件(强制执行安全模式) |
| `write_file` | 写入或追加文件(强制执行安全模式) |
| `remember` | 将目标情报保存到持久化内存中 |
| `recall` | 调用有关特定目标已保存的信息 |
## 项目结构
```
d3m0n/
├── main.go # entry point, CLI loop, agent loop
├── config/
│ └── config.go # config struct, YAML loading, defaults
├── tools/
│ ├── tools.go # tool definitions (OpenAI function schemas)
│ └── tool_wrapper.go # tool implementations and dispatcher
├── logger/
│ └── logger.go # SQLite session and tool call logging
├── ui/
│ └── ui.go # terminal UI (lipgloss styles, banner, prompts)
├── .github/
│ └── workflows/
│ └── build.yml # GitHub Actions CI build
├── config.yaml.example # example configuration file
├── Makefile # build, run, clean
├── .gitignore
├── go.mod
└── go.sum
```
## 会话记录
每次会话都存储在 `data/agent.db` 中(SQLite —— 无需服务端):
```
# 列出最近的会话
sqlite3 data/agent.db \
"SELECT id, start_time FROM sessions ORDER BY start_time DESC LIMIT 10;"
# 查看会话中的 tool calls
sqlite3 data/agent.db \
"SELECT tool, args FROM tool_logs WHERE session_id='20260601-143022';"
# 查看所有记住的目标
sqlite3 data/agent.db "SELECT host, info, updated FROM targets;"
```
或者可以在 d3m0n 中使用 `/history` 和 `/targets` slash 命令。
## 安全
- **安全模式**将所有文件读/写限制在配置中的 `allowed_paths` 内——可阻止路径遍历
- **API key** 从 `config.yaml` 或 `OPENROUTER_API_KEY` 环境变量加载——绝不硬编码
- **`config.yaml` 已被 gitignored**——凭证保留在本地
- 所有工具执行均在你的本地机器上进行
- 会话数据和报告本地存储在 `data/` 和 `output/` 目录中
## 推荐模型
| 模型 | 速度 | 工具调用 | 成本 |
|-------|-------|-------------|------|
| `anthropic/claude-3.5-haiku` | 快 | 优秀 | 低 |
| `openai/gpt-4o-mini` | 快 | 可靠 | 低 |
| `google/gemini-2.0-flash-001` | 非常快 | 良好 | 非常低 |
| `anthropic/claude-sonnet-4-5` | 中等 | 最佳 | 中等 |
| `llama3.2` (Ollama) | 本地 | 良好 (7B+) | 免费 |
| `qwen2.5:14b` (Ollama) | 本地 | 最佳本地模型 | 免费 |
## 构建
```
make build # build binary → ./d3m0n
make run # go run main.go
make clean # remove binary and data/sessions directories
```
## 路线图
- [ ] 用于完全隔离执行的 Docker + Kali 镜像
- [ ] Telegram bot 微服务(Python,独立仓库)
- [ ] 用于远程/多用户访问的 HTTP REST API
- [ ] Kubernetes 自动伸缩支持
- [ ] 用于自动化侦察 pipeline 的 Playbook/workflow 系统
- [ ] Web UI
## 许可证
MIT —— 详情请参阅 [LICENSE](LICENSE)。
使用 Go 构建 • 由 AI 驱动 • 为红队打造
**[github.com/d3v-sh](https://github.com/d3v-sh)**
标签:EVTX分析