← Back to Writeups
HTBVery EasyCryptography

Ancient Encodings

D3v0o0Nu119/2/20261 min read
#cryptography#htb#very easy

Ancient Encodings

Platform: HackTheBox | Category: Cryptography | Difficulty: Very Easy | Author: D3v0o0Nu11 | Date: 2026-02-10

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.

Solution Approach

Core idea: Identify the weakness from source review or fingerprinting first. Iterate with incremental payloads instead of guessing.

Steps

  1. First unzip the given attachment and we will get source.py and the output.txt

source.py

python
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

0x53465243657a51784d56383361444e664d32356a4d475178626a6c664e44497a5832677a4d6a4e664e7a42664e5463306558303d
  1. In the source code, we can see the code is used to encode the flag to base64 and then encode it again to hex and the result is written in the output.txt
  2. So we just need to decode the output from hex to strings and decode it again using base64 and we will get the flag. I am using cyberchef to decode the output

Flag

REDACTED

Lessons Learned

  1. Identify the weakness from source review or fingerprinting first.
  2. Iterate with incremental payloads instead of guessing.
  3. Reuse the same pattern in future engagements.