2017-11-13 01:13:00 +00:00
|
|
|
import re
|
|
|
|
|
|
2017-11-20 17:43:27 +00:00
|
|
|
from lib.core.common import HTTP_HEADER
|
|
|
|
|
|
2017-11-13 01:13:00 +00:00
|
|
|
|
|
|
|
|
__item__ = "CloudFlare Web Application Firewall (CloudFlare)"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def detect(content, **kwargs):
|
|
|
|
|
headers = kwargs.get("headers", None)
|
|
|
|
|
content = str(content)
|
2017-11-27 19:09:53 +00:00
|
|
|
detection_schemas = (
|
|
|
|
|
re.compile(r"CloudFlare Ray ID:|var CloudFlare=", re.I),
|
|
|
|
|
re.compile(r"cloudflare-nginx", re.I),
|
|
|
|
|
re.compile(r"\A__cfduid=", re.I),
|
|
|
|
|
re.compile(r"CF_RAY", re.I)
|
|
|
|
|
)
|
2017-11-13 01:13:00 +00:00
|
|
|
for detection in detection_schemas:
|
|
|
|
|
if detection.search(content) is not None:
|
|
|
|
|
return True
|
2017-11-27 19:09:53 +00:00
|
|
|
elif detection.search(headers.get(HTTP_HEADER.SERVER, "")) is not None:
|
2017-11-13 01:13:00 +00:00
|
|
|
return True
|
2017-11-27 19:09:53 +00:00
|
|
|
elif detection.search(headers.get(HTTP_HEADER.COOKIE, "")) is not None:
|
2017-11-13 01:13:00 +00:00
|
|
|
return True
|
2017-11-27 19:09:53 +00:00
|
|
|
elif detection.search(str(headers)) is not None:
|
2017-11-14 22:07:26 +00:00
|
|
|
return True
|