PHP base64+gzinflate压缩编码和解码代码


Posted in PHP onOctober 03, 2008

base64+gzinflate压缩编码(加密)过的文件通常是以 <? eval(gzinflate(base64_decode( 为头的一个php文件。以下我们给出了相关的编码解码(加密解密)代码。

压缩编码(加密)代码:

<?php 
function encode_file_contents($filename) { 
$type=strtolower(substr(strrchr($filename,'.'),1)); 
if('php'==$type && is_file($filename) && is_writable($filename)){// 如果是PHP文件 并且可写 则进行压缩编码 
$contents = file_get_contents($filename);// 判断文件是否已经被编码处理 
$pos = strpos($contents,'/*Protected by 草名 http://www.crazyi.cn Cryptation*/'); 
if(false === $pos || $pos>100){ // 去除PHP文件注释和空白,减少文件大小 
$contents = php_strip_whitespace($filename); 
// 去除PHP头部和尾部标识 
$headerPos = strpos($contents,'<?php'); 
$footerPos = strrpos($contents,'?>'); 
$contents = substr($contents,$headerPos+5,$footerPos-$headerPos); 
$encode = base64_encode(gzdeflate($contents));// 开始编码 
$encode = '<?php'." /*Protected by 草名 http://www.crazyi.cn Cryptation*/\n eval(gzinflate(base64_decode(".$encode.")));\n /*Reverse engineering is illegal and strictly prohibited- (C)草名 Cryptation 2008*/ \n?>"; 
return file_put_contents($filename,$encode); 
} 
} 
return false; 
} 
//调用函数 
$filename='g:\我的文档\桌面\test.php'; 
encode_file_contents($filename); 
?> 
<?php 
function encode_file_contents($filename) { 
$type=strtolower(substr(strrchr($filename,'.'),1)); 
if('php'==$type && is_file($filename) && is_writable($filename)){// 如果是PHP文件 并且可写 则进行压缩编码 
$contents = file_get_contents($filename);// 判断文件是否已经被编码处理 
$pos = strpos($contents,'/*Protected by 草名 http://www.crazyi.cn Cryptation*/'); 
if(false === $pos || $pos>100){ // 去除PHP文件注释和空白,减少文件大小 
$contents = php_strip_whitespace($filename); 
// 去除PHP头部和尾部标识 
$headerPos = strpos($contents,'<?php'); 
$footerPos = strrpos($contents,'?>'); 
$contents = substr($contents,$headerPos+5,$footerPos-$headerPos); 
$encode = base64_encode(gzdeflate($contents));// 开始编码 
$encode = '<?php'." /*Protected by 草名 http://www.crazyi.cn Cryptation*/\n eval(gzinflate(base64_decode(".$encode.")));\n /*Reverse engineering is illegal and strictly prohibited- (C)草名 Cryptation 2008*/ \n?>"; 
return file_put_contents($filename,$encode); 
} 
} 
return false; 
} 
//调用函数 
$filename='g:\我的文档\桌面\test.php'; 
encode_file_contents($filename); 
?>

压缩解码(解密)代码:

<?php 
$Code = '这里填写要解密的编码'; // base64编码 
$File = 'test.php';//解码后保存的文件 
$Temp = base64_decode($Code); 
$temp = gzinflate($Temp); 
$FP = fopen($File,"w"); 
fwrite($FP,$temp); 
fclose($FP); 
echo "解密成功!"; 
?>
PHP 相关文章推荐
cache_lite试用
Feb 14 PHP
php 文件上传系统手记
Oct 26 PHP
PHP实现手机归属地查询API接口实现代码
Aug 27 PHP
整理的一些实用WordPress后台MySQL操作命令
Jan 07 PHP
ThinkPHP中pathinfo的访问模式、路径访问模式及URL重写总结
Aug 23 PHP
php防止sql注入简单分析
Mar 18 PHP
分享php分页的功能模块
Jun 16 PHP
PHP内核学习教程之php opcode内核实现
Jan 27 PHP
PHP入门教程之操作符与控制结构流程详解
Sep 09 PHP
浅析php如何实现爬取数据原理
Sep 27 PHP
PHP中通过getopt解析GNU C风格命令行选项
Nov 18 PHP
PHP $O00OO0=urldecode &amp; eval 解密,记一次商业源码的去后门
Sep 13 PHP
php下实现在指定目录搜索指定类型文件的函数
Oct 03 #PHP
PHP Header用于页面跳转要注意的几个问题总结
Oct 03 #PHP
smarty section简介与用法分析
Oct 03 #PHP
php相当简单的分页类
Oct 02 #PHP
php仿discuz分页效果代码
Oct 02 #PHP
php仿ZOL分页类代码
Oct 02 #PHP
php生成缩略图的类代码
Oct 02 #PHP
You might like
一个程序下载的管理程序(四)
2006/10/09 PHP
php set_magic_quotes_runtime() 函数过时解决方法
2010/07/08 PHP
Yii框架form表单用法实例
2014/12/04 PHP
Yii2实现ActiveForm ajax提交
2017/05/26 PHP
node.js中的console.warn方法使用说明
2014/12/09 Javascript
ECMAScript6中Set/WeakSet详解
2015/06/12 Javascript
js实现贪吃蛇小游戏(容易理解)
2017/01/22 Javascript
轻松实现jQuery添加删除按钮Click事件
2017/03/13 Javascript
通过函数作用域和块级作用域看javascript的作用域链
2018/08/05 Javascript
vue 使用vue-i18n做全局中英文切换的方法
2018/10/29 Javascript
浅谈Vue.js中如何实现自定义下拉菜单指令
2019/01/06 Javascript
Vue表单控件绑定图文详解
2019/02/11 Javascript
如何使用gpu.js改善JavaScript的性能
2020/12/01 Javascript
前端如何实现动画过渡效果
2021/02/05 Javascript
[53:52]EG vs VGJ.T 2018国际邀请赛小组赛BO2 第一场 8.16
2018/08/17 DOTA
Python中的高级数据结构详解
2015/03/27 Python
Python回调函数用法实例详解
2015/07/02 Python
Python如何实现守护进程的方法示例
2017/02/08 Python
python实现Flappy Bird源码
2018/12/24 Python
python 多个参数不为空校验方法
2019/02/14 Python
Python 给定的经纬度标注在地图上的实现方法
2019/07/05 Python
python2爬取百度贴吧指定关键字和图片代码实例
2019/08/14 Python
Python中IP地址处理IPy模块的方法
2019/08/16 Python
Python利用多线程同步锁实现多窗口订票系统(推荐)
2019/12/22 Python
celery在python爬虫中定时操作实例讲解
2020/11/27 Python
Columbia美国官网:美国著名的户外服装品牌
2016/11/24 全球购物
EntityManager都有哪些方法
2013/11/01 面试题
人力资源经理自我评价
2014/01/04 职场文书
大学生求职自我评价
2014/01/16 职场文书
校庆筹备方案
2014/03/30 职场文书
五一活动标语
2014/06/30 职场文书
2014学校领导四风问题对照检查材料思想汇报
2014/09/22 职场文书
深入开展党的群众路线教育实践活动心得体会
2014/11/05 职场文书
大学学习委员竞选稿
2015/11/20 职场文书
如何在向量化NumPy数组上进行移动窗口
2021/05/18 Python
Go归并排序算法的实现方法
2022/04/06 Golang