HTB CTF 2024 - Vault Of Hope - Crypto - eXciting Outpost Recon Solution
Hijacking the outpost responsible for housing the messengers of the core gangs, we have managed to intercept communications between a newly-elected leader and the Tariaki, a well-established and powerful gang. In an attempt to sow conflict and prevent the creation of a singular all-powerful coalition to oppress the common people, we want YOU to use this message to our advantage. Can you use their obsequiousness to your advantage?
Difficulty: very easy
File Contents

Encryption code located in source.py
from hashlib import sha256
import os
LENGTH = 32
def encrypt_data(data, k):
data += b'\x00' * (-len(data) % LENGTH)
encrypted = b''
for i in range(0, len(data), LENGTH):
chunk = data[i:i+LENGTH]
for a, b in zip(chunk, k):
encrypted += bytes([a ^ b])
k = sha256(k).digest()
return encrypted
key = os.urandom(32)
with open('plaintext.txt', 'rb') as f:
plaintext = f.read()
assert plaintext.startswith(b'Great and Noble Leader of the Tariaki') # have to make sure we are aptly sycophantic
with open('output.txt', 'w') as f:
enc = encrypt_data(plaintext, key)
f.write(enc.hex())