Dec 30 00:07:14 VM-0-3-ubuntu server[3689789]: 2024-12-30 00:07:14.929 {89b6c95b89b115182c47ac1cc023299d} 404 "GET https www.xabaotu.com /search/ht6ebug6by.html HTTP/1.1" 140.884, 202.21.110.110, "https://www.xabaotu.com/search/d4061ed1e3.html", "Mozilla/5.0 (Linux; Android 10; M2004J19C) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Mobile Safari/537.36 OPR/54.2.2672.50007", 65, "Not Found", ""
Dec 30 00:07:14 VM-0-3-ubuntu server[3689789]: 2024-12-30 00:07:14.945 {5eefaf5c89b115182d47ac1c210b0c16} 404 "GET https www.xabaotu.com /search/yt279722by.html HTTP/1.1" 133.088, 114.7.9.102, "https://www.xabaotu.com/search/cbd92dcb39.html", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 YaBrowser/23.7.1.1140 Yowser/2.5 Safari/537.36", 65, "Not Found", ""
Dec 30 00:07:14 VM-0-3-ubuntu server[3689789]: 2024-12-30 00:07:14.954 {5ead465d89b115182e47ac1ccd09b98f} 404 "GET https www.xabaotu.com /search/b4eehmn080.html HTTP/1.1" 126.507, 196.202.217.10, "https://www.xabaotu.com/search/bdf5567a16.html", "Mozilla/5.0 (Linux; arm_64; Android 9; SM-G955F) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.6099.328 YaBrowser/24.1.0.328.00 SA/3 Mobile Safari/537.36", 65, "Not Found", ""
Dec 30 00:07:14 VM-0-3-ubuntu server[3689789]: 2024-12-30 00:07:14.966 {488cfa5d89b115182f47ac1cb8e93c91} 404 "GET https www.xabaotu.com /search/2q83kagz0a.html HTTP/1.1" 174.706, 177.220.237.178, "https://www.xabaotu.com/search/57c565a6cd.html", "Mozilla/5.0 (Linux; arm; Android 12; M2101K7BL) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.5993.133 YaBrowser/23.11.5.133.00 SA/3 Mobile Safari/537.36", 65, "Not Found", ""
Dec 30 00:07:14 VM-0-3-ubuntu server[3689789]: 2024-12-30 00:07:14.973 {9546675e89b115183047ac1c0e6f64bc} 404 "GET https www.xabaotu.com /search/j9pqg57htz.html HTTP/1.1" 130.695, 182.23.41.226, "https://www.xabaotu.com/search/c04bb881c9.html", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 YaBrowser/23.7.5.635 (beta) Yowser/2.5 Safari/537.36", 65, "Not Found", ""
Dec 30 00:07:14 VM-0-3-ubuntu server[3689789]: 2024-12-30 00:07:14.973 {7ab4675e89b115183147ac1c2ac397e1} 404 "GET https www.xabaotu.com /search/3vlruk127z.html HTTP/1.1" 155.420, 182.23.41.226, "https://www.xabaotu.com/search/c04bb881c9.html", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 YaBrowser/23.7.5.635 (beta) Yowser/2.5 Safari/537.36", 65, "Not Found", ""
Dec 30 00:07:14 VM-0-3-ubuntu server[3689789]: 2024-12-30 00:07:14.974 {182e725e89b115183247ac1c3d2caa5b} 404 "GET https www.xabaotu.com /search/m3im5t2tgj.html HTTP/1.1" 121.907, 182.23.41.226, "https://www.xabaotu.com/search/c04bb881c9.html", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 YaBrowser/23.7.5.635 (beta) Yowser/2.5 Safari/537.36", 65, "Not Found", ""
Dec 30 00:07:14 VM-0-3-ubuntu server[3689789]: 2024-12-30 00:07:14.975 {3d107d5e89b115183347ac1c54066c6a} 404 "GET https www.xabaotu.com /search/9wlh6k06zr.html HTTP/1.1" 95.408, 182.23.41.226, "https://www.xabaotu.com/search/c04bb881c9.html", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 YaBrowser/23.7.5.635 (beta) Yowser/2.5 Safari/537.36", 65, "Not Found", ""
Dec 30 00:07:14 VM-0-3-ubuntu server[3689789]: 2024-12-30 00:07:14.975 {8ab2855e89b115183447ac1c8775250d} 404 "GET https www.xabaotu.com /search/qpc2monebf.html HTTP/1.1" 96.130, 182.23.41.226, "https://www.xabaotu.com/search/c04bb881c9.html", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 YaBrowser/23.7.5.635 (beta) Yowser/2.5 Safari/537.36", 65, "Not Found", ""
Dec 30 00:07:14 VM-0-3-ubuntu server[3689789]: 2024-12-30 00:07:14.976 {4aac905e89b115183547ac1c063bbbe5} 404 "GET https www.xabaotu.com /search/buya6t1gop.html HTTP/1.1" 90.579, 182.23.41.226, "https://www.xabaotu.com/search/c04bb881c9.html", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 YaBrowser/23.7.5.635 (beta) Yowser/2.5 Safari/537.36", 65, "Not Found", ""
Dec 30 00:07:14 VM-0-3-ubuntu server[3689789]: 2024-12-30 00:07:14.977 {e9ec9b5e89b115183647ac1cd4ba7757} 404 "GET https www.xabaotu.com /search/s3en98pbvj.html HTTP/1.1" 89.707, 182.23.41.226, "https://www.xabaotu.com/search/c04bb881c9.html", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 YaBrowser/23.7.5.635 (beta) Yowser/2.5 Safari/537.36", 65, "Not Found", ""
Dec 30 00:07:14 VM-0-3-ubuntu server[3689789]: 2024-12-30 00:07:14.977 {e51a9c5e89b115183847ac1ce6f39668} 404 "GET https www.xabaotu.com /search/cil2i8cenk.html HTTP/1.1" 89.507, 202.57.210.65, "https://www.xabaotu.com/search/57c565a6cd.html", "Mozilla/5.0 (Windows NT 10.0; Win64; x64; Chromium GOST) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36", 65, "Not Found", ""
建议使用行为分析结合IP封禁
1.行为分析:
通过分析访问日志,识别出异常的访问模式。例如,短时间内大量的404错误请求、频繁访问特定页面等。
步骤1:收集访问日志
步骤2:分析日志
示例代码(Python):
使用Python脚本分析日志文件,识别频繁访问404页面的IP地址。
日志文件
logfile.log
改成自己的生成的ip文档
suspicious_ips.txt
名字自定义analyze_logs.py
2.IP封禁
一旦识别出异常行为,将可疑IP地址添加到Nginx配置文件中进行封禁。
更新Nginx配置
这里介绍两种方式
1.手动更新
在Nginx配置文件中添加以下内容,并创建
suspicious_ips.conf
文件名字自定义,路径改成自己的:2.自动化更新
使用Python脚本将 suspicious_ips.txt 文件中的IP地址添加到 suspicious_ips.conf 文件中:
update_nginx_conf.py
3.更新防火墙规则
使用 iptables 封禁可疑IP地址:
rules.v4
文件名自定义4.重载Nginx配置
补充
自动化整个过程
将上述步骤整合到一个脚本中:
update_security.sh
设置定时任务