# OpenAdmin Walkthrough

Here we come back again with one of **HackTheBox** machines ‘**OpenAdmin**’ which seems like all categories CTF, real life, etc so let’s take a look at its info

<figure><img src="https://cdn-images-1.medium.com/max/800/1*HY3VHGrSPP4VcxFmnu9-jw.png" alt=""><figcaption></figcaption></figure>

<figure><img src="https://cdn-images-1.medium.com/max/800/1*9fzcrPb35fkzK_N5i7bcMw.png" alt=""><figcaption></figcaption></figure>

As you can see it depends on CVE so let’s get started…

## **Nmap scan**

As usual, we start our scan with `nmap` to get more info about our target

`nmap -A -T4 -oG openadmin.gnmap 10.10.10.171`

<figure><img src="https://cdn-images-1.medium.com/max/800/1*0UhhtiZxSYnyUdOj5jFdGQ.png" alt=""><figcaption></figcaption></figure>

We have only 2 open ports `http and ssh` so I understand that I’ll get an entry point like leaked credentials or any custom exploitation from the `http:80` and then used it to log in to the box using `ssh:22` so let’s start enumerating the website

## **HTTP Enumerate**

If we access `10.10.10.171:80` and `openadmin.htb` we will get the default page of the server

<figure><img src="https://cdn-images-1.medium.com/max/800/1*EgEVdWRCanFoNA0QYvANEg.png" alt=""><figcaption></figcaption></figure>

So we need to brute-force the directories by using `dirsearch or gobuster or dirbuster`

<figure><img src="https://cdn-images-1.medium.com/max/800/1*x8FAi1Peu5XGBnbvdpJCGA.png" alt=""><figcaption></figcaption></figure>

I’ve 3 directories is available so let’s can check the first one

<figure><img src="https://cdn-images-1.medium.com/max/800/1*lrJpFI3I4udREEYE31S8bw.png" alt=""><figcaption></figcaption></figure>

I searched for any CMS or any admin panel to try to find an exploit for it, but unfortunately, there’s nothing found so let’s check `/music`

<figure><img src="https://cdn-images-1.medium.com/max/800/1*PuPl1B53-hFDq4PV3rfZlg.png" alt=""><figcaption></figcaption></figure>

Good we have another directory with `login` page, let’s check it

<figure><img src="https://cdn-images-1.medium.com/max/800/1*4nIl82qbyCSMIfUgSvQVHw.png" alt=""><figcaption></figcaption></figure>

It redirects us to this URL `10.10.10.171/ona` so what’s `ona` which has version `v18.1.1`? Let’s check its source code

<figure><img src="https://cdn-images-1.medium.com/max/800/1*GdWN-rv8M0FbkKqccFzMwQ.png" alt=""><figcaption></figcaption></figure>

That’s good `ona` means `opennetadmin`

## **Generating a shell**

Let’s search for exploits related to this CMS

<figure><img src="https://cdn-images-1.medium.com/max/800/1*k00bQE8B38YMkYiUt83FBQ.png" alt=""><figcaption></figcaption></figure>

We have one here with the same version and this exploit is also available at `metasploit` so let’s check it

<figure><img src="https://cdn-images-1.medium.com/max/800/1*X4KbbVDUaBVmhNOZltYpfg.png" alt=""><figcaption></figcaption></figure>

We have only one, let’s use it and edit its options

<figure><img src="https://cdn-images-1.medium.com/max/800/1*IjmKchg-ekQI21XnF1CB3g.png" alt=""><figcaption></figcaption></figure>

I’ve tried the payload `x86` but unfortunately, it doesn’t work, so I changed it and as you can see it works now, let’s open a shell and get an interactive one

<figure><img src="https://cdn-images-1.medium.com/max/800/1*5GY2AF3IEDPpBEiDjnn73Q.png" alt=""><figcaption></figcaption></figure>

Now we’re `www-data` and I’m not sure that I’ve permission to read the `user.txt` flag, let’s try

<figure><img src="https://cdn-images-1.medium.com/max/800/1*xCA2h3ImevbAxq_GHnBDcQ.png" alt=""><figcaption></figcaption></figure>

As I expected, permission was denied, so let’s search for any misconfiguration or anything else which manages us to login as one of these users

After few time of searching for any important files, I found this file in `opt/www/local/config` which contain a containsdatabase.

<figure><img src="https://cdn-images-1.medium.com/max/800/1*Xj4d88d8RcPdSUdyObSd_g.png" alt=""><figcaption></figcaption></figure>

I tried to use it to login as `joanna` but it failed but succeeded with `Jimmy`

<figure><img src="https://cdn-images-1.medium.com/max/800/1*7Pt5aF24cETHMy9ksoVrZg.png" alt=""><figcaption></figcaption></figure>

And now we’re in the server as `jimmy` let’s try to read `user.txt`

<figure><img src="https://cdn-images-1.medium.com/max/800/1*WwqMjiC8HI51NxUj5qY8DA.png" alt=""><figcaption></figcaption></figure>

Hmm !! Nothing here !! Okay

I’ve tried to check the network status to know if there’s anything thereby `netstat -tunlp`

<figure><img src="https://cdn-images-1.medium.com/max/800/1*f9YRgVuo6YOSyrALem04uw.png" alt=""><figcaption></figcaption></figure>

We have the localhost listening on 2 ports, so keep it now and try to find any interesting files again

<figure><img src="https://cdn-images-1.medium.com/max/800/1*oHcexH22-dBm1LnfRx38eg.png" alt=""><figcaption></figcaption></figure>

Here we have an interesting file in `/var/www/internal` which seems that returns back `/home/joanna/.ssh/id_rsa` from `joanna` directory if it accessed by a link

I’ll try to access it through the `localhost` with the open ports which it listens on them and sees what will happen

<figure><img src="https://cdn-images-1.medium.com/max/800/1*6K1jr1Syxp2KYc2JaciMrA.png" alt=""><figcaption></figcaption></figure>

<figure><img src="https://cdn-images-1.medium.com/max/800/1*9COXnQ2vxu69fayrdj1c9w.png" alt=""><figcaption></figcaption></figure>

Very good, we have the encrypted RSA for `joanna`

#### **Getting user.txt**

Let’s try to decrypt it by using `openssl` and note that we have a password → `ninja`

`openssl rsa -in encrypted_file -out decrypted_file` but unfortunately, it faces a problem that I can’t understand how to solve it, so I tried to crack it using `john the wripper`

`python ssh2john enc_key > rsa.hash` → to generate `john` hash

`john rsa.hash --wordlist=rockyou.txt`

<figure><img src="https://cdn-images-1.medium.com/max/800/1*nbll6Z_Auh36j6Y8_7whDw.png" alt=""><figcaption></figcaption></figure>

And we have the results now `bloodninjas` as the password

I’ve tried to login with `ninja` and `bloodninjas` as password, but it failed, so I’ll try to login using the key itself

<figure><img src="https://cdn-images-1.medium.com/max/800/1*OIKElxPmPdsaFQ-yQZ3FKA.png" alt=""><figcaption></figcaption></figure>

And finally we can read the `user.txt`

#### **Getting root.txt**

I’ve copied `linenum.sh` from my local machine to the `/tmp` directory

<figure><img src="https://cdn-images-1.medium.com/max/800/1*BBfH-KL5n9l7L7RCWpod_Q.png" alt=""><figcaption></figcaption></figure>

And after running it, I found that the `joanna` can execute commands as `root`

<figure><img src="https://cdn-images-1.medium.com/max/800/1*gNxq676SusUQsMmhAEFVVQ.png" alt=""><figcaption></figcaption></figure>

So the command is `nano` so I googled for `how to get shell from nano` and found this resource

<figure><img src="https://cdn-images-1.medium.com/max/800/1*436ZnsPyy2NaYpoAxB3HjA.png" alt=""><figcaption></figcaption></figure>

which tells you will type `nano` → ctrl-R + ctrl-X → `reset; sh 1>&0 2>&0` and you will be the root

<figure><img src="https://cdn-images-1.medium.com/max/800/1*p393PwHE_mhey2P2i67_Kw.png" alt=""><figcaption></figcaption></figure>

And it works :)

**Congrats ❤**
