TryHackME — Mustacchio

6 min readNov 23, 2023

First of all lets start with port scanning with the following command

nmap -Pn -p- 10.10.186.21 - T4

and see which service is working on which port , so we get 3 ports , lets visit the webpage hosted at the http service.

Linux Terminal

besides the nmap port scanning , start the directory enumeration as well with gobuster with the following command:

gobuster dir -u http://10.10.186.21 -w /usr/share/wordlists/dirb/common.txt -t 100
Linux Terminal

we get 5 directories that we can access , but the only useful directory is the index.html one that is hosting the webpage as well , lets visit it , but it also does not contain any useful information in the page as well in its source code.

FireFox

since we have 8765/ tcp open ultraseek-http port also open so upon visiting the port 8765 we found a login page but we do not know its email or password.

FireFox

upon visiting the webpage at the custom directory found above from the directory enumeration process we are able to find a user.bak file that contains a username of admin and password that is hashed.

FireFox
FireFox
Linux Terminal

now we can get the password form the hashed password by brute-forcing.

lets first identify the type of the found hash with hash-identifier by using the following command

hash-identifier 1868e36a6d2b17d4c2745f1659433a54d4bc5f4b
Linux Terminal

so the hash is of type SHA-1 , lets store the hash in a separate file and then use the hashcat to brute-force it.

hashcat - m 100 -a 0-0 hash.txt /usr/share/wordlists/rockyou.txt
Linux Terminal

another way is to check the hash value from crackstation.net

FireFox

lets login into the admin panel with the found username and password

FireFox

lets check the source code for the new page we just found

FireFox

from the page source i get to find 2 useful information , it gives us a path to a backup file at the address

Example=/auth/dontforget.bak”

and secondly it tells that the user barry can ssh using his key , but to do that first we need the ssh key for the user barry.

FireFox

lets download the dontforget.bak file first and then check its content

FireFox

so it gives us a xml structure to post a comment , lets first check if our comment section box supports xml , if yes then lets perform the xxe on the comment section box.

Linux Terminal

we check the above said thing by checking the request in our burp suite.

Hence , it is confirmed that xml is supported on the comment section box so that means we can try performing xxe attack on the comment section box.

FireFox + Burp Suite

lets try downloading the payload from the pentest monkey repository

lets copy the payload form it and make a xml based on the structure we got from the dontforget.bak

FireFox
FireFox

upon submitting the payloaded xxe we can access the passwd file.

FireFox

since we just found the username of barry via page source, we can try getting the ssh key from “/home/barry/.ssh/id_rsa” directory.

FireFox

you can copy the ssh key from the page source so that it is formatted well when you copy it.

FireFox

copy the ssh key form the source file and store it in a file.

FireFox

store the ssh in barry_hash.txt file , since the ssh key we got is in private key we have to load its hash and then brute force the hash , we can convert the private key into hash , first download the python script for it using the following command:

wet https://raw.githubusercontent.com/magnumripper/JohnTheRipper/bleeding-jumbo/run/ssh2john.py
Linux Terminal

use the below command to brute-force the hash to find the password using the following command:

john --wordlist=/usr/share/wordlists/rockyou.txt id_rsa.hash

then use the following command to check the found password:

john --show id_rsa.hash
Linux Terminal

before ssh-ing to the barry`s account change its permission into 600 for the hashed converted key

chmod 600 barry_hash.txt

now lets ssh into the barry`s account using the ssh key with found password.

ssh -i barry_hash.txt barry@10.10.7.251
Linux Terminal

after getting the ssh , capture the user flag from the home directory.

Linux Terminal

lets find the files that the user barry can execute with root privileges , from which the “live_log” file looks promising

Linux Terminal

/home/joe/live_log binary looks interesting. After running strings command on this binary, I found that it is using tail command

Linux Terminal

Now if we observe carefully, tail is not called from it's actual path, we can take advantage of this by adding our own path in $PATH environment variable and creating a new file with name tail.

lets cd to the tmp directory and perform that operation.

create a tail file in the tmp directory and add it to the $PATH environment variable , then make it executable as using chmod +x /tmp/tail now run the binary log file using the ./live_log
after that we have the root access , now we can find the root flag cd to /root

and you have completed the box.

Linux Terminal

CTF finished! clap 👏 this writeup and leave a comment ✍️ , Thank you.

TryHackMe

--

--

Syed Abeer Ahmed
Syed Abeer Ahmed

Written by Syed Abeer Ahmed

Cybersecurity | CS Tutor | Software Engineer | Flutter Dev

No responses yet