Как дешифровать или декодинг eval gzinflate base64_decode

Столкнулся вот только что с задачей как бы потихому вскрыть закодированный через <?php eval(gzinflate(base64_decode(‘encoded text‘))); ?> php код.
Как всегда за подсказкой решил обратиться к Гуглю. Ответ как всегда нашелся нашелся.
Вариант 1:
<html>
<body>
<!– начало дешифровки –>
<?php
$str = gzinflate(base64_decode(‘encoded text’));
while(1) {
if(($pos1 = strpos($str, ‘eval(’)) === FALSE) {
break;
}
$pos2 = strpos($str, ‘);’);
$newstr = substr($str,$pos1+5,$pos2-$pos1-5);
eval(‘$str =’.$newstr.";");
}
print $str;
?>
<!– конец дешифровки –>
</body>
</html>
Сохраняете этот файл как вам угодно, заливате на хост, или запускаете
у себя на локалхосте и копируете из исходника все, что находится между
тегами
<!– начало дешифровки –>
<!– конец дешифровки –>
Все. Код дешифрован.
Вариант 2:
В данном случае необходимо сделать следующее (перевод руководства в самом файле):
- сохранить этот файл как decrypt.php
- Зашифрованный код сохранить как coded.txt
- создать пустой файл decoded.txt (если будете запускать файл на сервере, то укажите ему CHMOD 0666)
- запустите файл decrypt.php
- в файле decoded.txt теперь должен лежать расшифрованный PHP код.
<?php
/*
Taken from http://www.php.net/manual/de/function.eval.php#59862
Directions:
1. Save this snippet as decrypt.php
2. Save encoded PHP code in coded.txt
3. Create a blank file called decoded.txt (from shell do CHMOD 0666 decoded.txt)
4. Execute this script (visit decrypt.php in a web browser or do php decrypt.php in the shell)
5. Open decoded.txt, the PHP should be decrypted if not comment below http://danilo.ariadoss.com/decoding-eval-gzinflate-base64-decode/
*/
echo "\nDECODE nested eval(gzinflate()) by DEBO Jurgen <jurgen@person.be>\n\n";
echo "1. Reading coded.txt\n";
$fp1 = fopen ("coded.txt", "r");
$contents = fread ($fp1, filesize ("coded.txt"));
fclose($fp1);
echo "2. Decoding\n";
while (preg_match("/eval\(gzinflate/",$contents)) {
$contents=preg_replace("/< \?|\?>/", "", $contents); eval(preg_replace("/eval/", "\$contents=", $contents)); } echo "3. Writing decoded.txt\n"; $fp2 = fopen("decoded.txt","w"); fwrite($fp2, trim($contents)); fclose($fp2);
?>
Upon decrypting the source code I realized that the freeware application downloaded spyware onto visitors’ computers as well as periodically initiated pop-ups that contained obvious spam. I posted this article in order for others to be able to examine the actual source of these applications in order to prevent them from inadvertently running malicious code on their websites. I hope this helped some of you and I will endeavor to continue to post useful and insightful entries from now on.
Если ни один из способов не помог, значит не судьба.