Sitemap

Member-only story

THM - Order

2 min readJul 6, 2025

--

A writeup for the room “Order” on TryHackMe

Perform a known-plaintext attack to recover a repeating-key XOR key and decrypt a hidden message.

https://tryhackme.com/room/hfb1order

Analysis

The challenge involves an encrypted message that uses a repeating-key XOR cipher.

Knowing the first characters of the plaintext enables us to determine at least part of the key, and if the known text is long enough, we can even determine the entire key, as is the case here.

The XOR operation is reversible, so we can apply the following formula:

message[i] = ciphertext[i] ^ key[i % len(key)]
key[i % len(key)] = header[i] ^ ciphertext[i]

Solution

First, we need the ciphertext that can be converted from a hex string into a byte array, which will simplify the XOR calculations.

ciphertext = "1c1c01041963730f31352a3a386e24356b3d32392b6f6b0d323c22243f6373"
ciphertext += "1a0d0c302d3b2b1a292a3a38282c2f222d2a112d282c31202d2d2e24352e60"

ciphertext = bytes.fromhex(ciphertext)

Then, we use the header to calculate the key.

header = "ORDER:"

key = ""
for i, c in enumerate(header):
key += chr(ord(c) ^ ciphertext[i])

print("Key:", key)

--

--

Francesco Pastore
Francesco Pastore

Written by Francesco Pastore

An engineering student in Milan and a web developer for an IT company. Write about programming and cybersecurity topics.

No responses yet