教你如何解密 “ PHP 神盾解密工具 ”_PHP

WBOY
Release: 2016-06-01 11:51:46
Original
820 people have browsed it

其实对神盾解密并没有那么感兴趣,只是看到了作者把工具又加密了,感觉不爽。研究了一下,其实解密没那么复杂。

利用php_apd扩展很轻松地就这把这搞定了。只有四句代码。

<&#63;php
rename_function('gzuncompress','new_gzuncompress');
override_function('gzuncompress', '$arg', 'print(new_gzuncompress($arg)); return new_gzuncompress($arg);');
 
require_once 'decryption.php';
decryption('decryption.php');
Copy after login

该工具的核心代码:decryption.php

<&#63;php
function decryption($fileName) {
  /**
   * 解码函数
   * @param string $str 待解码字符串
   * @param string $flg 是否解析后解码
   * @return string   已解码字符串
   */
  function decode($str, $flg = '') {
    if($flg === '') {
      $ret = $str;
    } else {
      $ret = '&#1775;'; $i = 0; $l = strlen($str);
      while($i++ < $l) {
        $c = ord($str[$i-1]);
        $ret .= $c<245 &#63; ( $c>136 &#63; chr($c/2) : $str[$i-1] ) : "";
      }
    }
    return base64_decode($ret);
  }
   
  $err = '解码遇到错误,请联系教主处理该文件!';
  $str = file_get_contents($fileName);
  $path = pathinfo($fileName);
  $dirname = $path['dirname']; // 文件所在目录
  $baseName = $path['filename']; // 文件名
   
   
  if (preg_match('|IN_DECODE_(\w{32})|s', $str, $arr)) {
    // 防止解密自己,其实方法都已经告诉你了,自己动手解码才快乐
    $arr[1] === '761b5f52db6dff7ce91344e99dcedab7' && die("err: [-1] - 请勿试图用本工具解密本工具!");
  } else {
    die("err: [-1] - 没有发现神盾特征,你确定这是神盾加密?");
  }
   
  // 匹配代码主题部分
  // '';@\$[\x00-\xff]+\(\\'([\x00-\xff]+&#63;)\\'\.\(
  preg_match('|\'\';@\$[\x00-\xff]+\(\\\\\'([\x00-\xff]+&#63;)\\\\\'\.\(|s', $str, $arr) || die("err: [0] - ".$err);
  $code = $arr[1];
 
  // 匹配中间加密部分
  preg_match('|\(\'([\x00-\xff]+)\',\'|s', $code, $arr) || die("err: [1] - ".$err);
  $key = base64_decode(decode($arr[1], "decode"));
 
  $code = preg_replace('|\'\.[\x00-\xff]+\'\)\)\.\'|s', $key, $code);
 
  // 匹配尾部被加密代码
  preg_match('|=\'(x[\x00-\xff]+)\'\)\);|s', $str, $arr) || die("err: [2] - ".$err);
  $core = $arr[1];
 
  // 匹配验证key
  preg_match('|[\w+/=]{59}=|s', $arr[1], $arr) || die("err: [3] - ".$err);
  $key = $arr[0];
 
  $core = str_replace($key, '', $core); // 去除key
  $suffix = gzuncompress($core); // 得到 base64 的末尾部分
 
  // 解码
  $code = gzuncompress(base64_decode($code . $suffix));
 
  // 匹配干净的代码
  if (preg_match('|<!--<\&#63;php endif;\&#63;>(<\&#63;php[\r\n]{1,2}[\x00-\xff]+\&#63;>)<\&#63;php \$GLOBALS\[|s', $code, $arr)) {
    $code = $arr[1];
  }
 
  // 写到文件
  $source = $dirname . DIRECTORY_SEPARATOR . $baseName . "_source.php";
  file_put_contents($source, $code);
  die("解密成功,已经保存为: " . $source);
}
Copy after login

Related labels:
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