✅TryHackMe - Brainpan 1 (Hard)
Summary
On port 10000, we can download a Windows executable in a hidden directory. This is an OSCP-like Windows Buffer Overflow exploit development challenge. Note that the victim machine is running Linux, not Windows.
In the privilege escalation, sudo -l allows us to open man page as root. Here we can spawn a root shell using a privesc payload from GTFOBins.
IP
RHOST: 10.10.180.215
LHOST: 10.13.12.2
Nmap

Asset Discovery
Run Gobuster against port 10000:
Gobuster finds /bin:

Visit http://brainpan1.thm:10000/bin and download the executable:

User Shell (Windows buffer overflow)
Step 1: Fuzzing (Locally)
Write a script:
We learn that the offset is less than 1000 bytes:

Step 2: Finding the Offset (Locally)
Generate a pattern of 1000 bytes:
Update the script:
Run this script and brainpan crashes. Note that the EIP is overwritten:

Compute the offset:

Step 3: Overwritting the EIP (Locally)
EIP is overwritten by 0x42424242, as expected:

Step 4: Finding Bad Characters (Locally)
Generate a list of badchars:
Update the script:
Find badchars:
There is no badchar:

Step 5: Finding the Right Module (Locally)
Find a JMP ESP gadget:
Mona finds one possible gadget:

Step 6: Generating Msfvenom Payload and Gaining Root (Remotely)
Generate a Linux reverse shell payload using Msfvenom:
Update the script:
Now we get an user shell as Puck:

Privlege Escalation (sudo man)
sudo -l:

Try executing this command:

Run sudo /home/anansi/bin/anansi_util manual ls. This is essential the same as man ls, but we are openning this man page as root:

Grab a privesc payload from GTFOBins:

Spawn a root shell with !/bin/bash:

Last updated