php代码混淆加密

最近由于对产品做交付,对产品做了License授权,有吧产品分装在kvm里面,但是感觉还是不太安全,于是想到对源码进行加密处理,目前市场上用的比较多的大致如下,本文使用了PHP Screw plus  文章开头使用别人写好的一些方案,就是就是流行的加解密产品 

参考如下

#方案类型是否免费优劣势分析
1Zend Guard基于加解密客户端收费PHP官方出品,是目前成熟的加密方案,不支持PHP7。Zend Guard用于加密(安装在开发或打包环境),Zend Guard Loader用于解密(安装在线上环境)软件下载
市面上仅流传出Zend Guard 6.0的破解版,支持PHP 5.3 5.4,安全平台使用的是PHP 5.6.30。
2ionCube PHP Encode基于加解密客户端收费Zend Guard只能对带有PHP标记或源码的文件进行加密,而ionCube可对PHP或非PHP文件进行加密,ionCube在功能方面经过测试优胜于Zend公司的ZendGuard。
没有找到破解版。
3Swoole Compiler加密后可直接运行收费支持5.4-7.2全系列版本,优点:进行了很深入的编译优化,以目前 PHP 反汇编领域的情况看,根本破不了。
Swoole Compiler 有两道工序,第一步:从源码编译为 opcode,这一步会移除代码中除逻辑以外的其他信息,如注释、变量名称、类名、常量、函数名。 第二步:opcode 加密混淆处理。这一步才是关键,最终生成的指令连 vld、phpdbg 这些工具都无法识别。
4PHP Screw加密后可直接运行免费开源项目,没有维护了。加密算法比较弱,网上已有 破解方法
5PHP Screw plus基于扩展免费开源项目,基于扩展来加解密,采用AES256算法。他还有个功能,可阻止执行未经许可的php文件,这样黑客就算上传了webshell也不能执行。
6PHP Beast基于扩展免费开源项目,基于扩展来加解密,可选DES、AES、BASE64加密算法。支持自定义开发加密模块。
  1. 拉取代码
    1. git clone https://git.oschina.net/splot/php-screw-plus.git

       

  2. 进去php-screw-plus
  3. 编译
    1.  
      /usr/local/php/bin/phpize

       

    2.  
      ./configure --with-config-php=/usr/local/php/bin/php-config

       

    3.  
      [root@dev02v php-screw-plus]# make 
      /bin/sh /home/jiangzhijie/safetyPhp/php-screw-plus/libtool --mode=compile cc  -I. -I/home/jiangzhijie/safetyPhp/php-screw-plus -DPHP_ATOM_INC -I/home/jiangzhijie/safetyPhp/php-screw-plus/include -I/home/jiangzhijie/safetyPhp/php-screw-plus/main -I/home/jiangzhijie/safetyPhp/php-screw-plus -I/usr/local/php/include/php -I/usr/local/php/include/php/main -I/usr/local/php/include/php/TSRM -I/usr/local/php/include/php/Zend -I/usr/local/php/include/php/ext -I/usr/local/php/include/php/ext/date/lib  -DHAVE_CONFIG_H  -g -O2   -c /home/jiangzhijie/safetyPhp/php-screw-plus/php_screw_plus.c -o php_screw_plus.lo 
      mkdir .libs
       cc -I. -I/home/jiangzhijie/safetyPhp/php-screw-plus -DPHP_ATOM_INC -I/home/jiangzhijie/safetyPhp/php-screw-plus/include -I/home/jiangzhijie/safetyPhp/php-screw-plus/main -I/home/jiangzhijie/safetyPhp/php-screw-plus -I/usr/local/php/include/php -I/usr/local/php/include/php/main -I/usr/local/php/include/php/TSRM -I/usr/local/php/include/php/Zend -I/usr/local/php/include/php/ext -I/usr/local/php/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /home/jiangzhijie/safetyPhp/php-screw-plus/php_screw_plus.c  -fPIC -DPIC -o .libs/php_screw_plus.o
      /bin/sh /home/jiangzhijie/safetyPhp/php-screw-plus/libtool --mode=link cc -DPHP_ATOM_INC -I/home/jiangzhijie/safetyPhp/php-screw-plus/include -I/home/jiangzhijie/safetyPhp/php-screw-plus/main -I/home/jiangzhijie/safetyPhp/php-screw-plus -I/usr/local/php/include/php -I/usr/local/php/include/php/main -I/usr/local/php/include/php/TSRM -I/usr/local/php/include/php/Zend -I/usr/local/php/include/php/ext -I/usr/local/php/include/php/ext/date/lib  -DHAVE_CONFIG_H  -g -O2   -o php_screw_plus.la -export-dynamic -avoid-version -prefer-pic -module -rpath /home/jiangzhijie/safetyPhp/php-screw-plus/modules  php_screw_plus.lo 
      cc -shared  .libs/php_screw_plus.o   -Wl,-soname -Wl,php_screw_plus.so -o .libs/php_screw_plus.so
      creating php_screw_plus.la
      (cd .libs && rm -f php_screw_plus.la && ln -s ../php_screw_plus.la php_screw_plus.la)
      /bin/sh /home/jiangzhijie/safetyPhp/php-screw-plus/libtool --mode=install cp ./php_screw_plus.la /home/jiangzhijie/safetyPhp/php-screw-plus/modules
      cp ./.libs/php_screw_plus.so /home/jiangzhijie/safetyPhp/php-screw-plus/modules/php_screw_plus.so
      cp ./.libs/php_screw_plus.lai /home/jiangzhijie/safetyPhp/php-screw-plus/modules/php_screw_plus.la
      PATH="$PATH:/sbin" ldconfig -n /home/jiangzhijie/safetyPhp/php-screw-plus/modules
      ----------------------------------------------------------------------
      Libraries have been installed in:
         /home/jiangzhijie/safetyPhp/php-screw-plus/modules
      
      If you ever happen to want to link against installed libraries
      in a given directory, LIBDIR, you must either use libtool, and
      specify the full pathname of the library, or use the `-LLIBDIR'
      flag during linking and do at least one of the following:
         - add LIBDIR to the `LD_LIBRARY_PATH' environment variable
           during execution
         - add LIBDIR to the `LD_RUN_PATH' environment variable
           during linking
         - use the `-Wl,--rpath -Wl,LIBDIR' linker flag
         - have your system administrator add LIBDIR to `/etc/ld.so.conf'
      
      See any operating system documentation about shared libraries for
      more information, such as the ld(1) and ld.so(8) manual pages.
      ----------------------------------------------------------------------
      
      Build complete.
      Don't forget to run 'make test'.
      
      [root@dev02v php-screw-plus]# make install
      Installing shared extensions:     /usr/local/php/lib/php/extensions/no-debug-non-zts-20131226/
      [root@dev02v php-screw-plus]# cd /usr/local/php/lib/php/extensions/no-debug-non-zts-20131226
      

       

    4.  把扩展加入到php.ini中,重启php,出现如下扩展,代表安装成功
    5.  
      [root@dev02v tools]# php -m | grep php_screw_plus
      php_screw_plus
      

       

  4. 初次使用
    1.  
      进入你相应的目录 
      /home/jiangzhijie/safetyPhp/php-screw-plus/tools
      
      执行 make 命令
      
      则多了screw文件,说明成功
      
      下面进行真正的操作
      
      加密
      
      随便写入一段php 如 index.php 
      
      执行  
      ./screw index.php
      
      出现 Success Decrypting - index.php 表示成功 
      
      你的文件则变成
      
      [root@dev02v tools]# more  index.php 灛汁谻׆򳊮C֓t(Į¦;y캶5۫z+ N^L뫱`7«Kᡓ㟯򧥴yu¬¢|tך`®Y,©饁║&a¦½ƙ
      㔬ޠ̺
      º&D#e6- ²£ЁȤDZҨˠӢ§𩲉a̞².dᙏ윂)񍌈$«ej񜸦¥+~,dYEh񐈘KᯤԜG4IRzԶºܠ˳3pT񡕃ޚ/¢𛴗󿿕£þfBꥠS±p峚Pڭ½±7X57LS󺾺q¥ª9f�_xþsI맙¶[ȫ{Ah¬G(µ¤Ô8P瘄.x!󢢠¡ƿN&1{6ʐzv«^L¤]¹󿷺㉳­.Ȳ㴳򐼭F[U»¼°gͶ(^ځ_zµb
      Ļcݾd["{s!¹ۿE4cw̤J9ꩄ@ֶٻ©IOoª<ӲrI󳚄:ɒ5򩐜p$l򗈦! 
      W1N¬IxO狌Jܨ󳔉>󖠝,޾²
      ϡ£´𐏆덍P֧¬¤ߥm|隣µлv¦
      m6o󶨋U󁄱¸~u=_§~΅+񫼺`㚣󥥼Q¾£َ{dڥ¦¯261*ɍ2܍Cµv3©Ȅ5¥zH΂³¼j򌜝Ɒ´^:𐫊w񁇡º9wº$£9¢_iA쑦bµT¼
      cd3塞²«9@o퐯,򍠋ˍMw𝿡ǪCe튚¬Y9U ׮ŰpCP֙z缱ºնҜ-򈉩¢ɑ
      ©$¢ԅYJWкҤJғ©dþ¡[¯󿝨܇½󿿡
      
      
      解密:
      
      执行
      ./screw index.php -d 
      出现  Success Decrypting - index.php 表示解密成功

      希望对大家有帮助

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值