Hacking the Basic Pen Test Machine (tryhackme)

 I started with the usual nmap scans and found several ports of interest.




I decided to visit the website on port 80 as a Gobuster scan was being undertaken. There was nothing of real interest on the page being served, but when I looked at its source I found a comment which referred to a developer directory. I tried /dev and /note but they did not work. The Gobuster scan found /development.





The obvious next place to go was the /development directory. I found two .txt files in there. They both contained useful information, but j.txt seemed to be the most useful for my next steps.




The name J was now of interest, so I kept it in mind as I went about checking out the SMB services listening on ports 139 and 445.





It would seem J stood for Jay and K for Kay. I created a file of possible usernames and then went about brute forcing accounts.





I started with the auxiliary/scanner/smb/smb_login module in msfconsole, but this did not work. I then tried default credentials for Tomcat on port 8080 at the /manager page. I used Burpsuite's intruder tool along with user:pass strings encoded into Base64 for this attempt (grepping on You are not authorized) but this did not work. My last port of call was SSH. I used hydra with my custom made username file and rockyou.txt





I was able to use the found credentials to SSH into the machine. I did some simple enumeration of the machine and discovered that kay was also a user but without root privileges.






I tried to use su to switch user to kay but without the correct password this did not work. sudo -l did not work because jan could not use sudo I checked /etc/crontab for cron job privilege escalation roots and I had a look at binaries with the SUID bit set. One of these stood out - it was vim.basic but without being able to use sudo I wasn't able to escalate to root from jan's account. I found a file called pass.bak in kay's home directory, but jan did not have read access to it. It became clear that I needed to find a way to log in as kay so I started searching for passwords. I eventually found an RSA private key.




I copied this to my local machine and tried to log back into the victim machine using it. I soon discovered that I needed to supply a passphrase in addition to the private key and after several attempts I aborted the effort.





My next step was to try to crack the passphrase for the RSA private key, so I located ssh2john.py and used it to create a hash I could use in johntheripper. John was successful so I could now try to SSH back into the machine as kay






This worked and I was now able to see the contents of the pass.bak file.




This marked the end of the Basic Pen Test machine on the tryhackme website as the last question was to provide the password I had just discovered. I wanted to carry on, however, as kay was still not root. I therefore tried sudo -l as kay and was happy to see the results.




I remembered how I had seen that vim.basic had the SUID bit set, so I decided I would now try to use that in order to get a root shell.





This worked and I was able to finally complete the machine by finding the root flag!














Popular posts from this blog

Hacking Year of the Owl (thm)

Hacking Reset (thm)

Simple CTF (tryhackme)