
30-07-2009
|
Members | | Join Date: May 2009
Posts: 44
| |
Eval encoded file decoder I am making a project in PHP where i am facing some issues with purchase script where i am using a very simple eval based encoding system i have try to think a lot and finally i have came to know how to decode the file by hand and following are the code for the same. PHP Code: <?php
// Open and read the content of the encoded file into a variable
$file = file_get_contents('encoded_file1.php');
// Strip php tags
$file = str_replace('<?php', "", $file);
$file = str_replace('<?', "", $file); // Make sure to get rid of short tags....
$file = str_replace('?>', "", $file);
// Strip new lines
$file = str_replace("\n", "", $file);
// Add semi colon to get around a parsing issue.
$file = $file.';';
// Change the Eval function
$file = str_replace('eval', 'echo ', $file);
// Function to eval the new string
function demo()
{
global $file;
ob_start();
eval($file);
$contents = ob_get_contents();
ob_end_clean();
return($contents);
}
// Run the code thru once
$file = demol();
// Counter
$cnt = 1;
// Loop it till it's decoded
while(preg_match('/^\?><\?php eval/', $file))
{
$file = str_replace('?><?php eval', 'echo', $file);
$file = str_replace('?><?', "", $file);
$file = deval();
++$cnt;
}
//clean up some tags
$file = str_replace('?><?php', "", $file);
$file = str_replace('?><?', "", $file);
echo $cnt,' iterations<br/><br/>';
echo '<pre>';
echo $file;
echo '</pre>';
?> |