Php_screw 1.5:php Encryption: Detailed installation and use _php tutorials

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

One is the encryption program, the implementation of the PHP file encryption. The other is to parse the encrypted PHP file to get the running result. The implementation of the former is relatively simple, is a program just. Most of the latter implementations are implemented in the form of PHP module.

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

With PHP hello.php test program can successfully display, after successful display, with screw to encrypt it (screw helllo.php), and then cat the PHP file, found that it is not text, has become a lot of random characters, explain the success of the secret, and then PHP hello.php, if the normal display of Hello,world, then the resolution of the encryption is no problem, everything is OK. Otherwise, there is no place to go, you need to double check.
Problems encountered during installation:
1. Phpize not Found
Phpize is a tool belonging to the php-develp, (please fix it yourself) Therefore, you must install the PHP-DEVELP package. There are some dependencies in the middle, as follows:
Copy CodeThe code is 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 a very obvious string pm9screw, so it is easy to be guessed to be encrypted with screw.
The solution to this problem needs to begin 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, to Peterhu, the corresponding length is no longer 10, but \tpeterhu\t, altogether 7.
Copy CodeThe code is as follows:
#define PM9SCREW "\tpm9screw\t"
#define Pm9screw_len 10

==================================================================================
Read a lot of Php_screw online installation articles. Also saw several times the source of the Reademe in the newspaper.
Really toss, either script mode can not be executed, or the page cannot be displayed. After the indomitable toss finally toss out ... Share the following methods ... If there are prawns know the specific reasons may wish to point twos.
Ps:centos Release 5.8 (Final), php5.2.x
Download php-screw-1.5, if PHP4 with php-screw-1.3
SOURCE Bundle: Http://sourceforge.net/projects/php-screw/files/latest/download?source=files
The source package is placed under the/usr/local and the installation begins.
1.TAR-ZXVF php_screw-1.5.tar.gz (out of permission and other mistakes add 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, it is best not to more than 5 digits, if changed to remember well, because the recompile to use)
5.VI Php_screw.h (inside is a cryptographic string, the default is Pm9screw, it is best to change to another string, the string changed to the following length, change to love, the length is 6, the string to write down)
6../configure
7. Make && make install
It worked. Output: Installing Shared extensions:/usr/lib64/php/modules/(this directory is the directory specified by Extension_dir in/etc under php.ini). Php_ The screw.so file is here, of course, under the modules of the compiled directory.
8. CD tools/
9. Make
This generates a cryptographic program that screw the
Under CP Screw/usr/bin
In this way, you can directly screw the file name without writing the screw path.
11. Modify INI
CD/ETC/PHP.D (here is a variety of extensions loaded by PHP.ini can be written here, open other files to see if you know)
VI Php_screw.ini
Inside write on extension=php_screw.so save exit
12. Restart Apache
Create a hello.php under the root directory

PHP hello.php
Output: Hello
Screw hello.php
Output: Success crypting (hello.php), indicating that the encryption is successful, the directory will be more than one file Hello.php.screw, now the hello.php is already encrypted, and the more is the source file backup.
Cat hello.php display garbled.
PHP hello.php output hello. Script parsing encrypted file successfully.
In the root directory to establish the phpinfo, if there is php_screw extension related information that can be accessed through the browser encrypted files. I don't have to look down. I have two php.ini, and the Web page is different from the INI that the script calls.
The next step is to recompile, in order to be able to display in the Web page normally.
1. To compile the directory
Make clean
Then the catalogue was deleted.
2.TAR-ZXVF php_screw.1.5.tar.gz re-unzip
3. Phpize
4. Myscrew.h and php_screw.h the same password and string.
5../configure--with-php-config=php-config path (available in PHP installation directory)
6.make && make Install
Output: Installing Shared extensions:/var/www/php5/lib/php/extensions/no-debug-non-zts-20060613/
(This time php_screw.so in this directory)
7.php_screw.so Copy to Phpinfo extension_dir The specified directory, my is/var/www/modules under
8. Modify the php.ini (PHP installation directory, the phpinfo will show which INI is loaded, 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 will be OK ~
At this point, the installation is over, although a little bit of a clue, but I still do not understand why it is compiled two times before the line ...
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
Put the org_compile_file of line 78,84,93 (File_handle, type);
modified to:
Org_compile_file (File_handle, type TSRMLS_CC);
Then make will 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 a member named ' Extended_info '/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 file under the current directory, the files contained in the 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 backup files for. PHP Source files
The command has been experimented with successfully ... There should be nothing more to add .....

http://www.bkjia.com/PHPjc/327735.html www.bkjia.com true http://www.bkjia.com/PHPjc/327735.html techarticle php files are usually stored in text format on the server side, it is easy for others to read the source code, in order to protect the source code, you can use the source code to encrypt the way. To implement this feature ...

  • 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.