Skip to main content

Python Challenge Time [thm]

This is the last (and only) challenge in the TryHackMe room Intro to Python.

You'll find a file attached to this task called encoded_flag.txt. Within this file, you will find some encoded information! This is your challenge as follows; Using the base64 library within python. Can you decode this and retrieve the flag? Note this has been encoded a total of 15 times

5 times encoded using base 64

5 times encoded using base 32

5 times encoded using base 16!

It might be tempting to decode it via the route b64 -> b32 -> b16 but think again.

My quick and dirty solution:

#!/usr/bin/env python3
import itertools
import base64

filename = "txt"

with open(filename) as f:
    cypher = f.readlines()[0]

for _ in itertools.repeat(None, 5):
    cypher = base64.b16decode(cypher)

for _ in itertools.repeat(None, 5):
    cypher = base64.b32decode(cypher)

for _ in itertools.repeat(None, 5):
    cypher = base64.b64decode(cypher)

plaintext = str(cypher, "utf-8")
print(plaintext)

Not much to it.

I just did this room to earn to some easy points but at least I learned something.