Find this useful? Enter your email to receive occasional updates for securing PHP code.
Signing you up...
Thank you for signing up!
PHP Decode
--TEST-- Phar: opendir test, recurse into --EXTENSIONS-- phar --INI-- phar.require_hash=0 ..
Decoded Output download
--TEST--
Phar: opendir test, recurse into
--EXTENSIONS--
phar
--INI--
phar.require_hash=0
--FILE--
<?php
$fname = __DIR__ . '/' . basename(__FILE__, '.php') . '.phar.php';
$pname = 'phar://' . $fname;
$file = "<?php
Phar::mapPhar('hio');
__HALT_COMPILER(); ?>";
$files = array();
$files['a'] = 'a';
$files['b/a'] = 'b';
$files['b/c/d'] = 'c';
$files['bad/c'] = 'd';
include 'files/phar_test.inc';
include $fname;
function dump($phar, $base)
{
var_dump($phar . $base);
$dir = opendir($phar . $base);
if ($base == '/')
{
$base = '';
}
while (false !== ($entry = readdir($dir))) {
$entry = $base . '/' . $entry;
var_dump($entry);
var_dump(is_dir($phar . $entry));
if (is_dir($phar . $entry))
{
dump($phar, $entry);
}
}
}
dump('phar://hio', '/');
?>
--CLEAN--
<?php unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
--EXPECT--
string(11) "phar://hio/"
string(2) "/a"
bool(false)
string(2) "/b"
bool(true)
string(12) "phar://hio/b"
string(4) "/b/a"
bool(false)
string(4) "/b/c"
bool(true)
string(14) "phar://hio/b/c"
string(6) "/b/c/d"
bool(false)
string(4) "/bad"
bool(true)
string(14) "phar://hio/bad"
string(6) "/bad/c"
bool(false)
Did this file decode correctly?
Original Code
--TEST--
Phar: opendir test, recurse into
--EXTENSIONS--
phar
--INI--
phar.require_hash=0
--FILE--
<?php
$fname = __DIR__ . '/' . basename(__FILE__, '.php') . '.phar.php';
$pname = 'phar://' . $fname;
$file = "<?php
Phar::mapPhar('hio');
__HALT_COMPILER(); ?>";
$files = array();
$files['a'] = 'a';
$files['b/a'] = 'b';
$files['b/c/d'] = 'c';
$files['bad/c'] = 'd';
include 'files/phar_test.inc';
include $fname;
function dump($phar, $base)
{
var_dump($phar . $base);
$dir = opendir($phar . $base);
if ($base == '/')
{
$base = '';
}
while (false !== ($entry = readdir($dir))) {
$entry = $base . '/' . $entry;
var_dump($entry);
var_dump(is_dir($phar . $entry));
if (is_dir($phar . $entry))
{
dump($phar, $entry);
}
}
}
dump('phar://hio', '/');
?>
--CLEAN--
<?php unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
--EXPECT--
string(11) "phar://hio/"
string(2) "/a"
bool(false)
string(2) "/b"
bool(true)
string(12) "phar://hio/b"
string(4) "/b/a"
bool(false)
string(4) "/b/c"
bool(true)
string(14) "phar://hio/b/c"
string(6) "/b/c/d"
bool(false)
string(4) "/bad"
bool(true)
string(14) "phar://hio/bad"
string(6) "/bad/c"
bool(false)
Function Calls
None |
Stats
MD5 | e622ec5ca508af8be11e46e1656deb23 |
Eval Count | 0 |
Decode Time | 85 ms |