Previous Level: Level 1
Login
SSH: ssh krypton2@krypton.labs.overthewire.org -p 2231
Task
This level contains an old form of cipher called a ‘Caesar Cipher’. The encrypt binary will look for the keyfile in your current working directory. Therefore, it might be best to create a working direcory in /tmp and in there a link to the keyfile. As the encrypt binary runs setuid krypton3, you also need to give krypton3 access to your working directory.
A little bit of Theory
The Caesar Cipher
is a shift cipher, meaning the letters are shifted by a certain number (the key). For example, with k=1, you encrypt A as B, B as C and so on until Z will be encrypted as A.
Calculating the encryption key is easy, when knowing just one letter pair of the message (original) and cipher text (encrypted). Taking the example from above: ‘A’ to ‘B’ is ‘1 -> 2’. The key is just the difference ‘1+x=2’ (as long as it does not wrap around).
To calculate the decryption key from the encryption key, you can do the following: amount of characters - encryption_key = decryption_key. So the example would be ‘26-1=25’. Meaning, you need to shift ‘B’ by 25 to get ‘A’ again. (2+25= 27 mod 26 = 1). Here ‘mod’ is revering to the modulo operation that is the remainder of a division. It is needed because the number needs to be between 1 and 26 to be mapped to a letter of the alphabet.
Solution
Start by reading the README to get the full task description (cat README
).
|
|
This task deals with the Ceasar cipher. Specifically, we need to find the key by comparing the message and cipher. Based on the example in the ‘README’ we do the following:
|
|
So I run the encryption executable with the text ‘AAAAA’ because it is the easiest to calculate the shift from the first letter. The result is ‘MMMMM’. Now we just need to figure out the key by calculating the amount shifts from ‘A’ to ‘M’ (1 -> 13). With ‘M’ being the 13th character, and therefore ‘12’ is the key. Since this is the encryption key, we need to convert it to do decryption, which is done the following way: 26 - 12 = 14.
We can use a similar command from the previous level to decrypt the message. We only shift by a different amount of characters (12 instead of 13):
|
|
https://overthewire.org/wargames/krypton/krypton2.html
Next Level: Level 3