当前位置:网站首页>PHP代码加密的几种方案
PHP代码加密的几种方案
2022-06-24 07:03:00 【一个不靠谱的程序员】
如何保护自己的PHP代码:
代码混淆+加密
实际加密算不上,具体实现思路就是把代码base64加密,然后对base64里的字符串进行字符串映射(随机生成字典混淆)然后eval执行 这种百分之百能被破解还原
代表代码如下:
<?php
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文件
$fpp1 = fopen('temp_'.$filename, 'w');
fwrite($fpp1, $s) or die('写文件错误');
?>
混淆乱码字符
代码混淆变量还有一些东西 和1原理差不多,不过是把字符串换到 ascii 127到255之间非人类还有编辑器看不懂的字符 ,结果也是百分之百能被破解和还原,只是时间问题。
发放opcode
不分发代码,而是先把PHP代码预编译,分发opcode,PHP7以后opcache深度集成这个东西 PHP7以后可以用这个方法保护源码,但是也会被opcode反编译回去 也会被破解。
混淆+加密+写PHP扩展
混淆+加密+写PHP扩展,但是只要是开源的PHP扩展都会被破解,除非自己写加密算法,把PHP代码加密, 然后自己拿C语音写扩展闭源, 别人不知道你加密思路和破解思路,被破解的可能性很小。
Swoole Compiler
swoole出的那个,是拿生成的opcode以后混淆加密, 然后这个就牛逼了,这个要想执行很明显zend引擎是不太可能认识混淆加密后的opcode,所以他实际上还需要重写zend,所以说配套的zend引擎也要换。据韩天峰说目前不存在被破解的可能 但是我在网上搜到了有说破解这个成功的,也没试过。
边栏推荐
- ZUCC_编译语言原理与编译_实验05 正则表达式、有限自动机、词法分析
- 12-- merge two ordered linked lists
- ZUCC_ Principles of compiling language and compilation_ Experiment 08 parsing LR parsing
- ZUCC_ Principles of compiling language and compilation_ Experiment 04 language and grammar
- 常用日期格式符与Qt获取当前时间的办法
- Shell basic operator -- arithmetic operator
- [micro services ~nacos] Nacos service providers and service consumers
- 5 minutes, excellent customer service chat handling skills
- One development skill a day: how to establish P2P communication based on webrtc?
- Three ways to uninstall Symantec Endpoint Protection Symantec
猜你喜欢

中国芯片独角兽公司

Introduction to RCNN, fast RCNN and fast RCNN

Permission model DAC ACL RBAC ABAC

Centos7安装jdk8以及mysql5.7以及Navicat连接虚拟机mysql的出错以及解决方法(附mysql下载出错解决办法)

Synthesize video through ffmpeg according to m3u8 file of video on the network

日本大阪大学万伟伟研究员介绍基于WRS系统机器人的快速集成方法和应用

分布式 | 如何与 DBLE 进行“秘密通话”

ZUCC_ Principles of compiling language and compilation_ Experiment 01 language analysis and introduction

ZUCC_编译语言原理与编译_实验03 编译器入门

MATLAB Camera Calibrator相机标定
随机推荐
到底哪一首才是唐诗第一?
Glusterfs replacement failure brick
(PKCS1) RSA 公私钥 pem 文件解析
Synthesize video through ffmpeg according to m3u8 file of video on the network
2021-03-04 comp9021 class 6 notes
Easynvr and easyrtc platforms use go language to manage projects. Summary of the use of govendor and gomod
Rescue system -- the application of read-write separation
String转Base64
Application of tidb in Netease games
App Startup
ZUCC_编译语言原理与编译_实验05 正则表达式、有限自动机、词法分析
pyQt 常用系统的事件
ZUCC_ Principles of compiling language and compilation_ Experiment 03 getting started with compiler
2021-03-09 comp9021 class 7 Notes
ZUCC_ Principles of compiling language and compilation_ Experiment 04 language and grammar
orb slam build bug: undefined reference to symbol ‘_ZN5boost6system15system_categoryEv‘
Take my brother to do the project. It's cold
The JS macro of WPS implements the separation method of picture text in the same paragraph
Matlab求解线性方程组Ax=b
js中通过key查找和更新对象中指定值的方法