【技术文档摘要】
英文版本: README_EN.md
OSINT连续监控系统基于BBOT、FastAPI,并使用Neo4j存储全部结果,通过MCP服务器从Cursor查询数据。
GitHub仓库: https://github.com/dn9uy3n/bbot-osint-mcp
参考资料:
./scripts/quick-install.sh (DNS Docker设置,运行时目录创建,密钥生成,构建及启动)cd /opt
sudo git clone https://github.com/dn9uy3n/bbot-osint-mcp.git
cd bbot-osint-mcp
# (可选) 将您的init_config.json文件放置到repo目录中
# nano init_config.json
chmod +x scripts/quick-install.sh
./scripts/quick-install.sh
# 检查日志
sudo docker logs -f bbot_osint
脚本将:
配置Docker守护程序的DNS(1.1.1.1, 8.8.8)以避免名称解析错误
创建运行时目录:logs/, cache/, scans/, secrets/
如果缺少则创建密钥(API_TOKEN, Neo4j密码)
构建并启动整个堆栈
系统连续监控自动按周期扫描目标,将全部数据保存到Neo4j(DNS记录、开放端口、技术、事件),并通过API和MCP进行查询。优化为全天候运行,减少流量,降低被封锁的风险。
target_sleep_seconds同一周期内每个目标之间的间隔(避免连续扫描)。cycle_sleep_seconds扫描完所有目标后开始新周期前的暂停。osint.query, osint.events.query, osint.status)。
/mcp/tools/osint.query, /mcp/tools/osint.events.query, /mcp/tools/osint.status。init_config.json(目标、API密钥、睡眠时间)。/ingest/output收集数据,使用自己的令牌;工作者可以在每次扫描后立即自动上传。docker-compose.ymlNeo4j和OSINT服务(FastAPI + MCP)。init_config.json输入配置(目标、API密钥、Telegram、扫描参数)。services/osintAPI源代码、BBOT运行器、MCP服务器。reverse-proxy/Caddyfile自动配置Caddy和Let's Encrypt。graph TB
subgraph "客户端层"
A[Cursor IDE<br/>仅MCP查询]
B[监控仪表板]
C[API客户端/脚本]
end
subgraph "VPS服务器"
D[Caddy反向代理<br/>端口80/443<br/>Let's Encrypt TLS]
subgraph "内部网络"
E[FastAPI服务<br/>端口8000<br/>+持续扫描器]
F[Neo4j数据库<br/>端口7687]
E -->|摄入数据| F
E -->|自动扫描循环| E
end
D --> E
end
subgraph "外部服务"
G[BBOT模块<br/>SecurityTrails, Shodan,<br/>VirusTotal等]
H[Telegram Bot API]
end
A -->|MCP查询HTTPS| D
B -->|HTTPS API| D
C -->|HTTPS API| D
E -->|持续扫描| G
E -->|循环完成通知| H
style D fill:#f9f,stroke:#333,stroke-width:2px
style E fill:#bbf,stroke:#333,stroke-width:2px
style F fill:#bfb,stroke:#333,stroke-width:2px
sequenceDiagram
participant S as 持续扫描器
participant B as BBOT
participant N as Neo4j
participant T as Telegram
Note over S: 服务启动
S->>S: 从init_config.json加载目标
loop 每个周期
Note over S: 周期开始
loop 对于每个目标
S->>B: 扫描目标[i]
B-->>S: 事件流
S->>N: 摄入事件(增量)
alt 不是最后一个目标
Note over S: 睡眠target_sleep_seconds
end
end
S->>N: 清理旧/离线数据
S->>T: 发送周期总结
Note over S: 睡眠cycle_sleep_seconds
end
graph LR
subgraph "BBOT事件"
E1[DNS_NAME]
E2[OPEN_TCP_PORT]
E3[TECHNOLOGY]
E4[URL]
E5[EMAIL]
end
subgraph "Neo4j节点"
N1[主机]
N2[域名]
N3[DNS_NAME]
N4[OPEN_TCP_PORT]
N5[TECHNOLOGY]
N6[IP]
N7[URL]
N8[电子邮件]
N9[模块]
N10[事件]
end
E1 --> N3
E2 --> N4
E3 --> N5
E4 --> N7
E5 --> N8
N1 -->|属于| N2
N3 -->|解析为| N1
N4 -->|在主机上| N1
N1 -->|使用技术| N5
N10 -->|关于| N1
N10 -->|关于| N2
N10 -->|由...发出| N9
style N1 fill:#bbf,stroke:#333,stroke-width:2px
style N2 fill:#bfb,stroke:#333,stroke-width:2px
style N3 fill:#fbb,stroke:#333,stroke-width:2px
style N4 fill:#fbf,stroke:#333,stroke-width:2px
style N5 fill:#ffb,stroke:#333,stroke-width:2px
sudoosint.example.com)sudo apt-get update -y && sudo apt-get upgrade -y
sudo apt-get install -y ca-certificates curl gnupg lsb-release git
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg \
| sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] \
https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" \
| sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update -y
sudo apt-get install -y docker-ce docker-ce-cli containerd.io \
docker-buildx-plugin docker-compose-plugin
sudo systemctl enable --now docker
sudo docker --version
sudo docker compose version
cd /opt
sudo git clone https://github.com/dn9uy3n/bbot-osint-mcp.git
cd bbot-osint-mcp
sudo chown -R $USER:$USER .
bash scripts/init-secrets.sh
cat secrets/credentials.txt
保存API_TOKEN和NEO4J_PASSWORD以在下一步中配置。
.env给中央cp .env.example .env
nano .env
变量:
LE_DOMAIN=osint.example.com
LE_EMAIL=admin@example.com
PUBLIC_BASE_URL=https://osint.example.com
NEO4J_USERNAME=neo4j
RATE_LIMIT_PER_MINUTE=120
MAX_CONCURRENT_SCANS=2
CLEANUP_ENABLED=true
EVENT_RETENTION_DAYS=30
OFFLINE_HOST_RETENTION_DAYS=30
ORPHAN_CLEANUP_ENABLED=true
.env示例(使用init_config.json的值和secrets/文件夹):cat <<'EOF' > .env
LE_DOMAIN=osint.example.com
LE_EMAIL=admin@example.com
NEO4J_PASSWORD="$(tr -d '\n' < secrets/neo4j_password)"
EOF
然后打开文件以添加其他变量(如PUBLIC_BASE_URL,RATE_LIMIT_PER_MINUTE,...)。
API_TOKEN和NEO4J_PASSWORDDocker秘密会自行从secrets/目录读取。TELEGRAM_BOT_TOKEN / TELEGRAM_CHAT_ID如果您想接收通知。init_config.json给中央cp init_config.json.example init_config.json
nano init_config.json
{
"targets": ["evilcorp.com", "target2.com"],
"deployment_role": "central",
"scan_defaults": {
"presets": ["subdomain-enum"],
"flags": ["safe"],
"max_workers": 2,
"target_sleep_seconds": 300,
"cycle_sleep_seconds": 3600
},
"bbot_modules": {
"securitytrails": { "api_key": "YOUR_SECURITYTRAILS_KEY" },
"shodan_dns": { "api_key": "YOUR_SHODAN_KEY" },
"virustotal": { "api_key": "YOUR_VIRUSTOTAL_KEY" }
},
"workers": [
{ "id": "worker-hcm", "token": "<64字节随机字符串>" },
{ "id": "worker-hn", "token": "<另一个字符串>" }
]
}
workers是一个允许上传的列表。docker compose restart osint。sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw allow 22/tcp
sudo ufw allow 8000/tcp comment 'bbot-osint API (可选)'
sudo ufw enable
sudo ufw status
sudo docker compose up -d --build
sudo docker logs -f bbot_caddy
Caddy将申请Let's Encrypt证书。LE_DOMAIN。
等待日志证书成功获取确认HTTPS功能。
如果您想限制资源:
docker ps -q | xargs -r -I{} docker update --cpus 0.8 {}
API_TOKEN=$(grep '^API_TOKEN:' secrets/credentials.txt | awk '{print $2}')
curl -s -H "X-API-Token: $API_TOKEN" https://osint.example.com/healthz
curl -s -H "X-API-Token: $API_TOKEN" https://osint.example.com/status
也可以监视扫描过程:
sudo docker logs -f bbot_osint
.env最小化cp .env.example .env
nano .env
LE_DOMAIN和LE_EMAIL为空或注释这两行。PUBLIC_BASE_URL可以设为http://127.0.0.1:8000(仅内部服务)。init_config.json给工作者{
"targets": ["acme.example"],
"deployment_role": "worker",
"scan_defaults": {
"presets": ["subdomain-enum"],
"flags": ["safe"],
"max_workers": 2,
"target_sleep_seconds": 300,
"cycle_sleep_seconds": 3600
},
"central_api": {
"url": "https://osint.example.com/ingest/output",
"worker_id": "worker-hcm",
"worker_token": "<64字节随机字符串>",
"auto_upload": true,
"compress": true,
"verify_tls": true,
"timeout": 180
}
}
central_api.url您可以使用中心域名或反向代理IP。auto_upload为false然后使用CLI。python -m app.worker_ingest ...。工作者只需要服务。osint:
sudo docker compose up -d --build --no-deps osint
sudo docker logs -f bbot_osint
neo4j和proxy不需要在工作者上运行。docker ps -q | xargs -r -I{} docker update --cpus 0.8 {}
在日志bbot_osint中会出现一行:
[INFO] 上传了4373条记录给acme.example来自新的扫描目录:[...]
在中心日志检查bbot_osint以查看导入N条记录对应的worker_id。
📖 查看更多:SLEEP_PARAMETERS.md
workers(中心专用):通过init_config.json配置允许上传的列表。
central_api(工作者专用):指定端点、凭据和上传行为。
1. 仅使用中央服务器(无工作者)
deployment_role为central(未声明时默认)。workers或留空数组,如果您不想接受外部上传。targets并将数据直接导入Neo4j。2. 中心 + 多个工作者
deployment_role: "central",声明列表workers,每个工作者有id/token。deployment_role: "worker",配置central_api,对应worker_id/worker_token,开启auto_upload,每个目标将调用自身。/ingest/output。workers中移除以禁用。3. 临时工作者 / 手动发送
deployment_role: "worker"但设置central_api.auto_upload = false。python -m app.worker_ingest --file ... --url ... --worker-id ... --worker-token ... --domain ...随时推送数据。