PG — Pwned1— Walkthrough (Offensive Security Proving Grounds Play Boxes)
This article aims to walk you through Pwned1 box, produced by Ajs Walker and hosted on Offensive Security’s Proving Grounds Labs. Anyone who has access to Vulnhub and Offensive Security’s Proving Grounds Play or Practice can try to pwn this Linux box, this is an easy and fun box. Hope you enjoy reading the walkthrough!
Since we are already provided with IP address of the box, we will scan it via Nmap.
We are going to scan the IP for all open ports by typing the following command on our terminal. -p- indicates that we want to check all open ports.
nmap -p- 192.168.x.x
After waiting for a while, we have got our results as shown below:
To gather further information on ports found by nmap, we will add some more arguments specifying open ports. -sV will scan to show service versions of applications on open ports, and -sC will run default scripts on services in order to check whether there is a vulnerability.
nmap -p 21,22,80 192.168.x.x -sV -sC
In a short while, we have got our results and more details regarding open ports. And we decide to start enumeration on port 80 as port 21 and 22 are not logical starting points because they do not provide us with a broad attack surface as an http server does.
First of all, we type IP address in our browser.
We find it is just a webserver that reveals a note from an Attacker. So, let us check the source code and inspect the page further.
There is nothing different from the page itself.
We will inspect the webpage.
We encounter a note embedded in the commented line of the body source code, but it does not reveal much. So, we will use gobuster to bruteforce directories to see if we have something useful. We will use -u argument to specify URL and -w argument to provide the wordlist we want to use for directory bruteforcing. And to make bruteforcing process fast, we will specify threads as 50 this time by -t argument.
gobuster dir -u http://192.168.x.x/ -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -t 50
We check the web directory and find that port 80 has two interesting directories. We look at /nothing directory first.
There is nothing.html and we check it as well.
As we find nothing, now we will check the other directory that is /hidden_txt.
There is a file named secret.dic and we click on it to open.
We come across a number of directory names, but just one of them is available that is /pwned.vuln.
We have a login form, but trying common credentials like admin:admin, root:root, etc. gives no results.
There is nothing in the source code as well, but when we look at the body of the source code through inspecting the page, we see that FTP credentials are noted in.
Now we will use these credentials to log into FTP server found during nmap port scaning.
We successfuly log into FTP server. We will enumerate FTP directories and sub-folders.
There is a directory on FTP server called share and it includes a note and SSH private key id_rsa.
We download files to read the note and use SSH private key.
We see that note.txt reveals a username Ariana, and we will try to connect to the box using this username and SSH private key after changing permissions of the file.
Changing permissions of id_rsa and connecting SSH server.
ssh -i id_rsa firstname.lastname@example.org
Now we have a low shell on the target box and get our first hash.
Now, we will try to escalate our privilege to have full authority on the box.
Privilege Escalation of this box was intermediate, there are some initial enumeration steps for privilege escalation after getting low shell, and the first one tried on this box, which was checking sudo permissions for the current user by typing sudo -l on the terminal, was the first step for privilege escalation.
We see that we can execute a script called messenger.sh as user Selena. Let’s see the code if we can manipulate the script.
The line towards the end of the code $msg 2> /dev/null indicates that we can manipulate the user input asked during script execution, so we will insert /bin/bash in order to get a shell as the user we execute the script. Lets’s start the script by following command:
sudo -u selena /home/messenger.sh
It asks for input to send messages to one of the listed users. So, we want to send /bin/bash command as a message to selena, and we are now on Selena’s teminal.
To have a stable shell, we will use python3 (since python2 is not installed on the system) to get a TTY shell, then read selena-personal.diary file.
python3 -c ‘import pty;pty.spawn(“/bin/bash”)’
We will check our id to see if we are in a group that has privileges on the box.
The user Selena is in the docker group, so we will check docker images available on the box, and try to execute commands to escalate our privilege to root level.
We see that there are three images listed, and start to execute the following command in order to get root shell.
docker run -v /:/mnt — rm -it alpine chroot /mnt sh
We try debian image first, but it is unavailable on the system and could not be found locally. So, we try alpine image, and it escalates our privilege to root and lets us to get a root shell on the system.
Now we have full authority on the box. Enjoy!
Basic Linux Privilege Escalation
Before starting, I would like to point out - I'm no expert. As far as I know, there isn't a "magic" answer, in this…
docker | GTFOBins
This requires the user to be privileged enough to run docker, i.e. being in the docker group or being root. Any other…
File Transfer Protocol - Wikipedia
The File Transfer Protocol ( FTP) is a standard communication protocol used for the transfer of computer files from a…
Nmap: the Network Mapper - Free Security Scanner
Nmap 7.90 has been released with Npcap 1.00 along with dozens of other performance improvements, bug fixes, and feature…
Proving Grounds Play and Practice | Offensive Security
Practice your pentesting skills in a standalone, private lab environment with the additions of PG Play and PG Practice…
Secure Shell Protocol - Wikipedia
The Secure Shell Protocol ( SSH) is a cryptographic network protocol for operating network services securely over an…