Refactoring WAF scripts

This commit is contained in:
stamparm
2013-02-26 15:54:50 +01:00
parent e5835dc74f
commit be50192d8d
13 changed files with 115 additions and 45 deletions

View File

@@ -8,12 +8,18 @@ See the file 'doc/COPYING' for copying permission
import re
from lib.core.enums import HTTPHEADER
from lib.core.settings import WAF_ATTACK_VECTORS
__product__ = "BinarySEC Web Application Firewall (BinarySEC)"
def detect(get_page):
page, headers, code = get_page()
retval = re.search(r"BinarySec", headers.get(HTTPHEADER.SERVER, ""), re.I) is not None
if not retval:
retval = False
for vector in WAF_ATTACK_VECTORS:
page, headers, code = get_page(get=vector)
retval = any(headers.get(_) for _ in ("x-binarysec-via", "x-binarysec-nocache"))
retval |= re.search(r"BinarySec", headers.get(HTTPHEADER.SERVER, ""), re.I) is not None
if retval:
break
return retval