Table of Contents
回复讨论(解决方案)
Home Backend Development PHP Tutorial 求问关于php 混淆字符+eval的解密构思。希望xuzuning等高手来帮忙

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

Jun 23, 2016 pm 01:59 PM

最近遇到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
输出的最后一行就是最后执行的代码

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Apr 05, 2025 am 12:04 AM

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

Describe the SOLID principles and how they apply to PHP development. Describe the SOLID principles and how they apply to PHP development. Apr 03, 2025 am 12:04 AM

The application of SOLID principle in PHP development includes: 1. Single responsibility principle (SRP): Each class is responsible for only one function. 2. Open and close principle (OCP): Changes are achieved through extension rather than modification. 3. Lisch's Substitution Principle (LSP): Subclasses can replace base classes without affecting program accuracy. 4. Interface isolation principle (ISP): Use fine-grained interfaces to avoid dependencies and unused methods. 5. Dependency inversion principle (DIP): High and low-level modules rely on abstraction and are implemented through dependency injection.

How to automatically set permissions of unixsocket after system restart? How to automatically set permissions of unixsocket after system restart? Mar 31, 2025 pm 11:54 PM

How to automatically set the permissions of unixsocket after the system restarts. Every time the system restarts, we need to execute the following command to modify the permissions of unixsocket: sudo...

How to debug CLI mode in PHPStorm? How to debug CLI mode in PHPStorm? Apr 01, 2025 pm 02:57 PM

How to debug CLI mode in PHPStorm? When developing with PHPStorm, sometimes we need to debug PHP in command line interface (CLI) mode...

Explain the concept of late static binding in PHP. Explain the concept of late static binding in PHP. Mar 21, 2025 pm 01:33 PM

Article discusses late static binding (LSB) in PHP, introduced in PHP 5.3, allowing runtime resolution of static method calls for more flexible inheritance.Main issue: LSB vs. traditional polymorphism; LSB's practical applications and potential perfo

How to send a POST request containing JSON data using PHP's cURL library? How to send a POST request containing JSON data using PHP's cURL library? Apr 01, 2025 pm 03:12 PM

Sending JSON data using PHP's cURL library In PHP development, it is often necessary to interact with external APIs. One of the common ways is to use cURL library to send POST�...

Explain late static binding in PHP (static::). Explain late static binding in PHP (static::). Apr 03, 2025 am 12:04 AM

Static binding (static::) implements late static binding (LSB) in PHP, allowing calling classes to be referenced in static contexts rather than defining classes. 1) The parsing process is performed at runtime, 2) Look up the call class in the inheritance relationship, 3) It may bring performance overhead.

See all articles