Mango HTB

IP

10.10.10.162

initial nmap scan

sudo nmap -p- --min-rate 10000 10.10.10.162 | cut -d"/" -f1 | tr '\n' ','

we have the following ports open on the machine

22,80,443

Lets run a more in-depth scan of the target

sudo nmap -sCV -p22,80,443 -oA nmap_results 10.10.10.162

results

PORT    STATE SERVICE  VERSION
22/tcp  open  ssh      OpenSSH 7.6p1 Ubuntu 4ubuntu0.3 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey: 
|   2048 a8:8f:d9:6f:a6:e4:ee:56:e3:ef:54:54:6d:56:0c:f5 (RSA)
|   256 6a:1c:ba:89:1e:b0:57:2f:fe:63:e1:61:72:89:b4:cf (ECDSA)
|_  256 90:70:fb:6f:38:ae:dc:3b:0b:31:68:64:b0:4e:7d:c9 (ED25519)
80/tcp  open  http     Apache httpd 2.4.29
|_http-server-header: Apache/2.4.29 (Ubuntu)
|_http-title: 403 Forbidden
443/tcp open  ssl/http Apache httpd 2.4.29 ((Ubuntu))
| tls-alpn: 
|_  http/1.1
|_http-title: Mango | Search Base
|_http-server-header: Apache/2.4.29 (Ubuntu)
|_ssl-date: TLS randomness does not represent time
| ssl-cert: Subject: commonName=staging-order.mango.htb/organizationName=Mango Prv Ltd./stateOrProvinceName=None/countryName=IN
| Not valid before: 2019-09-27T14:21:19
|_Not valid after:  2020-09-26T14:21:19
Service Info: Host: 10.10.10.162; OS: Linux; CPE: cpe:/o:linux:linux_kernel

Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 14.94 seconds

we can see

  • SSH is running on the target

  • Both HTTP and HTTPS is running on the target

  • Most likely a ubuntu machine\

  • Looks like we have the domain name and a hostname name

    • mango.htb and staging-order.mango.htb we will add these to our hosts file

Lets check out Port 443 first

Looks like some kind of search engine

Lets get feroxbuster running and see if we can find anything

results

Looking at the ssl certificate we can see the following

  • we can see a email admin@mango.htb

We could test this search base for any injection attacks using sqlmap

  1. first lets catch a request with burp, save the request to a file

  2. run sqlmap on the request we saved

HTTP

when we check out staging-order.mango.htb we can see a login screen

Lets bust out feroxbuster and see if we can find anything

  • Nothing interesting

Lets catch the login request with burp

Lets save this as a file and run sqlmap, we want to find if this is vulnerable to any injection type of attacks

  • Nothing interesting

I'm going to take a guesse and say this web application utilises mongo NoSQL given the name of the box and well the pictures of the mangos

Lets run with this so first we need to check if this is indeed vulnerable to an injection attack

here is a blog that explains this better then i could

alright we have a request of the login in burp we send that over to repeater

Now what we can do to bypass authentication is the following

notice the [$ne] , this is a common operator within NoSQL meaning 'not equal to' now we are essentially saying

  • username is not equal to 'shrek123'

  • password is not equal to 'shrek123'

because both of these statements are true, we are authenticated to the page

  • not much here

since we know we have a injection point within the login prompt, maybe we can dump some passwords

we can utilise the $regex filter

for example we can see if the first letter of the user admin's password is x

Now lets create a python script to brute force the usernames and passwords

Now Lets run this script

we have 2 users and associated password

Lets see if we can ssh into the machine'

we have a SSH session as mango

if we look within the home directory we can see both admin and mango

Lets see if we can switch our user to admin, using the admin password we found

we are admin, but we dont have sudo privileges on the machine

When we search for SUID files, we can see the following

we do find something interesting

  • /usr/lib/jvm/java-11-openjdk-amd64/bin/jjs

what we can do is write to a file (/root/.ssh/authroized_keys) and drop a SSH key into the file and ssh in as root, to do this

  1. Let's generate some keys

  1. Lets create a exploit script using the knowledge from gtfobins

  • copy the location of the authorized_keys file /root/.ssh/authorized_keys

  • copy our public key so it can be written to authorized_keys

copy and past the exploit in our SSH session

  1. Lets give our private key the necessary permissions and SSH into the machine as root

  • we are now root

Last updated