#加密#如何利用PHP代码生成混淆加密PHP文件

使用方法

首先,新建一个 index.php,然后把代码复制进去,修改代码中你要加密的文件名,并把要加密的文件放在同一目录下。接着,访问 index.php,然后就会自动生成加密后的文件在 index.php 的同一目录下

代码

 <?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2022/9/9
* Time: 17:09
*/
function RandAbc($length = "") { // 返回随机字符串
$str = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
return str_shuffle($str);
}

$filename = 'index.php'; //要加密的文件
$T_k1 = RandAbc(); //随机密匙 1
$T_k2 = RandAbc(); //随机密匙 2
$vstr = file_get_contents($filename);
$v1 = base64_encode($vstr);
$c = strtr($v1, $T_k1, $T_k2); //根据密匙替换对应字符。
$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;
// 生成 加密后的 PHP 文件--文件名前缀是temp_原文件名
$fpp1 = fopen('temp_'.$filename, 'w');
fwrite($fpp1, $s) or die('写文件错误');

 

加密效果

<?php 
$O00OOO00O0O0O0O00O0O0O0O=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");$O00O0OOO00O0O00O0OO00O0O=$O00OOO00O0O0O0O00O0O0O0O{3}.$O00OOO00O0O0O0O00O0O0O0O{6}.$O00OOO00O0O0O0O00O0O0O0O{33}.$O00OOO00O0O0O0O00O0O0O0O{30};$O0OO00O00OOO00O0O00O0O0O=$O00OOO00O0O0O0O00O0O0O0O{33}.$O00OOO00O0O0O0O00O0O0O0O{10}.$O00OOO00O0O0O0O00O0O0O0O{24}.$O00OOO00O0O0O0O00O0O0O0O{10}.$O00OOO00O0O0O0O00O0O0O0O{24};$OO0O00OO0O00O0O0O0O00O0O=$O0OO00O00OOO00O0O00O0O0O{0}.$O00OOO00O0O0O0O00O0O0O0O{18}.$O00OOO00O0O0O0O00O0O0O0O{3}.$O0OO00O00OOO00O0O00O0O0O{0}.$O0OO00O00OOO00O0O00O0O0O{1}.$O00OOO00O0O0O0O00O0O0O0O{24};$OO0000OO00O0O0O00O0O0O0O=$O00OOO00O0O0O0O00O0O0O0O{7}.$O00OOO00O0O0O0O00O0O0O0O{13};$O00O0OOO00O0O00O0OO00O0O.=$O00OOO00O0O0O0O00O0O0O0O{22}.$O00OOO00O0O0O0O00O0O0O0O{36}.$O00OOO00O0O0O0O00O0O0O0O{29}.$O00OOO00O0O0O0O00O0O0O0O{26}.$O00OOO00O0O0O0O00O0O0O0O{30}.$O00OOO00O0O0O0O00O0O0O0O{32}.$O00OOO00O0O0O0O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08wME8wTzAwTzBPME8oJE9PME8wME9PME8wME8wTzBPME8wME8wTygkTzBPMDAwT08wTzAwTzBPME8wTzAwTzBPLCRPTzAwMDBPTzAwTzBPME8wME8wTzBPME8qMiksJE9PME8wME9PME8wME8wTzBPME8wME8wTygkTzBPMDAwT08wTzAwTzBPME8wTzAwTzBPLCRPTzAwMDBPTzAwTzBPME8wME8wTzBPME8sJE9PMDAwME9PMDBPME8wTzAwTzBPME8wTyksJE9PME8wME9PME8wME8wTzBPME8wME8wTygkTzBPMDAwT08wTzAwTzBPME8wTzAwTzBPLDAsJE9PMDAwME9PMDBPME8wTzAwTzBPME8wTykpKSk7"));

经测试很好用

本文转载至自VPS评审的#加密#如何利用PHP代码生成混淆加密PHP文件

THE END