What is the webshell analysis of obfuscated deformation?
What is WebShell?
Originally, Webshell was often referred to as a script for Web server administrators to remotely manage the server. Later, with the birth of some Webshell management tools, the process of obtaining Web permissions was greatly simplified, so it was gradually called a Web intrusion tool script.
Webshell is different from vulnerabilities, but uses application vulnerabilities or server vulnerabilities (file upload vulnerabilities, file inclusion vulnerabilities, etc.) to upload script files to the server for subsequent exploitation, which belongs to the subsequent exploitation of penetration testing and ATT&CK's TA0002 Execution (execution) stage.
Figure 1 TA0002
Reference source: https://mitre-attack.github.io/attack-navigator/(ATT&CK Navigator)
In order to bypass detection and protection equipment, software, etc., attackers often change their Webshell writing methods to ensure that their scripts will not be detected while ensuring functionality. Among them, PHP scripts are more prominent because There are many available functions in the PHP scripting language, which leads to ever-changing confusion and deformation of writing methods in PHP.
One-sentence Trojans also belong to Webshell scripts. Friends who are interested in one-sentence Trojans can refer to the previous issue's "Multiple Transformations of One-Sentence Trojans" to learn and understand by themselves. This article will not go into details.
Background
When I analyzed Webshells before, I found that there is a type of Webshell that can completely bypass all kinds of detection software. This type of script often looks like it at the code level. It is meaningless and has no common Webshell features, but after digging through the layers, it is not difficult to find the idea of this type of obfuscated script. I just recently received an interesting obfuscated script, and I want to share the analysis process of the script with my friends. I also hope it can serve as a starting point.
First sight of the script
When I first saw this script, I saw the obvious eval function in its content, so I instinctively read this part of the code It was extracted, but it was not enough to prove anything, because the content was all seemingly clueless garbled code, without any trace of WebShell.
If you look carefully, you can find that in addition to eval, the three functions gzinflate, base64_decode, and str_rot13 are also called. Perhaps you can start with these three functions to find a breakthrough in analysis.
Figure 2 Script content
Function explanation
str_rot13()
ROT13 encoding moves each letter forward 13 letters in the alphabet. Numbers and non-alphabetic characters remain unchanged (Caesar cipher).
base64_decode()
Base64 encode the string content.
Gzinflate
The ZLIB_ENCODING_RAW encoding method is used by default for data, and the deflate data compression algorithm is used. In fact, LZ7 is used for compression first, and then Huffman coding is used for compression.
Analysis
1.Content Analysis
Figure 3 Calling the echo command
Using the echo command to parse the content, it was found that str_rot13() was executed, so I repeated this idea and tried to peel off the original content layer by layer.
Figure 4 Analysis results
2.Repeated analysis
After three echoes After repeated parsing of the command, what appeared was finally no longer a monotonous code, which proved that the direction of analysis was probably correct, and judging from the amount of code, it felt like a Trojan horse with multiple functions, commonly known as a horse.
Figure 5 Multiple parsing
3.Call the eval function to run the code content
Good guy, he is indeed a big horse.
After research, it was found that the functions of this Trojan include obtaining system information, reading directories, downloading files, uploading files, etc.
Picture 6 The original appearance of Malaysia
The above is the detailed content of What is the webshell analysis of obfuscated deformation?. For more information, please follow other related articles on the PHP Chinese website!

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

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

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



Scenario description assumes that in a real production environment, there is an RCE vulnerability, which allows us to obtain the installation of the WebShell environment. First, before pulling the vulnerable image on GetHub, we need to install nginx and tomcat on centos in advance and configure nginx and tomcat. Configuration file, use docker to pull down the image, and reproduce the vulnerability. 1. Set up the docker environment first. 2. Test whether tomcat can be accessed. As can be seen from the above figure, the back-end tomcat is accessible. 3. Check the load balancing of nginx reverse proxy in docker. 4. Check the ant in lbsnode1 in docker. .jsp text

1. After opening the URL, it was found that it was an upload page. 2. Directly uploaded the file with the suffix php, but found that it could not be uploaded. 3. Use BurpSuite to capture the packet, and change the suffix of the uploaded file with the suffix php to php5 to bypass it. After 4. Use a kitchen knife to connect. In the directory of var/www/html, a file with KEY is found. Open it and you will see key5. Open another URL, which is also an upload page, but the upload list is set. Only Allow files with the suffix .gif.jpg.png to be uploaded through 6. We write a txt one-sentence Trojan and change its suffix to jpg7. When uploading, use BurpSiuit to capture the packet and modify the file suffix to display

As Internet security issues become increasingly prominent, the security of major websites and applications has become an increasingly important issue. Especially in website operation and maintenance management, tools such as WebShell are often needed for maintenance and repair. However, WebShell is also often used by hackers and becomes an entry point for attackers to invade. This article will introduce the WebShell security settings of the Pagoda Panel to help website administrators improve the security of the site. 1. The concept and common uses of WebShell 1. Concept WebShell is

Local environment setup Judging from the retained screenshots, the other party's PHP version is 5.6.40, so I want to set up a test environment of apache+php5.6.40. Open virtualbox, copy the link to the centos image system, and configure it according to the following process. 1.Install apacheyuminstall-yhttpdhttpd-vServerversion:Apache/2.4.6(CentOS)Serverbuilt:Aug8201911:41:182.Install php5.6yum-yinstallepel-releaserpm-Uvhhttps://mi

This article introduces you to the Webshell of the Empire CMS framework. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to everyone.

SINE Security was conducting website vulnerability detection and repair on a customer's website and found that the website had serious SQL injection vulnerabilities and uploaded webshell website Trojan file vulnerabilities. The website used a CMS system, developed using PHP language, and the MySQL database architecture. The source code of this website is currently open source. A certain CMS is a social CMS system that focuses on providing paid knowledge. Payment for knowledge is in high demand on the current Internet. This system can share documents and download them for a fee. The knowledge content published by users can be hidden and provided to paying customers. read. The code is relatively streamlined and is well liked by the majority of webmasters. The vulnerability of this website mainly occurs when uploading the compressed package and constructing malicious decompression code to refer to the w in the zip package.

First of all, I understand that what I have to do is not to find where the uploaded location appears. I should log on to the server to perform webshel inspection and inspection to see if it has been invaded by others, whether there is a backdoor, etc. etc. Although the IP address reported is our company's IP address, if a few webshells are missed and uploaded successfully by others but not detected, what can we do if the server is invaded? So I went up to inspect the server, uploaded this webshell killing tool for killing, used netstat-anpt and iptables-L to determine whether there was a backdoor established, checked whether there was a mining program occupying the CPU, etc., I will not go into details here. . Fortunately, the server was not compromised, and then

What is WebShell? In the beginning, Webshell was often used as the abbreviation of a type of script used by Web server administrators to remotely manage the server. Later, with the birth of some Webshell management tools, the process of obtaining Web permissions was greatly simplified, so it was gradually called a Web intrusion tool script. Webshell is different from vulnerabilities, but uses application vulnerabilities or server vulnerabilities (file upload vulnerabilities, file inclusion vulnerabilities, etc.) to upload script files to the server for subsequent exploitation. It belongs to the subsequent exploitation of penetration testing and the TA0002Execution (execution) stage of ATT&CK. Figure 1TA0002 reference source: https
