The Challenge
Register and log in. The session cookie is a URL-encoded base64 blob. Decoding it reveals a structure like timestamp-role_flag-username where role_flag is 1 for a regular user. The admin page checks for role 0.
Approach
- Register and log in with arbitrary credentials.
- URL-decode and base64-decode the
sessioncookie. - Split on
-, setdata[1] = '0'(admin role),data[2] = 'admin'. - Re-join, base64-encode, URL-encode.
- Send the forged cookie to
home.php.
Solution
|
|
urllib.parse.unquote + base64.b64decode unwraps the cookie to the raw --delimited string. Modifying the fields and re-encoding with base64.b64encode + urllib.parse.quote produces the forged admin cookie. The home.php endpoint responds with the flag.
What I Learned
Encoding is not encryption. A cookie that is base64-encoded is readable and rewritable by any client. Cookies that control authorization must be signed (e.g. with HMAC) or encrypted with an authenticated cipher — otherwise any client can forge any role.