sefinek/UFW-AbuseIPDB-Reporter

GitHub: sefinek/UFW-AbuseIPDB-Reporter

实时监控 UFW 防火墙日志并将恶意 IP 自动上报至 AbuseIPDB 的 Node.js 服务,帮助管理员参与威胁情报共享。

Stars: 105 | Forks: 6

# 🛡️ UFW AbuseIPDB Reporter [![Version](https://img.shields.io/github/package-json/v/sefinek/UFW-AbuseIPDB-Reporter?label=version)](https://github.com/sefinek/UFW-AbuseIPDB-Reporter) [![License: GPL v3](https://img.shields.io/github/license/sefinek/UFW-AbuseIPDB-Reporter)](https://www.gnu.org/licenses/gpl-3.0) [![Node.js](https://img.shields.io/badge/node-%3E%3D20.0.0-339933?logo=node.js&logoColor=white)](https://nodejs.org) [![Last Commit](https://img.shields.io/github/last-commit/sefinek/UFW-AbuseIPDB-Reporter?label=last%20commit)](https://github.com/sefinek/UFW-AbuseIPDB-Reporter/commits) [![Stars](https://img.shields.io/github/stars/sefinek/UFW-AbuseIPDB-Reporter)](https://github.com/sefinek/UFW-AbuseIPDB-Reporter/stargazers) 一款集成工具,旨在分析 UFW 日志,并将被防火墙拦截的 IP 地址报告至 [AbuseIPDB](https://www.abuseipdb.com) 数据库。 为了防止在短时间内对同一个 IP 地址进行重复报告,该工具使用了一个临时缓存文件来记录之前已报告过的 IP 地址。 ## 📋 环境要求 - [Node.js + npm](https://gist.github.com/sefinek/fb50041a5f456321d58104bbf3f6e649) - [PM2](https://www.npmjs.com/package/pm2) (`npm i -g pm2`) - [Git](https://gist.github.com/sefinek/1de50073ffbbae82fc901506304f0ada) - Linux (Ubuntu 或 Debian) ## ✅ 功能特性 1. **配置简便** – 通过 [`config.js`](config.default.js) 文件可以实现快速且简单的配置。 2. **简易安装程序** – 能够实现快速、无缝的集成部署。 3. **自身 IP 保护 (IPv4 & IPv6)** – 即使您使用的是动态 IP 地址,该脚本也绝不会将属于您或您服务器的 IP 地址进行报告。 4. **IP 过滤** – 永远不会报告本地和特殊用途的 IP 地址。 5. **IP 白名单** – 维护一个 `whitelist.txt` 文件,用于记录绝不应被报告的 IP 地址(例如,在 VPS 上运行时的家庭 IP)。 6. **UDP 流量过滤** – 根据 [AbuseIPDB 的策略](https://github.com/sefinek/UFW-AbuseIPDB-Reporter/discussions/2),自动跳过 UDP 流量。 7. **报告冷却时间** – 在可配置的时间窗口(默认:12 小时)内,防止对同一 IP 进行重复报告。 8. **支持批量报告** – 如果脚本遇到速率限制,它将开始缓冲已收集的 IP,并发送批量报告。 9. **Discord Webhooks 集成**: - 关键通知 - 脚本错误警报 - 每日已报告 IP 汇总 10. **自动更新** – 脚本会定期获取并应用最新的更新。如果您不需要,可以禁用此功能。 ## 📥 安装说明 (Ubuntu & Debian) ### 自动安装(简单、快速且推荐) #### 通过 curl ``` bash <(curl -fsS https://raw.githubusercontent.com/sefinek/UFW-AbuseIPDB-Reporter/main/install.sh) ``` #### 通过 wget ``` bash <(wget -qO- https://raw.githubusercontent.com/sefinek/UFW-AbuseIPDB-Reporter/main/install.sh) ``` ### 手动安装 #### 安装 Node.js 参见 https://gist.github.com/sefinek/fb50041a5f456321d58104bbf3f6e649。 #### 安装 Git 参见 https://gist.github.com/sefinek/1de50073ffbbae82fc901506304f0ada。 #### 相关命令 ``` sudo apt update && sudo apt upgrade cd ~ git clone --recurse-submodules https://github.com/sefinek/UFW-AbuseIPDB-Reporter.git ufw-abuseipdb cd ufw-abuseipdb npm install --omit=dev cp config.default.js config.js sudo chown syslog:"$USER" "$ufw_log_path" sudo chmod 640 "$ufw_log_path" npm install -g pm2@latest sudo mkdir -p /var/log/ufw-abuseipdb sudo chown -R "$USER":"$USER" /var/log/ufw-abuseipdb pm2 start eval "$(pm2 startup | grep sudo)" pm2 save ``` ## 🖥️ 使用说明 成功安装后,该脚本将在后台持续运行,监控 UFW 日志并自动报告 IP 地址。 服务器会不断受到机器人的扫描,这些机器人通常试图寻找安全漏洞及类似的弱点。 因此,如果第二天发送到 AbuseIPDB 的报告数量超过了一千条,请不要感到惊讶。 ### 🔍 查看日志 ``` pm2 logs ufw-abuseipdb ``` ### 📄 示例报告 ``` Blocked by UFW on NY01 [8096/tcp] | SPT: 52458 | TTL: 243 | LEN: 40 | TOS: 0x08 • Reported by: github.com/sefinek/UFW-AbuseIPDB-Reporter ``` ``` Blocked by UFW on PL02 [64505/tcp] | SPT: 34017 | TTL: 43 | LEN: 44 | TOS: 0x00 • Reported by: github.com/sefinek/UFW-AbuseIPDB-Reporter ``` ## 🤝 开发贡献 如果您想为这个项目的开发做出贡献,欢迎随时创建一个新的 [Pull request](https://github.com/sefinek/UFW-AbuseIPDB-Reporter/pulls)。我将不胜感激! ## 🔑 [GPL-3.0 License](LICENSE) Copyright © 2024-2026 [Sefinek](https://sefinek.net)
标签:GNU通用公共许可证, MITM代理, Node.js, UFW, 威胁情报, 应用安全, 开发者工具, 运维工具, 防火墙