UofTCTF 2024 : CSS Password

Subject

My web developer friend said JavaScript is insecure so he made a password vault with CSS. Can you find the password to open the vault?

Wrap the flag in uoftctf{}

Writeup

with open("latch_vals.css", "r") as f :
    lines = f.readlines()

indexes = dict()
for i in range(len(lines)):
    if lines[i].find("/* b") != -1 :
        indexes[lines[i].strip()[3:-3]] = 1 if lines[i+2].strip().split(' ')[1][11:-2] == '0%' else 0

res = [0] * 19 * 8
for i in indexes :
    s = i.split('_')
    byte_no = int(s[0][1:])
    bit_no = int(s[1])
    print(f'{i=} {byte_no=} {bit_no=}: {indexes[i]}')
    res[(byte_no - 1) * 8 + bit_no - 1] = indexes[i]

bin_str = ''.join([ str(i) for i in res])
flag = ''.join([chr(int(bin_str[i:i+8], 2)) for i in range(0, len(bin_str), 8)])
print(flag)