search
HomeBackend DevelopmentPHP Tutorialphp_screw 1.5:php encryption: detailed explanation of installation and use_PHP tutorial

php_screw 1.5:php encryption: detailed explanation of installation and use_PHP tutorial

Jul 21, 2016 pm 03:04 PM
phpanduseencryptionexistInstalldocumenttextserverFormatendDetailed explanationPass

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

One is an encryption program to encrypt PHP files. The other is to parse the encrypted PHP files to get the running results. The implementation of the former is relatively simple, it is just a program. Most of the implementations of the latter are It is implemented in the form of php module.

php_screw (screw) can achieve the above functions. The latest version is 1.5, which can be downloaded from sourceforge.
Installation:
The purpose of installation is actually to generate two files: one is screw for encrypting PHP files, and the other is the parsing module loaded by php php_screw.so
1. Expand the source code package and enter Enter the directory:
2. Execute phpize, and a configure
3 will be generated in this directory. Then, run configure
4. Then make
In this way, the php_screw used for analysis is used. so is generated. Next, you need to get the encryption screw
1. Enter the tools directory of the source code
2. make
This way, screw is generated. If you want to encrypt an lx.php file , then: screw lx.php, lx.php becomes encrypted, and the original plain text lx.php is renamed lx.php.screw
The next task should be to load the php_screw.so module,
First, copy the file to the module directory. For the specific directory, please refer to the extension_dir item in the /etc/php.ini configuration file. In RHEL 5, it is /usr/lib/php/modules
Method 1: You can create a new screw.ini file in the /etc/php.d directory (the file can be taken at will), the content of which is one sentence extension=php_screw.so
Method 2: Modify the php.ini file, add extension=php_screw.so, and restart apache and it will be successful.
Important note:
The compiled .so file is theoretically related to your current PHP version. That is to say, if you compiled it under PHP 5.1, you cannot get PHP 5.2 to use it, because PHP Loadable modules are always version-specific. Theoretically, the screw executable file used for encryption does not matter, as long as it and screw.so belong to the same version.
Test:
Write a hello, world program, file The name hello.php is as follows:

Copy the code The code is as follows:

"Hello, world ";
?>

Use php hello.php to test whether the program can be successfully displayed. After it is successfully displayed, use screw to encrypt it (screw helllo.php), and then cat the program. php file, it is found that it is no longer text, but has become a lot of garbled characters, indicating that the encryption is successful, and then php hello.php. If hello and world can be displayed normally, it means that there is no problem with the encryption analysis, and everything is OK. Otherwise, it means there is something wrong and you need to check it carefully.
Problems encountered during the installation process:
1. Cannot find phpize
phpize is a tool that belongs to php-develp, (please figure out the specific function by yourself) Therefore, you must install the php-develp package. There are some dependencies in the middle, as follows:
Copy code The 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.每个加密的文件头部都一个很明显的字符串PM9SCREW, 这样很容易被人猜到是用screw加密的.
这个问题的解决需要在安装的第一步就开始. 该标识串在源码的php_screw.h中. 在编译之前, 可以更改这个字符串, 例如,更改为PeterHu, 相应的下面的长度就不再是10了, 而是tPeterHut,一共7个了.
复制代码 代码如下:

#define PM9SCREW        "tPM9SCREWt"
#define PM9SCREW_LEN     10

================================================== ===================================
I have read a lot of PHP_SCREW installation articles on the Internet. I have also read several README.
in the source code report is really frustrating, either the script cannot be executed, or the web page cannot be displayed. After unremitting tossing, I finally figured it out... Share the following method... If anyone knows the details You might as well give some advice on the reasons.
PS: CentOS release 5.8 (Final), php5.2.x
Download php-screw-1.5, if php4 use 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 if there is an error such as permission)
2.cd php_screw_1.5
3.phpize (If it cannot be executed, write the absolute path of phpize, assuming it is installed)
4.vi my_screw.h (It contains the password, change it if you want. It is best not to exceed 5 digits. If you change it, remember it because it will be used when recompiling)
5.vi php_screw.h( There is an encrypted string inside. The default is PM9SCREW. It is best to change it to another string. If the string changes, the length will also change. If it is changed to LOVE, the length will be 6. The string should be written down)
6. ./configure
7. make && make install
If successful, it will output: Installing shared extensions: /usr/lib64/php/modules/ (this directory is the directory specified by extension_dir in php.ini under /etc). The php_screw.so file is here, of course it is also under the modules of the compilation directory.
8. cd tools/
9. make
In this way, the encryption program screw is generated
10. cp screw / Under usr/bin
In this way, when encrypting, you can screw the file name directly without writing the screw path
11. Modify ini
cd /etc/php.d (here are the various files loaded by php.ini Extensions can be written here, just open other files and you will know)
vi php_screw.ini
Write extension=php_screw.so in it, save and exit
12. Restart apache
In the root directory Create hello.php

php hello.php
Output: hello
screw hello.php
Output: Success Crypting(hello.php) , indicating that the encryption is successful, there will be an extra file hello.php.screw in the directory. The current hello.php has been encrypted, and the extra file is a backup of the source file.
cat hello.php displays garbled characters .
php hello.php outputs hello. The script method successfully parsed the encrypted file.
Create phpinfo in the root directory. If there is information related to the php_screw extension, it means that the encrypted file can be accessed through the browser. No need to continue. Look down. I have two php.ini. The web page and the ini called by the script are different.
Next, I need to recompile it so that it can be displayed normally on the web page.
1. Go to the compilation directory
make clean
Then delete the directory.
2.tar -zxvf php_screw.1.5.tar.gz Re-decompress
3. phpize
4. myscrew.h and php_screw.h The password and string must be the same as before
5. ./configure --with-php-config=php-config path (available in 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. Copy php_screw.so to the directory specified by extension_dir in phpinfo, mine is under /var/www/modules
8. Modify php.ini (in the php installation directory, phpinfo will show which ini is loaded, just Change that)
Add extension=php_scrw.so at the bottom
9. Restart apache
10. Check if there is any php_screw related information in phpinfo, if there is, it will be ok ~
That’s it , the installation is over. Although I have some clues, I still don’t quite understand why it has to be compiled twice...
PS: Several problems encountered during the compilation process As follows (solution)
1. /root/php_screw-1.5/php_screw.c: In function 'pm9screw_compile_file':
Solution:
Need to modify php_screw.c
to 78, 84, 93 The line org_compile_file(file_handle, type);
is modified to:
org_compile_file(file_handle, type TSRMLS_CC);
and then make succeeds.
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' No 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' has no member named 'extended_info' member make: *** [php_screw.lo] Error 1
Solution:
Need to modify php_screw.c
Put CG(extended_info) = 1;
Modify to:
CG(compiler_options) |= ZEND_COMPILE_EXTENDED_INFO;
How php_screw encrypts the current directory, the files contained in the directory, and the files in the containing directory as a whole
find ./ -name "*.php" -print|xargs -n1 screw //Encrypt all .php files
find ./ -name "*.screw" -print/xargs -n1 rm //Delete all The backup file
command of the .php source file has been successfully tested... There should be nothing to add...

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/327735.htmlTechArticlephp files are usually stored in text format on the server side, and the source code can easily be read by others. In order to verify the source code To protect the code, you can encrypt the source code. To achieve this function...
Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
PHP's Current Status: A Look at Web Development TrendsPHP's Current Status: A Look at Web Development TrendsApr 13, 2025 am 12:20 AM

PHP remains important in modern web development, especially in content management and e-commerce platforms. 1) PHP has a rich ecosystem and strong framework support, such as Laravel and Symfony. 2) Performance optimization can be achieved through OPcache and Nginx. 3) PHP8.0 introduces JIT compiler to improve performance. 4) Cloud-native applications are deployed through Docker and Kubernetes to improve flexibility and scalability.

PHP vs. Other Languages: A ComparisonPHP vs. Other Languages: A ComparisonApr 13, 2025 am 12:19 AM

PHP is suitable for web development, especially in rapid development and processing dynamic content, but is not good at data science and enterprise-level applications. Compared with Python, PHP has more advantages in web development, but is not as good as Python in the field of data science; compared with Java, PHP performs worse in enterprise-level applications, but is more flexible in web development; compared with JavaScript, PHP is more concise in back-end development, but is not as good as JavaScript in front-end development.

PHP vs. Python: Core Features and FunctionalityPHP vs. Python: Core Features and FunctionalityApr 13, 2025 am 12:16 AM

PHP and Python each have their own advantages and are suitable for different scenarios. 1.PHP is suitable for web development and provides built-in web servers and rich function libraries. 2. Python is suitable for data science and machine learning, with concise syntax and a powerful standard library. When choosing, it should be decided based on project requirements.

PHP: A Key Language for Web DevelopmentPHP: A Key Language for Web DevelopmentApr 13, 2025 am 12:08 AM

PHP is a scripting language widely used on the server side, especially suitable for web development. 1.PHP can embed HTML, process HTTP requests and responses, and supports a variety of databases. 2.PHP is used to generate dynamic web content, process form data, access databases, etc., with strong community support and open source resources. 3. PHP is an interpreted language, and the execution process includes lexical analysis, grammatical analysis, compilation and execution. 4.PHP can be combined with MySQL for advanced applications such as user registration systems. 5. When debugging PHP, you can use functions such as error_reporting() and var_dump(). 6. Optimize PHP code to use caching mechanisms, optimize database queries and use built-in functions. 7

PHP: The Foundation of Many WebsitesPHP: The Foundation of Many WebsitesApr 13, 2025 am 12:07 AM

The reasons why PHP is the preferred technology stack for many websites include its ease of use, strong community support, and widespread use. 1) Easy to learn and use, suitable for beginners. 2) Have a huge developer community and rich resources. 3) Widely used in WordPress, Drupal and other platforms. 4) Integrate tightly with web servers to simplify development deployment.

Beyond the Hype: Assessing PHP's Role TodayBeyond the Hype: Assessing PHP's Role TodayApr 12, 2025 am 12:17 AM

PHP remains a powerful and widely used tool in modern programming, especially in the field of web development. 1) PHP is easy to use and seamlessly integrated with databases, and is the first choice for many developers. 2) It supports dynamic content generation and object-oriented programming, suitable for quickly creating and maintaining websites. 3) PHP's performance can be improved by caching and optimizing database queries, and its extensive community and rich ecosystem make it still important in today's technology stack.

What are Weak References in PHP and when are they useful?What are Weak References in PHP and when are they useful?Apr 12, 2025 am 12:13 AM

In PHP, weak references are implemented through the WeakReference class and will not prevent the garbage collector from reclaiming objects. Weak references are suitable for scenarios such as caching systems and event listeners. It should be noted that it cannot guarantee the survival of objects and that garbage collection may be delayed.

Explain the __invoke magic method in PHP.Explain the __invoke magic method in PHP.Apr 12, 2025 am 12:07 AM

The \_\_invoke method allows objects to be called like functions. 1. Define the \_\_invoke method so that the object can be called. 2. When using the $obj(...) syntax, PHP will execute the \_\_invoke method. 3. Suitable for scenarios such as logging and calculator, improving code flexibility and readability.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.