βœ…Networked (Easy)

Lesson Learn

Report-Penetration

Vulnerable Exploit: Improper validate filter

System Vulnerable: 10.10.10.146

Vulnerability Explanation: The machine doesn't proper restrict access to sensitive information which could allow us to download the source code and bypass file upload with reverse shell and lead to command execution and gain access on the machine.

Privilege Escalation Vulnerability: Insufficient Input validation

Vulnerability Fix: Restrict Access to Sensitive Information

Severity: High

Step to Compromise the Host:

Reconnaissance

Enumeration

Port 80 Apache/2.4.6

Going through the port 80, we found a message on the webpage. By checking on source code, we found some comments.

Let find hidden directory with gobuster.

Browsing on /upload.php, there is an upload options which we could verify if we can upload .php

Checking on /photo.php, we can see some images and source code, the images are in /uploads.

Checking on /backup we found a file backup.tar. We can download the backup file and extract.

Checking on upload.php file, it configured to filter the image upload with some extension.

We can bypass the filter by use magic bytesarrow-up-right.

Exploitation

Let write script to take cmd argument and execute.

We can upload our php shell script to the application.

By going through the shell we have upload, we can get code execution.

Then, we can send this to burp proxy and replace with bash reverse shell.

Privilege Escalation

Shell as guly

Now we are on the machine but we don't have privilege on user guly. Let enumerate on the script.

Base on cron job, the php script will run every 3minutes.

The check_attack.php is going to check every 3 minutes, if there is any invalid ip address or files on the machine, it will create file /tmp/attack.log and pass it to exec() function to delete it.

We can create a suspicious file which could trigger to the check_attack.php script and it will past it to exec() function to remote it.

Go to /var/www/html/uploads and create a file as netcat reverse shell. For the file we can not use / symbol. So, with netcat -c options we can get the bash shell.

Let start our netcat listener on port 5555. Wait for 3mns, the shell pop up as guly user.

Shell as root

Auto script bash

First thing first, I will run sudo -l to check misconfigure file.

One we run the files, it requires to input some data. Viewing the file it contains data we filled.

Reference: https://book.hacktricks.xyz/linux-unix/privilege-escalationarrow-up-right

The NAME= attributed in these network scripts is not handled correctly. If you have white/blank space in the name the system tries to execute the part after the white/blank space. Which means; everything after the first blank space is executed as root.

Last updated