May 9, 2020

Hack the Box - Obscurity

Posted on May 9, 2020  •  5 minutes  • 882 words

Welcome back everyone! Today we’ll be doing the machine Obscurity on Hack the Box. It’s listed as a medium Linux machine, let’s jump in!

As usual we start with nmap: nmap -sC -sV -T4 -p- -oA initial_scan

Here are our results:

Nmap scan report for
Host is up (0.055s latency).
Not shown: 65531 filtered ports
22/tcp   open   ssh        OpenSSH 7.6p1 Ubuntu 4ubuntu0.3 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey: 
|   2048 33:d3:9a:0d:97:2c:54:20:e1:b0:17:34:f4:ca:70:1b (RSA)
|   256 f6:8b:d5:73:97:be:52:cb:12:ea:8b:02:7c:34:a3:d7 (ECDSA)
|_  256 e8:df:55:78:76:85:4b:7b:dc:70:6a:fc:40:cc:ac:9b (ED25519)
80/tcp   closed http
8080/tcp open   http-proxy BadHTTPServer
| fingerprint-strings: 
|   GetRequest, HTTPOptions: 
|     HTTP/1.1 200 OK
|     Date: Mon, 23 Dec 2019 14:38:24
|     Server: BadHTTPServer
|     Last-Modified: Mon, 23 Dec 2019 14:38:24
|     Content-Length: 4171
|     Content-Type: text/html
|     Connection: Closed
|     <!DOCTYPE html>
|     <html lang="en">
|     <head>
|     <meta charset="utf-8">
|     <title>0bscura</title>
|     <meta http-equiv="X-UA-Compatible" content="IE=Edge">
|     <meta name="viewport" content="width=device-width, initial-scale=1">
|     <meta name="keywords" content="">
|     <meta name="description" content="">
|     <!-- 
|     Easy Profile Template
|     <!-- stylesheet css -->
|     <link rel="stylesheet" href="css/bootstrap.min.css">
|     <link rel="stylesheet" href="css/font-awesome.min.css">
|     <link rel="stylesheet" href="css/templatemo-blue.css">
|     </head>
|     <body data-spy="scroll" data-target=".navbar-collapse">
|     <!-- preloader section -->
|     <!--
|     <div class="preloader">
|_    <div class="sk-spinner sk-spinner-wordpress">
|_http-server-header: BadHTTPServer
|_http-title: 0bscura
9000/tcp closed cslistener
1 service unrecognized despite returning data. If you know the service/version, please submit the following fingerprint at :
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

Our results seem to show a web server with a production and dev enviornment. Looks like we’re running Wordpress on the 9000 port as well. Let’s visit the site and see what’s here. We know port 80 is closed but 8080 is running and we are greeted a basic page. From browsing the page we get a hostname, obscure.htb, so we’ll add that to our host file. We also know there are some more settings listed in a secret development directory somewhere. So we’ll load up gobuster and see what we get back.

Command: gobuster dir -u http://obscure.htb:8080 -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -t 75

When we run this we get a flood of errors back. This is to do gobuster using Head requests vs get. Well, we know that we are looking for We can just fuzz the directory(ies) we are looking for using ffuf or wfuzz.

Command: wfuzz -c -w /usr/share/wordlists/dirb/small.txt --hc 404 'http://obscure.htb:8080/FUZZ/'

I ran a few larger wordlists against the target but all of them failing after ~2,200 requests. So we pick an even smaller listing.

We find our target is stored under develop. Lets get the file.

Command: wget 'http://obscure.htb:8080/develop/'

Once we have it downloaded, we look at what’s inside.

We found our foothold. If we are able to pass our command and escape the first part, we should be able to execute some python code we inject. We need to make sure we format our request correctly. We want to close the first part of the ommand with '; then execute our code and close the command. I used a simple bash reverse shell:


We apply this to our URL and wait for our connector…

We now have a shell as www-data. Now that we have a shell we can start enumerating internally. We see a few files in Robert’s home directory. and passwordreminder.txt. We download the python script and look at it locally. It looks to contain an <code>Vigenere cipher</code> method. If you are familiar with this cipher you know that we can obtain the password for the file if you know the original input.

It looks like our password was alexandrovich. We can now take this password and decrypt our passwordreminder.txt. Repeating the process but supplying a -k of alexanderovich gives us a password of SecThruObsFTW. Which assumably is Robert’s password. We try to SSH as him and it works.

Now that we’ve gotten our user.txt. Lets start enumerating as Robert. We see that Robert is able to launch as sudo.

When we look through we see there are a few avenue’s of attack. The first being this command injection.

The application calls the command you input with the -u flag. So if we simply apply another -u to our input, we can do things as root!

The other method is that we see that copies the system shadow file out to a temporary directory every .1 seconds. If we can monitor this file location, we can snag the file before it’s deleted. So we’ll make a file on /tmp called snag. Then we’ll run the watch command every .1 seconds. We then run the script and snag the file before it’s created.

Command: watch -n .1 cp /tmp/SSH/* /tmp/snag

We can then get the contents of the file we copied. Inside it we have the root hash.

We can just run it through John and see if we get a password.

Sure enough, we get one: mercedes. We can now just su to root.

There we have it. Another box down!

Hopefully something was learned. If you found this write-up helpful, consider sending some respect my way: Lovecore&rsquo;s HTB Profile .

Follow me

I hack things and tweet about things...