You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
MiaCTFer/client-1/webinfo/wafw00f/plugins/cloudfront.py

28 lines
1.4 KiB

2 months ago
#!/usr/bin/env python
'''
Copyright (C) 2020, WAFW00F Developers.
See the LICENSE file for copying permission.
'''
NAME = 'Cloudfront (Amazon)'
def is_waf(self):
# 定义用于检测是否存在特定 Web 应用防火墙WAF的方案列表。
schemes = [
# 这是标准的检测方案,检查响应头中的 'Server' 字段是否为 'Cloudfront'。
self.matchHeader(('Server', 'Cloudfront')),
# 发现一些样本返回特定格式的 'Via' 头,如 'Via: 1.1 58bfg7h6fg76h8fg7jhdf2.cloudfront.net (CloudFront)'。
self.matchHeader(('Via', r'([0-9\.]+?)? \w+?\.cloudfront\.net \(Cloudfront\)')),
# 请求令牌随这个头一起发送,例如:'X-Amz-Cf-Id: sX5QSkbAzSwd-xx3RbJmxYHL3iVNNyXa1UIebDNCshQbHxCjVcWDww=='。
self.matchHeader(('X-Amz-Cf-Id', '.+?'), attack=True),
# 这是在响应头中发现的另一个可靠指纹,检查 'X-Cache' 头是否为 'Error from Cloudfront'。
self.matchHeader(('X-Cache', 'Error from Cloudfront'), attack=True),
# 这些指纹在拦截页面上找到,检查响应内容中是否包含特定字符串,表示由 cloudfrontCloudFront生成。
self.matchContent(r'Generated by cloudfront \(CloudFront\)')
]
# 如果方案列表中的任何一个方案为真,则认为检测到了 WAF。
if any(i for i in schemes):
return True
else:
return False