How night-have-dreams/php-cgi-injector works
Project type and purpose
• This is a CLI-based penetration-testing tool (a Python exploit framework) for automating PHP-CGI parameter-injection attacks (CVE-2024-4577 & CVE-2024-8926).
• It provides an interactive terminal UI, payload management, WAF bypass plugin system, Tor integration, file upload/download, logging, and detailed/force modes.
File structure
• Top-level scripts:
• banner.py – ASCII/intro UI
• exploit.py – main orchestration (CLI parser → exploit engine → interaction loop)
• bypass_manager.py – loads and orchestrates bypass modules
• tor_helper.py – encapsulates Tor session setup
• requirements.txt – library deps (requests, requests-tor, rich, etc.)
• tamper_example_template.txt – template for custom bypass scripts
• Directory “bypass_modules/”: each tamper_*.py is a plugin that mutates or obfuscates payloads or headers.
• README.md provides command-line options, modes, features, and the plugin model.
README for additional insights
• CLI flags control target URL, timeouts, delays, verbosity, Tor, bypass, force-mode, CGI endpoints.
• After detecting a vulnerability, the user enters an interactive exploit menu with modes: shell, custom PHP, upload, download, target switch, parameter settings.
• Bypass modules implement various WAF evasion strategies.
a. Main components to represent:
1) User / CLI Interface
2) Argument Parser & Controller (exploit.py)
3) Exploit Engine / Workflow Manager
4) HTTP Request Handler (with or without Tor)
5) Bypass Manager & Tamper Modules (plugin layer)
6) Payload Manager (predefined + custom combos)
7) Response Processor & Interactive Menu
8) File I/O (download/, log files)
9) External Components: Target PHP-CGI server, Tor network
10) Utility Modules: banner.py, tor_helper.py
b. Relationships and interactions:
• User issues CLI command → Argument Parser sets flags.
• Controller invokes Exploit Engine.
• For each request, Exploit Engine calls Bypass Manager to apply active tamper modules to payload and headers.
• Request Handler sends HTTP(s) to the target (directly or via tor_helper).
• Response returns to Response Processor, which dispatches to the interactive menu or logging subsystem.
• In upload/download modes, File I/O reads/writes to local FS.
• Payload Manager feeds payload templates or user-provided code into the engine.
c. Architectural patterns and design principles:
• Plugin architecture: bypass modules drop-in under bypass_modules/ and are discovered/loaded dynamically.
• Separation of concerns: CLI parsing, engine logic, HTTP transport, tampering, UI.
• Modular extensibility: new bypass scripts via template.
• Utility layering: tor_helper abstracts Tor vs. direct requests.
d. Key technologies and libraries:
• Python 3.x
• requests, urllib3 for HTTP
• requests-tor for Tor integration
• rich for terminal UI/animations
• chardet for encoding detection