πŸ‘¨β€πŸ’»
Jawad's Notes
  • πŸ‘¨β€πŸ«INFOSEC
    • πŸ•ΈοΈWeb
      • Burp Suite: Setting Foxyproxy
      • XSS
      • Wappalyzer
      • Directory Traversal
      • LFI
        • PHP Wrappers
        • RFI
      • Reverse Shell
        • Command Injection Quick Tips
      • File Upload
      • WPScan
      • SQL Injection
        • Schemas
        • SQLmap
        • MSSQL
        • MySQL
        • PostgreSQL
    • πŸ”§Tools
      • Whois
      • DNSRecon
      • DNSenum
      • nslookup
      • Netcat
        • Powercat
      • Nmap
        • Nmap Scripting Engine
        • Test-NetConnection
        • Grep
      • Server Message Block (SMB)
      • SNMP
      • SMTP
      • ExifTool
      • Search Engine Hacking
      • Source Control Hacking
      • Nessus
      • Canarytokens
      • Qualys SSL Server Test
      • Security Headers
      • theHarvester
      • Shodan
      • Gobuster
        • Dirb
      • Searchsploit
      • Password Cracking
        • Hashcat
        • John The Ripper
        • Hydra
        • hashID
        • CPU vs GPU
    • 🐧Linux
      • Symbols
      • cat
      • curl
      • openvpn
      • tcpdump
      • Remote Desktop
      • SmbShare
      • Tmux
      • Convert Windows-style line endings (CRLF) to Unix-style (LF)
      • SSH
    • πŸ–₯️Macros in Office
    • 🍎Enhancing Your MacOS Terminal Experience
    • 🚩CTF
      • SQL Injection
        • WHERE clause allowing retrieval of hidden data
        • Allowing login bypass
        • UNION attack, determining the number of columns returned by the query
        • UNION attack, finding a column containing text
        • UNION attack, retrieving data from other tables
        • UNION attack, retrieving multiple values in a single column
        • Querying the database type and version on Oracle
Powered by GitBook
On this page
  1. INFOSEC
  2. Web
  3. LFI

PHP Wrappers

PHP Wrappers are powerful tools in PHP that modify how file operations are handled, often exploited in LFI attacks to execute or disclose code.

How PHP Wrappers Work in LFI

  • Serve as a layer that interprets file streams in various ways, allowing attackers to manipulate file handling in PHP.

  • Exploited in file inclusion functions (include, require) to fetch or transform file data in malicious ways.

Common PHP Wrappers and Usage Examples

  • php://filter: Converts file data through filters. Attackers use it to read PHP files in base64 encoding.

    • Example: include('php://filter/read=convert.base64-encode/resource=index.php');

  • php://input: Reads raw data from the request body, used to execute code by including php://input and sending code in the request body.

    • Example: include('php://input'); and POSTing PHP code.

  • php://memory and php://temp: Allow access to read/write temporary data streams. Can be used to execute transient code that doesn't leave traces on the disk.

  • data://: Allows inclusion of inline data. Can be exploited to execute arbitrary data as code.

    • Example: include('data://text/plain;base64,SGVsbG8sIFdvcmxkIQ==');

Mitigation Strategies

  • Disable Dangerous Wrappers: Configure php.ini to disallow certain wrappers (e.g., php://filter, php://input) if they are not required.

  • Input Validation: Implement rigorous input validation to reject wrapper syntax or unexpected patterns.

  • Use of allow_url_include: Set allow_url_include to Off in php.ini to prevent the inclusion of files from remote locations.

PreviousLFINextRFI

Last updated 1 year ago

πŸ‘¨β€πŸ«
πŸ•ΈοΈ