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::setStub()/getStub() zip-based --EXTENSIONS-- phar --INI-- phar.require_hash..

Decoded Output download

--TEST--
Phar::setStub()/getStub() zip-based
--EXTENSIONS--
phar
--INI--
phar.require_hash=0
phar.readonly=0
--FILE--
<?php

$fname = __DIR__ . '/' . basename(__FILE__, '.php') . '.phar.zip';

$phar = new Phar($fname);
$phar->setStub($stub = '<?php echo "first stub
"; __HALT_COMPILER(); ?>' . "
");
$phar->setAlias('hio');
$phar['a'] = 'a';
$phar->stopBuffering();

var_dump($phar->getStub());
var_dump($phar->getStub() == $stub);

$newstub = '<?php echo "second stub
"; _x_HALT_COMPILER(); ?>';
try
{
    $phar->setStub($newstub);
}
catch(exception $e)
{
    echo 'Exception: ' . $e->getMessage() . "
";
}
var_dump($phar->getStub());
var_dump($phar->getStub() == $stub);
$phar->stopBuffering();
var_dump($phar->getStub());
var_dump($phar->getStub() == $stub);

?>
--CLEAN--
<?php
unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.phar.zip');
__HALT_COMPILER();
?>
--EXPECTF--
string(50) "<?php echo "first stub
"; __HALT_COMPILER(); ?>
"
bool(true)
Exception: illegal stub for zip-based phar "%sphar_stub_error.phar.zip"
string(50) "<?php echo "first stub
"; __HALT_COMPILER(); ?>
"
bool(true)
string(50) "<?php echo "first stub
"; __HALT_COMPILER(); ?>
"
bool(true)

Did this file decode correctly?

Original Code

--TEST--
Phar::setStub()/getStub() zip-based
--EXTENSIONS--
phar
--INI--
phar.require_hash=0
phar.readonly=0
--FILE--
<?php

$fname = __DIR__ . '/' . basename(__FILE__, '.php') . '.phar.zip';

$phar = new Phar($fname);
$phar->setStub($stub = '<?php echo "first stub\n"; __HALT_COMPILER(); ?>' . "\r\n");
$phar->setAlias('hio');
$phar['a'] = 'a';
$phar->stopBuffering();

var_dump($phar->getStub());
var_dump($phar->getStub() == $stub);

$newstub = '<?php echo "second stub\n"; _x_HALT_COMPILER(); ?>';
try
{
    $phar->setStub($newstub);
}
catch(exception $e)
{
    echo 'Exception: ' . $e->getMessage() . "\n";
}
var_dump($phar->getStub());
var_dump($phar->getStub() == $stub);
$phar->stopBuffering();
var_dump($phar->getStub());
var_dump($phar->getStub() == $stub);

?>
--CLEAN--
<?php
unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.phar.zip');
__HALT_COMPILER();
?>
--EXPECTF--
string(50) "<?php echo "first stub\n"; __HALT_COMPILER(); ?>
"
bool(true)
Exception: illegal stub for zip-based phar "%sphar_stub_error.phar.zip"
string(50) "<?php echo "first stub\n"; __HALT_COMPILER(); ?>
"
bool(true)
string(50) "<?php echo "first stub\n"; __HALT_COMPILER(); ?>
"
bool(true)

Function Calls

None

Variables

None

Stats

MD5 9040cc6e520d27fe41508081f3bd92f2
Eval Count 0
Decode Time 107 ms