Wfuzz使用教程#

软件介绍#

Wfuzz是一款功能强大的Web模糊测试工具,专注于自动化的Web应用漏洞发现。它不仅可以用于目录扫描,还可以用于参数模糊测试、认证测试等多种Web安全测试场景。

入门级使用#

基本目录扫描#

功能说明:使用默认设置扫描目标网站的目录和文件

使用示例

# 基本目录扫描
wfuzz -c -z file,/usr/share/wordlists/dirb/common.txt https://example.com/FUZZ

# 扫描多个URL
for url in https://example.com https://test.com; do wfuzz -c -z file,/usr/share/wordlists/dirb/common.txt $url/FUZZ; done

# 将结果输出到文件
wfuzz -c -z file,/usr/share/wordlists/dirb/common.txt https://example.com/FUZZ -o results.txt

# 从文件中读取URL列表
cat urls.txt | xargs -I {} wfuzz -c -z file,/usr/share/wordlists/dirb/common.txt {}FUZZ

参数说明

  • -c:彩色输出
  • -z:指定模糊测试参数
  • FUZZ:模糊测试占位符
  • -o:指定输出文件

简单的文件扩展名扫描#

功能说明:扫描带有特定文件扩展名的文件

使用示例

# 扫描PHP文件
wfuzz -c -z file,/usr/share/wordlists/dirb/common.txt https://example.com/FUZZ.php

# 扫描多种文件扩展名
wfuzz -c -z file,/usr/share/wordlists/dirb/common.txt -z list,php-html-asp https://example.com/FUZZ.FUZ2Z

# 扫描大字典
wfuzz -c -z file,/usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt https://example.com/FUZZ

# 扫描小字典(快速扫描)
wfuzz -c -z file,/usr/share/wordlists/dirb/small.txt https://example.com/FUZZ

参数说明

  • -z:指定模糊测试参数
  • FUZZ:第一个模糊测试占位符
  • FUZ2Z:第二个模糊测试占位符

初级使用#

扫描控制#

功能说明:控制扫描的行为和速度

使用示例

# 设置线程数
wfuzz -c -z file,/usr/share/wordlists/dirb/common.txt https://example.com/FUZZ --threads 50

# 设置请求延迟
wfuzz -c -z file,/usr/share/wordlists/dirb/common.txt https://example.com/FUZZ --delay 1

# 设置超时时间
wfuzz -c -z file,/usr/share/wordlists/dirb/common.txt https://example.com/FUZZ --conn-delay 10

# 设置最大重试次数
wfuzz -c -z file,/usr/share/wordlists/dirb/common.txt https://example.com/FUZZ --retries 3

# 限制扫描深度
wfuzz -c -z file,/usr/share/wordlists/dirb/common.txt https://example.com/FUZZ --depth 3

参数说明

  • --threads:设置线程数
  • --delay:设置请求延迟(秒)
  • --conn-delay:设置连接超时时间(秒)
  • --retries:设置最大重试次数
  • --depth:限制扫描深度

结果过滤#

功能说明:过滤和处理扫描结果

使用示例

# 仅显示特定状态码的结果
wfuzz -c -z file,/usr/share/wordlists/dirb/common.txt https://example.com/FUZZ --hc 404

# 排除特定状态码的结果
wfuzz -c -z file,/usr/share/wordlists/dirb/common.txt https://example.com/FUZZ --hc 404,403

# 最小响应大小过滤
wfuzz -c -z file,/usr/share/wordlists/dirb/common.txt https://example.com/FUZZ --ml 1000

# 最大响应大小过滤
wfuzz -c -z file,/usr/share/wordlists/dirb/common.txt https://example.com/FUZZ --mh 10000

# 仅显示有内容的响应
wfuzz -c -z file,/usr/share/wordlists/dirb/common.txt https://example.com/FUZZ -v

参数说明

  • --hc:隐藏特定的状态码
  • --ml:最小响应大小
  • --mh:最大响应大小
  • -v:详细输出

中级使用#

高级扫描选项#

功能说明:使用高级选项进行更深入的目录扫描

使用示例

# 启用递归扫描
wfuzz -c -z file,/usr/share/wordlists/dirb/common.txt https://example.com/FUZZ --sc 200 --follow

# 强制递归扫描
wfuzz -c -z file,/usr/share/wordlists/dirb/common.txt https://example.com/FUZZ --sc 200 --follow --depth 3

# 自定义请求方法
wfuzz -c -z file,/usr/share/wordlists/dirb/common.txt https://example.com/FUZZ -X POST

# 自定义用户代理
wfuzz -c -z file,/usr/share/wordlists/dirb/common.txt https://example.com/FUZZ -H "User-Agent: Mozilla/5.0"

# 启用跟随重定向
wfuzz -c -z file,/usr/share/wordlists/dirb/common.txt https://example.com/FUZZ --follow

参数说明

  • --sc:显示特定的状态码
  • --follow:跟随重定向
  • --depth:限制扫描深度
  • -X:设置请求方法
  • -H:设置自定义HTTP头

认证和会话#

功能说明:处理需要认证的网站

使用示例

# 基本认证
wfuzz -c -z file,/usr/share/wordlists/dirb/common.txt https://example.com/FUZZ --basic auth:password

# 使用cookie
wfuzz -c -z file,/usr/share/wordlists/dirb/common.txt https://example.com/FUZZ -b "session=abc123"

# 使用会话文件
wfuzz -c -z file,/usr/share/wordlists/dirb/common.txt https://example.com/FUZZ --session session.json

# 从浏览器导入cookie
wfuzz -c -z file,/usr/share/wordlists/dirb/common.txt https://example.com/FUZZ -b "$(cat cookie.txt)"

# 使用CSRF令牌
wfuzz -c -z file,/usr/share/wordlists/dirb/common.txt https://example.com/FUZZ -H "X-CSRF-Token: token123"

参数说明

  • --basic:设置基本认证凭据
  • -b:设置cookie
  • --session:使用会话文件
  • -H:设置自定义HTTP头

中上级使用#

绕过防护#

功能说明:绕过网站的安全防护措施

使用示例

# 启用随机用户代理
wfuzz -c -z file,/usr/share/wordlists/dirb/common.txt https://example.com/FUZZ --random-agent

# 设置请求延迟
wfuzz -c -z file,/usr/share/wordlists/dirb/common.txt https://example.com/FUZZ --delay 1

# 自定义请求头
wfuzz -c -z file,/usr/share/wordlists/dirb/common.txt https://example.com/FUZZ -H "X-Forwarded-For: 127.0.0.1" -H "Referer: https://google.com"

# 使用代理
wfuzz -c -z file,/usr/share/wordlists/dirb/common.txt https://example.com/FUZZ --proxy http://127.0.0.1:8080

# 使用SOCKS代理
wfuzz -c -z file,/usr/share/wordlists/dirb/common.txt https://example.com/FUZZ --proxy socks5://127.0.0.1:1080

# 禁用SSL验证
wfuzz -c -z file,/usr/share/wordlists/dirb/common.txt https://example.com/FUZZ --ssl -k

参数说明

  • --random-agent:使用随机用户代理
  • --delay:设置请求延迟(秒)
  • -H:设置自定义HTTP头
  • --proxy:使用代理
  • --ssl:启用SSL
  • -k:禁用SSL验证

自定义扫描#

功能说明:创建和使用自定义扫描配置

使用示例

# 使用自定义配置文件
wfuzz -c -z file,/usr/share/wordlists/dirb/common.txt https://example.com/FUZZ --config config.ini

# 自定义搜索模式
wfuzz -c -z file,/usr/share/wordlists/dirb/common.txt -z list,php-html https://example.com/FUZZ.FUZ2Z

# 扫描特定路径
wfuzz -c -z file,/usr/share/wordlists/dirb/common.txt https://example.com/admin/FUZZ

# 多线程深度扫描
wfuzz -c -z file,/usr/share/wordlists/dirb/common.txt https://example.com/FUZZ --threads 30 --follow

# 组合多种技术
wfuzz -c -z file,/usr/share/wordlists/dirb/common.txt -z list,php-html-asp https://example.com/FUZZ.FUZ2Z --threads 30 --follow -o detailed_results.txt

参数说明

  • --config:使用自定义配置文件
  • -z:指定模糊测试参数
  • FUZZ:第一个模糊测试占位符
  • FUZ2Z:第二个模糊测试占位符
  • --threads:设置线程数
  • --follow:跟随重定向
  • -o:指定输出文件

高级使用#

大规模扫描#

功能说明:处理大规模的目录扫描任务

使用示例

# 批量扫描多个网站
cat urls.txt | xargs -I {} wfuzz -c -z file,/usr/share/wordlists/dirb/common.txt {}FUZZ -o batch_results.txt

# 分布式扫描(使用多个实例)
# 实例1
head -n 50 urls.txt | xargs -I {} wfuzz -c -z file,/usr/share/wordlists/dirb/common.txt {}FUZZ -o results1.txt
# 实例2
tail -n 50 urls.txt | xargs -I {} wfuzz -c -z file,/usr/share/wordlists/dirb/common.txt {}FUZZ -o results2.txt

# 合并结果
cat results1.txt results2.txt | sort -u > final_results.txt

# 增量扫描
wfuzz -c -z file,new_wordlist.txt https://example.com/FUZZ -o incremental_results.txt

参数说明

  • -z:指定模糊测试参数
  • FUZZ:模糊测试占位符
  • -o:指定输出文件

结果分析#

功能说明:分析和处理扫描结果

使用示例

# 统计发现的文件和目录
wfuzz -c -z file,/usr/share/wordlists/dirb/common.txt https://example.com/FUZZ --sc 200 | wc -l

# 过滤特定状态码的结果
wfuzz -c -z file,/usr/share/wordlists/dirb/common.txt https://example.com/FUZZ --sc 200,301

# 提取完整URL
wfuzz -c -z file,/usr/share/wordlists/dirb/common.txt https://example.com/FUZZ --sc 200 | grep -E "[0-9]+\.\.[0-9]+" | awk -F' ' '{print $3}' > valid_urls.txt

# 与其他工具结合使用
cat valid_urls.txt | xargs -I {} nmap -sV {}

# 验证发现的文件是否可访问
cat valid_urls.txt | xargs -I {} curl -m 2 {}

参数说明

  • --sc:显示特定的状态码
  • 结合shell命令和其他工具进行结果分析

大师级使用#

自定义插件和脚本#

功能说明:创建和使用自定义插件和脚本

使用示例

# 自定义Python脚本处理结果
#!/usr/bin/env python3

import subprocess
import re

result = subprocess.run(
    ['wfuzz', '-c', '-z', 'file,/usr/share/wordlists/dirb/common.txt', 'https://example.com/FUZZ', '--sc', '200'],
    capture_output=True,
    text=True
)

for line in result.stdout.split('\n'):
    if re.search(r'\d+\.\.\d+', line):
        url = re.search(r'https?://[^\s]+', line).group(0)
        print(f'Found: {url}')

# 批量扫描脚本
#!/bin/bash

while read url; do
    echo "Scanning: $url"
    wfuzz -c -z file,/usr/share/wordlists/dirb/common.txt "$url/FUZZ" -o "results_$(echo $url | sed 's/\///g').txt"
done < urls.txt

# 结果汇总脚本
#!/bin/bash

for file in results_*.txt; do
    if [[ $file != "results.txt" ]]; then
        echo "Processing: $file"
        grep -E "200 OK|301 Moved Permanently|302 Found" "$file" >>汇总结果.txt
    fi
done

参数说明

  • 使用自定义脚本处理Wfuzz的结果

高级扫描策略#

功能说明:使用高级策略进行更有效的目录扫描

使用示例

# 多阶段扫描策略
# 第一阶段:快速扫描(小字典)
wfuzz -c -z file,/usr/share/wordlists/dirb/common.txt https://example.com/FUZZ --threads 50 -o fast_scan.txt

# 第二阶段:深度扫描(大字典)
wfuzz -c -z file,/usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt https://example.com/FUZZ --threads 20 -o deep_scan.txt

# 第三阶段:定向扫描(针对特定路径)
wfuzz -c -z file,/usr/share/wordlists/dirb/common.txt https://example.com/admin/FUZZ --threads 30 -o admin_scan.txt

# 智能扫描策略
# 1. 先扫描常见目录
wfuzz -c -z file,/usr/share/wordlists/dirb/common.txt https://example.com/FUZZ -o common_scan.txt

# 2. 基于发现的目录进行递归扫描
wfuzz -c -z file,/usr/share/wordlists/dirb/common.txt https://example.com/FUZZ --follow -o recursive_scan.txt

# 3. 针对发现的文件类型进行专门扫描
wfuzz -c -z file,/usr/share/wordlists/dirb/common.txt -z list,sql-backup-log https://example.com/FUZZ.FUZ2Z -o backup_scan.txt

参数说明

  • -z:指定模糊测试参数
  • FUZZ:第一个模糊测试占位符
  • FUZ2Z:第二个模糊测试占位符
  • --threads:设置线程数
  • --follow:跟随重定向
  • -o:指定输出文件

实战案例#

案例1:网站安全评估#

任务:评估目标网站的目录结构和潜在安全问题

执行步骤

  1. 基本扫描

    wfuzz -c -z file,/usr/share/wordlists/dirb/common.txt https://target.com/FUZZ -o initial_scan.txt
  2. 深度扫描

    wfuzz -c -z file,/usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt https://target.com/FUZZ --threads 30 --follow -o deep_scan.txt
  3. 敏感目录扫描

    wfuzz -c -z file,/usr/share/wordlists/dirb/common.txt https://target.com/FUZZ --sc 200 -o sensitive_scan.txt
  4. 结果分析

    # 过滤敏感文件和目录
    grep -E "backup|admin|config|db|log" deep_scan.txt > sensitive_findings.txt
    
    # 验证发现的内容
    grep -E "https?://[^\s]+" sensitive_findings.txt | xargs -I {} curl -I {}

案例2:漏洞挖掘前的信息收集#

任务:在漏洞挖掘前收集目标网站的详细信息

执行步骤

  1. 多轮扫描

    # 第一轮:常见目录
    wfuzz -c -z file,/usr/share/wordlists/dirb/common.txt https://target.com/FUZZ -o round1.txt
    
    # 第二轮:更多扩展名
    wfuzz -c -z file,/usr/share/wordlists/dirb/common.txt -z list,php-html-asp-aspx-jsp https://target.com/FUZZ.FUZ2Z -o round2.txt
    
    # 第三轮:递归扫描
    wfuzz -c -z file,/usr/share/wordlists/dirb/common.txt https://target.com/FUZZ --follow -o round3.txt
  2. 合并和去重

    cat round1.txt round2.txt round3.txt | sort -u > all_findings.txt
  3. 重点分析

    # 查找可能的漏洞点
    grep -E "upload|admin|config|backup|test|dev" all_findings.txt > potential_vulns.txt
    
    # 检查是否存在敏感文件
    grep -E "\.sql|\.bak|\.zip|\.tar|\.gz|\.log" all_findings.txt > sensitive_files.txt

总结#

Wfuzz是一款功能强大的Web模糊测试工具,专注于自动化的Web应用漏洞发现。通过本教程的学习,您应该能够:

  1. 入门级:掌握基本的目录扫描和简单的文件扩展名扫描
  2. 初级:了解扫描控制和结果过滤
  3. 中级:使用高级扫描选项和处理认证
  4. 中上级:掌握绕过防护和自定义扫描
  5. 高级:进行大规模扫描和结果分析
  6. 大师级:使用自定义插件和脚本,以及高级扫描策略

Wfuzz的优势在于其灵活性和多功能性,不仅可以用于目录扫描,还可以用于多种Web安全测试场景。在实际使用中,Wfuzz常常与其他安全工具结合使用,以实现更全面的Web应用安全评估。