You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
2.0 KiB
47 lines
2.0 KiB
#!/usr/bin/env python
|
|
'''
|
|
Copyright (C) 2020, WAFW00F Developers.
|
|
See the LICENSE file for copying permission.
|
|
'''
|
|
|
|
NAME = 'ModSecurity (SpiderLabs)'
|
|
|
|
|
|
def is_waf(self):
|
|
# 定义三个不同的检测模式。
|
|
schema1 = [
|
|
# 检查响应头中的'Server'字段是否为'mod_security'、'Mod_Security'或'NOYB'。
|
|
self.matchHeader(('Server', r'(mod_security|Mod_Security|NOYB)')),
|
|
# 检查响应内容中是否包含'This error was generated by Mod.?Security'。
|
|
self.matchContent(r'This error was generated by Mod.?Security'),
|
|
# 检查响应内容中是否包含'rules of the mod.security.module'。
|
|
self.matchContent(r'rules of the mod.security.module'),
|
|
# 检查响应内容中是否包含'mod.security.rules triggered'。
|
|
self.matchContent(r'mod.security.rules triggered'),
|
|
# 检查响应内容中是否包含'Protected by Mod.?Security'。
|
|
self.matchContent(r'Protected by Mod.?Security'),
|
|
# 检查响应内容中是否包含'/modsecurity[-_]errorpage/'。
|
|
self.matchContent(r'/modsecurity[\-_]errorpage/'),
|
|
# 检查响应内容中是否包含'modsecurity iis'。
|
|
self.matchContent(r'modsecurity iis')
|
|
]
|
|
schema2 = [
|
|
# 检查响应原因是否为'ModSecurity Action',并且响应状态码为 403。
|
|
self.matchReason('ModSecurity Action'),
|
|
self.matchStatus(403)
|
|
]
|
|
schema3 = [
|
|
# 检查响应原因是否为'ModSecurity Action',并且响应状态码为 406。
|
|
self.matchReason('ModSecurity Action'),
|
|
self.matchStatus(406)
|
|
]
|
|
# 如果 schema1 中的任何一个条件为真,则认为检测到了 WAF。
|
|
if any(i for i in schema1):
|
|
return True
|
|
# 如果 schema2 中的所有条件都为真,则认为检测到了 WAF。
|
|
if all(i for i in schema2):
|
|
return True
|
|
# 如果 schema3 中的所有条件都为真,则认为检测到了 WAF。
|
|
if all(i for i in schema3):
|
|
return True
|
|
return False |