Zipping HTB

IP

10.10.11.229

intial nmap scan

sudo nmap -p- --min-rate 10000 10.10.11.229 | cut -d"/" -f1 | tr '\n' ','

we can see the following ports open on the target machine

22,80

Lets run a more in-depth scan of the target

sudo nmap -sCV -p22,80 -oA tcp_ports 10.10.11.229

results

PORT   STATE SERVICE VERSION
22/tcp open  ssh     OpenSSH 9.0p1 Ubuntu 1ubuntu7.3 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey: 
|   256 9d:6e:ec:02:2d:0f:6a:38:60:c6:aa:ac:1e:e0:c2:84 (ECDSA)
|_  256 eb:95:11:c7:a6:fa:ad:74:ab:a2:c5:f6:a4:02:18:41 (ED25519)
80/tcp open  http    Apache httpd 2.4.54 ((Ubuntu))
|_http-server-header: Apache/2.4.54 (Ubuntu)
|_http-title: Zipping | Watch store
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 18.79 seconds

we can see

  • SSH is up and running

  • We have a http Apache we server, version 2.4.54

  • ubuntu server

Let's check out this web server

initial thoughts

  • ECommerce shop (watch business)

  • given it is a web server we should see if we can find any directories

  • we do find some .php functions on the web app

navigating through the web server we can find some interesting information

Looking around the page we can find a directory /upload.php , which looks like some kind of PHP function that only accepts zip files with pdf's residing in them

Lets submit a blank pdf file that has been zippped up, catch the request with burp and analyze further

once we have selected the zip file (with a pdf file inside) we can hit upload and looking through burp we can see the following

  • notice we have been given a link to our pdf file to view it

  • we can see the file that will be accepted is .zip files

Lets see if we can utilize symlinks

what is a symlink?

  • A symlink (also called a symbolic link) is a type of file in Linux that points to another file or a folder on your computer. Symlinks are similar to shortcuts in Windows

How is this useful to us?

  • we can create a zip archive with symlink, essentially we can create a file.pdf that point to another location somewhere within the web application, say maybe /var/www/html/shop/index.php on the back system

creating a symlink

creating a zip archive with symlinks

Now we can upload our zip filp

and we can see the source code for index.php

Looks like we have discovered a LFI vulnerability, lets create another zip file except this tim we want to symlink test.pdf to /etc/passwd

same processes as before and we can see when we send the request to repeater

looks like we have the user rektsu and mysql running within the target

Now if we look back at the source code for /var/www/html/shop/index.php we can see another function

I want to see if these function has any hard coded creds

so lets set up our zip file to upload

Once we have uploaded and are given the location lets catch the request and pass it through to repeater

looking at the function we can see the following

looks like we found some creds for MySQL

Let's enumerate this site further and check out the PHP function

by looking at the cart.php function

we can see a comment

we can see product_id is our vulnerable parameter, Now we just need to find a way to exploit this, we know we are mysql root given the function.php hard coded credentials we found earlier

cmds

Last updated