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/cachewall.py

32 lines
1.4 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#!/usr/bin/env python
'''
Copyright (C) 2020, WAFW00F Developers.
See the LICENSE file for copying permission.
'''
NAME = 'CacheWall (Varnish)'
def is_waf(self):
# 定义用于检测是否存在特定 Web 应用防火墙WAF的方案列表。
schemes = [
# 检查响应头中的 'Server' 字段是否为 'Varnish'。
self.matchHeader(('Server', 'Varnish')),
# 检查响应头中是否存在 'X-Varnish' 字段且其值不为空。
self.matchHeader(('X-Varnish', '.+')),
# 检查响应头中是否存在 'X-Cachewall-Action' 字段且其值不为空。
self.matchHeader(('X-Cachewall-Action', '.+?')),
# 检查响应头中是否存在 'X-Cachewall-Reason' 字段且其值不为空。
self.matchHeader(('X-Cachewall-Reason', '.+?')),
# 检查响应内容中是否包含特定字符串,表示由 'cachewall' 提供安全防护。
self.matchContent(r'security by cachewall'),
# 检查响应内容中是否包含特定字符串,包含 '403 naughty' 和后续一些字符,如 'not nice!'。
self.matchContent(r'403 naughty.{0,10}?not nice!'),
# 检查响应内容中是否包含特定字符串,表示是 'varnish cache server'。
self.matchContent(r'varnish cache server')
]
# 如果方案列表中的任何一个方案为真,则认为检测到了 WAF。
if any(i for i in schemes):
return True
else:
return False