破解PHP eval gzinflate base64_decode
通常加密的前面为 eval( gzinflate( base64_decode(
(例如:<?php eval(gzinflate(base64_decode(’encoded text’))); ?>),但是这样做的一个缺点就是,当你希望修改其中一部分代码时就无法进行,对于追求完美的朋友来说这样做是不能容忍的,怎样才能让这些被搞乱的代码还原呢?今天在玩弄一个Wordpress的theme遇到这样一个问题,虽然破解非常的简单,还是保留原来作者的链接,毕竟,修改别人的版权,有那个一点不厚道。
这个加密方式代码特征如下:
<?php eval(gzinflate(base64_decode(‘FZfHDoTIFUV/ZXYeiwU5ySOPyDlnNiMyNKnJ4evd
……
……
?>
破解eval gzinflate base64_decode其实非常的简单的,使用程序破解只需要两步就可以完成,在本机服务器环境建立一个decrypt.php文件,代码如下:
<?php
$code_file = ‘coded.txt’; //加密后文件
$decode_file = ‘decoded.txt’; //解密后代码存放文件
echo ‘<pre>’;
echo “\nDECODE nested eval(gzinflate()) by DEBO Jurgen AND modify By jayeeliu\r\n”;
echo “1. Reading coded file\n”;
$contents = file_get_contents($code_file);
echo “2. Decoding\n”;
$i=1;
while (preg_match(“/eval[ ]*\([ ]*gzinflate/”,$contents)) {//在eval(的’(‘两边加入多空格匹配
echo $i++.”\r\n”;//显示解密次数
$contents=preg_replace(“/<\?php|\?>/”, “”, $contents);
$contents=preg_replace(“/<\?|\?>/”, “”, $contents);
eval(preg_replace(“/eval/”, “\$contents=”, $contents));
}
$contents = substr(substr($contents, 2), 0, -2);//去除开始的\?\>(\只是转义,文件中没有)和结尾的<?
echo “3. Writing decoded file\n”;
echo file_put_contents($decode_file, $contents);
echo ‘</pre>’;
?>
在相同目录建立一个coded.txt文件,将加密的内容Copy到改文件,使用浏览器打开http://127.0.0.1/decrypt.php,正常打开,完成后,
在该目录下就会生成一个decoded.txt 文件,解密之后的内容被保存在该文件中。
注意:如果是Linux服务器,则需要手工建立一个空白的decoded.txt 文件,并设置权限为666。


博主很牛x