Published on

PCC '23 - Rev - [etyBtloB]

Authors

Challenge Description

Alt text

Solution

This binary was a per-user binary; meaning each user had a different flag in their binaries. Starting the instance; we're greeted with a simple web-page from where we can download the binary

download-page

Now, this challenge was uploaded as part of the PCC qualifiers but no one was able to solve it. However it was pretty easy. Running the binary:

Alt text

Well, let's try and look at the strings of the binary:

strings

One thing that is weird; everything is rotated, one line looked like it made sense; reversing it:

gcc

Well, it matches GCC, but HCD. Oh, It looks like each byte is shifted-by-1 and the entire binary is currently reversed. Let's firstly un-reverse the binary and then look at the bytes to actually confirm our theory.

solve.py
#!/usr/bin/env python3

with open('boltbyte', 'rb') as f:
    _in = f.read()

_in = _in[::-1] # Reversing

with open('final', 'wb') as f:
    f.write(_in)
Alt text

Now, let's look the binary's bytes:

Alt text

Well, this confirmed our theory, every even byte is shifted by-1, so let's write a simple script to fix the binary:

solve.py
#!/usr/bin/env python3

with open('boltbyte', 'rb') as f:
    _in = f.read()

data = _in[::-1] # Reversing

buf = b""
for i in range(0, len(data)):
    buf += ((data[i] - 1) % 256 if i % 2 == 0 else data[i]).to_bytes(1, 'little')

with open('final', 'wb') as f:
    f.write(buf)

After running the script and running file on file:

Alt text

Overall, I know it was a bit of a guessy challenge, but ;-;. I hope you enjoyed the writeup.