Krypton Level 0 to Level 2 | Basic Cryptographic Techniques
Learn basic cryptographic techniques by playing Krypton wargame from OverTheWire. Below is the solution of Level 0 → Level 1, Level 1 → Level 2 and Level 2 → Level 3.
Krypton Level 0 → Level 1
Level Info
Welcome to Krypton! The first level is easy. The following string encodes the password using Base64:
S1JZUFRPTklTR1JFQVQ=
Use this password to log in to krypton.labs.overthewire.org with username krypton1 using SSH on port 2222. You can find the files for other levels in /krypton/
Solution
To get the password of the next level decode the given string using command
echo S1JZUFRPTklTR1JFQVQ= | base64 -d
and the password is KRYPTONISGREAT
.
Reference : How can I decode a base64 string from the command line?
Krypton Level 1 → Level 2
Level Info
The password for level 2 is in the file ‘krypton2’. It is ‘encrypted’ using a simple rotation. It is also in non-standard ciphertext format. When using alpha characters for cipher text it is normal to group the letters into 5 letter clusters, regardless of word boundaries. This helps obfuscate any patterns. This file has kept the plain text word boundaries and carried them to the cipher text. Enjoy!
Solution
Command to login ssh krypton1@krypton.labs.overthewire.org -p 2222
and password is KRYPTONISGREAT
.
The file krypton2 is in directory /krypton/krypton1. First change into that directory cd /krypton/krypton1
.
The password in krypton2 file is encrypted using simple rotation. We can decrypt it like we did in Bandit Level 11 → Level 12. The command is
cat krypton2 | tr "[a-zA-Z]" "[n-za-mN-ZA-M]
and the password is ROTTEN
.
Krypton Level 2 → Level 3
Level Info
This level contains an old form of cipher called a ‘Caesar Cipher’. A Caesar cipher shifts the alphabet by a set number. For example:
plain: a b c d e f g h i j k ...
cipher: G H I J K L M N O P Q ...
In this example, the letter ‘a’ in plaintext is replaced by a ‘G’ in the ciphertext so, for example, the plaintext ‘bad’ becomes ‘HGJ’ in ciphertext.
The password for level 3 is in the file krypton3. It is in 5 letter group ciphertext. It is encrypted with a Caesar Cipher. Without any further information, this cipher text may be difficult to break. You do not have direct access to the key, however you do have access to a program that will encrypt anything you wish to give it using the key. If you think logically, this is completely easy.
Solution
Command to login ssh krypton2@krypton.labs.overthewire.org -p 2222
and password is ROTTEN
.
The encrypted password is in the krypton3 which is in the /krypton/krypton2 directory. So first change into that directory. cd /krypton/krypton2
.
In the directory there is encrypt binary and keyfile.dat which contains the key but we cannot open it. When we execute the binary the output says that a file containing plaintext should be executed along with the binary.
We can create a directory /tmp/programmercave . This directory mush have executable permission set because we will execute the encrypt binary. This directory will contain a plaintext file with text ABCD.
mkdir /tmp/programmercave
chmod 777 /tmp/programmercave
cd /tmp/programmercave
cat > plaintext
ABCD
^C
We need to create symbolic link to file /krypton/krypton2/keyfile.dat because when encrypt is executed, key should there in that directory. This can be done using
ln -s /krypton/krypton2/keyfile.dat
The command /krypton/krypton2/encrypt plaintext
will encrypt the text ABCD in plaintext using key from keyfile.dat to new file ciphertext. The file ciphertext contains MNOP. This means the key is converting ABCD to MNOP.
Using this we can decrypt the password in krypton3 file using tr
program. The command is
cat /krypton/krypton2/krypton3 | tr "[m-za-lM-ZA-L]" "[a-zA-Z]"
and the password is CAESARISEASY
.