Zeus-Scanner/lib/firewall/cloudflare.py

24 lines
802 B
Python

import re
from lib.core.common import HTTP_HEADER
__item__ = "CloudFlare Web Application Firewall (CloudFlare)"
def detect(content, **kwargs):
headers = kwargs.get("headers", None)
content = str(content)
detection_schemas = (re.compile(r"CloudFlare Ray ID:|var CloudFlare=", re.I),)
for detection in detection_schemas:
if detection.search(content) is not None:
return True
try:
if re.compile(r"cloudflare-nginx", re.I).search(headers.get(HTTP_HEADER.SERVER)) is not None:
return True
if re.compile(r"\A__cfduid=", re.I).search(headers.get(HTTP_HEADER.COOKIE)) is not None:
return True
if re.compile(r"CF_RAY", re.I).search(str(headers)) is not None:
return True
except Exception:
pass