ioncube加密与解密 php代码

ioncube_encoder用于php代码的加密
 ioncube_loaders用户php代码的解密,经ioncube_encoder加密后的代码,不经 ioncube_loaders解密是运行不了的!
ioncube_encoder分免费和收费的两种,以避免费版本作测试,加密软件是收费的,解密软件是免费的!
下载ioncube_encoder_evaluation.tar.gz
tar zxvf ioncube_encoder_evaluation.tar.gz
mv ioncube_encoder /usr/local
cd /usr/local
ln -s  ioncube_encoder  encoder 
我已经配置好了lnmp环境,/data/www为为的web目录,该目录下有一个a.php文件
内容以下:
[root@haproxy1 php encode]# cd /data/www/
[root@haproxy1 www]# cat a.php 
phpinfo();
?>
测试解密该文件以下:
[root@haproxy1 www]# /usr/local/encoder/ioncube_encoder54  a.php  -o b.php

[root@haproxy1 www]# cat a.phpphp

phpinfo();css

?>html

[root@haproxy1 www]# cat b.phpnginx

// IONCUBE ENCODER 8.1 EVALUATIONweb

// THIS LICENSE MESSAGE IS ONLY ADDED BY THE EVALUATION ENCODER ANDapache

// IS NOT PRESENT IN PRODUCTION ENCODED FILESwindows

 

if(!extension_loaded('ionCube Loader')){$__oc=strtolower(substr(php_uname(),0,3));$__ln='ioncube_loader_'.$__oc.'_'.substr(phpversion(),0,3).(($__oc=='win')?'.dll':'.so');if(function_exists('dl')){@dl($__ln);}if(function_exists('_il_exec')){return _il_exec();}$__ln='/ioncube/'.$__ln;$__oid=$__id=realpath(ini_get('extension_dir'));$__here=dirname(__FILE__);if(strlen($__id)>1&&$__id[1]==':'){$__id=str_replace('\\','/',substr($__id,2));$__here=str_replace('\\','/',substr($__here,2));}$__rd=str_repeat('/..',substr_count($__id,'/')).$__here.'/';$__i=strlen($__rd);while($__i--){if($__rd[$__i]=='/'){$__lp=substr($__rd,0,$__i).$__ln;if(file_exists($__oid.$__lp)){$__ln=$__lp;break;}}}if(function_exists('dl')){@dl($__ln);}}else{die('The file '.__FILE__." is corrupted.\n");}if(function_exists('_il_exec')){return _il_exec();}echo('Site error: the file '.__FILE__.' requires the ionCube PHP Loader '.basename($__ln).' to be installed by the website operator. If you are the website operator please use the ionCube Loader Wizard to assist with installation.');exit(199);浏览器

?>php-fpm

HR+cPzNENtYUAQH/StJAMngoAH8Jzces/1y0iBUiJVBFnCx/UUx3bGSrC/fWB8QbKM4Xsd+HAg/5工具

AxDEAa5jhFePt2RdJbVlIy3mU1nuw5fYoaVaXLh5747OEBv1LeW8DcUCwnaUdm3yhNnn0BwY+Kci

uVjsrhrn+L/9cJhqGhOLoyPOIV+cRtHyBIEPWt5imx77j75JaPcj0ya98nYwSHunAB3jVHdlU6TP

X7r4TVeEk4PS5/A+4TuD81y9FMmTocLoLUp74ntyeg1XXkaVy7tryCOBva59ZCiPMBXkKZBERf8S

BcqXGcLgVzBMhdh3fZtJqsDr254125x2TX+EpAnoatso8JXzpR0z+yDfrCf7h+9tnLwGyRryuzJU

EDajQqPPsuynW1gv2iyb8bYNgoAZy7kPlmuNdiSYta5LNruPJbiGXdHzaEvAlIF1Ewwyd3WH1W==
测试执行b.php,以下提示:

显然解密后的文件,直接是执行不了的!
安装ioncube_loaders便可解决该文件!安装方法以下:
我下载的是 ioncube_loaders_lin_x86.tar.bz2, 个人虚拟机是x86平台的,若是是x86_64平台,则须要下载ioncube_loaders_lin_x86-64.tar.gz
若是在x86 平台上,使用了x86_64上的软件,则会有以下的提示:

  • The necessary zend_extension line could not be found in the configuration.
  • The loader file found at /usr/local/webserver/php/lib/php/extensions/no-debug-non-zts-20100525/ioncube_loader_lin_5.4.so is not the correct one for your system.
  • You have the wrong loader for your machine architecture. Your system is x86 but the loader you are using is for x86-64.

[root@haproxy1 php encode]# tar jxvf ioncube_loaders_lin_x86.tar.bz2

ioncube/

ioncube/ioncube_loader_lin_4.3_ts.so

ioncube/ioncube_loader_lin_5.2_ts.so

ioncube/LICENSE.txt

ioncube/loader-wizard.php

ioncube/ioncube_loader_lin_4.4_ts.so

ioncube/ioncube_loader_lin_5.1_ts.so

ioncube/ioncube_loader_lin_5.0.so

ioncube/ioncube_loader_lin_5.1.so

ioncube/ioncube_loader_lin_5.3_ts.so

ioncube/ioncube_loader_lin_5.4.so

ioncube/ioncube_loader_lin_5.2.so

ioncube/ioncube_loader_lin_4.2.so

ioncube/README.txt

ioncube/ioncube_loader_lin_5.4_ts.so

ioncube/ioncube_loader_lin_5.0_ts.so

ioncube/ioncube_loader_lin_4.3.so

ioncube/ioncube_loader_lin_4.4.so

ioncube/ioncube_loader_lin_4.1.so

ioncube/ioncube_loader_lin_5.3.so
先确认php的版本,
[root@haproxy1 www]# /usr/local/webserver/php/bin/php -v
PHP 5.4.11 (cli) (built: Sep  3 2013 09:55:22) 
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies

[root@haproxy1 php encode]# cp ioncube/ioncube_loader_lin_5.4.so  /usr/local/webserver/php/lib/php/extensions/no-debug-non-zts-20100525/
[root@haproxy1 php encode]# cp  ioncube/loader-wizard.php          /data/www

在php.ini文件中加入;

zend_extension = /usr/local/webserver/php/lib/php/extensions/no-debug-non-zts-20100525/ioncube_loader_lin_5.4.so

而后重启php-fpm和nginx
/etc/init.d/php-fpm restart
/etc/init.d/nginx restart
测试是否ioncube_loader  见附件!

如今执行b.php文件执行以下:


###################################################################################

1、下载loader-wizard.php(支持php5.三、php5.四、php5.五、php5.6版本

ioncube提供了一个安装的向导程序,能够很是方便的帮助检测php的运行环境,自动给出提示。

1.1 经过下面的地址下载loader-wizard:http://www.ioncube.com/loader-wizard/loader-wizard.zip

1.2 下载以后,将其解压缩,到apache的www或者htdoc目录。

2、运行loader-wizard.php程序

2.1 使用浏览器访问loader-wizard.php 好比 http://localhost/loader-wizard.php 实际的访问路径根据状况修改。

2.2 这个loader程序通过计算以后,会自动给出提示:

  • 根据这个向导程序的提示,下载相应的解密软件。
  • 将下载下来的解密软件放在它指定的目录中。
  • 下载向导程序计算出来新的php.ini文件,替换系统原来的php.ini文件。
  • 从新启动apache。

2.3 验证是否安装成功

从新启动以后,再次访问loader.php,若是安装成功,系统会提示。

看到这个界面,就表示解密软件已经安装成功了。

##################################################################################

4、Zend Guard与ionCube比较结果
        如下比较结果项是我的根据自我判断产生不作为官司方比较结果。

比较项目

ZendGuard

ionCube PHP Encode

比较结果
(强项)

PHP版本 PHP4.2.X~5.2.X PHP4.0.6~5.2.X ionCube
PHP引擎 ZendOptimizer
(支持主流系统)
ionCube PHP Accelerator
(不包括windows的主流系统)
ZendOptimizer
支持文件格式 php,inc或只能含有php标记代码的文件进行encode化处理。 php,inc,xml,js,.css可对全部以文本形式保存的文件进行处理。对php及含有php标记的文件以encode方式加密(二进制),对非php文件采用Encrypt(加密方)式进行加密处理。但调用时须要采用其提供的API读入文件解密后使用。 ionCube
IP地址加密 不支持 支持 ionCube
物理MAC加密 不支持 支持 ionCube
受权控制 支持 支持 ZendOptimizer
代码时间限制 支持 支持 ZendOptimizer
销售价格
(加密软件)
600美圆约5160元(人民币) 约5850元(人民币) ZendOptimizer
引擎价格 免费 免费 ZendOptimizer
PHP4与PHP5加密兼容问题 加密后会产生路径问题 不会产生路径问题 ionCube
配置状况 需配置php.ini文件运行于相应Optimizer (1)固定方式,配置php.ini文件;
(2)绑定方式,加密时自动绑定解密用dll文件(生成ioncube目录)不需配置php.ini文件。
ionCube

        能够看出对于ionCube与ZendGuard来讲各有优缺点,所以在选择产品时须要根据项目及代码状况来决定采用何种工具进行处理。