Files
aaPanel/class/panelDefense.py
T
Jack ed55fa708d Update to 7.7.0
Since version 7.7.0, we recommend yours update python to 3.12.

[+] Using nginx technology to load static files improves access speed
[+] Refactor homepage, website, FTP, and database using vue3
[+] Table loading changed to skeleton screen
[+] Add Website statistics-v2 professional plug-in
[+] Add Home page - top 5 resource occupancy
[+] Add protection for Files management (requires Tamper-proof for Enterprise 3.7)
[+] Website, FTP, Databases page add program status
[+] Add FTP log analysis (only supports Centos)
[+] Add password-free login to phpMyAdmin
[+] Add Proxy Project in Website (Supported when web service uses Nginx)
[+] Add WP Toolkit (Pro version only)
[+] Redesigned Docker module
[+] Add WP Toolkit Protection
[+] Add WP Toolkit Backup and Restore
[+] Add WP Toolkit Migrated
[+] Add WP Toolkit Clone site (supports new domain and subdomain)
[+] Add WP Toolkit Create site from backup of other panel
[+] Add WP Toolkit support for Cron automatic backup (only save Local disk)
[+] Add WP Toolkit operation log
[+] Add Integrity check for WP Toolkit
[+] Add WP Toolkit plug-in management and themes management

[*] Optimize phpMyAdmin formula access method
[*] Optimize Home page PHP display problem
[*] Optimize jump to the login interface after the login expires
[*] Optimize automatic renewal of SSL at some times
[*] Optimize Let's Encrypt to increase application success rate

[-] Fix Logs Audit cannot be opened
[-] Fix apache URL rewrite issue
[-] Fix phpmyadmin installation problem
[-] Fix the problem that some servers cannot install software
[-] Fix upload file error
[-] Fix left menu hiding problem
[-] Fix aaPanel Mobile QR code display problem
[-] Fix problem that third-party plug-ins are not displayed in the App Store
[-] Fix issue where the menu bar is blank when opening new tabs
[-] Fixed panel not being accessible in some cases
[-] Fix the issue where Curl warning caused the inability to apply for SSL
[-] Fix Quota issues for Website, FTP, Databases
[-] Fix file interface display problem on mobile terminal
2024-07-19 11:25:10 +08:00

88 lines
3.2 KiB
Python

#coding: utf-8
# +-------------------------------------------------------------------
# | aaPanel
# +-------------------------------------------------------------------
# | Copyright (c) 2015-2099 aaPanel(www.aapanel.com) All rights reserved.
# +-------------------------------------------------------------------
# | Author: hwliang
# +-------------------------------------------------------------------
# +-------------------------------------------------------------------
# | 面板防御模块
# +-------------------------------------------------------------------
import public
class bot_safe:
'''
@name 机器防御模块
'''
def is_spider_bot(self,user_agent):
'''
@name 检查是否为搜索引擎爬虫
@auth hwliang
@param user_agent <str> User-Agent
@return <bool> True/False
'''
spider_uas = ["bot","spider"]
for spider_ua in spider_uas:
if spider_ua in user_agent: return True
return False
def is_scanner(self,user_agent):
'''
@name 检查是否为扫描器
@auth hwliang
@param user_agent <str> User-Agent
@return <bool> True/False
'''
scanner_uas = ["wpscan","httrack","antsword","harvest","audit","dirbuster","pangolin","nmap","sqln","hydra","parser","libwww","bbbike","sqlmap","w3af","owasp","nikto","fimap","havij","zmeu","babykrokodil","netsparker","httperf"," sf/"]
for scanner_ua in scanner_uas:
if scanner_ua in user_agent: return True
return False
def is_scripter(self,user_agent):
'''
@name 检查是否为脚本工具
@auth hwliang
@param user_agent <str> User-Agent
@return <bool> True/False
'''
scripter_uas = ["curl","requests","python","php","c#","urllib","wget","winhttp","webzip","fetchurl","node-superagent","java/","feeddemon","jullo","indy library","alexa toolbar","asktbfxtv","ahrefsbot","crawldaddy","java","feedly","apache-httpasyncclient","universalfeedparser","apachebench","microsoft url control","zmeu","jaunty","yyspider","digext","httpclient","heritrix","easouspider","ezooms","flightdeckreports"]
for scripter_ua in scripter_uas:
if scripter_ua in user_agent: return True
return False
def spider(self,user_agent,ip):
'''
@name 爬虫防御
@auth hwliang
@param user_agent <str> User-Agent
@param ip <str> 客户端IP地址
@return <bool> True/False
'''
# 检查参数
if not user_agent or not ip: return False
# ua长度小于24位的拒绝
ua_len = len(user_agent)
if ua_len < 24 or ua_len > 350: return False
# 放行局域网IP
if public.is_local_ip(ip): return True
user_agent = user_agent.lower()
# 检查是否为搜索引擎爬虫
if self.is_spider_bot(user_agent): return False
# 检查是否为扫描器
if self.is_scanner(user_agent): return False
# 检查是否为脚本工具
if self.is_scripter(user_agent): return False
return True