# Hack The Box - Ethereal

## Quick Summary

Hey guys today Ethereal retired and here is my write-up about it. And as the difficulty says , It’s insane ! The most annoying part about this box is that it was very hard to enumerate because we only get a blind RCE and the firewall rules made it even harder because it only allowed TCP connection for 2 ports. It was fun and annoying at the same time but I liked it. It’s a Windows box and its ip is 10.10.10.106 I added it to /etc/hosts as ethereal.htb , Let’s jump right in !

## Nmap

As always we will start with nmap to scan for open ports and services :
nmap -sV -sT -sC ethereal.htb

And we get FTP on port 21 , HTTP on port 80 and 8080. It also tells us that FTP anonymous authentication is allowed. As always we will enumerate HTTP first.

## HTTP Initial Enumeration

On port 80 we see this website :

The only interseting thing is in the menu we see an Admin-area :

Clicking on that we get redirected to this page which has some other options like Notes , Messages , Desktop and Ping :

By going to notes we only get this :

So now we know that there’s a “test connection” page somewhere , we also get a potential username alan. By clicking on messages we get nothing , but desktop :

And it’s very clear that this is fake , also the user.txt is a troll :

By clicking on ping we get redirected to port 8080 which asks us for authentication and it uses http basic auth :

So now we know what’s on port 8080 , the “Test Connection” page. But we need credentials to access it.
One more thing to check is sub directory enumeration with gobsuter or any alternative :

gobuster only found /corp with the wordlist /usr/share/wordlists/dirb/common.txt and that’s the subdirectory that had the admin stuff. We can’t get any more info and there’s nothing to exploit so next thing to look at is FTP

## FTP Enumeration

On FTP there are some files but the most interesting ones are FDISK.zip and DISK.zip so we will check them first :

We will unzip them :

Then we will check what kind of files do we have with file :

Most likely they are mountable disks so we will create a directory to mount them and call it mnt then we will make a directory for disk1 , disk2 and fdisk and finally we will mount them mount -o loop [Disk] [Directory] :

In disk1 and disk2 there are some files that are not very interesting :

But on fdisk there’s a directory called pbox :

It contains an executable called pbox.exe and a dat file called pbox.dat :

## Getting Credentials

We will switch to a windows box to run that executable , you can alternatively use wine or a program called dosbox. wine didn’t work for me and dosbox kept crashing every 15 seconds.

When we try to open it it asks for a password :

At this point the only option I had was to guess the password because I didn’t know how to bruteforce the password in this case , however the password was “password” :D , so no bruteforce is needed it’s only a quick guess , after we get in , we see this password database :

databases :

msdn :

learning :

ftp drop :

backup :

truecrypt :

management server :

svn :

Back to our kali , now we can create a list with all the information we got :

I put the passwords in a separate list to bruteforce the http auth with it :

We will use wfuzz and we will try the username alan first :
wfuzz -u http://ethereal.htb:8080 --basic alan:FUZZ -w passwords.txt

Password : !C414m17y57r1k3s4g41n!

## Blind RCE

Now after we login we get the “Test Connection” page and we have an input for the ip address to ping.

Now we can try to bypass that and inject system commands using & or | , but we don’t get any output. I also tried to host nc.exe on a python http server and used certutil to download it but the python server didn’t get any requests. Finally when I ran responder :

I finally got something :

We can try to execute a system command and get the output by doing this :

This is executing whoami then taking the output and doing nslookup with the output to our ip :

We get etherealalan and that’s unusual as we expected ethereal\alan.
We will start enumerating the filesystem this way , read this if you don’t understand some of the for commands that we will use.

So the current directory is c:\windows\system32\inetsrv
We also need to know the users on the box :

We have 5 users on the box alan , jorge , Public , rupal and Administrator. We are executing commands as alan
Next thing to look at is the installed programs :

We notice that OpenSSL is installed which is unusual , we also need to know why can’t we make the box connect back to us so we will check the firewall rules. In our case the easiest way to do this is to execute the command and only look for the string Rule Name: then redirect that output to a file , and read that file like we are doing. But first we need to find a place that we can write to. After some attempts I could write to c:\users\public\desktop\shortcuts , so we will do this :

Then we will list the contents of c:\users\public\desktop\shortcuts :

And we see that we have successfully written into that directory , next step is to read the file :

It’s only allowing TCP conections to port 73 and 136 , we saw earlier that openssl was installed on the box , we can create a SSL/TLS server on these ports and use openssl to make the box connect back to us.

## Generating certs and setting up the server

First step is to generate certificates because we need them to set up the server :

Then we will split our terminal and run 2 servers , one on port 73 and the other on port 136 :

We are setting up 2 servers because we are going to use openssl on the box to connect on port 73 and take our input , then we will pipe that input to cmd.exe then we will pipe the output to our server on port 136.
Now we need to locate openssl.exe , if we listed the contents of OpenSSL-v1.1.0 in Program Files (x86) (can also be written Progra~2. check this) we will get this output :

We see a directory called bin that’s where openssl.exe is located so the path is c:\progra~2\OpenSSL-v1.1.0\bin\openssl.exe
Now everything is ready , in the ping page we will write this :

Then we will check our server :

Now we will write the commands on the first server (port 73) , then we will refresh the ping page , to send the post request again (this will pipe our input from port 73 to cmd.exe then to the server on port 136) then we will get our output on the second server.

alan’s desktop doesn’t have the flag so we need to escalate to another user , there’s a note on alan’s desktop in a file called note-draft.txt:

## Creating a malicious lnk and getting User

From the note we knew that there’s a lnk on Public’s desktop and other users on the box are using it.

So if we replaced it with a payload we can get a shell as another user. There’s a tool on github called LNKup I used it to create the payload :

To uplaod it we will close any one of the servers and run it again but this time we will redirect the lnk file to it :

Then on the ping page we will type this :

We will close the server , run the 2 servers and get our shell as alan like we did before , then we will delete the original lnk and copy ours with the name of the old lnk :

Then we will close the 2 servers , run them again and wait for someone to execute the lnk file , after a minute we will get a shell as jorge :

With this we don’t need to refresh any pages because the connection is not handled by the ping page anymore so the command will be piped immediately from the first server to the second server.

Finally we owned user !

## More Filesystem Enumeration

If we checked the other drives :
fsutil fsinfo drives

We will find that C is not the only drive and there’s also D.
Unfortunately if someone started to enumerate without doing this important step in windows enumeration , they won’t get anything.
Contents of D:

In DEV there’s a directory called MSIs and it has a note :

So we have to create a malicious msi and place it there to get a shell as rupal. We also need to get the certs to sign the msi , the certs are found in D:\Certs , MyCA.cer and MyCA.pvk , to transfer them to our box we will use openssl to base64 encode the certs then we can copy and decode on our box.

Now we will go to a windows box again to create the msi

## Creating Malicious msi and getting root

In order to create the msi we will use wixtools , you can use other msi builders but they didn’t work for me.
We will create an msi that executes our lnk file :

We will use candle.exe from wixtools to create a wixobject from msi.xml

Then we will use light.exe to create the msi file from the wixobject

After that we need tools from microsoft sdk to sign our msi , first we will use makecert.exe to create new certs from the original certs we got from the box

Then we will use pvk2pfx.exe to create a pfx for both the cer and the pvk files :

And finally we will use signtool.exe to sign the msi with the pfx :

Now back to our kali we will upload the msi the same way we uploaded the lnk file before , and we also need to make sure that the lnk file is in c:\users\public\desktop\shortcuts\ because the msi is just executing that lnk. We will put the msi into D:\DEV\MSIs

Then we will close the servers , run them again and wait for around 3-5 minutes until rupal opens the msi

And we got root !

That’s it , Feedback is appreciated !