Root Me

Date: 17, May, 2021

Author: Dhilip Sanjay S


Click Herearrow-up-right to go to the TryHackMe room.

Reconnaissance

$ nmap -sC -sV 10.10.202.137 -oN nmap.out
Starting Nmap 7.91 ( https://nmap.org ) at 2021-05-17 01:01 IST
Nmap scan report for 10.10.202.137
Host is up (0.19s latency).
Not shown: 998 closed ports
PORT   STATE SERVICE VERSION
22/tcp open  ssh     OpenSSH 7.6p1 Ubuntu 4ubuntu0.3 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey: 
|   2048 4a:b9:16:08:84:c2:54:48:ba:5c:fd:3f:22:5f:22:14 (RSA)
|   256 a9:a6:86:e8:ec:96:c3:f0:03:cd:16:d5:49:73:d0:82 (ECDSA)
|_  256 22:f6:b5:a6:54:d9:78:7c:26:03:5a:95:f3:f9:df:cd (ED25519)
80/tcp open  http    Apache httpd 2.4.29 ((Ubuntu))
| http-cookie-flags: 
|   /: 
|     PHPSESSID: 
|_      httponly flag not set
|_http-server-header: Apache/2.4.29 (Ubuntu)
|_http-title: HackIT - Home
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 17.60 seconds

Scan the machine, how many ports are open?

  • Answer: 2

What version of Apache is running?

  • Answer: 2.4.29

What service is running on port 22?

  • Answer: ssh

Find directories on the web server using the GoBuster tool.

What is the hidden directory?

  • Answer: /panel/


Getting a shell

  • Visit http://10.10.202.137/panel/.

Filter Bypass Attempt 1

  • Initially, I tried to upload file php-reverse-shell.php (Don't forget to put your IP and Port in the file), which gave the following output:

Filter Bypass Attempt 2

  • To bypass the filter, change the file name to php-reverse-shell.php.jpg and then try uploading:

  • Listen on the appropriate port using netcat: nc -lvnp 1234

  • Open the uploaded file in the browser: http://10.10.202.137/uploads/php-reverse-shell.php.jpg

  • But unfortunately the image couldn't be opened. So, we need to look for some other filter bypass

Filter Bypass Attempt 3

  • Change the file name to php-reverse-shell.phtml and upload it.

  • Now, visit http://10.10.202.137/uploads/php-reverse-shell.phtml.

  • The code was executed and the reverse shell was obtained as the user www-data.

  • We'll upgrade it to a stable shell:

user.txt

  • Answer: THM{y0u_g0t_a_sh3ll}

  • Steps to Reproduce:


Privilege Escalation

Search for files with SUID permission, which file is weird?

  • Answer: /usr/bin/python

  • Steps to Reproduce:

Abusing SUID bit of /usr/share/python

root.txt

  • Answer: THM{pr1v1l3g3_3sc4l4t10n}

  • Steps to Reproduce:


Last updated