当前位置:网站首页>Several schemes of PHP code encryption

Several schemes of PHP code encryption

2022-06-24 08:39:00 An unreliable programmer

How to protect your PHP Code :

Code obfuscation + encryption

Actual encryption is not , The specific implementation idea is to put the code base64 encryption , Then on base64 String mapping for strings in ( Randomly generated dictionaries are confused ) then eval perform This kind of 100% can be cracked and restored

The representative code is as follows :

<?php

 function RandAbc($length = "") {
     //  Returns a random string  
  $str = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; 
  return str_shuffle($str); 
 } 

 $filename = 'index.php'; // Files to be encrypted  
 $T_k1 = RandAbc(); // Random key 1 
 $T_k2 = RandAbc(); // Random key 2 
 $vstr = file_get_contents($filename); 
 $v1 = base64_encode($vstr); 
 $c = strtr($v1, $T_k1, $T_k2); // Replace the corresponding characters according to the key . 
 $c = $T_k1.$T_k2.$c; 
 $q1 = "O00O0O"; 
 $q2 = "O0O000"; 
 $q3 = "O0OO00"; 
 $q4 = "OO0O00"; 
 $q5 = "OO0000"; 
 $q6 = "O00OO0"; 
 $s = '$'.$q6.'=urldecode("%6E1%7A%62%2F%6D%615%5C%76%740%6928%2D%70%78%75%71%79%2A6%6C%72%6B%64%679%5F%65%68%63%73%77%6F4%2B%6637%6A");$'.$q1.'=$'.$q6.'{3}.$'.$q6.'{6}.$'.$q6.'{33}.$'.$q6.'{30};$'.$q3.'=$'.$q6.'{33}.$'.$q6.'{10}.$'.$q6.'{24}.$'.$q6.'{10}.$'.$q6.'{24};$'.$q4.'=$'.$q3.'{0}.$'.$q6.'{18}.$'.$q6.'{3}.$'.$q3.'{0}.$'.$q3.'{1}.$'.$q6.'{24};$'.$q5.'=$'.$q6.'{7}.$'.$q6.'{13};$'.$q1.'.=$'.$q6.'{22}.$'.$q6.'{36}.$'.$q6.'{29}.$'.$q6.'{26}.$'.$q6.'{30}.$'.$q6.'{32}.$'.$q6.'{35}.$'.$q6.'{26}.$'.$q6.'{30};eval($'.$q1.'("'.base64_encode('$'.$q2.'="'.$c.'";eval(\'?>\'.$'.$q1.'($'.$q3.'($'.$q4.'($'.$q2.',$'.$q5.'*2),$'.$q4.'($'.$q2.',$'.$q5.',$'.$q5.'),$'.$q4.'($'.$q2.',0,$'.$q5.'))));').'"));'; 

 $s = '<?php '."\n".$s."\n".' ?>'; 
 //echo $s; 
 //  Generate   Encrypted PHP file  
 $fpp1 = fopen('temp_'.$filename, 'w'); 
 fwrite($fpp1, $s) or die(' Error writing file '); 

 ?>

Confusing garbled characters

Code obfuscate variables and other things and 1 The principle is similar , Just change the string to ascii 127 To 255 There are also characters that non-human editors cannot understand , The result is that 100% can be cracked and restored , It's just a matter of time .

issue opcode

Do not distribute code , But the first PHP Code precompile , distribution opcode,PHP7 in the future opcache Deep integration PHP7 You can use this method to protect the source code in the future , But also opcode Decompile back Will also be cracked .

confusion + encryption + Write PHP Expand

confusion + encryption + Write PHP Expand , But as long as it is open source PHP Extensions will be cracked , Unless you write your own encryption algorithm , hold PHP Code encryption , Then take it yourself C Voice write extension closed source , Others don't know your encryption and cracking ideas , The possibility of being cracked is very small .

Swoole Compiler

swoole The one that came out , It's generated opcode Confuse encryption later , Then this one is awesome , It is very obvious to implement this zend The engine is unlikely to recognize the confusion after encryption opcode, So he actually needs to rewrite zend, So the matching zend The engine has to be changed . According to hantianfeng, there is no possibility of being cracked But I found a successful solution on the Internet , I haven't tried .

原网站

版权声明
本文为[An unreliable programmer]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/175/202206240612375503.html