crazymarky/pentest-skills/exploit-lfi
Claude Code and agent skill by crazymarky/pentest-skills
Trust tier 2
- community
Source check pending
Checking that the SKILL.md file is still in the repository.
本地文件包含 (LFI) 漏洞检测和利用工具。使用 curl、ffuf 等工具测试 LFI 漏洞,支持路径遍历、PHP 伪协议利用、日志投毒 RCE、敏感文件读取。当用户需要检测 LFI 漏洞、利用文件包含漏洞读取服务器文件时使用此技能。
Install
npx vskill@latest install crazymarky/pentest-skills/exploit-lfiSKILL.md
本地文件包含 (LFI) 检测和利用
概述
本 Skill 专注于本地文件包含 (LFI) 类型漏洞的检测与利用。
LFI 漏洞发生在应用程序将用户输入直接用作文件路径或在未正确验证的情况下包含文件时。攻击者可通过路径遍历或伪协议读取敏感文件、执行任意代码。
与 exploit-file-download 的区别:
- LFI: 参数值被 include() 或保存为文件内容,危害=代码执行 (RCE)
- 文件下载: 参数值用于下载文件到本地,危害=信息泄露
核心功能
1. LFI 漏洞检测
自动识别以下 LFI 特征:
- 参数模式识别:
file、page、include、dir、document、path、content、title等 - 文件包含模式: 参数值被直接用作
include()或require()的文件路径 - 目录遍历模式:
../序列用于遍历目录 - 伪协议利用:
php://filter、php://input、data:、expect://等 - 响应特征分析: 识别 Linux/Windows 文件内容特征
2. 操作系统自动检测
测试时自动识别目标 OS:
| OS | 特征文件 | 测试路径 | |
|---|---|---|---|
| Linux | /etc/passwd 内容:root:x:0:0: | /etc/passwd, /etc/shadow | |
| Windows | C:\Windows\win.ini 内容:[fonts], [extensions] | C:\Windows\win.ini, C:\Windows\System32\drivers\etc\hosts |
3. 常见 LFI Payload
| 类型 | Payload | 适用场景 | |
|---|---|---|---|
| 路径遍历 | ?title=../../../etc/passwd | 基础目录遍历 | |
| 伪协议读取 | ?file=php://filter/convert.base64-encode/resource=/etc/passwd | 读取敏感文件源码 | |
| 数据注入 | ?file=data://text/plain;base64,PD9waHAgc3l... | 代码注入 | |
| 命令执行 | ?file=expect://ls | RCE(需 expect 扩展) |
4. LFI 利用场景
- 源码读取: 使用
php://filter读取 PHP 源码进行分析 - 配置获取: 读取数据库配置文件获取凭证
- 日志投毒: 通过 LFI 写入日志获取 RCE
- 临时文件: 配合文件上传 getshell
- /proc/self/environ: 通过环境变量注入实现 RCE
工具安装
必备工具
使用方式
快速开始
常见测试场景
1. 基础路径遍历
2. 伪协议利用
3. 日志投毒 RCE
4. /proc/self/environ 利用
5. 临时文件竞争
工具选择指南
| 场景 | 推荐工具 | 命令示例 | |
|---|---|---|---|
| 快速单点测试 | curl | curl "URL?file=../etc/passwd" | |
| 批量 Payload 测试 | ffuf | ffuf -u URL -w payloads.txt | |
| 深度测试 | 自定义脚本 | 见下方深度测试脚本 | |
| 响应分析 | grep/diff | grep -i "root:x:0" response.txt |
深度测试脚本
测试清单
侦察阶段
- [ ] 识别所有可能存在 LFI 的参数(file, page, title, include 等)
- [ ] 测试基础路径遍历(../)
- [ ] 确认目标操作系统(Linux/Windows)
- [ ] 测试伪协议可用性(php://filter)
利用阶段
- [ ] 读取系统敏感文件(/etc/passwd, /etc/shadow)
- [ ] 读取 Web 应用配置文件(.env, config.php)
- [ ] 读取 PHP 源码分析应用逻辑
- [ ] 尝试日志投毒获取 RCE
- [ ] 尝试/proc/self/environ 利用
- [ ] 尝试临时文件竞争利用
绕过测试
- [ ] URL 编码绕过(%2e%2e%2f)
- [ ] 双重 URL 编码(%252e%252e%252f)
- [ ] Unicode 混淆(%c0%ae%c0%ae%c0%af)
- [ ] 路径变体(..\, ..//, ..././)
- [ ] 空字节截断(%00)
- [ ] 扩展名绕过(file.php.jpg, file.php.)
敏感文件路径
Linux
Windows
LFI Payload 清单
基础 Payload
编码 Payload
PHP 伪协议
替代方案
如果主要工具不可用,可以使用以下替代方案:
| 主要工具 | 替代方案 | 说明 | |
|---|---|---|---|
| curl | wget | wget -qO- "URL" 等同于curl -s "URL" | |
| ffuf | gobuster | gobuster dir -u URL -w payloads.txt | |
| ffuf | dirsearch | dirsearch -u URL -e php |
参考资料
- 技术文档:
references/lfi_techniques.md- LFI 完整技术详解 - PHP 伪协议:
references/php_wrappers.md- PHP wrapper 参考 - 绕过技术:
references/bypass_techniques.md- 编码和过滤绕过 - RCE 方法:
references/rce_methods.md- 远程代码执行汇总
与 results-storage 集成
发现 LFI 漏洞后,可以存储到数据库:
数据库位置: ./data/results.db
相关技能: results-storage - 查询数据、生成报告
最佳实践
- 始终编码 Payload - 使用 URL 编码避免被 WAF 拦截
- 从浅到深测试 - 先测试 1-2 层遍历,再逐步加深
- 记录响应长度 - 成功响应通常长度异常
- 使用 base64 - 读取源码时用 base64 避免代码执行
- 不要忽略 403/404 - 有些 WAF 返回假错误码
授权声明
本 Skill 仅用于授权安全测试。使用前请确保:
- 获得目标系统所有者的明确书面授权
- 测试范围和授权内容已明确定义
- 遵守当地法律法规
未经授权的渗透测试是非法行为。
最后更新: 2026-03-05 版本: 2.0
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingexploit-lfi/SKILL.md
Popularity
- Repository stars
- 216
- Repository forks
- 26
- 7-day trend score
- 27
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/crazymarky/pentest-skills/exploit-lfi)