Post

Write-up / Inclusion Dockerlabs.

Write-up exploiting Path Traversal vulnerabilty and performing PE in a Linux system.

Write-up / Inclusion Dockerlabs.

Download vulnerable target machine: Inclusion - Dockerlabs.es

Discovery

Ports scan

We see 2 open ports; 22 ssh and 80 http. img-description

img-description

Let’s explore the web server and see what’s in there. img-description

Fuzzing.

I just saw a typicall index page so i proceed to execute a directory fuzzing to see if there is something else in here. img-description

We have the shop directory. Let’s check it. img-description

Exploitation.

Path Traversal.

You can see how to execute the following attack in detail at Local File Inclusion Attack.

The server is showing the next error message.

img-description

This error message is asking us for an “archivo” (file). Let’s try to use this parameter name in the url and try to show a file.

img-description

We can read /etc/passwd, this means that we have found a Path Traversal vulnerability.

I tried different ways to execute commands: Log Poisoning, PHP wrappers and PHP filter Chain but nothing worked. Then i remembered that the ssh service was runing so I executed a brute force attack against it with the usernames extracted from /etc/passwd.

SSH Brute Force Attack.

I used hydra to perform this attack and found the next credentials.

1
hydra -l <username> -P <passwordList> -t <threads> <RHost> <service>

img-description

After finding the credentials it’s time to access the system. img-description

Post Exploitation.

Privilege Escalation.

I made manual and automatic enumeration with the use of linpeas.sh but I didn’t see any possible way to elevate my privileges.

Passwords Brute Force Attack.

You can check how to perform the next attack in Privilege Escalation - Su Brute Force attack.

My last idea was to brute force other system users found in /etc/passwd. To do so I used scp to send rockyou.txt via ssh to this system and execute the attack using this passwords dictionary. img-description Runing the brute force script.

img-description

img-description

We have found the password for the user seller. Let’s log in!

img-description

SUID Privilege Escalation.

After gaining access to the new user, I performed a user enumeration back again and found that seller can use /usr/bin/php as root without specifying password.

img-description

If we go to gtfobins#php we can see how to procceed.

img-description

img-description

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