phpjm解密程序,也适用于其他混淆加密的破解

  2021-02-03    阅读:110
 
  1. <?php
  2.  
    $file = 'plugin.php'; //要破解的文件
  3.  
     
  4.  
     
  5.  
    $fp = fopen($file, 'r');
  6.  
    $str = fread($fp, filesize($file));
  7.  
    fclose($fp);
  8.  
     
  9.  
    copy($file, '0_'.$file);
  10.  
     
  11.  
    $n = 1;
  12.  
    while($n < 10){
  13.  
    $code = strdecode($str);
  14.  
    if($n == 1){
  15.  
    $code = str_replace("__FILE__", "'0_$file'", $code);
  16.  
    }
  17.  
     
  18.  
    $replace = '$decode'.$n.'=trim';
  19.  
    if(strpos($code, 'eval(') > 0){
  20.  
    $code = str_replace('eval(', $replace.'(', $code);
  21.  
    }else{
  22.  
    preg_match("/@\\$(.*)\(\\$(.*),(.*)\(/isU", $code, $res);
  23.  
    $code = str_replace($res[3], "'$replace", $code);
  24.  
    }
  25.  
     
  26.  
    $code = preg_replace('/\\$(.*)=false;(.*?)\(\);/', '', $code); //上一版本
  27.  
    $code = preg_replace('/\|\|@\\$(.*?)\(\);/', '|| print("ok");', $code);
  28.  
     
  29.  
    $code = destr($code);
  30.  
    $tmp_file = 'detmp'.$n.'.php';
  31.  
    file_put_contents($tmp_file, $code);
  32.  
    include($tmp_file);
  33.  
     
  34.  
    $val = 'decode'.$n;
  35.  
    $str = $$val;
  36.  
     
  37.  
    unlink($tmp_file);
  38.  
     
  39.  
    if(strpos($str, ';?>') === 0){
  40.  
    $decode = $str;
  41.  
    break;
  42.  
    }
  43.  
     
  44.  
    $str = "<?php\r\n". $str;
  45.  
    $n++;
  46.  
    }
  47.  
     
  48.  
     
  49.  
    $decode = preg_replace("/^(.*)exit\('Access Denied'\); /", "<?php\r\n", $decode);
  50.  
    $del = strrchr($decode, 'unset');
  51.  
    $decode = str_replace($del, "\r\n?>", $decode);
  52.  
    file_put_contents($file.'.de.php' ,$decode);
  53.  
    unlink('0_'.$file);
  54.  
    echo 'done';
  55.  
     
  56.  
     
  57.  
    function val_replace($code, $val, $deval){
  58.  
    $code = str_replace('$'.$val.',', '$'.$deval.',', $code);
  59.  
    $code = str_replace('$'.$val.';', '$'.$deval.';', $code);
  60.  
    $code = str_replace('$'.$val.'=', '$'.$deval.'=', $code);
  61.  
    $code = str_replace('$'.$val.'(', '$'.$deval.'(', $code);
  62.  
    $code = str_replace('$'.$val.')', '$'.$deval.')', $code);
  63.  
    $code = str_replace('$'.$val.'.', '$'.$deval.'.', $code);
  64.  
    $code = str_replace('$'.$val.'/', '$'.$deval.'/', $code);
  65.  
    $code = str_replace('$'.$val.'>', '$'.$deval.'>', $code);
  66.  
    $code = str_replace('$'.$val.'<', '$'.$deval.'<', $code);
  67.  
    $code = str_replace('$'.$val.'^', '$'.$deval.'^', $code);
  68.  
    $code = str_replace('$'.$val.'||', '$'.$deval.'||', $code);
  69.  
    $code = str_replace('($'.$val.' ', '($'.$deval.' ', $code);
  70.  
    return $code;
  71.  
    }
  72.  
     
  73.  
    function fmt_code($code){
  74.  
    global $vals,$funs;
  75.  
    preg_match_all("/\\$[0-9a-zA-Z\[\]']+(,|;)/iesU", $code, $res);
  76.  
    foreach($res[0] as $v){
  77.  
    $val = str_replace(array('$',',',';'), '', $v);
  78.  
    $deval = destr($val, 1);
  79.  
    $vals[$val] = $deval;
  80.  
    $code = val_replace($code, $val, $deval);
  81.  
    }
  82.  
     
  83.  
    preg_match_all("/\\$[0-9a-zA-Z\[\]']+=/iesU", $code, $res);
  84.  
    foreach($res[0] as $v){
  85.  
    $val = str_replace(array('$','='), '', $v);
  86.  
    $deval = destr($val, 1);
  87.  
    $vals[$val] = $deval;
  88.  
    $code = val_replace($code, $val, $deval);
  89.  
    }
  90.  
     
  91.  
    preg_match_all("/function\s[0-9a-zA-Z\[\]]+\(/iesU", $code, $res);
  92.  
    foreach($res[0] as $v){
  93.  
    $val = str_replace(array('function ','('), '', $v);
  94.  
    $deval = destr($val, 1);
  95.  
    $funs[$val] = $deval;
  96.  
    $code = str_replace('function '.$val.'(', 'function '.$deval.'(', $code);
  97.  
    $code = str_replace('='.$val.'(', '='.$deval.'(', $code);
  98.  
    $code = str_replace('return '.$val.'(', 'return '.$deval.'(', $code);
  99.  
    }
  100.  
    return $code;
  101.  
    }
  102.  
     
  103.  
    function strdecode($str){
  104.  
    $len = strlen($str);
  105.  
    $newstr = '';
  106.  
    for($i=0; $i<$len; $i++){
  107.  
    $n = ord($str[$i]);
  108.  
    $newstr .= decode($n);
  109.  
    }
  110.  
    return $newstr;
  111.  
    }
  112.  
     
  113.  
    function decode($dec){
  114.  
    if(($dec > 126 || $dec<32) && $dec<>13 && $dec<>10){
  115.  
    return '['.$dec.']';
  116.  
    }else{
  117.  
    return chr($dec);
  118.  
    }
  119.  
    }
  120.  
     
  121.  
    function destr($str, $val=0){
  122.  
    $k = 0;
  123.  
    $num = '';
  124.  
    $n = strlen($str);
  125.  
    $code = '';
  126.  
    for($i=0; $i<$n; $i++){
  127.  
    if($str[$i] == '[' && ($str[$i+1]==1 || $str[$i+1]==2)){
  128.  
    $k = 1;
  129.  
    }elseif($str[$i] == ']' && $k==1){
  130.  
    $num = intval($num);
  131.  
    if($val==1){
  132.  
    $num = 97 + fmod($num, 25);
  133.  
    }
  134.  
    $code .= chr($num);
  135.  
    $k = 0;
  136.  
    $num = null;
  137.  
    }else{
  138.  
    if($k == 1){
  139.  
    $num .= $str[$i];
  140.  
    }else{
  141.  
    $code .= $str[$i];
  142.  
    }
  143.  
    }
  144.  
    }
  145.  
    return $code;
  146.  
    }
  147.  
    ?>


 

 

  1.  
    <?php
  2.  
    //解密 PHP神盾
  3.  
     
  4.  
    $file = 'Code2.php';
  5.  
     
  6.  
    $fp = fopen($file, 'r');
  7.  
    $str = fread($fp, filesize($file));
  8.  
    fclose($fp);
  9.  
     
  10.  
    $code = strdecode($str);
  11.  
     
  12.  
    //for func de1
  13.  
    preg_match("/;(.*)\]='(.*?)';for\(/e", $code, $res);
  14.  
    $c1 = $res[2];
  15.  
     
  16.  
    //for func de1
  17.  
    preg_match("/;(.*)=(.*)\('(.*)'\);(.*);(.*)$/e", $res[1], $rs);
  18.  
    $c2 = $rs[3];
  19.  
     
  20.  
    //for func de2
  21.  
    preg_match("/'\(@(.*?)\(\\\'(.*?)\\\'\)\)/e", $code, $res);
  22.  
    $c3 = $res[2];
  23.  
     
  24.  
    preg_match("/'\.(.*?)\.'/e", $c3, $r);
  25.  
    preg_match("/\('(.*?)','/e", $r[1], $r2);
  26.  
    $c4 = $r2[1];
  27.  
    $c4 = base64_decode(de1(destr($c4), 1));
  28.  
    $c3 = str_replace($r[0], $c4, $c3);
  29.  
     
  30.  
    $funstr = gzuncompress(base64_decode($c3)).base64_decode($c1);
  31.  
    preg_match("/if(.*),'(.*?)'\)\)/e", $funstr, $res);
  32.  
    $c5 = $res[2];
  33.  
     
  34.  
    //find main code
  35.  
    preg_match("/'\(@(.*)\(\\\'(.*?)\\\'\.\(/e", $code, $res);
  36.  
    $c = $res[2];
  37.  
    preg_match("/'\.(.*?)\.'/e", $c, $r);
  38.  
    preg_match("/\('(.*?)','/e", $r[1], $r2);
  39.  
    $c6 = base64_decode(de1(destr($r2[1]), 1));
  40.  
    $c = str_replace($r[0], $c6, $c);
  41.  
     
  42.  
    //find $de2
  43.  
    preg_match("/\"\.\((.*)='(.*?)'\)\);/e", $code, $res);
  44.  
    $de2 = destr($res[2]);
  45.  
    $x = ($de2.=de2($de2));
  46.  
    $c .= $x;
  47.  
    $decode = gzuncompress(base64_decode($c));
  48.  
     
  49.  
    $str = explode('<!--<?php endif;?>', $decode);
  50.  
    $str = explode('?><?php $GLOBALS', $str[1]);
  51.  
    $decode = $str[0].'?>';
  52.  
     
  53.  
    echo $decode;
  54.  
     
  55.  
    file_put_contents($file.'.de.php' ,$decode);
  56.  
     
  57.  
    //
  58.  
     
  59.  
    function de1($de1,$str2=''){
  60.  
    global $c1,$c2;
  61.  
    if(!$str2)return(base64_decode(destr($de1)));
  62.  
    $s9=de1($c2);
  63.  
    for($i=0;$i<strlen($de1);$i++)
  64.  
    $s9.=ord($de1{$i})<245?((ord($de1{$i})>140&&ord($de1{$i})<245)?chr(ord($de1{$i})/2):$de1{$i}):"";
  65.  
    return(base64_decode($s9));
  66.  
    }
  67.  
     
  68.  
    function de2(&$de2){
  69.  
    global $c5;
  70.  
    if(strstr($de2,$c5)){
  71.  
    $de2=str_replace($c5,'',$de2);
  72.  
    $de2=gzuncompress($de2);
  73.  
    }
  74.  
    if(strstr($de2,$c5)){
  75.  
    $de2=str_replace($c5,'',$de2);
  76.  
    de2($de2);
  77.  
    }
  78.  
     
  79.  
    }
  80.  
     
  81.  
    /
  82.  
     
  83.  
    function strdecode($str){
  84.  
    $len = strlen($str);
  85.  
    $newstr = '';
  86.  
    for($i=0; $i<$len; $i++){
  87.  
    $n = ord($str[$i]);
  88.  
    $newstr .= decode($n);
  89.  
    }
  90.  
    return $newstr;
  91.  
    }
  92.  
     
  93.  
    function decode($dec){
  94.  
    if(($dec > 126 || $dec<32)){
  95.  
    return '['.$dec.']';
  96.  
    }else{
  97.  
    return chr($dec);
  98.  
    }
  99.  
    }
  100.  
     
  101.  
    function destr($str){
  102.  
    $k = 0;
  103.  
    $num = '';
  104.  
    $n = strlen($str);
  105.  
    $code = '';
  106.  
    for($i=0; $i<$n; $i++){
  107.  
    if($str[$i] == '['){
  108.  
    $k = 1;
  109.  
    }elseif($str[$i] == ']'){
  110.  
    $num = intval($num);
  111.  
    $code .= chr($num);
  112.  
    $k = 0;
  113.  
    $num = null;
  114.  
    }else{
  115.  
    if($k == 1){
  116.  
    $num .= $str[$i];
  117.  
    }else{
  118.  
    $code .= $str[$i];
  119.  
    }
  120.  
    }
  121.  
    }
  122.  
    return $code;
  123.  
    }
  124.  
    ?>

免责声明:
本站部份内容系网友自发上传与转载,不代表本网赞同其观点;
如涉及内容、版权等问题,请在30日内联系,我们将在第一时间删除内容!

相关Destoon技术

(c)2012-2023 www.qiyeyunshang.com All Rights Reserved.
慧一科技destoon模板   辽ICP备2021002520号-1
  QQ咨询

购买模板 售前咨询

  咨询QQ

3292628658
(早8:30-晚10:00)

  微信咨询

咨询微信
客服微信

  返回顶部