Skip to content

Instantly share code, notes, and snippets.

@shemanaev
Last active July 5, 2016 19:42
Show Gist options
  • Save shemanaev/7655441 to your computer and use it in GitHub Desktop.
Save shemanaev/7655441 to your computer and use it in GitHub Desktop.
PHPLockIt decoder
<?php
/*
PHPLockIt (new versions?) decoder
Usage:
`php _php_lockit_decoder.php5 <directory_in> <directory_out>`
*/
if ($argv[1] == 'DECODE') {
$in = $argv[2];
$output = $argv[3];
$input = file_get_contents($in);
$out = str_replace('__FILE__', "'".$in."'", $input);
$out = str_replace('<?php', '', $out);
$out = preg_replace('/\?\>.*/i', '', $out);
$out = preg_replace('/echo\(.*return;/i', $step1, $out);
$out = str_replace('eval', 'echo', $out);
ob_start();
eval($out);
$step1 = ob_get_contents();
ob_end_clean();
$step1 = str_replace('eval', 'echo', $step1);
$out = preg_replace('/echo\(.*return;/i', $step1, $out);
ob_start();
eval($out);
$step2 = ob_get_contents();
ob_end_clean();
$step2 = str_replace('eval', 'echo', $step2);
$out = preg_replace('/echo\(.*\);/i', $step2, $out);
ob_start();
eval($out);
$final = ob_get_contents();
ob_end_clean();
$final = "<?php\n".$final;
file_put_contents($output, $final);
} else {
mkdir($argv[2]);
$in = realpath($argv[1]);
$out = realpath($argv[2]);
$di = new RecursiveDirectoryIterator($in);
foreach (new RecursiveIteratorIterator($di) as $filename => $file) {
if (is_dir($filename)) continue;
$nf = str_replace($in, $out, $filename);
if (!is_dir(dirname($nf))) mkdir(dirname($nf), 0, true);
if ($file->getExtension() == 'php' && $filename != __FILE__) {
chdir(dirname($filename));
echo exec(PHP_BINARY.' '.__FILE__.' DECODE "'.$filename.'" "'.$nf.'"');
} else {
if ($filename != __FILE__) copy($filename, $nf);
}
echo str_replace($in, '', $filename)." done\n";
}
}
@openbrasil
Copy link

hello,
not understand the functioning ... could post a script running? emviar or in my email?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment