CSS Password
This challenge was my first rev challenge and it really showed me the wonders of programming. People who do rev at a high level are honestly a completely different breed. The challenge author really woke up one day and decided to implement RAM in CSS, and CSS only.
Description
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?
The challenge file can be found here.
Initial State of Confusion
Upon opening the file, we see a whole load of classes and class names that seemingly doesn’t make sense at all. We are told to make all the LED lights turn green in order to retrieve the flag. The first thought that came to mind was each of these bytes represent a letter in the final flag, since ASCII values can be represented in binary. Though this is indeed the correct way, I had absolutely no clue how I was going to pinpoint the right value.
The Big Aha Moment
After staring at my screen for a lot longer than I’d like to admit, and going down a rabbit
hole of searching how SR-Latches worked, I finally figured out how the LEDs were supposed to
turn green. Some of the repeating lines of CSS seem to set the transform
to translateX(-100%)
,
which moves the overlapping red circle off the screen. Once all the red circles are moved away,
the green circle below is revealed.
However, the transform
is only changed when a certain condition is fulfilled, and the
condition seemed to be dependent on the latch__set
or latch__reset
class.
The latch__set
class represented a 1
state, and latch__reset
represents a 0
state.
The comments provided in the source code proved to be very helpful too. It states which
byte the bit belongs to. Using these information, we can write a script to parse out
the bit values and convert it to a string.
Messy Ahh Parser
When we were solving this challenge, we had about an hour left thus we had to speedrun the script. The code below would be quite messy, so this is kind of an apology in advance.
The script loads all the values into a dictionary that is structured as:
It looks for every comment that starts with b
, indicating its a
comment about a bit, parses out the byte
and bit
position and
sets it as a key.
It continues looking for a line that contains translateX(-100%)
,
which is what indicates that the switch is correct. Then depending
if the class above is latch__set
or latch__reset
, it sets the
dictionary value as 1
or 0
.
The dictionary is then sorted and joined together before I dumped the value into a online binary to string converter, where I got the final flag.
Flag: uoftctf{CsS_l0g1c_is_fun_3h}