This is my write-up for TryHackMe's Binex Room
Enumeration
Using nmap, we see that SSH and SMB are running on the target.
The hint showed that the longest username in RID range 1000-1003 has an insecure password. We then run enum4linux to enumerate the users.
Foothold
Connecting via SSH using the credentials we found, we can run find to search for files with SUID bit set.
From the results, we see that the /usr/bin/find has its SUID bit set.
From gtfobins, we can use find to escalate privilege.
I find it easier copying bof onto my attack machine rather than running gdb on the target (Just a matter of preference and also because I have gdb-peda installed on my system). Let's see what happens when we send too much data to it.
It turns out it is susceptible to buffer overflow exploitation!
Buffer Overflow
Through trial and error, we find that the program crashes with an input of 700 characters.
We can use RBP to compute for the offset to the RIP for this case here.
The above means that the offset to RIP overwrite is 608 + 8 bytes. We can test this by:
We find bof wants to return to the RSP ("CCCCCCCCCC").
So now we know that RIP can be overwritten! We also know that prior to the return, the RSP is 0x7fffffffe1b8. We can have a very large NOP sled at the start of the buffer. Let's try with the following script:
Using the provided shellcode and the tweaking the original script a little, we get:
No comments:
Post a Comment