SniffCatDB/T-Pot-To-SniffCat
GitHub: SniffCatDB/T-Pot-To-SniffCat
T-Pot 蜜罐日志自动化分析与上报至 SniffCat 的集成工具,降低重复告警与人工处理负担。
Stars: 2 | Forks: 0
# T-Pot 到 SniffCat
[](https://github.com/SniffCatDB/T-Pot-To-SniffCat)
[](https://www.gnu.org/licenses/gpl-3.0)
[](https://nodejs.org)
[](https://github.com/SniffCatDB/T-Pot-To-SniffCat/commits)
[](https://github.com/SniffCatDB/T-Pot-To-SniffCat/stargazers)
将 T-Pot 蜜罐检测到的恶意活动自动报告给 SniffCat。
该脚本会监控日志、分析攻击尝试并自动上报。
## 🎯 主要功能
✅ 支持 **Cowrie**、**Dionaea** 和 **Honeytrap** 蜜罐(计划支持更多)。
✅ 智能上报机制,最小 **15 分钟冷却时间**,有效消除重复报告。
✅ 根据检测到的攻击类型自动分配滥用类别。
✅ 达到 API 限制时支持批量上报。
✅ 防止缓冲区溢出和数据丢失的保护机制。
✅ 自动重试失败的 API 请求。
✅ 完整支持 **IPv4** 和 **IPv6** 地址。
✅ 自动跳过 **UDP** 流量和专用 IP 地址(`local`、`private`、`multicast`)。
✅ **IP 白名单** – 维护一个 `whitelist.txt` 文件,包含不应上报的 IP(例如在 VPS 上运行时的家庭 IP)。该文件会监听变更并自动重新加载。
✅ 可选 **Discord** 通知,包含攻击告警和每日统计。
✅ 可选记录 IP 活动历史到文件。
✅ 通过 **Git** 和 **cron** 定时自动更新项目。
✅ 定期检查公网 IP 地址以防止自我上报。
✅ 自动检测新版本并通知更新。
✅ 提供开箱即用的 **PM2** 生产配置。
## 📦 系统要求
* **[Node.js](https://gist.github.com/sefinek/fb50041a5f456321d58104bbf3f6e649)** 版本 **20.x 或更高**(检查方式:`node -v`)
* **npm** 版本 **10.x 或更高**(检查方式:`npm -v`)
* **[Git](https://gist.github.com/sefinek/1de50073ffbbae82fc901506304f0ada)**(推荐最新版本)
* **T-Pot**(已安装并正常工作的蜜罐)
* **SniffCat API 密钥**([点击获取](https://sniffcat.com/api))
* **Discord Webhook**(用于攻击和错误通知,可选)
* **访问 T-Pot 日志**(默认位置:`~/tpotce/data/`)
## 🚀 安装与配置
### 1. 克隆仓库
```
git clone --recurse-submodules https://github.com/SniffCatDB/T-Pot-To-SniffCat.git
```
### 2. 安装 npm 依赖
```
cd T-Pot-To-SniffCat
npm install
```
### 3. 配置
复制默认配置文件并根据需要调整:
```
cp config.default.js config.js
```
然后用你喜欢的文本编辑器(如 `mcedit`、`nano`)打开 `config.js` 并配置以下选项:
#### 🔑 必需设置
```
SniffCat_API_KEY: 'your-api-key' // Obtain from https://sniffcat.com/api
```
#### 🖥️ 服务器设置
```
SERVER_ID: 'pl-waw-honeypot', // Your honeypot identifier (e.g. 'pl-waw-honeypot', 'home-honeypot')
EXTENDED_LOGS: false // Verbose logging (useful for debugging)
```
#### 📁 日志路径
如果 T-Pot 安装位置不同,请调整路径:
```
COWRIE_LOG_FILE: '~/tpotce/data/cowrie/log/cowrie.json',
DIONAEA_LOG_FILE: '~/tpotce/data/dionaea/log/dionaea.json',
HONEYTRAP_LOG_FILE: '~/tpotce/data/honeytrap/log/attackers.json'
```
#### 🌐 网络设置
```
IP_ASSIGNMENT: 'dynamic', // 'static' or 'dynamic'
IP_REFRESH_SCHEDULE: '0 */6 * * *', // IP check every 6 hours
IPv6_SUPPORT: true // true if your ISP provides IPv6
```
#### ⏱️ 报告管理
```
IP_REPORT_COOLDOWN: 6 * 60 * 60 * 1000 // Time between reports for the same IP (default: 6 hours)
// NOTE: Minimum is 15 minutes (900000 ms) – SniffCat requirement
```
#### 📝 IP 历史(可选)
```
LOG_IP_HISTORY_ENABLED: false, // Enable history logging
LOG_IP_HISTORY_DIR: './data' // Directory for IP history
```
#### 🔔 Discord Webhook(可选)
```
DISCORD_WEBHOOK_ENABLED: false,
DISCORD_WEBHOOK_URL: 'https://discord.com/api/webhooks/...',
DISCORD_WEBHOOK_USERNAME: 'SERVER_ID', // Display name (use 'SERVER_ID' for automatic naming)
DISCORD_USER_ID: 'your-discord-id' // You will receive mentions (@mention) on important events
```
📊 **每日摘要**:自动生成的每日攻击统计
🚨 **错误通知**:关键问题的即时告警
✅ **启动确认**:脚本成功启动时的通知
🔄 **更新通知**:新版本的告警
⚡ **速率限制**:每 3 秒最多 3 条消息
#### 🔄 自动更新
```
AUTO_UPDATE_ENABLED: false, // Enable only if you actively monitor the server
AUTO_UPDATE_SCHEDULE: '0 14,16,20 * * *' // Update schedule
```
### 5. 首次运行测试
```
node .
```
#### 使用 PM2 以生产模式运行
PM2 是一个 Node.js 进程管理器,可让脚本在后台运行并在失败时自动重启。
本仓库已包含可直接使用的 PM2 配置文件,无需额外设置。 😉
**安装 PM2:**
```
npm install pm2 -g
```
**启动:**
```
pm2 start
```
**添加到系统启动:**
```
eval "$(pm2 startup | grep sudo)"
```
**有用的 PM2 命令:**
```
pm2 logs # Show logs of all processes in real time
pm2 logs tpot-SniffCat # Show logs only for this script
pm2 list # Status of all running processes
pm2 restart tpot-SniffCat # Restart the script
pm2 stop tpot-SniffCat # Stop the script
pm2 delete tpot-SniffCat # Remove the script from PM2
pm2 monit # Real-time process monitoring
pm2 flush # Clear all logs
```
### 6. 项目更新
要更新到最新版本,请运行:
```
npm run update
```
脚本会自动:
* 从 Git 仓库获取最新更改,
* 更新子模块,
* 更新所需的 npm 依赖,
* 重启 PM2 进程。
更新后,请检查 `pm2 logs` 确保一切正常运行。
## 📊 示例报告
```
Honeypot hit: Brute-force attack detected on 22/SSH
• Credentials used: support:support, ubnt:ubnt, usario:usario, user:user, admin:admin
• Number of login attempts: 5
• Client: SSH-2.0-libssh_0.11.1
```
```
Honeypot hit: Unauthorized traffic (243 bytes of payload); 20443 [3] TCP
```
```
Honeypot hit: Empty payload (likely service probe); 1028 [1] TCP
```
```
Honeypot hit: Unauthorized connection attempt detected on 23/TELNET
```
```
Honeypot hit: HTTP/1.1 request on 8800
GET /
User-Agent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Encoding: identity; 8800 [2] TCP
```
```
Honeypot hit: HTTP/1.1 request on 13261
CONNECT myip.wtf:443
User-Agent: Go-http-client/1.1; 13261 [2] TCP
```
## 📄 [GPL-3.0 许可证](LICENSE)
版权 © 2025-2026 [Sefinek](https://sefinek.net)
标签:API报告, cron定时, Dionaea, Discord通知, GNU通用公共许可证, GPLv3, Honeytrap, IPv4, IPv6, IP白名单, MITM代理, Node.js, PowerShell, Python 3.9+, Shellcode执行, SniffCat, UDP过滤, 去重, 开源, 恶意流量, 攻击分析, 网络安全, 网络安全研究, 自动报告, 自动重试, 自定义脚本, 蜜罐, 证书利用, 防数据丢失, 隐私保护, 集成