Prompt
The notorious hacker group, Liber8tion, has revealed a key within their communications. See if you can use the key below to unlock the ciphertext we also found.
01101011 01100101 01111001
Walkthrough
This challenge asks you to use a key to convert ciphertext to plaintext via an XOR operation. XOR (or Exclusive or), in a cryptography sense, is a foundational concept to understand the application of block ciphers often used in more modern cryptography contexts. However, XOR is often used in pseudo-random number generation, checksums, parity checks, and in other applications in computer science.
A key part to understanding XOR is understanding number bases. If you need to refresher on binary and number bases, check out our resources here.
While it is easier to perform this operation with the use of website programs and computer calculations, the guide below will demonstrate how to solve an XOR by hand.
How would we know to try XOR? The ciphertext contains symbols along with numbers and letters, so it’s reasonable to assume that the key somehow changes the plaintext through the full set of ASCII printable characters. However, notice that while there are repeating characters, there are no repeating patterns in the ciphertext:
2*,K(,81Y>+5.$+%E.#$-K<6>E1*3<K)<*77.!Y8. F$7,)T[VM^
Since the output is scattered, the key likely performs an XOR operation to modify the bits of the original message. It’s worth testing if an XOR operation has been used since the same exact key can be used to convert the plaintext to the ciphertext and back again; this makes checking your answer easy.
Spaces are used in the binary representations to delineate, or indicate, separate characters and make the binary easier for human eyes to comprehend. As an example, the key that is given, 01101011 01100101 01111001 , is binary for ‘key’.
01101011 = k 01100101 = e 01111001 = y
However, there is a keyboard space in the ciphertext. The keyboard space characters that are part of the ciphertext (or plaintext output) are represented in binary as 00100000 (or decimal value of 32). The space in the ciphertext needs to be XOR’d with the key like any other character.
A bitwise XOR operation involves comparing two values bit-by-bit. If the input bits are different, a 1 is the result. If the input bits are the same a 0 is the result.
1 XOR 1 | 0 |
1 XOR 0 | 1 |
0 XOR 1 | 1 |
0 XOR 0 | 0 |
Guide
To perform an XOR operation by hand on the first few characters of the ciphertext, it is easiest to convert the ciphertext to binary. This guide will demonstrate the process with the first six characters of the ciphertext:
2*,K(, = 00110010 00101010 00101100 01001011 00101000 00101100
Now, line up the key with each binary character. Each character is represented by 8-bits in binary. The key is a total of 24 bits (key= 01101011 01100101 01111001). Each 8-bit portion of the key will be matched bit-for-bit with the ciphertext. Once the whole key (24 bits) has been used, the key will be repeated again. For the first six characters of the ciphertext, they key is used twice. Both the ASCII and binary ciphertext are shown in the table below:
Ciphertext character | 2 | * | , | K | ( | , |
Ciphertext Binary | 00110010 | 00101010 | 00101100 | 01001011 | 00101000 | 00101100 |
Portion of Key used for bitwise XOR | 01101011 | 01100101 | 01111001 | 01101011 | 01100101 | 01111001 |
Key converted from binary to ASCII | k | e | y | k | e | y |
Let’s breakdown the bitwise operation for the first character of the ciphertext (00110010 or 2) with the first character of the key (01101011 or k). Per the XOR logic chart above, anytime the top (ciphertext) digit matches the bottom (key) digit, the result will be 0. Anytime the top (ciphertext) digit does not match the bottom (key), the result with be 1.
binary bit order | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
Ciphertext binary bit | 0 | 0 | 1 | 1 | 0 | 0 | 1 | 0 |
Key binary bit | 0 | 1 | 1 | 0 | 1 | 0 | 1 | 1 |
Plaintext binary bit | 0 | 1 | 0 | 1 | 1 | 0 | 0 | 1 |
Using a binary text converter, reveals that the plaintext, 01011001, converts to ‘Y’ in ASCII.
For the first six characters you should get the binary of: 01011001 01001111 01010101 00100000 01001101 01010101
⚠️ Since the binary for capital and lowercase alphabet characters is different, please be sure to use the correct letter case when using XOR.
Performing this process manually for each character could be cumbersome, so once you understand the process, try using some online converters such as CyberChef, or dcode.
🚧 Be aware that not all online converters are reliable but all require the correct usage of the tool via its input fields.
Useful tools for this challenge:
- Exclusive or: https://en.wikipedia.org/wiki/Exclusive_or
- Cybersecurity Computer Fundamentals: Data (number bases): https://trove.cyberskyline.com/computer-fundamentals-for-cybersecurity/data
- Binary to ASCII converter: https://www.rapidtables.com/convert/number/binary-to-ascii.html
- Cyber Chef XOR recipe: https://cyberchef.io/#recipe=XOR({'option':'UTF8','string':'key'},'Standard',false)
- dcode XOR: https://www.dcode.fr/xor-cipher