Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use php_screw

2025-04-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly shows you "how to use php_screw", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "how to use php_screw" this article.

Php files are usually stored in text format on the server, and the source code can be easily read by others. In order to protect the source code, the source code can be encrypted. To achieve this function, you need two parts:

First, the encryption program, to achieve the encryption of PHP files. The other is to parse the encrypted PHP file to get the running result. The realization of the former is relatively simple, it is just a program. The implementation of the latter is mostly 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 to produce two files: one is the screw used to encrypt PHP files, and the other is the parsing module php_screw.so loaded by php.

1. Expand the source code package and enter the directory:

two。 Execute phpize, and a configure will be generated in that directory

3. Then, run configure

4. Re-make

In this way, the php_screw.so for parsing is generated. Next, we need to get the screw for encryption.

1. Enter the tools directory of the source code

2. Make

In this way, screw is generated. If you want to encrypt a lx.php file, then: screw lx.php, lx.php becomes encrypted, and the original plaintext lx.php is renamed to lx.php.screw

The next task should be to load the php_screw.so module

First, COPY the file to the module directory, and see the extension_dir entry in the / etc/php.ini configuration file, which is / usr/lib/php/modules in RHEL 5

Method 1: you can create a new screw.ini file under the / etc/php.d directory (the file can be taken at will), and its content is one sentence extension=php_screw.so

Method 2: by modifying the php.ini file, add a sentence extension=php_screw.so, restart apache will be successful.

Important note:

The compiled .so file is theoretically related to your current version of php, that is, if you compiled it under php 5.1, you can't get php 5.2 for use, because the loadable module of php is always related to its version. theoretically, it doesn't matter if the screw executable for encryption belongs to the same version as screw.so.

Test:

Write a hello, world program with the file name hello.php as follows:

The copy code is as follows:

Use php hello.php to test whether the program can be successfully displayed, after the successful display, use screw to encrypt it (screw helllo.php), and then cat the php file, it is found that it is not a text, it has become a lot of random characters, indicating that the secret is successful, and then php hello.php, if you can display hello,world normally, then there is no problem with encrypted parsing, even if everything is OK. Otherwise, it means that there is something wrong and needs to be examined carefully.

Problems encountered during installation:

1. Phpize not found

Phpize is a tool that belongs to php-develp, so you must install the php-develp package. There are some dependencies in the middle, as follows:

The copy 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%]

two。 Each encrypted file header has an obvious string PM9SCREW, so it is easy to guess that it is encrypted with screw.

The resolution of this problem needs to start at the first step of installation. The identification string is in the php_screw.h of the source code. Before compiling, you can change this string, for example, to PeterHu, and the corresponding length is no longer 10, but\ tPeterHu\ t, a total of seven.

The copy code is as follows:

# define PM9SCREW "\ tPM9SCREW\ t"

# define PM9SCREW_LEN 10

=

Read a lot of PHP_SCREW installation articles online. I have also read the READEME in the source code newspaper several times.

Really troublesome, either the script can not be executed, or the web page can not be displayed. After indomitable struggle, it finally came out. Share the following methods. If there are prawns who know the specific reasons, you might as well point out one or two.

PS:CentOS release 5.8 (Final), php5.2.x

Download php-screw-1.5, if php4 uses php-screw-1.3

Source code package: http://sourceforge.net/projects/php-screw/files/latest/download?source=files

Put the source code package under / usr/local and start the installation.

1.tar-zxvf php_screw-1.5.tar.gz (add sudo to errors such as permission)

2.cd php_screw_1.5

3.phpize (write the absolute path of phpize if you can't execute it, if it is installed)

4.vi my_screw.h (inside is the password, you can change it if you want, it is best not to exceed 5 digits, if you change it, remember it well, because you need to use it when recompiling)

5.vi php_screw.h (encrypted string is inside. Default is PM9SCREW. It is best to change it to another string. If the string changes, the following length should also be changed. If changed to LOVE, the length is 6, and the string should be written down.)

6.. / configure

7. Make & & make install

If you succeed, you will output: Installing shared extensions: / usr/lib64/php/modules/ (this directory is the directory specified by php.iniriextension _ dir under / etc). The php_screw.so file is here, as well as under the modules of the compilation directory.

8. Cd tools/

9. Make

In this way, the encryption program screw is generated.

10. Under cp screw / usr/bin

In this way, when encrypting, you can directly screw the file name without having to write the path of screw.

11. Modify ini

Cd / etc/php.d (here are various extensions loaded by php.ini that can be written here, just open other files and see)

Vi php_screw.ini

Extension=php_screw.so is written inside to save and exit.

twelve。 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 if the encryption is successful, there will be an extra file hello.php.screw in the directory. Now the hello.php is encrypted, and the extra file is a backup of the source file.

Cat hello.php shows garbled code.

Php hello.php output hello. The script parsed the encrypted file successfully.

Set up phpinfo in the root directory, and if there is information about the php_screw extension, you can access the encrypted files through the browser. There is no need to read on. I have two php.ini, the web page is different from the ini that is called by 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 delete the directory.

2.tar-zxvf php_screw.1.5.tar.gz re-decompression

3. Phpize

4. The passwords and strings in myscrew.h and php_screw.h should be the same as before.

5. / configure-- with-php-config=php-config path (under the 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 is in this directory.)

7.php_screw.so is copied to the directory specified by phpinfori extension _ dir, mine is under / var/www/modules

8. Modify php.ini (under the php installation directory, the phpinfo will show which ini is loaded, just change that)

Add extension=php_scrw.so at the bottom

9. Restart apache

10. Check phpinfo to see if there is any information related to php_screw, and if so, it will be ok.

At this point, the installation is over, although I have a clue, but I still don't quite understand why it has to be compiled twice.

PS: several problems encountered in the compilation process are as follows (solution)

one. / root/php_screw-1.5/php_screw.c: In function 'pm9screw_compile_file':

Solution:

Php_screw.c needs to be modified

Org_compile_file (file_handle, type) in line 78, 84 and 93

Modified to:

Org_compile_file (file_handle, type TSRMLS_CC)

And then make will be successful.

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

Solution:

Php_screw.c needs to be modified

CG (extended_info) = 1

Modified to:

CG (compiler_options) | = ZEND_COMPILE_EXTENDED_INFO

How php_screw encrypts the files contained in the current directory and the files in the included directory as a whole

Find. /-name "* .php"-print | xargs-N1 screw / / encrypt all .php files

Find. /-name "* .clients"-print/xargs-N1 rm / / Delete all backup files of .php source files

All the orders have been tested successfully. There should be nothing to add.

The above is all the contents of this article "how to use php_screw". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 301

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report