fail2ban+AbuseIPDB让滥用曝光在阳光下

in 云服务器 with 0 comment

前一篇我们讲了使用fail2ban来屏蔽那些在网上尝试暴力破解的IP。经过这两天摸索,我又找到这个公共的滥用IP的收集曝光平台:AbuseIPDB.
我们可以通过简单的配置,让fail2ban来自动将被封锁的IP,以及他们的犯罪证据,发送给这个平台,供全网共同来抵制这些IP。

什么是滥用IPDB?

AbuseIPDB 是一个致力于帮助打击互联网上黑客、垃圾邮件发送者和滥用活动的传播的项目。

我们的使命是通过为网站管理员、系统管理员和其他相关方提供中央黑名单来报告和查找与在线恶意活动相关的 IP 地址,从而帮助提高 Web 的安全性。

您可以使用上面的搜索框报告与恶意活动相关的 IP 地址,或检查是否已报告 IP 地址。

高级用户?考虑注册一个帐户来访问我们强大的免费 API,以报告和检查 IP 地址的报告状态。我们还支持与 Fail2Ban 集成,以自动报告滥用 IP。

AbuseIPDB注册和认证

打开以下地址,填写注册资料后提交
https://www.abuseipdb.com/register?plan=free
在邮箱里点击激活链接,激活一下。
然后再登录进 https://www.abuseipdb.com/account/webmasters
下载网站认证的html文件,上传到网站对应的位置,确保链接是可以正常打开的。然后回后台提交认证,认证完成后,接口的使用限制也小了很多。
2024-01-24T03:29:30.png

认证后的样子:
2024-01-24T03:30:57.png

生成API和激活fail2ban的推送

其实也比较简单,在 https://www.abuseipdb.com/account/api 页面中,新建API。

查看官方的说明文档,在VPS里配置一下。
/etc/fail 2ban/jail.local定义一下“action_abuseipdb”:

# Report ban via abuseipdb.com.
#
# See action.d/abuseipdb.conf for usage example and details.
#
action_abuseipdb = abuseipdb

其实这一步我看了一下,新版的fail2ban基本都有了,不需要单独配置,当然得确认一下。

然后还是在/etc/fail2ban/jail.local中,激活AbuseIPDB

[sshd]
enabled = true

# To use more aggressive sshd modes set filter parameter "mode" in jail.local:
# normal (default), ddos, extra or aggressive (combines all).
# See "tests/files/logs/sshd" or "filter.d/sshd.conf" for usage example and details.
#mode   = normal
port    = ssh
logpath = %(sshd_log)s
backend = %(sshd_backend)s

# Ban IP and report to AbuseIPDB for SSH Brute-Forcing
action = %(action_)s
         %(action_abuseipdb)s[abuseipdb_apikey="my-api-key", abuseipdb_category="18,22"]

其实主要是添加

         %(action_abuseipdb)s[abuseipdb_apikey="my-api-key", abuseipdb_category="18,22"]

记得把"my-api-key"改为自己的API KEY,后面的18和22,就是你要报告的滥用的类型,18就是尝试暴力破解,22就是针对SSH的滥用。

以下是官方的类别说明,可以查看 https://www.abuseipdb.com/categories

IDTitle标题Description描述
1DNS Compromise DNS妥协Altering DNS records resulting in improper redirection. 更改DNS记录导致不正确的重定向。
2DNS Poisoning DNS中毒Falsifying domain server cache (cache poisoning). 伪造域服务器缓存(缓存中毒)。
3Fraud Orders 欺诈命令Fraudulent orders. 欺诈命令
4DDoS Attack DDoS攻击Participating in distributed denial-of-service (usually part of botnet). 参与分布式拒绝服务(通常是僵尸网络的一部分)。
5FTP Brute-Force FTP暴力破解
6Ping of DeathOversized IP packet. IP数据包已解密。
7Phishing 钓鱼Phishing websites and/or email. 钓鱼网站和/或电子邮件。
8Fraud VoIP 欺诈VoIP
9Open Proxy 开放代理Open proxy, open relay, or Tor exit node. 打开代理、打开中继或Tor出口节点。
10Web Spam Web垃圾Comment/forum spam, HTTP referer spam, or other CMS spam. 评论/论坛垃圾邮件、HTTP引用垃圾邮件或其他CMS垃圾邮件。
11Email Spam 电子邮件SPAMSpam email content, infected attachments, and phishing emails. Note: Limit comments to only relevent information (instead of log dumps) and be sure to remove PII if you want to remain anonymous. 垃圾电子邮件内容、受感染的附件和网络钓鱼电子邮件。注意:将评论限制为仅相关信息(而不是日志转储),如果您想保持匿名,请确保删除PII。
12Blog Spam 博客spamCMS blog comment spam. CMS博客评论垃圾邮件。
13VPN IP VPN IpConjunctive category. 合取范畴。
14Port Scan Port Scan端口扫描Scanning for open ports and vulnerable services. 扫描开放端口和易受攻击的服务。
15Hacking 黑客
16SQL Injection SQL注入Attempts at SQL injection. 尝试SQL注入。
17Spoofing 欺骗Email sender spoofing. 电子邮件发件人欺骗。
18Brute-Force 蛮力Credential brute-force attacks on webpage logins and services like SSH, FTP, SIP, SMTP, RDP, etc. This category is seperate from DDoS attacks. 对网页登录和SSH、FTP、SIP、SMTP、RDP等服务的凭据暴力攻击。这一类别与DDoS攻击不同。
19Bad Web Bot 坏的Web BotWebpage scraping (for email addresses, content, etc) and crawlers that do not honor robots.txt. Excessive requests and user agent spoofing can also be reported here. 网页抓取(针对电子邮件地址、内容等)和不支持荣誉robots.txt的爬虫。过多的请求和用户代理欺骗也可以在这里报告。
20Exploited Host 被利用的主机Host is likely infected with malware and being used for other attacks or to host malicious content. The host owner may not be aware of the compromise. This category is often used in combination with other attack categories. 主机可能感染了恶意软件,并被用于其他攻击或托管恶意内容。主机所有者可能不知道这种危害。此类别通常与其他攻击类别结合使用。
21Web App Attack Web App攻击Attempts to probe for or exploit installed web applications such as a CMS like WordPress/Drupal, e-commerce solutions, forum software, phpMyAdmin and various other software plugins/solutions. 试图探测或利用已安装的Web应用程序,例如WordPress/Drupal等CMS,电子商务解决方案,论坛软件,phpMyAdmin和各种其他软件插件/解决方案。
22SSHSecure Shell (SSH) abuse. Use this category in combination with more specific categories. 安全外壳(SSH)滥用。将此类别与更具体的类别结合使用。
23IoT Targeted IoT目标Abuse was targeted at an "Internet of Things" type device. Include information about what type of device was targeted in the comments. 滥用的目标是“物联网”类型的设备。在评论中包括有关针对哪种类型器械的信息。

最后,重新启动或是重新加载一下fail2ban,就可以了。

fail2ban-client reload

查看你报告的IP

https://www.abuseipdb.com/account/api 页面,可以查看你的IP报告的情况。
2024-01-24T03:42:25.png
以及近一个月的报告情况和每个API KEY的报告数量。
2024-01-24T03:52:32.png

将AbuseIPDB贡献标识放在自己的网站里。

页面: https://www.abuseipdb.com/account/contributor
你可以使用一段代码,将你报告的IP数量显示在自己的网站上。比如我下面的:

AbuseIPDB Contributor Badge

放置后,从网站点击跳转过去,再看后台的API限制,已经提升到了支持者的级别了。
2024-01-24T06:53:00.png

浏览报告的IP详情

打开 https://www.abuseipdb.com/account/reports
这里列出了所有报告的IP和类型,你可以在这里选择删除报告,也可以点击每个IP查看这个IP被报告了多少次,以及报告的分类是什么,还有IP的归属地及运营商,可以说是非常详细了。
2024-01-24T10:47:19.png

你这种被报告了7000多次的。。。真不知道运营商该怎么处理这种客户。。。

2024-01-24T10:49:12.png

还可以查看这个IP被别的网友报告的次数详情。
2024-01-24T10:50:10.png

最后

这种滥用IP的,其实最终受伤的还是运营商或是后面不知情的消费者。购买了VPS,结果来了个在某个领域被封锁住的IP,有些平台还不让免费换IP,这就很坑人了。而平台免费换IP,那就更坑了,运营商的IP会被这些人逐个弄废掉。

运营商还是得提高自己的技术能力,能实时监测出这些作妖的SB,并形成行业黑名单,最好也能全网实名曝光。

未来,还是需要全球立法,让这些无聊的SB们,不敢轻举妄动。不然,治标不治本。

Responses