Lets start with an Nmap Scan:
![](https://static.wixstatic.com/media/eb0517_d4f43ca827d54485a2f82ef4d4083a80~mv2.png/v1/fill/w_916,h_598,al_c,q_90,enc_auto/eb0517_d4f43ca827d54485a2f82ef4d4083a80~mv2.png)
The Nmap Scan shows us that there is only one port open, Port 80.
so lets go visit the website:
![](https://static.wixstatic.com/media/eb0517_c9574bfd438b41228a473a7eef2299cf~mv2.png/v1/fill/w_980,h_393,al_c,q_90,usm_0.66_1.00_0.01,enc_auto/eb0517_c9574bfd438b41228a473a7eef2299cf~mv2.png)
So we have a pretty standard web application, and after enumerating the web page, there is not much to be found.
Lets try Directory Busting and performing a Nikto scan:
![](https://static.wixstatic.com/media/eb0517_2304bba01c0d47acb294339235c9f1d2~mv2.png/v1/fill/w_945,h_470,al_c,q_90,enc_auto/eb0517_2304bba01c0d47acb294339235c9f1d2~mv2.png)
Above is the output from a Go Buster scan (the Nikto scan failed to identify anything interesting).
Here we can see 8 results, with the most interesting result being /dev. So lets go take a look at it.
![](https://static.wixstatic.com/media/eb0517_7263d951a30e41d2a9b856fe740d688d~mv2.png/v1/fill/w_388,h_111,al_c,q_85,enc_auto/eb0517_7263d951a30e41d2a9b856fe740d688d~mv2.png)
We have 2 php scripts, and clicking on them reveals a backup command line interface.
We can see on the terminal that we are the user www-data, and we can grab the user flag in /home/arrexel.
After looking around this environment, the terminal is limited in some ways, so lets see if we can get a reverse shell on there and get a shell back on our own environment.
Placing a reverse shell on the php terminal failed, however I noticed in the GoBuster results that there was an /uploads directory. If we can upload a reverse shell onto this directory and then visit it, we could pop a shell, lets try.
I grabbed a PHP reverse shell from https://github.com/pentestmonkey/php-reverse-shell, hosted the directory using Python, and then used the wget command to transfer this file to the /var/www/html/uploads directory.
![](https://static.wixstatic.com/media/eb0517_2b60c226dfec47ae9ca236daac719796~mv2.png/v1/fill/w_401,h_74,al_c,q_85,enc_auto/eb0517_2b60c226dfec47ae9ca236daac719796~mv2.png)
![](https://static.wixstatic.com/media/eb0517_61d33d05b89c42e0bc8b66d24a92e416~mv2.png/v1/fill/w_594,h_131,al_c,q_85,enc_auto/eb0517_61d33d05b89c42e0bc8b66d24a92e416~mv2.png)
Now we can set up a listener on our Kali machine, and then visit the URL, http://10.10.14.15/uploads/x.php.
This gave us a shell, now lets improve it with, python -c 'import pty; pty.spawn("/bin/bash")'
Privilege Escalation:
Before running any PE scripts, lets first enter sudo -l to see if we can get an easy win.
Doing this command gave us the output:
![](https://static.wixstatic.com/media/eb0517_c0eb148a48674a428ec2c91d5de9dc46~mv2.png/v1/fill/w_841,h_153,al_c,q_85,enc_auto/eb0517_c0eb148a48674a428ec2c91d5de9dc46~mv2.png)
This tells us that we can switch to user 'scriptmanager' using sudo. The command for this would be the following:
![](https://static.wixstatic.com/media/eb0517_455cefe1165a42819bbdb9cf45a0334d~mv2.png/v1/fill/w_432,h_124,al_c,q_85,enc_auto/eb0517_455cefe1165a42819bbdb9cf45a0334d~mv2.png)
After enumerating the machine manually, I couldn't find much, so lets host linpeas.sh from our kali machine, and use the same wget command as earlier to transfer it over to the victim machine (I placed this in the /tmp directory).
Then we can use the command, chmod +x linpeas.sh to make it an executable, then run it, ./linpeas.sh
Within the output we can see a very interesting file called test.txt:
![](https://static.wixstatic.com/media/eb0517_3568b6e0740647b395d5061fad10b95d~mv2.png/v1/fill/w_632,h_171,al_c,q_85,enc_auto/eb0517_3568b6e0740647b395d5061fad10b95d~mv2.png)
Lets cd over into /scripts, and ls -la to look deeper into the files in that directory.
![](https://static.wixstatic.com/media/eb0517_77055056d677413497d5649f1929bca4~mv2.png/v1/fill/w_633,h_146,al_c,q_85,enc_auto/eb0517_77055056d677413497d5649f1929bca4~mv2.png)
Here we can see that test.txt was run not long ago, we can confirm this with entering ls -la again, and notice that the overwrite time has changed.
![](https://static.wixstatic.com/media/eb0517_d926c54f011a47c5bab892bcc8d3cf8d~mv2.png/v1/fill/w_415,h_121,al_c,q_85,enc_auto/eb0517_d926c54f011a47c5bab892bcc8d3cf8d~mv2.png)
So here we can see that this had been run to write to test.txt, and so this cronjob must be being run as root, or else this file would not have permission to write to a root owned file. And we can determine that the whole of the directory is being run as a cronjob, and as root.
With this in mind we can create our own file in this directory, and because the cronjob is being run by root, the malicious file we create will also be run as root, hopefully giving us a shell as root (mentioned root a lot there aha).
I'm going to overwrite the test.py file, as I know for sure that this has worked in the past (as the test.txt file had been overwritten at some point). Lets first create a malicious Python program on our Kali machine, I grabbed one from https://github.com/swisskyrepo/PayloadsAllTheThings/blob/master/Methodology%20and%20Resources/Reverse%20Shell%20Cheatsheet.md#python
I then indented accordingly (this is important as other attempts failed before doing this), and named the file test.py:
![](https://static.wixstatic.com/media/eb0517_6a34fb6415be49e8a7122c28e6f34f9a~mv2.png/v1/fill/w_425,h_152,al_c,q_85,enc_auto/eb0517_6a34fb6415be49e8a7122c28e6f34f9a~mv2.png)
I first removed the original test.py file from the victim machine (using 'rm test.py'), and then used the same wget command as earlier to transfer it onto the victim.
Then I set the new file with executable rights, chmod +x test.py.
All that was left to do was set up a listener on our Kali machine and wait around a minute:
![](https://static.wixstatic.com/media/eb0517_31f4ba49d41d43b7ae8592f2309d2aab~mv2.png/v1/fill/w_570,h_136,al_c,q_85,enc_auto/eb0517_31f4ba49d41d43b7ae8592f2309d2aab~mv2.png)
BOOM! We got a shell as root, we can confirm this with the 'whoami' command.
Now you can grab the root flag in /root.
Congratulations, you have pwned this box!!
Comments