search
HomePHP FrameworkThinkPHPTeach you how to look at Thinkphp historical vulnerabilities from a protection perspective

The following is the Thinkphp framework development tutorial column to introduce to you the historical vulnerabilities of Thinkphp from the perspective of protection. I hope it will be helpful to friends in need!

1. Foreword

At the beginning of 2019, two RCE vulnerabilities of Thinkphp5 were disclosed on the Internet. The vulnerabilities are very easy to use, resulting in many attackers using scanners to scan the entire network. scanning. We continue to observe a large amount of attack traffic using these vulnerabilities to conduct batch getshell attacks through ips devices. This article mainly analyzes briefly from the traffic perspective and uses thinkphp to attack the entire network scan and getshell traffic traces.

2. Thinkphp RCE vulnerability and scanning traffic

2.1 Review of vulnerability principle

2.1.15.0.x Version vulnerability

The principle is that the key class used by Thinkphp to process requests is Request(thinkphp/library/think/Request.php), which can implement some settings for HTTP requests

Thinkphp Supports configuring "form camouflage variable". By default, the value of this variable is _method. Therefore, in method(), you can use "form camouflage variable" to overwrite the variable to call any function of this class, and $_POST is used as the function. Parameters are passed in. Requests can be constructed to override Request class attribute values, such as overwriting the filter attribute (the filter attribute stores functions used for global filtering), thereby achieving code execution.

2.1.25.1.x-5.2.x version vulnerability

Similar to the 5.0.x version vulnerability, the vulnerability points all exist in Request(thinkphp/library/think/ Request.php) class, where:

Teach you how to look at Thinkphp historical vulnerabilities from a protection perspective

##$method variable is $this->method, which is equivalent to the "_method" parameter value of POST, and can be used to override $ The attribute value of filter (the filter attribute stores the function used for global filtering) to achieve code execution.

When this vulnerability is triggered, a warning-level exception will occur, causing the program to terminate. At this time, you need to set the ignore exception prompt. Configure error_reporting(0) in public/index.php to ignore the exception and continue running the code, as shown below:

Teach you how to look at Thinkphp historical vulnerabilities from a protection perspective

2.2 Whole network scan for Thinkphp vulnerabilities

From a traffic perspective, using the Thinkphp vulnerability is to send an http packet. We found that a hacker's scanner first writes a simple sentence as a fingerprint, and then accesses the file to see if the fingerprint information is returned. A successful access indicates that the shell has been successful. Basically, it sends two http packets, and the scanner records the successful write. Enter the website IP and URL of the shell and then manually connect with a kitchen knife for subsequent operations.

From IPS device logs and manual verification, the attacker's attack steps include 2 steps: 1. Scan the entire network to send exp, and identify whether to getshell based on fingerprints; 2. Connect with a chopper for remote control;

2.2.1 Whole network scan and send exp

Generally, scanning logs traverse segment B or segment C, and the time is relatively intensive. A certain recorded scanner log fragment is as follows,

Teach you how to look at Thinkphp historical vulnerabilities from a protection perspective

has 3 characteristics: 1. The destination IP is the same segment C or B, 2. The port is relatively fixed, 3. The scanning time is very intensive

Scan The message sent by the scanner to confirm that the shell has been written successfully uses the scanner's dedicated fingerprint, so ips does not have this detection rule.

2.2.2 Chopper connection

When the attacker manually connects the compromised site with a chopper, it will also be detected by ips, and the source can be traced to the thinkphp vulnerability through context association. The attacker's breach point. Select a few typical cases recorded at that time:

The compromised Zhengzhou server 1 (122.114.24.216):

Teach you how to look at Thinkphp historical vulnerabilities from a protection perspective

This website was indeed developed for thinkphp5, At that time, the webshell Trojan was still on the server and had not been deleted. The Trojan uploaded by the hacker can be accessed through the server. The fingerprint information is baidu. The scanner uses this fingerprint to automatically determine the success of getshell and record the URL.

Teach you how to look at Thinkphp historical vulnerabilities from a protection perspective

The compromised Sichuan server (182.151.214.106):

The compromised Sichuan server (182.151.214.106):

This Although the Trojan in the case was removed, the server could still be connected at that time. The server was also a thinkphp framework. The username was suspected to be chanpei

Teach you how to look at Thinkphp historical vulnerabilities from a protection perspective

. The device recorded the hacker's connection to the Trojan and execution of network query commands. message, the information obtained is consistent with the above error message. And it can be seen that the server is also located on a machine in the intranet. The screenshot shows that the network contains at least two subnets, 192.168.9.0 and 192.168.56.0, as shown below:

Teach you how to look at Thinkphp historical vulnerabilities from a protection perspective

The compromised US server (161.129.41.36):

The webshell on this US server has also been cleaned up. Through device packet capture, it was found that there was a hacker The same webshell Trojan was used, namely x.php, and it is suspected that it is the same group of hackers.

Teach you how to look at Thinkphp historical vulnerabilities from a protection perspective

When the hacker browsed the contents of the x.php (webshell) file on the US server, the device recorded that the password of x.php was xiao, and the flag was also baidu.

Teach you how to look at Thinkphp historical vulnerabilities from a protection perspective

It can be seen that using these two high-risk RCE vulnerabilities in Thinkphp, a large number of server vulnerabilities were discovered at that time.

3. Summary

This article combines the historical vulnerability principles of Thinkphp and shares the successful cases of exploiting Thinkphp vulnerabilities. Currently, the most common logs detected by the device every day are direct getshell logs such as weblogic, struts2, thinkphp, or ssh rdp brute force cracking logs. Once many attackers discover the latest exploit, they equip their own scanners to scan the entire network, which may result in several shells in a day. Therefore, when high-risk vulnerabilities occur, it is recommended that users apply patches in time and configure security device policies. Judging from several actual cases, the risk of scanners has always been there. If the website can be configured to prohibit direct IP access, this threat can be mitigated to some extent. Due to the limited level, everyone is welcome to point out the errors in the article and share your suggestions

The above is the detailed content of Teach you how to look at Thinkphp historical vulnerabilities from a protection perspective. For more information, please follow other related articles on the PHP Chinese website!

Statement
This article is reproduced at:FreeBuf.COM. If there is any infringement, please contact admin@php.cn delete
What Are the Key Features of ThinkPHP's Built-in Testing Framework?What Are the Key Features of ThinkPHP's Built-in Testing Framework?Mar 18, 2025 pm 05:01 PM

The article discusses ThinkPHP's built-in testing framework, highlighting its key features like unit and integration testing, and how it enhances application reliability through early bug detection and improved code quality.

How to Use ThinkPHP for Building Real-Time Stock Market Data Feeds?How to Use ThinkPHP for Building Real-Time Stock Market Data Feeds?Mar 18, 2025 pm 04:57 PM

Article discusses using ThinkPHP for real-time stock market data feeds, focusing on setup, data accuracy, optimization, and security measures.

What Are the Key Considerations for Using ThinkPHP in a Serverless Architecture?What Are the Key Considerations for Using ThinkPHP in a Serverless Architecture?Mar 18, 2025 pm 04:54 PM

The article discusses key considerations for using ThinkPHP in serverless architectures, focusing on performance optimization, stateless design, and security. It highlights benefits like cost efficiency and scalability, but also addresses challenges

How to Implement Service Discovery and Load Balancing in ThinkPHP Microservices?How to Implement Service Discovery and Load Balancing in ThinkPHP Microservices?Mar 18, 2025 pm 04:51 PM

The article discusses implementing service discovery and load balancing in ThinkPHP microservices, focusing on setup, best practices, integration methods, and recommended tools.[159 characters]

What Are the Advanced Features of ThinkPHP's Dependency Injection Container?What Are the Advanced Features of ThinkPHP's Dependency Injection Container?Mar 18, 2025 pm 04:50 PM

ThinkPHP's IoC container offers advanced features like lazy loading, contextual binding, and method injection for efficient dependency management in PHP apps.Character count: 159

How to Use ThinkPHP for Building Real-Time Collaboration Tools?How to Use ThinkPHP for Building Real-Time Collaboration Tools?Mar 18, 2025 pm 04:49 PM

The article discusses using ThinkPHP to build real-time collaboration tools, focusing on setup, WebSocket integration, and security best practices.

What Are the Key Benefits of Using ThinkPHP for Building SaaS Applications?What Are the Key Benefits of Using ThinkPHP for Building SaaS Applications?Mar 18, 2025 pm 04:46 PM

ThinkPHP benefits SaaS apps with its lightweight design, MVC architecture, and extensibility. It enhances scalability, speeds development, and improves security through various features.

How to Build a Distributed Task Queue System with ThinkPHP and RabbitMQ?How to Build a Distributed Task Queue System with ThinkPHP and RabbitMQ?Mar 18, 2025 pm 04:45 PM

The article outlines building a distributed task queue system using ThinkPHP and RabbitMQ, focusing on installation, configuration, task management, and scalability. Key issues include ensuring high availability, avoiding common pitfalls like imprope

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)
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Chat Commands and How to Use Them
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

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

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.