xdrew87/CanaryNet

GitHub: xdrew87/CanaryNet

一个基于 Python 与 FastAPI 的金丝雀令牌蜜罐系统,用于检测未授权访问与凭证抓取并提供实时告警。

Stars: 0 | Forks: 0

# 🍯 CanaryNet [![Python 3.11+](https://img.shields.io/badge/python-3.11%2B-blue.svg)](https://www.python.org/) [![FastAPI](https://img.shields.io/badge/FastAPI-0.110%2B-009688.svg)](https://fastapi.tiangolo.com/) [![SQLite](https://img.shields.io/badge/database-SQLite%2FPostgres-003B57.svg)](https://sqlite.org/) [![License: Apache 2.0](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](LICENSE) [![Defensive Research](https://img.shields.io/badge/purpose-defensive%20research-green.svg)]() 一个用于生产环境的金丝雀令牌蜜罐系统。部署诱饵文件以检测未经授权的访问、凭证抓取器和威胁行为者——具备实时告警、地理增强、风险评分和深色主题仪表板。 ## ⚠️ 法律声明 ## ✨ 功能特性 - 🪤 **金丝雀令牌** — 内嵌在诱饵文件中的可追踪唯一 URL - 📁 **诱饵生成器** — `.env`、GitHub Actions 工作流、配置文件 JSON、假的 PAT README 和 API 文档 - 🌐 **IP 增强** — 地理信息(ip-api.com)、AbuseIPDB、GreyNoise 集成 - 🤖 **UA 指纹识别** — 检测扫描器、机器人、无头浏览器 - 📊 **风险评分** — 可配置的权重规则,4 个严重等级 - 🔔 **多渠道告警** — Discord、Slack、邮件,支持突发抑制 - 📈 **深色主题仪表板** — 实时图表、事件表格、行为画像、金丝雀管理 - 🔗 **GitHub Webhook 接收器** — 记录并分析 Webhook 事件 - 💾 **SQLite / PostgreSQL** — 异步 SQLAlchemy 2.x,易于切换 - 🖥️ **丰富的 CLI** — 带有美观终端输出的完整管理界面 ## 🏗️ 架构 ``` ┌─────────────────────────────────────────────────────────────┐ │ CanaryNet │ │ │ │ ┌──────────┐ ┌─────────────┐ ┌──────────────────┐ │ │ │ Bait │ │ Canary │ │ Webhook │ │ │ │ Generator│ │ Tokens │ │ Receiver │ │ │ └────┬─────┘ └──────┬──────┘ └────────┬─────────┘ │ │ │ │ │ │ │ └─────────────────▼─────────────────────┘ │ │ ┌──────────┐ │ │ │ Events │ │ │ └────┬─────┘ │ │ ┌──────────▼──────────┐ │ │ │ Enrichers │ │ │ │ IP Geo · UA · Risk │ │ │ └──────────┬──────────┘ │ │ ┌───────────────▼──────────────┐ │ │ │ Alert Manager │ │ │ │ Discord · Slack · Email │ │ │ └───────────────┬──────────────┘ │ │ ┌─────▼──────┐ │ │ │ Database │ │ │ │ SQLite / │ │ │ │ PostgreSQL │ │ │ └─────┬──────┘ │ │ ┌─────▼──────┐ │ │ │ Dashboard │ │ │ │ FastAPI │ │ │ └────────────┘ │ └─────────────────────────────────────────────────────────────┘ ``` ## 🚀 快速开始 ``` # 1. 克隆并进入目录 git clone https://github.com/xdrew87/canarynet.git cd canarynet # 2. 创建虚拟环境 python3 -m venv .venv source .venv/bin/activate # Windows: .venv\Scripts\activate # 3. 安装依赖 pip install -r requirements.txt # 4. 配置环境 cp .env.example .env # 使用您的值编辑 .env(Webhook URL、API 密钥等) # 5. 初始化数据库 python main.py db init # 6. 启动服务器 python main.py serve # 7. 打开仪表板 # http://localhost:8000 ``` ## 🖥️ CLI 参考 | 命令 | 描述 | |---------|-------------| | `python main.py serve` | 启动仪表板服务器 | | `python main.py serve --reload` | 启动开发模式自动重载 | | `python main.py serve --port 9000` | 指定端口启动 | | `python main.py db init` | 创建数据库表 | | `python main.py db stats` | 显示行数统计 | | `python main.py canary list` | 列出所有金丝雀令牌 | | `python main.py canary create "My Bait"` | 创建金丝雀令牌 | | `python main.py canary deactivate ` | 停用令牌 | | `python main.py generate env` | 生成 `.env` 诱饵文件 | | `python main.py generate workflow` | 生成 Actions 诱饵文件 | | `python main.py generate bundle` | 生成完整诱饵包 | | `python main.py events list` | 列出最近事件 | | `python main.py events list --risk high` | 按风险等级过滤 | | `python main.py events export --format csv` | 导出事件为 CSV | | `python main.py actors list` | 列出行为画像 | | `python main.py actors blocklist 1.2.3.4` | 切换黑名单 | ## 🔧 环境变量 | 变量 | 默认值 | 描述 | |----------|---------|-------------| | `DATABASE_URL` | `sqlite+aiosqlite:///./canarynet.db` | 数据库连接字符串 | | `ADMIN_SECRET` | *(required)* | API 认证密钥(`X-Admin-Key` 头) | | `DISCORD_WEBHOOK_URL` | — | Discord 入站 Webhook URL | | `SLACK_WEBHOOK_URL` | — | Slack 入站 Webhook URL | | `EMAIL_HOST` | `smtp.hostinger.com` | SMTP 主机 | | `EMAIL_PORT` | `465` | SMTP 端口 | | `EMAIL_USER` | — | SMTP 用户名 | | `EMAIL_PASS` | — | SMTP 密码 | | `EMAIL_TO` | — | 告警接收地址 | | `ABUSEIPDB_API_KEY` | — | AbuseIPDB v2 API 密钥(可选) | | `GREYNOISE_API_KEY` | — | GreyNoise 社区 API 密钥(可选) | | `CANARY_BASE_URL` | `http://localhost:8000` | 公网金丝雀链接基础 URL | | `WEBHOOK_SECRET` | *(required)* | GitHub Webhook HMAC 密钥 | | `ALERT_BURST_THRESHOLD` | `5` | 每个 IP 每次突发窗口最大告警数 | | `ALERT_BURST_WINDOW_SECONDS` | `60` | 突发窗口秒数 | | `DAILY_SUMMARY_HOUR` | `8` | UTC 时每日摘要小时 | | `LOG_LEVEL` | `INFO` | 日志详细程度 | ## 🚢 VPS 部署 在 `/etc/systemd/system/canarynet.service` 创建 systemd 服务: ``` [Unit] Description=CanaryNet Honeypot Monitor After=network.target [Service] Type=simple User=canarynet WorkingDirectory=/opt/canarynet ExecStart=/opt/canarynet/.venv/bin/python main.py serve --host 127.0.0.1 --port 8000 Restart=always RestartSec=5 Environment=PYTHONUNBUFFERED=1 [Install] WantedBy=multi-user.target ``` ``` sudo systemctl daemon-reload sudo systemctl enable canarynet sudo systemctl start canarynet sudo systemctl status canarynet ``` 使用 Nginx 作为反向代理并终止 TLS(推荐使用 Let's Encrypt)。 ## 🔒 安全 如需报告安全漏洞,请参阅 [SECURITY.md](SECURITY.md)。 **不要公开在 GitHub 上提交安全漏洞问题。** ## 📄 许可证 根据 Apache License 2.0 授权——详情见 [LICENSE](LICENSE)。
标签:AMSI绕过, AV绕过, CLI, Discord告警, FastAPI, GitHub Webhook, IP地理定位, PostgreSQL, Python, SEO词: 威胁检测平台, SEO词: 实时告警系统, SEO词: 暗色主题仪表盘, SEO词: 蜜罐系统, SEO词: 金丝雀令牌, Slack告警, SQLite, Web API, Webhook接收器, WiFi技术, 事件溯源, 仪表盘, 凭证刮取, 告警抑制, 威胁检测, 开源安全工具, 异步SQLAlchemy, 扫描器检测, 文档结构分析, 无后门, 暗色主题, 未授权访问, 机器人检测, 欺骗技术, 测试用例, 滥用IP数据库, 灰噪声, 用户代理指纹识别, 终端工具, 蜜罐, 证书利用, 诱饵文件, 逆向工具, 逆向工程平台, 邮件告警, 金丝雀令牌, 防御性研究, 风险评分