解析如何用php screw加密php源代碼
更新時(shí)間:2013年06月20日 15:11:42 作者:
本篇文章是對用php_screw加密php源代碼進(jìn)行了詳細(xì)的分析介紹,需要的朋友參考下
在使用PHP過程中發(fā)現(xiàn),自己編寫的php代碼因?yàn)槎际窃创a方式放在服務(wù)器上的所以很容易就被別人拿走隨便修改(變成自己開發(fā)的)使用了。
為了保住自己的勞動成果,我一直尋找一種可以加密php代碼的軟件。
最著名的就是Zend公司的Zendencoder了,但是不是開源軟件(要價(jià)很高,也沒有找到破解版)。
既然收費(fèi)的用不起,我們就用開源的。我找到了php_screw這個開源軟件,目前最新版本是1.5
安裝環(huán)境
系統(tǒng):centos 5.3
軟件:Apache 2.2.9
PHP 5.2.10
以上環(huán)境全部是自己下載配置安裝的。具體的Apache+php+mysql安裝方法請從網(wǎng)上搜索。
安裝
1.用tar解壓縮 tar -zxvf php_screw-1.5.tar.gz
2.進(jìn)入php_screw-1.5目錄開始安裝
cd php_screw-1.5
phpize
關(guān)于phpize ,它在php5-dev擴(kuò)展模塊中 只要安裝php5-dev模塊就行了。
./confiugre
3.設(shè)置自己用來加密的密碼
vi my_screw.h
-- Please change the encryption SEED key (pm9screw_mycryptkey) into the
values according to what you like.
The encryption will be harder to break, if you add more values to the
encryption SEED array. However, the size of the SEED is unrelated to
the time of the decrypt processing.
* If you can read and understand the source code, to modify an original
encryption logic will be possible. But in general, this should not
be necessary.
OPTIONAL: Encrypted scripts get a stamp added to the beginning of the
file. If you like, you may change this stamp defined by
PM9SCREW and PM9SCREW_LEN in php_screw.h. PM9SCREW_LEN must
be less than or equal to the size of PM9SCREW.
4.編譯
make
5.拷貝modules目錄下的php_screw.so文件到/usr/lib/php5/extension目錄下
cp modules/php_screw.so /usr/lib/php5/extension/
6.編輯php.ini文件
在php.ini文件里,加入如下語句
extension=php_screw.so
7.重新啟動Apache
/srv/apache/bin/apachectl restart
8.編譯加密工具
cd tools
make
9.將tools目錄下加密用的工具screw拷貝到適當(dāng)目錄
cp screw /usr/bin/
經(jīng)過以上的10步,就已經(jīng)把php_screw-1.5全部安裝完成了。并且現(xiàn)在的php也已經(jīng)支持解釋加密過的php文件了
使用
1.現(xiàn)寫一個要加密的php文件。
我寫了如下的一個用來測試php速度的test.php文件
<?
$a=0;
$t=time();
for($i=0;$i<5000000;$i++)
{$a=$a*$i;}
$t1=time();
echo "<p>";
echo "It used:";
echo $t1-$t;
echo "seconds";
?>
將上面的test.php文件放到/var/www/目錄下。通過瀏覽器訪問,將顯示出php在大量計(jì)算時(shí)的速度(粗略估計(jì))
2.將我們寫的php文件加密
cd /var/www/
screw test.php
我們加密后,現(xiàn)在目錄下的test.php文件就是我們已經(jīng)加密的了。而源文件被改名為test.php.screw存放了。
我們現(xiàn)在再測試一下test.php,看看能否正常使用?速度如何?
我比較了一下,加密前后的速度大概一樣,基本沒有太多的損失。
3.批處理加密文件
在debian, apache2, php5上測試過對.html文件加密后,能正確解析;
php_screw如何對當(dāng)前目錄下,對目錄下包含的文件,以及包含目錄下的文件進(jìn)行整體加密
find ./ -name "*.php"-print|xargs -n1 screw //加密所有的.php文件
find ./ -name "*.screw" -print/xargs -n1 rm //刪除所有的.php源文件的備份文件
這樣在當(dāng)前目錄下的所有.php文件就全部背加密了
為了保住自己的勞動成果,我一直尋找一種可以加密php代碼的軟件。
最著名的就是Zend公司的Zendencoder了,但是不是開源軟件(要價(jià)很高,也沒有找到破解版)。
既然收費(fèi)的用不起,我們就用開源的。我找到了php_screw這個開源軟件,目前最新版本是1.5
安裝環(huán)境
系統(tǒng):centos 5.3
軟件:Apache 2.2.9
PHP 5.2.10
以上環(huán)境全部是自己下載配置安裝的。具體的Apache+php+mysql安裝方法請從網(wǎng)上搜索。
安裝
1.用tar解壓縮 tar -zxvf php_screw-1.5.tar.gz
2.進(jìn)入php_screw-1.5目錄開始安裝
cd php_screw-1.5
phpize
關(guān)于phpize ,它在php5-dev擴(kuò)展模塊中 只要安裝php5-dev模塊就行了。
./confiugre
3.設(shè)置自己用來加密的密碼
復(fù)制代碼 代碼如下:
vi my_screw.h
-- Please change the encryption SEED key (pm9screw_mycryptkey) into the
values according to what you like.
The encryption will be harder to break, if you add more values to the
encryption SEED array. However, the size of the SEED is unrelated to
the time of the decrypt processing.
* If you can read and understand the source code, to modify an original
encryption logic will be possible. But in general, this should not
be necessary.
OPTIONAL: Encrypted scripts get a stamp added to the beginning of the
file. If you like, you may change this stamp defined by
PM9SCREW and PM9SCREW_LEN in php_screw.h. PM9SCREW_LEN must
be less than or equal to the size of PM9SCREW.
4.編譯
make
5.拷貝modules目錄下的php_screw.so文件到/usr/lib/php5/extension目錄下
cp modules/php_screw.so /usr/lib/php5/extension/
6.編輯php.ini文件
在php.ini文件里,加入如下語句
extension=php_screw.so
7.重新啟動Apache
/srv/apache/bin/apachectl restart
8.編譯加密工具
cd tools
make
9.將tools目錄下加密用的工具screw拷貝到適當(dāng)目錄
cp screw /usr/bin/
經(jīng)過以上的10步,就已經(jīng)把php_screw-1.5全部安裝完成了。并且現(xiàn)在的php也已經(jīng)支持解釋加密過的php文件了
使用
1.現(xiàn)寫一個要加密的php文件。
我寫了如下的一個用來測試php速度的test.php文件
復(fù)制代碼 代碼如下:
<?
$a=0;
$t=time();
for($i=0;$i<5000000;$i++)
{$a=$a*$i;}
$t1=time();
echo "<p>";
echo "It used:";
echo $t1-$t;
echo "seconds";
?>
將上面的test.php文件放到/var/www/目錄下。通過瀏覽器訪問,將顯示出php在大量計(jì)算時(shí)的速度(粗略估計(jì))
2.將我們寫的php文件加密
cd /var/www/
screw test.php
我們加密后,現(xiàn)在目錄下的test.php文件就是我們已經(jīng)加密的了。而源文件被改名為test.php.screw存放了。
我們現(xiàn)在再測試一下test.php,看看能否正常使用?速度如何?
我比較了一下,加密前后的速度大概一樣,基本沒有太多的損失。
3.批處理加密文件
在debian, apache2, php5上測試過對.html文件加密后,能正確解析;
php_screw如何對當(dāng)前目錄下,對目錄下包含的文件,以及包含目錄下的文件進(jìn)行整體加密
find ./ -name "*.php"-print|xargs -n1 screw //加密所有的.php文件
find ./ -name "*.screw" -print/xargs -n1 rm //刪除所有的.php源文件的備份文件
這樣在當(dāng)前目錄下的所有.php文件就全部背加密了
相關(guān)文章
PHP單例模式數(shù)據(jù)庫連接類與頁面靜態(tài)化實(shí)現(xiàn)方法
這篇文章主要介紹了PHP單例模式數(shù)據(jù)庫連接類與頁面靜態(tài)化實(shí)現(xiàn)方法,涉及php面向?qū)ο髥卫J綌?shù)據(jù)庫連接類的定義與使用方法,以及緩存實(shí)現(xiàn)頁面靜態(tài)化相關(guān)操作技巧,需要的朋友可以參考下2019-03-03PHP中unset,array_splice刪除數(shù)組中元素的區(qū)別
php中刪除數(shù)組元素是非常的簡單的,但有時(shí)刪除數(shù)組需要對索引進(jìn)行一些排序要求我們會使用到相關(guān)的函數(shù),這里我們來介紹使用unset,array_splice刪除數(shù)組中的元素區(qū)別吧2014-07-07PHP實(shí)現(xiàn)逐行刪除文件右側(cè)空格的方法
這篇文章主要介紹了PHP實(shí)現(xiàn)逐行刪除文件右側(cè)空格的方法,涉及php針對文件的打開、逐行讀取、rtrim函數(shù)刪除右側(cè)空格及文件保存等技巧,需要的朋友可以參考下2015-12-12