Php_screw 1.5:php Encryption: Installation and use of detailed _php tips

Source: Internet
Author: User
Tags phpinfo automake
PHP files are usually stored in text format on the server side, it is easy to read the source code, in order to protect the source code, you can use the source code to encrypt the way. You need two parts to implement this functionality:

One is the encryption program, to achieve the encryption of PHP files. The other is to parse the encrypted PHP file to get the run result. The former is simple to achieve, it is a procedure. Most of the latter implementations are implemented in the form of PHP module.

Php_screw (screws) can achieve the above functions. The latest version is 1.5, which can be downloaded from the SourceForge.
Installation:
The purpose of the installation is actually to produce two files: one is used to encrypt the PHP file screw, the other is PHP loaded parsing module php_screw.so
1. Expand the source code package and enter the directory:
2. The execution of Phpize will create a configure in the directory
3. Then, run configure
4. Make again
In this way, the php_screw.so of parsing is generated. The next step is to get the screw for encryption.
1. Access to the source of the tools directory
2. Make
This creates a screw. If you want to encrypt a lx.php file, then: Screw lx.php, lx.php becomes encrypted, the original clear lx.php was renamed Lx.php.screw
The next task should be to load the php_screw.so module,
First, copy the file to the module directory, which is the directory, see the Extension_dir entry in the/etc/php.ini configuration file, RHEL 5 for/usr/lib/php/modules
method One: You can create a new Screw.ini file in the/ETC/PHP.D directory (the file can be arbitrarily taken), its content is a sentence extension=php_screw.so
method Two: By modifying php.ini file, added a sentence of extension=php_screw.so, restart Apache after the success.
Important NOTE:
The compiled. So file is theoretically relevant to your current version of PHP, which means that if you compile under PHP 5.1, you can't get PHP 5.2, because PHP's loadable modules are always related to their version. The screw executable file used for encryption is theoretically irrelevant, and only he and screw.so belong to the same version.
Test:
Write a Hello, world program with file name hello.php as follows:
Copy Code code as follows:

<?phpecho
"Hello,world";
?>

PHP hello.php test program can be successfully displayed, after the successful display, using screw to encrypt it (screw helllo.php), and then cat the PHP file, found that is not the text, and became a lot of chaotic characters, explain the secret success, and then PHP h ello.php, if the normal display of hello,world, it means that the resolution of encryption is no problem, all even OK. Otherwise, it means that there is something wrong, which needs to be examined carefully.
Problems encountered during installation:
1. Phpize not Found
Phpize is a tool that belongs to the PHP-DEVELP (please do it yourself) Therefore, you must install the PHP-DEVELP package. There are some dependencies in the middle, as follows:
Copy Code code as follows:

[Root@localhost server]# RPM-IVH php-devel-5.1.6-5.el5.i386.rpm
Warning:php-devel-5.1.6-5.el5.i386.rpm:header V3 DSA Signature:nokey, key ID 37017186
error:failed dependencies:
Autoconf is needed by php-devel-5.1.6-5.el5.i386
Automake is needed by php-devel-5.1.6-5.el5.i386
[Root@localhost server]# RPM-IVH autoconf
autoconf213-2.13-12.1.noarch.rpm autoconf-2.59-12.noarch.rpm
[Root@localhost server]# RPM-IVH autoconf-2.59-12.noarch.rpm
Warning:autoconf-2.59-12.noarch.rpm:header V3 DSA Signature:nokey, key ID 37017186
error:failed dependencies:
Imake is needed by Autoconf-2.59-12.noarch
[Root@localhost server]# RPM-IVH imake-1.0.2-3.i386.rpm
Warning:imake-1.0.2-3.i386.rpm:header V3 DSA Signature:nokey, key ID 37017186
Preparing ... ########################################### [100%]
1:imake ########################################### [100%]
[Root@localhost server]# RPM-IVH autoconf-2.59-12.noarch.rpm
Warning:autoconf-2.59-12.noarch.rpm:header V3 DSA Signature:nokey, key ID 37017186
Preparing ... ########################################### [100%]
1:autoconf ########################################### [100%]
[Root@localhost server]# RPM-IVH Automake
automake14-1.4p6-13.noarch.rpm automake16-1.6.3-8.noarch.rpm automake-1.9.6-2.1.noarch.rpm
automake15-1.5-16.noarch.rpm automake17-1.7.9-7.noarch.rpm
[Root@localhost server]# RPM-IVH automake-1.9.6-2.1.noarch.rpm
Warning:automake-1.9.6-2.1.noarch.rpm:header V3 DSA Signature:nokey, key ID 37017186
Preparing ... ########################################### [100%]
1:automake ########################################### [100%]
[Root@localhost server]# RPM-IVH php-devel-5.1.6-5.el5.i386.rpm
Warning:php-devel-5.1.6-5.el5.i386.rpm:header V3 DSA Signature:nokey, key ID 37017186
Preparing ... ########################################### [100%]
1:php-devel ########################################### [100%]

2. Each encrypted file header is an obvious string pm9screw, which is easily guessed to be encrypted with screw.
The solution to this problem needs to start at the first step of the installation. The identity string is in the php_screw.h of the source code. Before compiling, you can change this string, for example, changed to Peterhu, the corresponding length is no longer 10, but \tpeterhu\t, altogether 7.
Copy Code code as follows:

#define PM9SCREW "\tpm9screw\t"
#define Pm9screw_len 10

==================================================================================
Read a lot of online php_screw installation articles. Also saw several times in the source newspaper Reademe.
Really toss, either the script is not executed, or the page cannot be displayed. After the relentless toss finally toss out ... Share the following methods ... If the shrimp know the specific reasons may wish to guide twos.
Ps:centos Release 5.8 (Final), php5.2.x
Download php-screw-1.5, if PHP4 with php-screw-1.3
SOURCE Package: Http://sourceforge.net/projects/php-screw/files/latest/download?source=files
Source Pack under/usr/local, start installation
1.TAR-ZXVF php_screw-1.5.tar.gz (Come out permission and so on and then sudo)
2.CD php_screw_1.5
3.phpize (do not write phpize absolute path, installed the premise)
4.VI My_screw.h (inside is the password, want to change, preferably not more than 5 digits, if changed to remember well, because recompile to use)
5.VI Php_screw.h (inside is the encrypted string, the default is Pm9screw, it is best to change to another string, the string changed the length of the following to be followed by change, changed to love words length is 6, string to write down)
6./configure
7. Make && make install
Success is output: Installing Shared extensions:/usr/lib64/php/modules/(this directory is the directory specified in php.ini/etc below Extension_dir). php_ The screw.so file is here, of course, under the modules of the compilation directory.
8. CD tools/
9. Make
This generates a program for encryption, screw.
Under CP Screw/usr/bin
This way the encryption can be directly screw the filename, do not write the screw path
11. Modify INI
CD/ETC/PHP.D (here is the php.ini load of various extensions can be written here, open the other files to see the know)
VI Php_screw.ini
Inside Write extension=php_screw.so Save exit
12. Restart Apache
Create a hello.php under the root directory
<?echo ' Hello ';? >
PHP hello.php
Output: Hello
Screw hello.php
Output: Success crypting (hello.php), indicating the success of encryption, the directory will be more than one file Hello.php.screw, now the hello.php has been encrypted, and the more out of the source file backup.
Cat hello.php display garbled.
PHP hello.php Output Hello. Script method Parse encrypted file succeeded.
In the root directory to establish Phpinfo, if there is a php_screw extension of relevant information on the browser can access the encrypted file. There's no need to keep looking down. I have two php.ini, the Web page is different from the INI called by the script.
The next step is to recompile it so that it can be displayed properly on the Web page.
1. To compile the directory
Make clean
Then the catalogue was deleted.
2.TAR-ZXVF php_screw.1.5.tar.gz re-decompression
3. Phpize
4. Myscrew.h and php_screw.h passwords and strings remember to be the same as before
5../configure--with-php-config=php-config path (available under PHP installation directory)
6.make && make Install
Output: Installing Shared extensions:/var/www/php5/lib/php/extensions/no-debug-non-zts-20060613/
(This php_screw.so in this catalogue)
7.php_screw.so copied into phpinfo extension_dir specified directory, mine is under/var/www/modules
8. Modify PHP.ini (PHP installation directory, the phpinfo will show the load is which ini, change that)
Add extension=php_scrw.so at the bottom
9. Restart Apache
10. In the phpinfo to see the wood has php_screw related information, some words on the OK ~
At this point, the installation is over, although a bit of a clue, but I still do not understand why to compile two times to do so.
PS: Several problems encountered during the compilation process are as follows (workaround)
1. /root/php_screw-1.5/php_screw.c:in function ' Pm9screw_compile_file ':
Workaround:
Need to modify PHP_SCREW.C
The Org_compile_file (File_handle, type) of the 78,84,93 line;
modified to:
Org_compile_file (File_handle, type TSRMLS_CC);
Then make it and make it succeed.
2./opt/soft/php_screw-1.5/php_screw.c:in function' Zm_startup_php_screw ':/opt/soft/php_screw-1.5/php_screw.c:124: Error: ' Zend_compiler_globals ' does not have the name ' Extended_info ' Members of the/opt/soft/php_screw-1.5/php_screw.c:in function ' zm_shutdown_php_screw ':/opt/soft/php_screw-1.5/php_screw.c : 133: Error: ' Zend_compiler_globals ' does not have a member named ' Extended_info ' Make: * * * [Php_screw.lo] Error 1
Workaround:
Need to modify PHP_SCREW.C
Put CG (Extended_info) = 1;
modified to:
CG (compiler_options) |= zend_compile_extended_info;
Php_screw How to encrypt the files that are contained in the directory under the current directory and the files contained in the directory
Find./-name "*.php"-print|xargs-n1 screw//Encrypt all. php files
Find./-name "*.screw"-print/xargs-n1 RM//delete all. php Source files Backup files
The command has been tested successfully ... There should be nothing to add ...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.