Post

Write-up / theFirstAvenger theHackersLabs.

Write-up / theFirstAvenger theHackersLabs.

Download vulnerable target machine: theFirstAvenger - thehackerslabs

Discovery.

Port Scan.

The first step is allways to run nmap and see which ports are opened in the target.

1
nmap -p- -Pn -sS --min-rate 5000 --open <IP> -oN scan.txt

img-description Ports scan.

1
nmap -p<PORTS> -sVC -Pn <IP> -oN versionScan.txt

img-descriptionOnce we know wich ports are opened we make an nmap version scan.

Ports 80 and 22 are opened. Let’s explore port 80.

Web Server Enumeration.

img-description

Fuzzing.

I found interesting info in the fuzzing phase: img-description

img-description

The current url /wp1 indicates that we are facing a Wordpress CMS, to confirm, we can run a whatweb scan to verify it.

img-description

Let’s run another directory listing with ffuf to find more interesting paths:

img-description

wpscan.

Wpscan is a wordpress enumeration tool, we can use it to find vulnerabilities in the server.

img-description

img-description

img-description

In the previous wpscan we found the user admin.

Exploitation

xmlrpc brute force attack.

We can perform a brute force attack using wpscan as follows: wpscan --url http://thefirstavenger.thl/wp1/ -U admin -P /usr/share/wordlists/rockyou.txt --api-token="<TOKEN>"

img-description

Now we can access to the login panel. http://thefirstavenger.thl/wp1/wp-login.php

Sublime's custom image

Reverse Shell.

The following steps outline a method to obtain a reverse shell after gaining administrator access.

img-description

img-description

img-description Installing file manager

img-description Activating file manager

img-description

img-description

img-description

img-description

img-description We have to create a file containing our code.

The last step is to find our file and execute it.

img-description

Post Exploitation.

Lateral Movement.

mysql leaked credentials.

I found the file wp-config.php, which is a typicall wordpress file to store credentials.

img-description

img-description

You can find detailed information and a step-by-step explanation of how to use mysql command line tool at Github - mysql Basics.

Let’s try to use the credentials:

img-description

img-description

img-description

We found the following passwords:

img-description

Reading the /etc/passwd file I saw the user steve, let’s try to decrypt the password and use it.

img-description

img-description

img-description

img-description

Root Privilege Escalation.

After trying different ways to elevate my privileges, I decided to run ‘linpeas.sh’. While running the script, I noticed some new open ports and proceeded to check what they were hosting.

img-description

We can obtain the same information by executing ss -tuln if we prefer to perform manual enumeration only.

img-description

I checked the pors using curl and I found:

img-description

Port Forwarding.

Chisel.

I will use Chisel to execute a Port Forwarding.

img-description

img-description

img-description

img-description We can now acces to the port 7092 of the target from our own system.

We need to add socks5 to foxyProxy if we want to see it in the browser. img-description

Manual Enumeration.

The web is asking for an IP to execute ping. img-description

Using tcpdump, we can see that the command works properly. img-description

After trying to exploit an OS Injection attack, I noticed that my command was being reflected in the output as we can see in the following picture.

img-description

Server Side Template Injection(SSTI),

You can find a step-by-step explanation of how to perform the next attack at Github - Server Side Template Injection (SSTI).

img-description

img-description

Commands are being executed, it’s time to find a payload and obtain a Reverse Shell.

img-description

img-description

From SSTI to Shell.

img-description

img-description

img-description

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