-
Notifications
You must be signed in to change notification settings - Fork 337
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
286 changed files
with
581 additions
and
3 deletions.
There are no files selected for viewing
Empty file.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file.
Empty file.
Empty file.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Empty file.
Empty file.
Empty file.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Empty file.
Empty file.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Empty file.
Empty file.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Empty file.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Empty file.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Empty file.
Empty file.
Empty file.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Empty file.
Empty file.
Empty file.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Empty file.
Empty file.
Empty file.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Empty file.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Empty file.
Empty file.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
本系列文章将针对 **ThinkPHP** 的历史漏洞进行分析,今后爆出的所有 **ThinkPHP** 漏洞分析,也将更新于 [ThinkPHP-Vuln](https://github.com/Mochazz/ThinkPHP-Vuln) 项目上。本篇文章,将分析 **ThinkPHP** 中存在的 **SQL注入漏洞** ( **insert** 方法注入)。 | ||
|
||
## 漏洞概要 | ||
|
||
本次漏洞存在于 **Builder** 类的 **parseData** 方法中。由于程序没有对数据进行很好的过滤,将数据拼接进 **SQL** 语句,导致 **SQL注入漏洞** 的产生。漏洞影响版本: **5.0.13<=ThinkPHP<=5.0.15** 、 **5.1.0<=ThinkPHP<=5.1.5** 。 | ||
|
||
## 漏洞环境 | ||
|
||
通过以下命令获取测试环境代码: | ||
|
||
```bash | ||
composer create-project --prefer-dist topthink/think=5.0.15 tpdemo | ||
``` | ||
|
||
将 **composer.json** 文件的 **require** 字段设置成如下: | ||
|
||
```json | ||
"require": { | ||
"php": ">=5.4.0", | ||
"topthink/framework": "5.0.15" | ||
} | ||
``` | ||
|
||
然后执行 `composer update` ,并将 **application/index/controller/Index.php** 文件代码设置如下: | ||
|
||
```php | ||
<?php | ||
namespace app\index\controller; | ||
|
||
class Index | ||
{ | ||
public function index() | ||
{ | ||
$username = request()->get('username/a'); | ||
db('users')->insert(['username' => $username]); | ||
return 'Update success'; | ||
} | ||
} | ||
``` | ||
|
||
在 **application/database.php** 文件中配置数据库相关信息,并开启 **application/config.php** 中的 **app_debug** 和 **app_trace** 。创建数据库信息如下: | ||
|
||
```sql | ||
create database tpdemo; | ||
use tpdemo; | ||
create table users( | ||
id int primary key auto_increment, | ||
username varchar(50) not null | ||
); | ||
``` | ||
|
||
访问 **http://yoursite/index/index/index?username[0]=inc&username[1]=updatexml(1,concat(0x7,user(),0x7e),1)&username[2]=1** 链接,即可触发 **SQL注入漏洞** 。(没开启 **app_debug** 是无法看到 **SQL** 报错信息的) | ||
|
||
![1](ThinkPHP5漏洞分析之SQL注入1/1.png) | ||
|
||
## 漏洞分析 | ||
|
||
![2](ThinkPHP5漏洞分析之SQL注入1/2.png) | ||
|
||
首先在官方发布的 **5.0.16** 版本更新说明中,发现其中提到该版本包含了一个安全更新,我们可以查阅其 **commit** 记录,发现其修改的 **Builder.php** 文件代码比较可疑。 | ||
|
||
![3](ThinkPHP5漏洞分析之SQL注入1/3.png) | ||
|
||
接着我们直接跟着上面的攻击 **payload** 来看看漏洞原理。首先, **payload** 数据经过 **ThinkPHP** 内置方法的过滤后(不影响我们的 **payload** ),直接进入了 **$this->builder** 的 **insert** 方法,这里的 **$this->builder** 为 **\think\db\builder\Mysql** 类,代码如下: | ||
|
||
![4](ThinkPHP5漏洞分析之SQL注入1/4.png) | ||
|
||
而 **Mysql** 类继承于 **Builder** 类,即上面的 **$this->builder->insert()** 最终调用的是 **Builder** 类的 **insert** 方法。在 **insert** 方法中,我们看到其调用 **parseData** 方法来分析并处理数据,而 **parseData** 方法直接将来自用户的数据 **$val** 进行了拼接返回。我们的恶意数据存储在 **$val[1]** 中,虽经过了 **parseKey** 方法处理,当丝毫不受影响,因为该方法只是用来解析处理数据的,并不是清洗数据。 | ||
|
||
![5](ThinkPHP5漏洞分析之SQL注入1/5.png) | ||
|
||
上面,我们看到直接将用户数据进行拼接。然后再回到 **Builder** 类的 **insert** 方法,直接通过替换字符串的方式,将 **$data** 填充到 **SQL** 语句中,进而执行,造成 **SQL注入漏洞** 。 | ||
|
||
![6](ThinkPHP5漏洞分析之SQL注入1/6.png) | ||
|
||
至此,我们已将整个漏洞分析完了。实际上,上面的 **switch** 结构中,3种情况返回的数据都有可能造成 **SQL** 注入漏洞,但是在观察 **ThinkPHP** 官方的修复代码中,发现其只对 **inc** 和 **dec** 进行了修复,而对于 **exp** 的情况并未处理,这是为什么呢? | ||
|
||
实际上, **exp** 的情况早在传入 **insert** 方法前就被 **ThinkPHP** 内置过滤方法给处理了,如果数据中存在 **exp** ,则会被替换成 **exp空格** ,这也是为什么 **ThinkPHP** 官方没有对 **exp** 的情况进行处理的原因了。具体内置过滤方法的代码如下: | ||
|
||
![7](ThinkPHP5漏洞分析之SQL注入1/7.png) | ||
|
||
## 漏洞修复 | ||
|
||
![8](ThinkPHP5漏洞分析之SQL注入1/8.png) | ||
|
||
## 攻击总结 | ||
|
||
最后,再通过一张攻击流程图来回顾整个攻击过程。 | ||
|
||
![9](ThinkPHP5漏洞分析之SQL注入1/9.png) |
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
本系列文章将针对 **ThinkPHP** 的历史漏洞进行分析,今后爆出的所有 **ThinkPHP** 漏洞分析,也将更新于 [ThinkPHP-Vuln](https://github.com/Mochazz/ThinkPHP-Vuln) 项目上。本篇文章,将分析 **ThinkPHP** 中存在的 **SQL注入漏洞** ( **update** 方法注入)。 | ||
|
||
## 漏洞概要 | ||
|
||
本次漏洞存在于 **Mysql** 类的 **parseArrayData** 方法中由于程序没有对数据进行很好的过滤,将数据拼接进 **SQL** 语句,导致 **SQL注入漏洞** 的产生。漏洞影响版本: **5.1.6<=ThinkPHP<=5.1.7** (非最新的 **5.1.8** 版本也可利用)。 | ||
|
||
## 漏洞环境 | ||
|
||
通过以下命令获取测试环境代码: | ||
|
||
```bash | ||
composer create-project --prefer-dist topthink/think tpdemo | ||
``` | ||
|
||
将 **composer.json** 文件的 **require** 字段设置成如下: | ||
|
||
```json | ||
"require": { | ||
"php": ">=5.6.0", | ||
"topthink/framework": "5.1.7" | ||
} | ||
``` | ||
|
||
然后执行 `composer update` ,并将 **application/index/controller/Index.php** 文件代码设置如下: | ||
|
||
```php | ||
<?php | ||
namespace app\index\controller; | ||
|
||
class Index | ||
{ | ||
public function index() | ||
{ | ||
$username = request()->get('username/a'); | ||
db('users')->where(['id' => 1])->update(['username' => $username]); | ||
return 'Update success'; | ||
} | ||
} | ||
``` | ||
|
||
在 **config/database.php** 文件中配置数据库相关信息,并开启 **config/app.php** 中的 **app_debug** 和 **app_trace** 。创建数据库信息如下: | ||
|
||
```sql | ||
create database tpdemo; | ||
use tpdemo; | ||
create table users( | ||
id int primary key auto_increment, | ||
username varchar(50) not null | ||
); | ||
insert into users(id,username) values(1,'mochazz'); | ||
``` | ||
|
||
访问 **http://localhost:8000/index/index/index?username[0]=point&username[1]=1&username[2]=updatexml(1,concat(0x7,user(),0x7e),1)^&username[3]=0** 链接,即可触发 **SQL注入漏洞** 。(没开启 **app_debug** 是无法看到 **SQL** 报错信息的) | ||
|
||
![1](ThinkPHP5漏洞分析之SQL注入2/1.png) | ||
|
||
## 漏洞分析 | ||
|
||
![2](ThinkPHP5漏洞分析之SQL注入2/2.png) | ||
|
||
首先在官方发布的 **5.1.9** 版本更新说明中,发现其中提到该版本包含了一个安全更新,我们可以查阅其 **commit** 记录,发现其删除了 **parseArrayData** 方法,这处 **case** 语句之前出现过 **insert** 注入,所以比较可疑。 | ||
|
||
![3](ThinkPHP5漏洞分析之SQL注入2/3.png) | ||
|
||
接着我们直接跟着上面的攻击 **payload** 来看看漏洞原理。首先, **payload** 数据经过 **ThinkPHP** 内置方法的过滤后(不影响我们的 **payload** ),直接进入了 **Query** 类的 **update** 方法,该方法调用了 **Connection** 类的 **update** 方法,该方法又调用了 **$this->builder** 的 **insert** 方法,这里的 **$this->builder** 为 **\think\db\builder\Mysql** 类,该类继承于 **Builder** 类,代码如下: | ||
|
||
![4](ThinkPHP5漏洞分析之SQL注入2/4.png) | ||
|
||
在 **Builder** 类的 **update** 方法中,调用了 **parseData** 方法。这个方法中的 **case** 语句之前存在 **SQL注入漏洞** ,现已修复,然而却多了 **default** 代码段,而这段代码也是在新版本中被删除的。 | ||
|
||
![5](ThinkPHP5漏洞分析之SQL注入2/5.png) | ||
|
||
我们跟进到 **parseArrayData** 方法,发现其中又将可控变量进行拼接,其变量来源均来自用户输入。之后的过程就和之前的 **insert** 注入一样,用 **str_replace** 将变量填充到 **SQL** 语句中,最终执行,导致 **SQL注入漏洞** 。 | ||
|
||
![6](ThinkPHP5漏洞分析之SQL注入2/6.png) | ||
|
||
上面 **第15行** 的 **$result** 相当于 **$a('$b($c)')** 其中 **$a、$b、$c** 均可控。最后形成的 **SQL** 语句如下: | ||
|
||
```sql | ||
UPDATE `users` SET `username` = $a('$b($c)') WHERE `id` = 1; | ||
``` | ||
|
||
接着我们想办法闭合即可。我们令 **$a = updatexml(1,concat(0x7,user(),0x7e),1)^** 、 **$b = 0** 、 **$c = 1** ,即: | ||
|
||
```sql | ||
UPDATE `users` SET `username` = updatexml(1,concat(0x7,user(),0x7e),1)^('0(1)') WHERE `id` = 1 | ||
``` | ||
|
||
## 漏洞修复 | ||
|
||
官方修复方法比较暴力,直接将 **parseArrayData** 方法删除了。 | ||
|
||
![7](ThinkPHP5漏洞分析之SQL注入2/7.png) | ||
|
||
## 攻击总结 | ||
|
||
最后,再通过一张攻击流程图来回顾整个攻击过程。 | ||
|
||
![8](ThinkPHP5漏洞分析之SQL注入2/8.png) |
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
本系列文章将针对 **ThinkPHP** 的历史漏洞进行分析,今后爆出的所有 **ThinkPHP** 漏洞分析,也将更新于 [ThinkPHP-Vuln](https://github.com/Mochazz/ThinkPHP-Vuln) 项目上。本篇文章,将分析 **ThinkPHP** 中存在的 **SQL注入漏洞** ( **select** 方法注入)。 | ||
|
||
## 漏洞概要 | ||
|
||
本次漏洞存在于 **Mysql** 类的 **parseWhereItem** 方法中。由于程序没有对数据进行很好的过滤,将数据拼接进 **SQL** 语句,导致 **SQL注入漏洞** 的产生。漏洞影响版本: **ThinkPHP5全版本** 。 | ||
|
||
## 漏洞环境 | ||
|
||
通过以下命令获取测试环境代码: | ||
|
||
```bash | ||
composer create-project --prefer-dist topthink/think=5.0.10 tpdemo | ||
``` | ||
|
||
将 **composer.json** 文件的 **require** 字段设置成如下: | ||
|
||
```json | ||
"require": { | ||
"php": ">=5.4.0", | ||
"topthink/framework": "5.0.10" | ||
}, | ||
``` | ||
|
||
然后执行 `composer update` ,并将 **application/index/controller/Index.php** 文件代码设置如下: | ||
|
||
```php | ||
<?php | ||
namespace app\index\controller; | ||
|
||
class Index | ||
{ | ||
public function index() | ||
{ | ||
$username = request()->get('username'); | ||
$result = db('users')->where('username','exp',$username)->select(); | ||
return 'select success'; | ||
} | ||
} | ||
``` | ||
|
||
在 **config/database.php** 文件中配置数据库相关信息,并开启 **config/app.php** 中的 **app_debug** 和 **app_trace** 。创建数据库信息如下: | ||
|
||
```sql | ||
create database tpdemo; | ||
use tpdemo; | ||
create table users( | ||
id int primary key auto_increment, | ||
username varchar(50) not null | ||
); | ||
insert into users(id,username) values(1,'mochazz'); | ||
``` | ||
|
||
访问 **http://localhost:8000/index/index/index?username=) union select updatexml(1,concat(0x7,user(),0x7e),1)#** 链接,即可触发 **SQL注入漏洞** 。(没开启 **app_debug** 是无法看到 **SQL** 报错信息的) | ||
|
||
![1](ThinkPHP5漏洞分析之SQL注入3/1.png) | ||
|
||
## 漏洞分析 | ||
|
||
由于官方根本不认为这是一个漏洞,而认为这是他们提供的一个功能,所以官方并没有对这个问题进行修复。但笔者认为这里的数据过滤还是存在问题的,所以我们还是来分析分析这个漏洞。 | ||
|
||
程序默认调用 **Request** 类的 **get** 方法中会调用该类的 **input** 方法,但是该方法默认情况下并没有对数据进行很好的过滤,所以用户输入的数据会原样进入框架的 **SQL** 查询方法中。首先程序先调用 **Query** 类的 **where** 方法,通过其 **parseWhereExp** 方法分析查询表达式,然后再返回并继续调用 **select** 方法准备开始构建 **select** 语句。 | ||
|
||
![2](ThinkPHP5漏洞分析之SQL注入3/2.png) | ||
|
||
上面的 **$this->builder** 为 **\think\db\builder\Mysql** 类,该类继承于 **Builder** 类,所以接着会调用 **Builder** 类的 **select** 方法。在 **select** 方法中,程序会对 **SQL** 语句模板用变量填充,其中用来填充 **%WHERE%** 的变量中存在用户输入的数据。我们跟进这个 **where** 分析函数,会发现其会调用生成查询条件 **SQL** 语句的 **buildWhere** 函数。 | ||
|
||
![3](ThinkPHP5漏洞分析之SQL注入3/3.png) | ||
|
||
继续跟进 **buildWhere** 函数,发现用户可控数据又被传入了 **parseWhereItem** where子单元分析函数。我们发现当操作符等于 **EXP** 时,将来自用户的数据直接拼接进了 **SQL** 语句,最终导致了 **SQL注入漏洞** 。 | ||
|
||
![4](ThinkPHP5漏洞分析之SQL注入3/4.png) | ||
|
||
## 漏洞修复 | ||
|
||
未修复。 | ||
|
||
## 攻击总结 | ||
|
||
最后,再通过一张攻击流程图来回顾整个攻击过程。 | ||
|
||
![5](ThinkPHP5漏洞分析之SQL注入3/5.png) |
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.