Posts

dCTF 2021: This one is really basic

Solving a recursive base64 challenge with a small decoding script.

Original challenge writeup: This one is really basic.md

The challenge description was:

The answer to life, the universe, and everything.

Solution

The challenge gave us a cipher.txt file with thousands and thousands of characters.

It was recursively base64 encoded. We tried CyberChef and the basecrack repo on GitHub, but neither worked for this file.

The hint was that the encoded string started with Vm0. Searching for b64 Vm0 showed that, for some reason, if you base64-encode a string enough times, it eventually starts with the same prefix.

That meant the challenge probably was not switching between encodings like base32 or base58. It was just base64 over and over.

So I wrote this small script:

import base64

# original = open("cipher.txt", r)

with open("cipher.txt", "r") as f:
    b64 = base64.b64decode(f.read()).strip()
    for i in range(42):
        b64 = base64.b64decode(b64)
        print(b64)

Eventually the script throws an exception and crashes, but that was good enough. Before crashing, it prints the flag:

dctf{Th1s_l00ks_4_lot_sm4ll3r_th4n_1t_d1d}