Skip to content

Back to the catalog

0xv1n.github.iowriteup

HackTheBox | xorxorxor

A HackTheBox crypto challenge writeup ('xorxorxor') walking through how to break a weak custom encryption scheme where a flag is XOR-encrypted with a 4-byte repeating key generated via os.urandom(4). The author demonstrates a known-plaintext attack: since HTB flags always start with 'HTB{', the first 4 known plaintext bytes are XORed against the ciphertext to recover the full key, which is then used to decrypt the rest of the flag. It's a beginner-friendly explainer of XOR logic and how key reuse/short keys make repeating-key XOR trivially breakable with known-plaintext.

TL;DR HTB crypto challenge writeup showing how a known 'HTB{' plaintext prefix reveals a 4-byte repeating XOR key, fully breaking the flag's encryption.

Organisations named here

  • known-plaintext attack

Technologies named here

  • challenge.py
  • Online XOR tool
  • Hex to binary converter
  • ASCII Table
  • Python

Techniques named here

  • Known-plaintext attack against XOR encryption

Related in Learning