最近由於對產品做交付,對產品做了License授權,有吧產品分裝在kvm裏面,但是感覺還是不太安全,於是想到對源碼進行加密處理,目前市場上用的比較多的大致如下,本文使用了PHP Screw plus 文章開頭使用別人寫好的一些方案,就是就是流行的加解密產品
參考如下
# | 方案 | 類型 | 是否免費 | 優劣勢分析 |
---|---|---|---|---|
1 | Zend Guard | 基於加解密客戶端 | 收費 | PHP官方出品,是目前成熟的加密方案,不支持PHP7。Zend Guard用於加密(安裝在開發或打包環境),Zend Guard Loader用於解密(安裝在線上環境)軟件下載 市面上僅流傳出Zend Guard 6.0的破解版,支持PHP 5.3 5.4,安全平臺使用的是PHP 5.6.30。 |
2 | ionCube PHP Encode | 基於加解密客戶端 | 收費 | Zend Guard只能對帶有PHP標記或源碼的文件進行加密,而ionCube可對PHP或非PHP文件進行加密,ionCube在功能方面經過測試優勝於Zend公司的ZendGuard。 沒有找到破解版。 |
3 | Swoole Compiler | 加密後可直接運行 | 收費 | 支持5.4-7.2全系列版本,優點:進行了很深入的編譯優化,以目前 PHP 反彙編領域的情況看,根本破不了。 Swoole Compiler 有兩道工序,第一步:從源碼編譯爲 opcode,這一步會移除代碼中除邏輯以外的其他信息,如註釋、變量名稱、類名、常量、函數名。 第二步:opcode 加密混淆處理。這一步纔是關鍵,最終生成的指令連 vld、phpdbg 這些工具都無法識別。 |
4 | PHP Screw | 加密後可直接運行 | 免費 | 開源項目,沒有維護了。加密算法比較弱,網上已有 破解方法 |
5 | PHP Screw plus | 基於擴展 | 免費 | 開源項目,基於擴展來加解密,採用AES256算法。他還有個功能,可阻止執行未經許可的php文件,這樣黑客就算上傳了webshell也不能執行。 |
6 | PHP Beast | 基於擴展 | 免費 | 開源項目,基於擴展來加解密,可選DES、AES、BASE64加密算法。支持自定義開發加密模塊。 |
- 拉取代碼
-
git clone https://git.oschina.net/splot/php-screw-plus.git
-
- 進去php-screw-plus
- 編譯
-
/usr/local/php/bin/phpize
-
./configure --with-config-php=/usr/local/php/bin/php-config
-
[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
- 把擴展加入到php.ini中,重啓php,出現如下擴展,代表安裝成功
-
[root@dev02v tools]# php -m | grep php_screw_plus php_screw_plus
-
- 初次使用
-
進入你相應的目錄 /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¥+~,dYEhKᯤԜG4IRzԶºܠ˳3pTޚ/¢£þfBꥠS±p峚Pڭ½±7X57LSq¥ª9f�_xþsI맙¶[ȫ{Ah¬G(µ¤Ô8P瘄.x!¡ƿN&1{6ʐzv«^L¤]¹㉳.Ȳ㴳F[U»¼°gͶ(^ځ_zµb Ļcݾd["{s!¹ۿE4cw̤J9ꩄ@ֶٻ©IOoª<ӲrI:ɒ5p$l! W1N¬IxO狌Jܨ>,² ϡ£´덍P֧¬¤ߥm|隣µлv¦ m6oU¸~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 表示解密成功
希望對大家有幫助
-