BroScience

Enumeration

Rustscan

mkdir rust; sudo rustscan -t 1500 -b 1500 --ulimit 65000 -a 10.129.126.84 -- -sV -sC -oA ./rust/{{ip}}

Ports

Open 10.129.126.84:22
Open 10.129.126.84:80
Open 10.129.126.84:443

Services

PORT    STATE SERVICE REASON         VERSION
22/tcp  open  ssh     syn-ack ttl 63 OpenSSH 8.4p1 Debian 5+deb11u1 (protocol 2.0)
80/tcp  open  http    syn-ack ttl 63 Apache httpd 2.4.54
|_http-title: Did not follow redirect to https://broscience.htb/
| http-methods: 
|_  Supported Methods: GET HEAD POST OPTIONS
|_http-server-header: Apache/2.4.54 (Debian)
443/tcp open  ssl     syn-ack ttl 63
|_ip-https-discover: ERROR: Script execution failed (use -d to debug)
|_http-title: 400 Bad Request
| http-methods: 
|_  Supported Methods: GET HEAD POST
|_http-server-header: Apache/2.4.54 (Debian)
| tls-alpn: 
|_  http/1.1
|_ssl-date: TLS randomness does not represent time

Sitename

Using curl we are able to determine the servername and can add it to our /etc/hosts file which can help us for example in subdomain enumeration

Dirsearch

Website

The website itself can be described as a collection of training excercises that can be added and commented by registered users.

Registration

When we try to register a user it says that the activation code will be send to us by email.

IDOR

While browsing the page we were able to identify an IDOR that exposes

  • E-Mail Address

  • IS Activated

  • IS Admin

LFI

While checking https://broscience.htb/includes/ we discover a php file named img.php. Opening that page will tell us

Basic LFI will fail and tell us Error: Attack detected. We have to double URL Encode it so that it will work

/etc/passwd

/var/www/html/includes/db_connect.php

/var/www/html/includes/utils.php

Seems to be the script that generates activation codes and is used to update a cookie called user-prefs. Since user-prefs uses serialization this could be an attack vector during our next steps.

/var/www/html/activate.php

Used to activate a freshly registered user account

Exploitation

User activation

We'll use the code snippet discovered in includes/utils.php to generate an activation code for our previously created user. The date has been taken from the burp request that was captured while registering on the page.

Now it's time to activate the account

Deserialization

After we logged in we can see that a new Cookie called users-prefs has been added. This cookie changes as soon as we switch the theme using swap_theme.php

Following code has been taken from includes/utils.php

Reference Code

get_theme()

class Avatar

Exploitation

We'll no change the class Avatar code up a little to generate serialized data that we will inject using the user-prefs cookie.

serialized.php

rev.php

Shell

Privilege Escalation - Bill

Postgres

We start with enumeration of the database of which we already discovered the credentials

Cracking Hashes

Every password used NaCl as password salt so we have to edit our wordlist before we can crack the hashes

Cracking md5 hashes

Using the password ilCENSORDgym we are able to become user bill

Privilege Escalation

Local Enumeration

First we upload pspy64 for further enumeration

Using pspy64 it's clear that the root user runs a script to check if a certificate needs to be renewed

Abusing renew_cert.sh

renew_cert.sh

Let's create a certificate that will expire soon so that root will create a new one. We will leave everything empty except the commonName, that's the place where we store our payload.

After waiting for a while /bin/bash will be modified and we can use the suid permissions to become root!

ROOT

Last updated