Posts Tryhackme - Mnemonic
Post
Cancel

Tryhackme - Mnemonic


Mnemonic is a fun room in Tryhackme and the final objective is to get the user and root flag.


cover_image

Authorvillwocki
DescriptionI hope you have fun.

Deploy the VM and lets go.

Task 1


Just watch the youtube video and hit the completed button. Let’s move to the second task.

Task 2


nmap_scan

The nmap scan results shows that there are 3 ports open and SSH runs on a specific port. This answers the first two questions. I tried to login ftp service but it seems anonymous login is not enabled.

From the nmap scan it seems we can access the robots.txt file.

Or we can use gobuster to find the hidden directories.


gobuster dir -u http://ip-addr/ -w /usr/share/dirb/wordlists/common.txt -t 70 -x php,html,js,txt


gobuster_root_folder

Again use gobuster in the /webmasters directory.


gobuster_webmasters

I checked the /admin directory and found a login page but I couldn't go any further.

So, I tried to access the /backups directory but it just loads and there is only a blank screen.

Just use gobuster to find the hidden file.


gobuster dir -u http://ip-addr/webmasters/backups -w /usr/share/dirb/wordlists/common.txt -t 70 -x php,html,js,txt,zip,rar,sql


gobuster_webmasters_backups

Task 3


The zip file is password protected.

Crack it using fcrackzip.


fcrackzip -D -p path-to-wordlist -u zip-file.zip


fcrackzip_answer

After unzipping the zip file with the cracked password, I found a text file. The text file seems like a message for a user named James and it gives the username for the ftp service

Use hydra to get the password for the user


hydra_ftp

Without further delay lets login to ftp service

Found two files in the directory

Download it using the get command


get file-name


The not.txt is just a message for the user James

With the private ssh key downloaded from ftp I changed the permissions and tried to login to ssh but...another obstacle...it is password protected. Convert it to hash using ssh2john.


/usr/share/john/ssh2john.py id_rsa > hash.txt


And crack the hash using john.


john_crack

The cracked password is the ssh password for the user James Login to ssh using the credentials.


ssh_login

Atlast....logged into ssh. Let's get going.

Sometime after I logged into the machine the machine executes a program and the system reboots itself.


IPS_program

I logged into the machine again and tried to enumerate before the program executes and reboots the system.

In the home directory of the user james I found two text files.


home_dir_james


I copied the contents of the two text files in my local machine.

Next, I tried to find executables which can be run as root.


find_fail


Without redirecting the output I used the find command and found some interesting files.


files_list


Both of the files seems to have base64 names.

I tried decoding it and found the user flag and a link to a image.


user_flag


image_link

Here is the link

Download the image

I saw the hint for finding condor's password.


hint


I searched in google and came across the link.


google_link


Clone the repository.


git clone https://github.com/MustafaTanguner/Mnemonic.git


page_readme

Follow the instruction given in the github page for the installation of python libraries and finally run the python file.


python3 Mnemonic.py


run_file

Enter the image path, choose decrypt and enter the text file name.


decryption


And we'll get the answer to the last question in the task i.e, condor's password.

Task 4


Login to ssh with the username condor.


ssh_condor

User flag


We already got the user flag when decoding one of the filename. So, let's move onto the root flag.


In case you didn't get it. Here...


user_flag

Root flag


I found a file which is owned by root.


sudo_check
sudo_check1


I tried running the file and chose the most interesting option but it rebooted the system. So, I tried checking all the other options but nothing seemed suspicous.


After a while, I checked the code of the file and this part caught my attention.


interesting_part


I ran the file again, choose the exit(0) option, instead of giving "yes" I used a period and finally the root shell spawned after giving the path as "/bin/sh".


root_shell


Go to the /root dir and you'll see the root flag waiting for you...


root_flag

Don't forget to MD5 encrypt the contents of the root flag before submitting.

That’s it folks. Happy Hacking!!!!

This post is licensed under CC BY 4.0 by the author.