Machine Info
Spoiler
User
Reconnaissance
We are going to start by running our nmap scan:
| |
Laravel 8.4.0 RCE

/login & /register route.
| |
After registering a user we come across this screen which basically let us enable debug mode for Laravel.
Looking it up online with the version we found we come across a well known RCE vulnerability for Laravel 8.4.2 and prior and exists when debug mode is on. The vulnerability is listed as CVE-2021-3129.
Looking at the exploit code it has some hardcoded values regarding the victim host so we put the correct IP and also enable APP_DEBUG = [ENABLED] on the website.
| |
We have achieved rce! Let’s now change the commands in order to get a reverse shell. We used a simple netcat reverse shell.
| |
| |
That’s how we get local.txt. Just remember the public exploit can be tricky. I messed up for quite some time with the one from ExploitDB and another on from github which were the full path of the log directory for laravel.
Root
Skunk - PHP
We start we some basic enumeration and we find a MYSQL database and credentials!
| |
| |
Unfortunately nothing important was on the database. Here we took our time to run different tools such as linpeas and but we didn’t much.
We cannot run sudo since there is no password for www-data user and user skunk doesn’t seem to have much exposure. We tried the passwords find with his accounts with no luck. We also checked the sudo version, which wasn’t vulnerable either.
We moved then and run pspy to monitor running processes and maybe we could get something from this.
| |
Interestingly enough we spot cron jobs running as user 1001 (skunk). Most interesting one is the /usr/bin/php /var/www/html/lavita/artisan clear:pictures.
Looking at the /var/www/html/lavita/artisan we see we as www-data are the owner!
Let’s overwrite it with a PHP reverse shell. We used a classic one from PentestMonkey which can be found here.
| |
We got reverse shell as user skunk! Let’s see what we can do now.
SUDO Composer
Immediatelly we check sudo rights and we are able to run composer as root.
| |
We can easily abuse this and get a root shell as we see on GTFOBins.
| |
We need to place the composer.json under /var/www/html/lavita and we need user www-data for that.
| |
| |
Root shell achieved!
