The thinkphp framework tutorial column below will introduce you to the auditing (sharing) of the ThinkPHP framework in one minute. I hope it will be helpful to friends in need!
Introduction to ThinkPHP
ThinkPHP is a It is a free and open source, fast and simple object-oriented lightweight PHP development framework. It was founded in early 2006 and released under the Apache2 open source agreement. It was born for agile WEB application development and simplified enterprise application development. ThinkPHP has been adhering to the simple and practical design principle since its birth. While maintaining excellent performance and minimal code, it also focuses on ease of use. It has many original functions and features. With the active participation of the community team, it has been continuously optimized and improved in terms of ease of use, scalability and performance. It has grown into the most leading and influential WEB application development framework in China, with many Typical cases ensure that it can be stably used for commercial and portal-level development.
Vulnerability Brief
##Although the ThinkPHP 5.0.x framework uses parameterized queries method to operate the database, but in the insert and update methods, the parameters passed in are controllable and not strictly filtered, which ultimately led to the occurrence of this SQL injection vulnerability.
Using ThinkPHP framework 5.0.x sql injection vulnerability for analysis
thinkphpOfficial website download version 5.0.15: http://www.thinkphp.cn/down/1125.html . Set up the database, the database is tp, the table name is user, and there are two fields id and username.
Modify the database configuration information application/database.php, in application/config Turn on debugging and trace in .php.
Add a method to the Index class in application/index/controller/Index.php:
##public function testsql()
{
$username = input('get.username/a');
db('user')->where(['id'=> 1])->insert(['username'=>$username]);
}
The explanation is as follows:
http://127.0.0.1/thinkphp/ public/ index.php/ index/ index/ index domain name website directory external access directory entry file front desk controller method name
Extension: ##About updatexml function UPDATEXML (XML_document, XPath_string, new_value );
The first parameter: XML_document is in String format and is the name of the XML document object. The text is Doc
The second parameter: XPath_string (string in Xpath format). If you don’t understand Xpath syntax, you can find tutorials on the Internet.
The third parameter: new_value, String format, replaces the found data that meets the conditions
作用:改变文档中符合条件的节点的值 访问payload,就可以触发漏洞了。 漏洞分析 首先,我们知道 insert 方法存在漏洞,那就查看 insert 方法的具体实现。 通过input获取到参数后,username变量情况如下: 跟入insert,thinkphp/library/think/db/Query.php 然后执行insert语句 跟入 thinkphp/library/think/db/Builder.php 跟入parseData至 thinkphp/library/think/db/Builder.php 可以看出$val是数组,且根据$val[0]值为inc,会通过switch语句进入到’inc’: 此处的parseKey,即thinkphp/library/think/db/builder/Mysql.php 此处并未对传入的$key进行更多的过滤与检查,将其与前面经过parseKey的结果进行拼接后返回给result 至此注入成功。 漏洞修复 https://github.com/top-think/framework/commit/363fd4d90312f2cfa427535b7ea01a097ca8db1b 在进行dec和inc操作之前对$val[1]的值进行了再次确认。 总结 第一次审计Thinkphp框架 ,结合Thinkphp5.0手册以及网上教程完成此次漏洞的审计。 相关推荐:最新的10个thinkphp视频教程$sql = $this->builder->insert($data, $options, $replace);
The above is the detailed content of Learn about the audit of ThinkPHP framework in one minute (share). For more information, please follow other related articles on the PHP Chinese website!

This article demonstrates building command-line applications (CLIs) using ThinkPHP's CLI capabilities. It emphasizes best practices like modular design, dependency injection, and robust error handling, while highlighting common pitfalls such as insu

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

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

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

The article discusses preventing SQL injection vulnerabilities in ThinkPHP through parameterized queries, avoiding raw SQL, using ORM, regular updates, and proper error handling. It also covers best practices for securing database queries and validat

The article discusses key differences between ThinkPHP 5 and 6, focusing on architecture, features, performance, and suitability for legacy upgrades. ThinkPHP 5 is recommended for traditional projects and legacy systems, while ThinkPHP 6 suits new pr

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.

The article discusses best practices for handling file uploads and integrating cloud storage in ThinkPHP, focusing on security, efficiency, and scalability.


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

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

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

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.