#!/usr/bin/env python ''' Copyright (C) 2020, WAFW00F Developers. See the LICENSE file for copying permission. ''' NAME = 'Wordfence (Defiant)' def is_waf(self): # 定义用于检测是否存在特定 Web 应用防火墙(WAF)的方案列表。 schemes = [ # 检查响应头中的'Server'字段是否为'wf[_-]?WAF',其中'[_-]?'表示下划线或连字符可有可无。 self.matchHeader(('Server', r'wf[_\-]?WAF')), # 检查响应内容中是否包含'Generated by Wordfence'。 self.matchContent(r"Generated by Wordfence"), # 检查响应内容中是否包含'broke one of (the )?Wordfence (advanced )?blocking rules'。 self.matchContent(r'broke one of (the )?Wordfence (advanced )?blocking rules'), # 检查响应内容中是否包含'/plugins/wordfence'。 self.matchContent(r'/plugins/wordfence') ] # 如果方案列表中的任何一个条件为真,则认为检测到了 WAF。 if any(i for i in schemes): return True else: return False