Page cover

Gallery (SQLI, Backup, nano)

First, we need to enumerate using nmap and rustscan.

╭─hnl@hnl ~/Desktop/ctf/tryhackme/gallery  
╰─➤  nmap -A 10.10.145.252 | tee nmap.log
Starting Nmap 7.80 ( https://nmap.org ) at 2022-04-24 09:22 +0630
Stats: 0:01:38 elapsed; 0 hosts completed (1 up), 1 undergoing Connect Scan
Connect Scan Timing: About 91.60% done; ETC: 09:24 (0:00:08 remaining)
Nmap scan report for 10.10.145.252
Host is up (0.39s latency).
Not shown: 995 closed ports
PORT     STATE    SERVICE        VERSION
80/tcp   open     http           Apache httpd 2.4.29 ((Ubuntu))
|_http-server-header: Apache/2.4.29 (Ubuntu)
|_http-title: Apache2 Ubuntu Default Page: It works
8080/tcp open     http           Apache httpd 2.4.29 ((Ubuntu))
| http-cookie-flags: 
|   /: 
|     PHPSESSID: 
|_      httponly flag not set
| http-open-proxy: Potentially OPEN proxy.
|_Methods supported:CONNECTION
|_http-server-header: Apache/2.4.29 (Ubuntu)
|_http-title: Simple Image Gallery System

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

Port 80

When you browse to http://10.10.145.252/, you will see default webpage. Let's enumerate some sub directories.

Port 8080

Wen you browser to http://10.10.145.252:8080/, you will find login page http://10.10.145.252/gallery/login.php.

You can simply bypass using through sqli admin' or '1'='1. And then you will find a dashboard.

In Albums directory, we can upload a image. But we only upload PHP reverse shell file. And then click it.

In netcat, we got a connection.

User

Spawning a TTY Shell

We can't read user.txt. Becasue we are www-data user.

In /var/backups directory, we found some interesting file.

Change to this directory and read .bash_history file.

It can be mike user password, so we change to mike user. We successfully change to mike user.

Read the user flag.

Root

Check privileges with sudo -l, you will find something.

/opt/rootkit.sh

Bypass it.

I can't bypass at terminal and get many error. So, I will create a stable shell and bypass it.

Read the root flag.

Read mysql data.

Last updated