Post

HackTheBox Ancient Encodings Writeup

Explore the basics of cybersecurity in the Ancient Encodings Challenge on Hack The Box. This very-easy-level Challenge introduces encryption reversal and file handling concepts in a clear and accessible way, perfect for beginners.

https://app.hackthebox.com/challenges/475

Description

Your initialization sequence requires loading various programs to gain the necessary knowledge and skills for your journey. Your first task is to learn the ancient encodings used by the aliens in their communication.

Source

source.py

1
2
3
4
5
6
7
8
9
10
11
12
13
14
from Crypto.Util.number import bytes_to_long
from base64 import b64encode
from secret import FLAG

def encode(message):
    return hex(bytes_to_long(b64encode(message)))

def main():
    encoded_flag = encode(FLAG)
    with open("output.txt", "w") as f:
        f.write(encoded_flag)

if __name__ == "__main__":
    main()

output.txt

1
0x53465243657a51784d56383361444e664d32356a4d475178626a6c664e44497a5832677a4d6a4e664e7a42664e5463306558303d

Exploitation

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
from Crypto.Util.number import long_to_bytes
from base64 import b64decode

def decode(encoded_hex):
    encoded_int = int(encoded_hex, 16)
    encoded_base64 = long_to_bytes(encoded_int)
    return b64decode(encoded_base64)

def main():
    with open("output.txt", "r") as f:
        encoded_hex = f.read().strip()
    flag = decode(encoded_hex)
    print(f"Recovered FLAG: {flag.decode()}")

if __name__ == "__main__":
    main()

Summary

Ancient Encodings on Hack The Box is a very easy-level challenge focused on reversing layered encodings to retrieve a hidden flag. The challenge involves analyzing a script that encodes the flag using Base64 and hex-encoded integer conversion. By reversing the process with tools like Python’s Crypto.Util and Base64, participants decode the output file to recover the flag. This challenge introduces basic encryption reversal concepts, making it ideal for beginners in cybersecurity.

This post is licensed under CC BY 4.0 by the author.