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: disallow stub and alias setting via offset*() methods --EXTENSIONS-- phar -..
Decoded Output download
--TEST--
Phar: disallow stub and alias setting via offset*() methods
--EXTENSIONS--
phar
--INI--
phar.readonly=0
phar.require_hash=1
--FILE--
<?php
$fname = __DIR__ . '/' . basename(__FILE__, '.php') . '.phar.php';
$pname = 'phar://'.$fname;
$phar = new Phar($fname);
$phar->setDefaultStub();
$phar->setAlias('susan');
$phar['a.txt'] = "first file
";
$phar['b.txt'] = "second file
";
try {
$phar->offsetGet('.phar/stub.php');
} catch (Exception $e) {
echo $e->getMessage()."
";
}
try {
$phar->offsetGet('.phar/alias.txt');
} catch (Exception $e) {
echo $e->getMessage()."
";
}
try {
$phar->offsetSet('.phar/stub.php', '<?php __HALT_COMPILER(); ?>');
} catch (Exception $e) {
echo $e->getMessage()."
";
}
var_dump(strlen($phar->getStub()));
try {
$phar->offsetUnset('.phar/stub.php');
} catch (Exception $e) {
echo $e->getMessage()."
";
}
var_dump(strlen($phar->getStub()));
try {
$phar->offsetSet('.phar/alias.txt', 'dolly');
} catch (Exception $e) {
echo $e->getMessage()."
";
}
var_dump($phar->getAlias());
try {
$phar->offsetUnset('.phar/alias.txt');
} catch (Exception $e) {
echo $e->getMessage()."
";
}
var_dump($phar->getAlias());
?>
--CLEAN--
<?php unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
--EXPECTF--
Entry .phar/stub.php does not exist
Entry .phar/alias.txt does not exist
Cannot set stub ".phar/stub.php" directly in phar "%sphar_offset_check.phar.php", use setStub
int(6643)
int(6643)
Cannot set alias ".phar/alias.txt" directly in phar "%sphar_offset_check.phar.php", use setAlias
string(5) "susan"
string(5) "susan"
Did this file decode correctly?
Original Code
--TEST--
Phar: disallow stub and alias setting via offset*() methods
--EXTENSIONS--
phar
--INI--
phar.readonly=0
phar.require_hash=1
--FILE--
<?php
$fname = __DIR__ . '/' . basename(__FILE__, '.php') . '.phar.php';
$pname = 'phar://'.$fname;
$phar = new Phar($fname);
$phar->setDefaultStub();
$phar->setAlias('susan');
$phar['a.txt'] = "first file\n";
$phar['b.txt'] = "second file\n";
try {
$phar->offsetGet('.phar/stub.php');
} catch (Exception $e) {
echo $e->getMessage()."\n";
}
try {
$phar->offsetGet('.phar/alias.txt');
} catch (Exception $e) {
echo $e->getMessage()."\n";
}
try {
$phar->offsetSet('.phar/stub.php', '<?php __HALT_COMPILER(); ?>');
} catch (Exception $e) {
echo $e->getMessage()."\n";
}
var_dump(strlen($phar->getStub()));
try {
$phar->offsetUnset('.phar/stub.php');
} catch (Exception $e) {
echo $e->getMessage()."\n";
}
var_dump(strlen($phar->getStub()));
try {
$phar->offsetSet('.phar/alias.txt', 'dolly');
} catch (Exception $e) {
echo $e->getMessage()."\n";
}
var_dump($phar->getAlias());
try {
$phar->offsetUnset('.phar/alias.txt');
} catch (Exception $e) {
echo $e->getMessage()."\n";
}
var_dump($phar->getAlias());
?>
--CLEAN--
<?php unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
--EXPECTF--
Entry .phar/stub.php does not exist
Entry .phar/alias.txt does not exist
Cannot set stub ".phar/stub.php" directly in phar "%sphar_offset_check.phar.php", use setStub
int(6643)
int(6643)
Cannot set alias ".phar/alias.txt" directly in phar "%sphar_offset_check.phar.php", use setAlias
string(5) "susan"
string(5) "susan"
Function Calls
None |
Stats
MD5 | 60f02ab4bb59bdf4b4a89845f3b93815 |
Eval Count | 0 |
Decode Time | 86 ms |