#!/usr/bin/env python ''' Copyright (C) 2020, WAFW00F Developers. See the LICENSE file for copying permission. ''' NAME = 'pkSecurity IDS (pkSec)' def is_waf(self): # 定义两个不同的检测模式。 schema1 = [ # 检查响应内容中是否包含'pk.?Security.?Module',其中问号表示点可有可无。 self.matchContent(r'pk.?Security.?Module'), # 检查响应内容中是否包含'Security.Alert'。 self.matchContent(r'Security.Alert') ] schema2 = [ # 检查响应内容中是否包含'As this could be a potential hack attack'。 self.matchContent(r'As this could be a potential hack attack'), # 检查响应内容中是否包含'A safety critical (call|request) was (detected|discovered) and blocked'。 self.matchContent(r'A safety critical (call|request) was (detected|discovered) and blocked'), # 检查响应内容中是否包含'maximum number of reloads per minute and prevented access'。 self.matchContent(r'maximum number of reloads per minute and prevented access') ] # 如果 schema2 中的任何一个条件为真,则认为检测到了 WAF。 if any(i for i in schema2): return True # 如果 schema1 中的所有条件都为真,则认为检测到了 WAF。 if all(i for i in schema1): return True return False