HackTheBox - Traverxec

Featured image

Hello Guys , I am Faisal Husaini. My username on HTB is ferllen . Also join me on discord.

The IP of this box is 10.10.10.165

Port Scan

Running masscan on it , we get

masscan -p1-65535,U:1-65535 10.10.10.165 --rate=200 -e tun0

placeholder

Running NMAP against the open ports

placeholder

Port 22 running OpenSSH 7.9p1 and Port 80 running nostromo 1.9.6

Moving to the Web Part

Port 80 — nostromo 1.9.6

Running the IP on the browser

placeholder

We see a webpage related to web development, but since we saw the web server was nostromo 1.9.6 I went to search for potential exploits for it

placeholder

We see 2 exploit, one of them being on metasploit so we will use that one for our ease

Spawning metasploit and searching the module

placeholder

Checking and setting the required options

placeholder

Now we run the exploit command

placeholder

We got shell on the box as www-data, but since this is an unstable shell , so I wish go for little bit more stable shell by using bash oneliner reverse shell command

placeholder

Looking back to the netcat listener

placeholder

Looking further inside we get a folder for nostromo

placeholder

Here we went into the conf folder of nostromo and then upon looking on the nhttpd.conf file we see that there is a .htpasswd file on the conf folder

placeholder

We got a hash along with the username david and looking at the hash type in hashcat website

placeholder

We see that its md5crypt or MD5(Unix) , since we now the mode to use which is 500, I will use hashcat for cracking it

placeholder

We cracked the password which is Nowonly4me, trying to login to the user david

placeholder

We see that it fails, remember from the above config file we saw there was a public_www which was listed as homedir_public

If you go to the home directory of user david

placeholder

We see that we cant see the contents of the folder, but if we try to access the public_www folder inside it

placeholder

We got into that folder and also there is one more folder named protected-file-area so we try to access that

placeholder

We see two files named .htaccess and backup-ssh-identity-files.tgz

placeholder

We got a message in .htaccess file , looking into the other file type

placeholder

We see its a gzip compressed file, so we will bring it to our box

placeholder

placeholder

So here we used the base64 encoding method to bring the file to our box and now we work on it

placeholder

Here we decompressed the gzip tar file and we see that we got ssh keys

placeholder

We see that the ssh key is encrypted, so we will have to crack the passphrase

placeholder

Now we crack it using John

placeholder

We cracked it successfully and got the passphrase as hunter

placeholder

We got in successfully and now time to get the user flag

placeholder

Moving onto the priv esc part

Privilege Escalation

Looking into the directory of the user david

placeholder

We see a folder named bin in the home directory of user david and also inside that folder are two files one of them being a bash script

placeholder

We see that last time which uses sudo, but when we use sudo

placeholder

It asks for password which we dont have, but when we use the last line command

placeholder

Upon looking on GTFOBins, I figured it out we could exploit the journalctl binary if it gets us a prompt but for that we need to change out terminal to tty

placeholder

We see we get a prompt at the end of the line, so now we abuse it to get the a shell

placeholder

After pressing enter

placeholder

We got root!!! Root flag in the usual place as always

placeholder

Overall a big troll at the end :)

Youtube Video

References

Nostromo Exploit

journalctl | GTFOBins