The Notebook (Medium)

Enumeration

nmap

nmap -sC -sV -oA nmap/10.10.10.230 10.10.10.230
Nmap scan report for 10.10.10.230
Host is up (0.19s latency).
Not shown: 997 closed ports
PORT      STATE    SERVICE VERSION
22/tcp    open     ssh     OpenSSH 7.6p1 Ubuntu 4ubuntu0.3 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey: 
|   2048 86:df:10:fd:27:a3:fb:d8:36:a7:ed:90:95:33:f5:bf (RSA)
|   256 e7:81:d6:6c:df:ce:b7:30:03:91:5c:b5:13:42:06:44 (ECDSA)
|_  256 c6:06:34:c7:fc:00:c4:62:06:c2:36:0e:ee:5e:bf:6b (ED25519)
80/tcp    open     http    nginx 1.14.0 (Ubuntu)
|_http-server-header: nginx/1.14.0 (Ubuntu)
|_http-title: The Notebook - Your Note Keeper
10010/tcp filtered rxapi
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 at Fri Jun 25 12:11:33 2021 -- 1 IP address (1 host up) scanned in 55.36 seconds

Let's navigate to port 80 as usual

If we click register, we will able to register

After register we will see a page like this

After poking around, we can see there is a jwt authentication token at cookie. By using cookie editor, we can see something like this.

We can proceed to decode it using jwt.io

After some researching, the kid parameter at the header actually vulnerable.

Still, after some researching, I stumbled across this script. Basically we can just write a script and self-signed the token

We need to change the localhost from the kid parameter to our IP address so they know where to find the privKey.key file to validate the token authentication.

We first open a listener and paste the generated token to the cookie editor.

And then walla, got an Admin Panel

From the admin panel, we are able to upload files

Reverse Shell

Then we proceed to uplaod a reverse shell file

After uploaded the reverse shell file, we will see this

We can proceed to start a listener and grab a reverse shell by clicking the view

User Shell Escalation

After some digging, we can see this home.tar.gz file under /var/backups

We can proceed to netcat the file back to our machine and extract it.

After extracted, we will get a home directory

Got an id_rsa file ! Finally we can login as user noah

Privilege Escalation

We can see there is a command we can execute using sudo.

We can see the version of the docker by supplying docker --version

This version of docker actually vulnerable to Docker escape--runc container escape vulnerability (CVE-2019-5731)

By researching, we can find this github where it teaches the PoC how to exploit the docker.

After supplying this command, we can get a root container

We are not yet getting the root user.

What we need to do is to modify the exploit given by the PoC

Then, we can build it using go command

We can then send it to the victim machine

We then need to run the script, and during the running state when showing Overwritten /bin/sh successfully, we need to have another terminal at the same time running another command

Terminal 1

Then we need to fire up our netcat listener before the process of exploiting and when the command is sent, we will get the shell back.

Congratz!

Last updated

Was this helpful?