第一章:为了女神小芳![封神台-掌控安全在线演练靶场]
第一章:为了女神小芳!
题目描述
根据题目描述可以知道是一道SQL注入的题目,点击传送门,进入站点
解题
打开链接,发现网页只有一个可以点的地方,点击进入。
进入一篇文章,url为http://rhiq8003.ia.aqlab.cn/?id=1
,根据题目描述,考虑SQL注入
url加入and 1=1
,页面返回正常;加入and 1=2
,报错,可以判断这里存在注入点。
有了注入点,就可以开始猜测字段数。猜测字段数可以利用两种方式
- 一种是利用order by x,表示根据第几列来进行排序
- 一种是利用union select 1,2,3....
随便选择一种,我这里选择第一种方式,发现order by 2
页面返回正常,order by 3
页面返回错误,则可以推断出来字段数为2。
获得字段数之后,开始获取数据库的库名、表名,字段名。
使用下面的语句拼接url,获得数据库名maoshe
and 1=2 union select 1,database()
获取到了数据库名,就可以去information_schema
库中查数据库对应的表名,拼接url,获得maoshe
数据库下所有的表名,为admin,dirs,news,xss
,这里的数据库表大于2,但是只有字段的位置,所以需要用group_concat
函数,
关于
group_concat
函数的简单介绍group_concat([DISTINCT] 要连接的字段 [Order BY ASC/DESC 排序字段] [Separator '分隔符'])
参考:https://blog.csdn.net/qq_35531549/article/details/90383022
and 1=2 union select 1,group_concat(table_name) from information_schema.tables where table_schema='maoshe'
获取了表名之后,我们根据题目描述,需要获取admin
中的数据,所以查询admin
表的字段,为Id,username,password
and 1=2 union select 1,group_concat(column_name) from information_schema.columns where table_name='admin'
根据题目描述,管理员密码就是flag,所以只需要获取管理员密码就可以
and 1=2 union select 1,password from admin
完成~