Skip to main content

Phasestream 1- Cyberapocalypse 2021 CTF

· 2 min read

This is a writeup for the challenge Phasestream 1, part of the Hack the box's Cyberapocalypse CTF 2021, category Crypto.

Phasestream 1

In the first challenge, we're given a hex code, and the knowledge that it's been encoded using XOR with a 5-byte long key.

The top information here, is the length of the key. Since we expect to see a flag pop out of this encoded value, we know that it will start with CHTB{, which is exactly 5 bytes long.

And since the XOR operation is its own inverse, we know that if we apply a XOR operation on the encoded value using our known result CHTB{ as "key", we will get the original key as output.

We can simply use an online tool for this:

Importing the hex representation of the encoded flag
Choosing our "key" as the beginning of the flag
Getting the 5-byte key to be "mykey"

We get our key to be mykey!

We could also do this using this tool to do the same, since we can supply a key to it to decode. But we need to supply it with an ASCII representation of the encoded result.

  1. Decode the hex of the encrypted flag into ASCII
echo 2e313f2702184c5a0b1e321205550e03261b094d5c171f56011904 | xxd -r -ps > encodedascii.txt
  1. Find the key by supplying the encrypted flag to xor-decrypt, and CHTB{ as key
python3 -i "encodedascii.txt" -o key.txt -k CHTB{ -d

So we get mykey[IeqZQu@nOK6_KzZL, and deduce that mykey is the 5-byte key

  1. Decrypt the encrypted flag using our key
python3 -i encodedascii.txt -o flag.txt -k mykey -d

And so, our flag finally is