PHP encryption technology

Posted by V_dirt_God on Mon, 14 Feb 2022 01:47:01 +0100

Hello, everyone. Meet again. I'm Jun Quan.

PHP encrypted code can run in PHP version above 5 +. Cross platform, Windows, CentOS and Ubuntu platforms can operate normally. Support virtual host, VPS and independent server. No additional extensions need to be installed. Maintain the original code structure and do not inject any additional code. The Web server does not require any modification. Excellent and efficient irreversible encryption obfuscation algorithm. Ultra high encryption strength

1. Be sincere and open. Today I want to tell you how to encrypt the php source code.

In the actual development work, some core or particularly important php pages need to be protected against theft or malicious modification, as well as against those dishonest customers or bosses. At this time, we need to encrypt these files.

2. First of all, we need to build a php running environment locally, or directly put php files in the space where the running environment is php.

Here, I use space.

3. Then create a php file to be encrypted: index (click) php.

//index.php
<?php
$nowTime = time();//Get the timestamp of the current time
$expireTime = 1500103230;//Get the timestamp after two minutes through the timestamp conversion tool
if($nowTime <= $expireTime){
  echo 'The website is running normally!';
}else{
  echo 'Website closed!';
}
?>

Write the encrypted code in it. Here, I use the simplest code as an example. The code idea is as follows: first get the current time, and then use the timestamp conversion tool to get the timestamp after two minutes. Judge whether the current time is less than or equal to the expiration time. If true, return: the website is running normally.

Otherwise, return: the website is closed.

4. Now our protagonist is on the stage, which is encryption (click) php file.

//encryption.php
<?php 
function RandAbc($length=""){//Returns a random string
$str="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
return str_shuffle($str);
}
$filename='index.php';//Enter the PHP file that needs to be encrypted
$T_k1=RandAbc();//Random key 1
$T_k2=RandAbc();//Random key 2
$vstr=file_get_contents($filename);//Files to encrypt
$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
'.$s.
'
?>';
echo "OK,Encryption complete!";
//Generate encrypted PHP file
$fpp1 = fopen('test.php','w');
fwrite($fpp1,$s) or die('Write file error'); 
?>

You can study the specific implementation steps yourself. Now let me talk about what needs attention.

First, put the full name of the php file to be encrypted in single quotation marks on line 6.

Second, fill in the encrypted php file name in the first single quotation mark in line 26.

5. Now replace the timestamp with the timestamp in two minutes. Then upload these two files to the space.

Execute encryption (click) PHP file. http://www.test.com/encryption.php

Then you can see a test in the root directory of the space (click) php file generation.

This test (click) php is created by index (DOT) php encryption.

Then execute test (click) PHP file. http://www.test.com/test.php

You can see the running results and index (click) the result of running php file is the same. The website will be closed in two minutes.

6. Open test (click) php file, which is the encrypted source code.

//test.php
<?php
$O00OO0=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");$O00O0O=$O00OO0{3}.$O00OO0{6}.$O00OO0{33}.$O00OO0{30};$O0OO00=$O00OO0{33}.$O00OO0{10}.$O00OO0{24}.$O00OO0{10}.$O00OO0{24};$OO0O00=$O0OO00{0}.$O00OO0{18}.$O00OO0{3}.$O0OO00{0}.$O0OO00{1}.$O00OO0{24};$OO0000=$O00OO0{7}.$O00OO0{13};$O00O0O.=$O00OO0{22}.$O00OO0{36}.$O00OO0{29}.$O00OO0{26}.$O00OO0{30}.$O00OO0{32}.$O00OO0{35}.$O00OO0{26}.$O00OO0{30};eval($O00O0O("JE8wTzAwMD0iV1h2ck5DSlV4SHdFRmhHQmJJUWRQUnNxTHRsT2FaZ29BZnVpa0tZU1ZUamNleU1tcER6blhSQm5Fa2dXWU9sWlVoeUZBdVF4ZFRqQ3ZWcXNOS1BlU0RMdEhjcGZKSW9ybXdHaWF6TWJkejlsTk9TY2d5NUJ4MVRhQVhXUGRmRjBOWDFxY2tIN3Z3L3VlQVg5VkFPT2pHQ1lCc2YxWUdDWUJzZjBsUWVIS1JobE5SZ3FKeXFWS2ZTOXV6WjFHelNZR3pHd0dNUzd2dy9FQ3ZiOXdueTg1dklGMTZDN0w3aUhCVi91ZUFYOWxBMjMxVkFJTEJzMVlHQ1lCc2YwbFFhYUt0UEhBaTkzSnlxVktmUzhkZlNIS1JobE5SZ3FKeXFWS2ZxN2tQcXFwMmhCdWtERStFWCsxRDJNZTlJdjBFelgwY3NoZ01qY0RYSmpyMko3a1BxcXAyaEJ1a0RFK0VYKzBWeTUydk9KZTZaYnNsYTlrbzgra1BlY2tQZWMiO2V2YWwoJz8+Jy4kTzAwTzBPKCRPME9PMDAoJE9PME8wMCgkTzBPMDAwLCRPTzAwMDAqMiksJE9PME8wMCgkTzBPMDAwLCRPTzAwMDAsJE9PMDAwMCksJE9PME8wMCgkTzBPMDAwLDAsJE9PMDAwMCkpKSk7"));
?>

Then put the index (click) save the php file, and only run test. php in the space (click) the php file can achieve the encryption effect.

7. Come and test it yourself Publisher: full stack programmer, stack length, please indicate the source for Reprint: https://javaforall.cn/111852.html Original link: https://javaforall.cn