How to encrypt php source code with php screw

  • 2020-06-15 07:56:02
  • OfStack

In the process of using PHP, I found that the php code I wrote was easy to be modified by others because it was stored on the server in the form of source code.
In order to keep my work, I am looking for a software that can encrypt php code.
The most famous is Zend's Zendencoder, but it is not open source software (it costs a lot and has not found a cracked version).
Since we can't afford it, we'll use open source. I found the open source software php_screw, the latest version is 1.5
Installation environment
System: centos 5.3
Software: Apache 2.2.9
PHP 5.2.10
The above environment is all downloaded by their own configuration installation. Please search the Internet for the installation method of Apache+php+mysql.
The installation
1. Extract tar-ES25en php_ES27en-1.5.ES28en.gz with tar
2. Enter the php_screw-1.5 directory to start installation
cd php_screw-1.5
phpize
As for phpize, it is only necessary to install the php5-ES42en module in the php5-ES40en extension module.
./confiugre
3. Set your own password to encrypt

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. Compile
make
5. Copy php_screw modules directory. so file to/usr lib php5 / extension directory
cp modules/php_screw.so /usr/lib/php5/extension/
6. Edit php.ini file
In the php.ini file, add the following statement
extension=php_screw.so
Restart Apache
/srv/apache/bin/apachectl restart
8. Compile encryption tools
cd tools
make
9. Copy screw to the appropriate directory
cp screw /usr/bin/
After the above 10 steps, the es85EN_ES86en-1.5 installation is complete. And php now supports interpreting encrypted php files
use
1. Write an php file to be encrypted.
I wrote the following test.php file to test the php speed

<?
$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";
?>

Place the test.php file above in the /var/www/ directory. When accessed through a browser, the speed of php (a rough estimate) is shown when performing a large number of calculations
2. Encrypt the php file we wrote
cd /var/www/
screw test.php
After we encrypt it, the test.php file in our directory is now encrypted. The source file was renamed test. php. screw was stored.
Now let's test test. php again to see if it can be used normally. How fast is it?
I compared 1. The speed before and after encryption was about 1, basically without too much loss.
3. Batch encrypted files
debian, apache2, php5, html file encryption, can be correctly resolved;
php_screw How to encrypt files in the current directory, the files contained in the directory, and the files contained in the directory as a whole
find./ -name "*.php "-print | xargs-n1 screw // encrypt all.php files
find./ -ES140en "*.screw "-ES142en/ES143en-ES144en1 rm // Delete all backup files of.php source files
All.php files in the current directory are backencrypted

Related articles: