Mohammad Abd El-Fattah Mohammad
Cybersecurity & AI Engineer
Open to opportunities

Offensive Security

PathTraversalChecker

Python script that tries encoded and plain payloads on a URL parameter and prints a summary of the ones that worked. (README)

By Mohammad Abd El-Fattah Mohammad · 2 min read

PathTraversalChecker

This script checks for path traversal vulnerabilities in a given URL by testing various payloads. It prints the results in green if a vulnerability is found and in red if not. At the end, it provides a summary of the total vulnerabilities found and the payloads that worked.

LIVE

Prerequisites

  • Python 3.x
  • requests library
  • colorama library

You can install the required libraries using pip:

pip install requests colorama | pip install requests

Usage

Run the script from the terminal and pass the URL as a command-line argument:

python Path_Traversal_Checker.py <url>

Example:

python Path_Traversal_Checker.py https://example.com/image?filename

Script Details

The script performs the following steps:

  • Parse the URL: Identifies potential entry points in the URL query parameters.
  • Payloads: Uses a comprehensive list of payloads (both encoded and unencoded) to test for path traversal vulnerabilities.
  • Send Requests: Constructs request URLs with the payloads and sends them to the target URL.
  • Analyze Responses: Checks the response for indicators of a successful path traversal attack (e.g., presence of “root:x:” or “boot loader”).
  • Print Results: Outputs the results in green if a vulnerability is found and in red if not.
  • Summary: Prints a summary of the total vulnerabilities found and the payloads that worked.
Example Output
Testing URL: https://example.com/image?filename=../../../etc/passwd
No vulnerability found with payload: ../../../etc/passwd
Testing URL: https://example.com/image?filename=../../../../../etc/passwd
Vulnerability found with payload: ../../../../../etc/passwd

Summary:
Total vulnerabilities found: 1
Payloads that worked:
../../../../../etc/passwd

Final Summary:
Total Payloads that worked: 1
Payloads that worked:
../../../../../etc/passwd

Notes

  • Ensure you have permission to test the target URL for vulnerabilities.
  • The script checks for specific strings in the response that are commonly found in sensitive files. Adjust the indicators as needed for your specific use case.

License

  • This project is licensed under the MIT License.

Source file in my repo: README.md