Cookies

Cookies

Author: Madstacks

Description

Who doesn't love cookies? Try to figure out the best one. http://mercury.picoctf.net:29649/arrow-up-right

Solution

Website takes in cookie name and checks for 'special' cookie.

By inspecting Cookies from Web Developer Tools we can see name cookie being set to a number. If number is changed so is the cookie name.

Using script we can cycle through the cookies to find 'special' one.

import requests
import re

URL = "http://mercury.picoctf.net:29649/check"

for i in range(32):
    resp = requests.get(URL, cookies={"name": str(i)}).text
    if "Not very special though" not in resp:
        print(i, re.search(r"<code>(picoCTF.*)</code>", resp).group(1))
        break
    cookie = re.search(r"I love (.*) cookies!", resp).group(1)
    print(f"Trying: {i=}\t{cookie=}{' '*16}", end='\r')
circle-check
circle-info

Special cookie is at index 18

More Cookies

Description

I forgot Cookies can Be modified Client-side, so now I decided to encrypt them! http://mercury.picoctf.net:34962/arrow-up-right

chevron-rightHint 1hashtag

[Homomorphic Encryption](https://www.wikiwand.com/en/Homomorphic_encryption)

chevron-rightHint 2hashtag

The search endpoint is only helpful for telling you if you are admin or not, you won't be able to guess the flag name

Analysis

Website says: Welcome to my cookie search page. Only the admin can use it!

Description is also written a little funny, Cookies can Be modifed Client-side => CBC Encryptionarrow-up-right. There's a known vulnerability called The Bit Flipping attackarrow-up-right.

Solution

To reduce bruteforce count my first approach was to try Byte Flip.

circle-check
circle-info

Match: position=9 byte=0

Most Cookies

Description

Alright, enough of using my own encryption. Flask session cookies should be plenty secure! server.pyarrow-up-right http://mercury.picoctf.net:53700/arrow-up-right

Solution

Vulnaribility is app.secret_key = random.choice(cookie_names). secret_key prevents users manipulating the cookies in flask application, if it's known then user can change cookies to whatever, so secret_key must be secured.

I first converted the list of cookies into wordlist (text file seperated by newlines), then used flask-unsignarrow-up-right to get the secret key and forge new cookie.

Change the cookie on website, I like to do it from Web Developer Tools.

circle-check
circle-info

Encountered similar challenge at Very Securearrow-up-right

Last updated