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.
Reproduction and proof of concept
With Burp running, log in with
wiener:peterwith the Stay logged in option selected. Notice that this sets a
Examine this cookie in the Inspector panel and notice that it is Base64-encoded. Its decoded value is
wiener:51dc30ddc473d43a6011e9ebba6ca770. Study the length and character set of this string and notice that it could be an MD5 hash. Given that the plaintext is your username, you can make an educated guess that this may be a hash of your password. Hash your password using MD5 to confirm that this is the case. We now know that the cookie is constructed as follows:
Log out of your account.
Send the most recent
GET /my-accountrequest to Burp Intruder.
In Burp Intruder, add a payload position to the
stay-logged-incookie and add your own password as a single payload.
Under Payload processing, add the following rules in order. These rules will be applied sequentially to each payload before the request is submitted.
As the Update email button is only displayed when you access the
/my-accountpage in an authenticated state, we can use the presence or absence of this button to determine whether we have successfully brute-forced the cookie. On the Options tab, add a grep match rule to flag any responses containing the string
Update email. Start the attack.
Notice that the generated payload was used to successfully load your own account page. This confirms that the payload processing rules work as expected, and you were able to construct a valid cookie for your own account.
Make the following adjustments and then repeat this attack:
Remove your own password from the payload list and add the list of candidate passwords instead.
Change the Add prefix rule to add
When the attack is finished, the lab will be solved. Notice that only one request returned a response containing
Update email. The payload from this request is the valid
stay-logged-incookie for Carlos’s account.
An attacker needs to brute-force Carlos’s cookie to gain access to his My account page.