πŸ”¦Expose

License

The following post by anthonyjsaab is licensed under CC BY 4.0arrow-up-right

0 - Introduction

Link to room: https://tryhackme.com/r/room/exposearrow-up-right

Machine version: exposev6

This writeup walks you through a room on TryHackMe created by tryhackmearrow-up-right and 1337rcearrow-up-right

1 - Port Scan

1a - Discovery

β”Œβ”€β”€(kaliγ‰Ώkali)-[~]
└─$ sudo nmap -sS -T4 -p- 10.10.98.61   
[sudo] password for kali: 
Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-04-28 22:16 EEST
Nmap scan report for 10.10.98.61
Host is up (0.11s latency).
Not shown: 65530 closed tcp ports (reset)
PORT     STATE SERVICE
21/tcp   open  ftp
22/tcp   open  ssh
53/tcp   open  domain
1337/tcp open  waste
1883/tcp open  mqtt

Nmap done: 1 IP address (1 host up) scanned in 307.40 seconds

1b - Versioning and OS fingerprinting

1c - Vulners

2 - Port 1337

2a - Dirbusting

2b - /admin - false lead

The form does not work at all. No communication with the backend at all

2c - /admin_101

2ci - Probing

In the bottom right, we can clearly see that the email field in directly inserted in an SQL statement without sanitization

2cii - SQLmap

2d - /admin_101 but logged in - dead end

2z - What we know so far

The SQLMap output was very helpful:

  • The password of [email protected] on admin_101

  • There are files we have to inspect:

    • :1337/file1010111/index.php

    • :1337/upload-cv00101011/index.php

3 - Port 1337 mysterious files

3a - /file1010111/index.php

We should input the password cracked earlier using SQLmap
Hint clearly points at an LFI using GET parameters
We add ?file=/etc/passwd to URL, we are asked again for the same password
Voila! We can see the username we need is 'zeamkish'

3b - /upload

Form only allows upload of png files
Getting PHP reverse shell code and saving it in rev_php.png
Upload can send the file now that extension is .png
We intercept the request with Burp and change the filename's extension to php before forwarding
Reverse shell code has been infiltrated to the target machine. We still need to detonate it. The hint below helps us
We can execute the reverse shell!

Now that we have the SSH credentials, let us exit the dumb reverse shell and connect via SSH instead. Much more convenient.

4 - PrivEsc - Lucked out!

After I tried looking for something interesting in sudo -l, I began listing programs that are usually owned by root and that could have the SUID bit set. First try, find!

Last updated