TryHackMe CTF Walkthrough - "Bounty Hacker"

Note: This is a reupload of a CTF walkthrough from my original website which no longer exists.

Today I'll be doing a writeup on the easy difficulty CTF machine "Bounty Hacker" from the cybersecurity training website TryHackMe.

As always, we will start with an Nmap scan of the machine. Here we will be running an aggressive service scan with default scripts enabled.


I will also sometimes simultaneously run the above scan alongside another nmap scan which will be using the vulnerability script for additional enumeration. However in this case I decided to simply go ahead with the above command.



As we can see we have a little bit of information to go off of. We can see the FTP and SSH are both open, with FTP allowing anonymous logon. Just from personal experience I am already familiar with the versions of vsftpd and OpenSSH that are currently running, and I also know that there aren't any publicly available exploits to leverage against them. Considering that this is considered an "easy" CTF, it's highly unlikely that you will be expected to write a custom exploit or perform any sophisticated attacks against the target machine. 

We can also see HTTP is open and that the web server is running Apache httpd version 2.4.18. Also another dead end in terms of finding vulnerable service versions. Let's check out what the web server is running.


If you didn't already know this was a Cowboy Bebop themed machine, now you do. Not much else on the webpage to find nor were there any secrets hidden in the source code. Let's run gobuster in an attempt to find any hidden directories and in the meantime, check out the FTP server.


If you are unaware, when an FTP server allows anonymous logon, you are able to simply ftp to the server with the username and sometimes password, of 'anonymous'. Once logged in, you can use the help command to give you a list of all the commands available to use. Let's give it a try.


Let's do run ls -la  which will list all files, including hidden files, on the server.


Here we can see two files, "locks.txt" and "task.txt" in the current directory. Let's download them to our machine so we can read them. You can do this using the "get" command.


Let's look at the contents on our own machine in order to see if they hold any useful information.


From the contents of the two files it looks like we do in fact have something valuable on our hands. The first file appears to be a simple list of tasks by a specific person, "lin", and the second appears to be a list of credentials. If the first thing to come to mind isn't SSH bruteforcing, it should be. Let's spin up Hydra and see if we can't find the right pair.



And we got it! Hydra is a great tool to brute force SSH and FTP. There is also a Metasploit module that will do the exact same thing, but I prefer Hydra. Make sure to thoroughly read through Hydra's help list in order to make sure you're using the correct flags.

 Now, let's SSH into the target machine and see what we can find. 

As always, Linpeas is an option you can use if you would like to fully enumerate the host in order to find a potential privesc vector, but before you do that, it's good practice to simply run sudo -l in order to see if there are any additional permissions you might have right off the bat.


As we can see already right off the bat, we are able to run the tar utility as root. For anyone who has never used Linux or even heard of it, tar is an archiving utility, similar to zip in Windows. Now that we know that we have permissions to run tar as root, we could leverage this into spawning into a root shell. A great utility/website that is essentially a repository for Linux privilege escalation vectors for various Linux utilities and binaries is GTFOBins. Let's check to see if they have any entries on the tar utility.


A quick search shows that they do in fact have a tar entry, with an available command to run that should allow you to escalate privileges if you have the right permissions. Let's give it a try.


And boom. We're root. 

I found this CTF to be enjoyable but very simple even by my sub-novice skill-level self. As always I will plug TryHackMe as a great learning resource for anyone interested in offensive/defensive cybersecurity. 

Comments

Popular posts from this blog

TryHackMe CTF Walkthrough - "Simple CTF"

Malware Overview - ZeuS

Group Overview - Evil Corp