环境:
dvwa: 192.168.11.135 dvwa版本: Version 1.9 (Release date: 2015-09-19)
kail机器:192.168.11.156
1、Low级别
代码:
![](https://img-blog.csdnimg.cn/img_convert/c294ee4b881d2d8c43fc7608615ffd58.png)
1、启动 burpsuite 开始抓包,然后点击 login,然后在 bp 里面就能看见抓包到的包。这就是我们刚刚输入的账号密码:
![](https://img-blog.csdnimg.cn/img_convert/7f5a1796f656cd3ce1e4ca3b601bcfd3.png)
2、发送抓到的包到暴力破解bp的Intruder 模块
点击Positions,选择要要爆破的用户和密码,选择attack type为Cluster bomb
![](https://img-blog.csdnimg.cn/img_convert/3867e6bf16e7eccd98d67afebde64a31.png)
点击 payloads 添加字典,先添加第一个用户名字典,再切换成2,添加密码字典:
![](https://img-blog.csdnimg.cn/img_convert/f58b02abe338d5cd5ac8fffd5f9590c0.png)
![](https://img-blog.csdnimg.cn/img_convert/056e58f21823b2fc0063592aa02509c2.png)
3、然后点击 start attack 开始爆破
4、看回复的字节长度(其余都是5270,成功项长度5329)与响应内容,确定用户与密码分别是admin、password
![](https://img-blog.csdnimg.cn/img_convert/070763cea4e69a1ae6557a21f9206d49.png)
2、Medium级别
代码:增加了mysql_real_escape_string函数对参数的过滤
![](https://img-blog.csdnimg.cn/img_convert/657f305cb4bd142fd274fbb37168ccfc.png)
用 burpsuite爆破:发现成功破解的字段长度是不同的,能确定用户与密码分别是admin、password。中级的暴力破解相对来说较慢是因为有个sleep函数,在破解失败后会使程序停止运行两秒。
![](https://img-blog.csdnimg.cn/img_convert/65609b3373e67e9e385b89a90b40e66e.png)
3、High级别
代码:增加了token机制(CSRF)、stripslashes函数实现转义字符(返回一个去除转义反斜线后的字符串(\' 转换为 ' 等等)。双反斜线(\\)被转换为单个反斜线(\))、mysql_real_escape_string函数对参数的过滤
![](https://img-blog.csdnimg.cn/img_convert/9262517b0f85c7c62f3501631ee935ab.png)
1、抓包,发送到Intruder模块:选择attack type为Pitchfork(因为每次token不同,不能用cluster bomb模式),定义变量 username、password 和 token
![](https://img-blog.csdnimg.cn/img_convert/72dcb1b03d09626103a76cb009b290a3.png)
2、选择options将线程数设置为1
因为需要顺序发送请求,才能以此获取token,所以设置单线程:
![](https://img-blog.csdnimg.cn/img_convert/f1ef2f413984a57f7437b3b4b58062af.png)
否则攻击报错:
![](https://img-blog.csdnimg.cn/img_convert/52fe719190734392766c6b7f68cc00cb.png)
3、设置payload
参数 username、password的payload正常通过load加载,Payload type设置为Simple list,切记:attack type为Pitchfork时,用户名要和密码对应(位置相同,此处都是第三个)
![](https://img-blog.csdnimg.cn/img_convert/9ac171d97c406c47254fa6092e0dae8d.png)
![](https://img-blog.csdnimg.cn/img_convert/9050cd66b0d98f6b8a8113a523c054bf.png)
找到Grep-Extract模块进行相应设置:
![](https://img-blog.csdnimg.cn/img_convert/4df0cfeb133cca63cfa4f57013746177.png)
![](https://img-blog.csdnimg.cn/img_convert/e950be039fb1180b6c354c116359933b.png)
复制token对应的value值(77b869ce00b774e3dfd701fe1d969897),这个值后面会用到:
![](https://img-blog.csdnimg.cn/img_convert/84751e6ae018a7ba4787abc41ce817f6.png)
intruder会自动为我们编写,提取这个位置的值的正则表达式:
![](https://img-blog.csdnimg.cn/img_convert/ac81d3f61781f1d14521f8584831907c.png)
找到Redirections模块设置允许重定向,选择always:
![](https://img-blog.csdnimg.cn/img_convert/f4b0f7001f68ee698f70fec3a27aca86.png)
参数token设置payload:因为每次爆破的token,需要从上一次的回应中提取,所以payload type选择Recursive grep(表示将服务器每次返回的数据来替换payload中的变量,这里用来每次替换user_token的值),然后将刚才复制token的值粘贴进去:
![](https://img-blog.csdnimg.cn/img_convert/f8ba9489df707c39c4c056d6032ef3f1.png)
这样intruder会自动利用正则表达式,从上一次的请求中帮我们提取token的值。
4、攻击:对比返回长度大小与回应数据,找到用户名与密码
![](https://img-blog.csdnimg.cn/img_convert/e23016abd25e5845baf930792923567f.png)