Lavita

Nmap Scan

$ nmap -sC -sV -p- --min-rate 10000 -Pn -oN nmap 192.168.158.38 
Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-06-11 15:13 +08
Nmap scan report for 192.168.158.38
Host is up (0.0080s latency).
Not shown: 65533 closed tcp ports (conn-refused)
PORT   STATE SERVICE VERSION
22/tcp open  ssh     OpenSSH 8.4p1 Debian 5+deb11u2 (protocol 2.0)
| ssh-hostkey: 
|   3072 c9:c3:da:15:28:3b:f1:f8:9a:36:df:4d:36:6b:a7:44 (RSA)
|   256 26:03:2b:f6:da:90:1d:1b:ec:8d:8f:8d:1e:7e:3d:6b (ECDSA)
|_  256 fb:43:b2:b0:19:2f:d3:f6:bc:aa:60:67:ab:c1:af:37 (ED25519)
80/tcp open  http    Apache httpd 2.4.56 ((Debian))
|_http-title: W3.CSS Template
|_http-server-header: Apache/2.4.56 (Debian)
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 12.35 seconds

Initial Access

Port 80

There is a website that is running on port 80.

There is also a form.

After we put in random inputs, we will get this instead.

We can see that this is running Laravel 8.4.0.

After searching online, we can see that this version is vulnerable to this exploit. However, the debug mode must be enabled.

Hidden /register subdirectory

We will also run gobuster to see if there is any hidden subdirectories.

We can see there is a /register subdirectory.

After going in, we see this.

We will input everything as per normal and click on register. It will bring us to this screen instead.

Since the exploit requires the APP_DEBUG mode to be enabled, we will just enable it.

CVE-2021-3129

We will first test if the exploit can work first.

After executing, we can see that the ping command works.

So now we will put our actl payload inside.

The payload we are using is this:

After executing our payload, we are able to get our reverse shell.

Lateral Movement

Upgrading Shell

First we will upgrade the shell using Native Linux Method.

Linpeas

From the scan, we can see that there is a user called skunk.

When we are running pspy64, we can see that the user is running this once every minute.

Upon inspecting the file, we can see that the file is executing PHP code.

We can also see that we have access to modify the code as we want.

So the next step is to create a PHP webshell, which will trigger the payload. This will be the payload that we will be using. We will create a file called artisan and put this as the content of the file.

Then we will download to the target server.

After a while, we should be able to get a reverse shell as skunk.

Privilege Escalation

Sudo for composer

Since we know skunk can use sudo as the user is in the sudo group, we can just sudo -l to see what command it can run as root.

After some searching online, we can see that this command can be run using sudo get root shell.

We need to put a file called composer.json into that folder. So in this case the folder is /var/www/html/lavita. However, skunk does not have write access to the folder. However, www-data is able to write.

So we will execute this on www-data

Then we will execute composer using sudo from skunk to get root access.

Last updated