Weak RSA
Weak RSA writeup by Thamizhiniyan C S
Overview
Hello everyone, In this writeup we are going to solve Weak RSA from HackTheBox.
Link for the machine : https://app.hackthebox.com/challenges/6
Lets Start 🙌
Initial Setup
First download the given file.
The give file is a zip file. Extract the zip file using the following command and the given password:
Command: unzip <zip_file>
password: hackthebox
The zip file contains two files: flag.enc
and key.pub
Enumeration
From the challenge name, we can assume that the encryption used to encrypt the flag.enc
file is RSA.
We need the private key to decrypt the flag.enc
file, since the public key is given which shows that asymmetric encryption is used to encrypt the file flag.enc
.
The public key in the key.pub
is smaller, i.e., of less length. Its possible to retrieve private keys from short or smaller public keys.
We can do this by using the tool RsaCtfTool.
To install and run this tool execute the commands given below:
Now we have successfully installed the tool. Now we have to retrieve the private key by using the following command:
We have successfully recovered the private key. Now copy and store the private key in a private.key
file.
Getting the Flag
Now we can use this private key to decrypt the contents of the flag.enc
file. We can do this by using the openssl
utility.
Use the following command to decrypt the flag.enc
file and store the output in flag.txt
file.
We have successfully decrypted the file and got the flag!!!!!
Thankyou !!!!!
Last updated