Home > Backend Development > PHP Tutorial > 求问关于php 混淆字符+eval的解密构思。希望xuzuning等高手来帮忙

求问关于php 混淆字符+eval的解密构思。希望xuzuning等高手来帮忙

WBOY
Release: 2016-06-23 13:59:47
Original
1309 people have browsed it

最近遇到2个php文件加密比较恶心,好像用了混淆+eval。
这个混淆不同于0 | o的区别。好像编码比较乱看起来想ascii编码过的函数名字。
不知道高手能不能给个思路?
废话不多,直接上代码

<?php global $?????;$?????=array('?????'=>__FILE__);if(!defined('FEEAABFAA')){define("FEEAABFAA",1395120187);function ?????($?????,$?????=""){global $?????;$?????=base64_decode($?????);if(empty($?????)) return "";if($?????==""){return ~$?????;}else{$?????=$?????['?????']($?????);$?????=$?????['?????']($?????,$?????,$?????);return $?????^$?????;}}}$?????['?????']=?????('jIuNk5qR','');$?????['?????']=?????('mpKPi4Y=','');$?????['?????']=?????('nZ6MmsnLoJua?JCbmg==','');$?????['?????']=?????('jIuN?I+emw==','');$?????['?????']=?????('AgYIDg==','gpibl4mKhJ8=');$?????['?????']=?????('GStOLDVHHCA?OEgu','iY+Kj5yP');$?????['?????']=?????('0MvIzsfMm?rPmsmex8+encnJyczM?8rGmcrKnsfHnsjO?Jo=','');eval($?????['?????'](' 写不下了,这里省略…………'));return;?>4861704e7c6c38ed5439414665b9adb0
Copy after login

另外还有一个
<?php if(!defined('BCCEFFAFDBEC')){define("BCCEFFAFDBEC",1377408872);function ?????($?????,$?????=""){global $?????;$?????=base64_decode($?????);if(empty($?????)) return "";if($?????==""){return ~$?????;}else{$侗?????$?????['侗?????]($?????);$?????=$?????['船???豹']($?????,$侗?????$?????);return $?????^$?????;}}}global $?????;$?????=array('?酣????=>__FILE__);$?????['?????']=?????('nZ6Mm?nLoJuan?Cbmg==','');$?????['侗?????]=?????('jIuNk5qR','');$?????['?????']=?????('mpKPi4Y=','');$?????['船???豹']=?????('jIuNoI+emw?=','');$?????['辜脯千?羌']=?????('0J2cz5?amZn?nsaZx?nLzJv?y53H?5qcy8?JzMjOys?H0Jo=','');$?????['?『???']=?????('CDomNQ==','mLGYqYGhx6M=');$?????['噶????']=?????('GChXHzBKKh?YVEwj','hZ2xo8Odt5/FoQ==');$?????['?????']=?????('/K73993Zn?b0kA==','k4qfiY+Vw7M=');@$?????['噶????']($?????['辜脯千?羌'],$?????['?『???'].'('.$?????['?????'].'('.$?????['?????'].'(\'这里省略…………写不下了');return;?>616df3258c3d0520a46c2829342b76be 
Copy after login


两个代码我打包了
链接: http://pan.baidu.com/s/1tNVxs 密码: gtip


希望各位大大赐教一下


回复讨论(解决方案)

链接: http://pan.baidu.com/s/1tNVxs 密码: gtip
Copy after login

地址重新发布一下。

??文件在?行的?候都提示有?法??,??法?你

??文件在?行的?候都提示有?法??,??法?你
亲,单独运行的没错,但是不会报错。下载一下,百度网盘的;

如果你觉得看起来比较恶心,你自己换成字母好了,原理是一样的。

如果你觉得看起来比较恶心,你自己换成字母好了,原理是一样的。
我试过改动,可以随便改动一下就出问题。

你的 dadadi.php 被你改动过了吧?

你的 dadadi.php 被你改动过了吧?

链接: http://pan.baidu.com/s/1qWLLFDa 密码: 4372
Copy after login

这个应该没有问题。

另外我自己尝试破解了一下plugin.class.php,得出下面2个php
但是发现好像是循环的,应该是核心算法应该是
//function 在上面//定义了一个fun($var1,$var2='');大体意思是先先把$var1 base64还原 然后reutren ~取补数。再判断var2是否有值,下面那个好像没读懂 最后是 rerun aaa^bbb;(互斥)//下面加密了一串变量//放在一个数组中//数组的话,我后面的压缩包里面有个detempb可以弄出来,好像显示正确preg_match('正则表达式(我没有还原出来,还是还原错了感觉不对)',eval(gzuncompress(base64_decode(加密字符串穿))), ‘这里好像是一串数字’)
Copy after login


另外我自己弄了半天。生成这两个文件是plugin.class.php的解密文件,运行没错误,应该没有解密错。后面的不知道怎么弄了
当再打算再输出一遍 那个加密字符串时候,感觉不对。始终得不到正确结果。求指点
链接: http://pan.baidu.com/s/1u3Tgy 密码: j15w
Copy after login

手工解密的方法就是看eval里的变量的值,可能出来的还是带eval的,要如此反复。反正是个体力活就对了。

哦?想当然了吧
第一遍出来就没有 eval 了

手工解密的方法就是看eval里的变量的值,可能出来的还是带eval的,要如此反复。反正是个体力活就对了。

哦?想当然了吧
第一遍出来就没有 eval 了


手工解密的方法就是看eval里的变量的值,可能出来的还是带eval的,要如此反复。反正是个体力活就对了。
没想当然,我只是说可能,又没说这个代码第一遍解出来的一定有。说可能,只是因为我解过一个,要反复三四次才最后搞定。

哦?想当然了吧
第一遍出来就没有 eval 了


手工解密的方法就是看eval里的变量的值,可能出来的还是带eval的,要如此反复。反正是个体力活就对了。
这个我弄了一下,执行好像是经过二次@gzuncompress(base64_decode( code....... ))
第二遍eval 好像存在之前的数组中
但是到第二遍@gzuncompress(base64_decode( code....... ))执行后出现data error不知道您是怎么做的?能给个思路么?

他的结构比较复杂
第一层

Array(    [?????] => plugin.class.php.php    [?????] => strlen    [?????] => empty    [?????] => base64_decode    [?????] => str_pad    [?????] => eval    [?????] => preg_replace    [?????] => /47183fe0e6a80ab66633459f55a88a71/e)
Copy after login
Copy after login
Copy after login

第二层
Array(    [?????] => plugin.class.php.php    [?????] => strlen    [?????] => empty    [?????] => base64_decode    [?????] => str_pad    [?????] => eval    [?????] => preg_replace    [?????] => /47183fe0e6a80ab66633459f55a88a71/e    [?????] => time    [?????] => basename    [?????] => die    [?????] => ?????    [?????] => explode    [?????] => in_array    [?????] => gethostbyname)
Copy after login
Copy after login
Copy after login
第三层又直接使用了 eval

由于是通过 preg_replace 驱动的(正则附加属性 e)拦截起来比较困难
需要把数组中的 eval 改成自定义函数

解出的代码需拆分,先执行前面的参数设置,然后处理后面的自解码代码

他的结构比较复杂
第一层

Array(    [?????] => plugin.class.php.php    [?????] => strlen    [?????] => empty    [?????] => base64_decode    [?????] => str_pad    [?????] => eval    [?????] => preg_replace    [?????] => /47183fe0e6a80ab66633459f55a88a71/e)
Copy after login
Copy after login
Copy after login

第二层
Array(    [?????] => plugin.class.php.php    [?????] => strlen    [?????] => empty    [?????] => base64_decode    [?????] => str_pad    [?????] => eval    [?????] => preg_replace    [?????] => /47183fe0e6a80ab66633459f55a88a71/e    [?????] => time    [?????] => basename    [?????] => die    [?????] => ?????    [?????] => explode    [?????] => in_array    [?????] => gethostbyname)
Copy after login
Copy after login
Copy after login
第三层又直接使用了 eval

由于是通过 preg_replace 驱动的(正则附加属性 e)拦截起来比较困难
需要把数组中的 eval 改成自定义函数

解出的代码需拆分,先执行前面的参数设置,然后处理后面的自解码代码


数组中的eval (原始加密)在原始位置已经替换成了echo,后面的怎么拆分?

他的结构比较复杂
第一层

Array(    [?????] => plugin.class.php.php    [?????] => strlen    [?????] => empty    [?????] => base64_decode    [?????] => str_pad    [?????] => eval    [?????] => preg_replace    [?????] => /47183fe0e6a80ab66633459f55a88a71/e)
Copy after login
Copy after login
Copy after login

第二层
Array(    [?????] => plugin.class.php.php    [?????] => strlen    [?????] => empty    [?????] => base64_decode    [?????] => str_pad    [?????] => eval    [?????] => preg_replace    [?????] => /47183fe0e6a80ab66633459f55a88a71/e    [?????] => time    [?????] => basename    [?????] => die    [?????] => ?????    [?????] => explode    [?????] => in_array    [?????] => gethostbyname)
Copy after login
Copy after login
Copy after login
第三层又直接使用了 eval

由于是通过 preg_replace 驱动的(正则附加属性 e)拦截起来比较困难
需要把数组中的 eval 改成自定义函数

解出的代码需拆分,先执行前面的参数设置,然后处理后面的自解码代码

能不能提供一下你解密获取array的代码,我研究一下

preg_replace('\b777fb918ffda23fb0979c4ca77ab814\e',eval(gzuncompress(base64_decode($code))),'??b777fb918ffda23fb0979c4ca77ab814???');
Copy after login

这个该如何重组,解码呢?

代码是这样的
应该是思路有点问题,做不下去了

$filename = __DIR__ . '/plugin.class.php';$gl = '';$old_vars = '';$c = explode('eval', file_get_contents($filename));file_put_contents($filename.'_0.php', $c[0]);$old_vars = get_defined_vars();include $filename.'_0.php';$new_vars = array_diff_key(get_defined_vars(), $old_vars);//print_r($new_vars);$gl = key($new_vars);$ev = array_search('eval', $$gl);${$gl}[$ev] = '$code';$code = create_function('$s', <<< CODEglobal \$$gl;echo \$s,PHP_EOL;eval(explode('@', \$s)[0]);file_put_contents('t_2.php', '<?php '. explode('@', \$s)[1]);CODE);file_put_contents($filename.'_1.php', '<?php eval'.$c[1]);include $filename.'_1.php';//include 't_2.php';print_r($$gl);
Copy after login

调整了一下思路,应该是解开了

$filename = __DIR__ . '/plugin.class.php';function code($s) {  $v = $GLOBALS['gl'];  $$v =& $GLOBALS[$v];  echo $s . PHP_EOL;  $s = str_replace('eval(', 'code(', $s);  eval($s);}$gl = '';$old_vars = '';$c = explode('eval', file_get_contents($filename));file_put_contents($filename.'_0.php', $c[0]);$old_vars = get_defined_vars();include $filename.'_0.php';$new_vars = array_diff_key(get_defined_vars(), $old_vars);$gl = key($new_vars);$ev = array_search('eval', $$gl);${$gl}[$ev] = 'code';file_put_contents($filename.'_1.php', '<?php eval'.$c[1]);include $filename.'_1.php';print_r($$gl);
Copy after login
输出的最后一行就是最后执行的代码

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template