On July 11, 2020, InfoSec Preparation Group on discord started a giveaway, but to enter it, one needed to solve a box, get the flag and then submit it to the bot to become eligible. This is my attempt at writing a report for the Box.
Discord Link for InfoSec Prep: https://discord.gg/BUjnWps
Setting up the Environment
Downloading the VM
Link: https://www.vulnhub.com/entry/infosec-prep-oscp,508/
- MD5: B25476F6CE9CB78D573C3B05F4D7F111
- SHA1: CA3FD5FEE9E9DBADE90332666EF54E359D9CBE8C
Importing the VM
On unzipping ‘oscp.zip’, we get oscp.ova. ‘.ova’ files can be directly imported into virtual box by double-clicking on the file.

I usually check up the settings before booting the VM, and we see that Invalid Settings were detected, we should change the graphics controller to remediate the situation.

Changing the Graphics controller to ‘VMSVGA’ worked for me
Network Settings: As usual ( Host-Only Adapter )
Everything looks good, let us boot the VM :D

Notice that we get the OS Version Information ( Ubuntu 20.04 ) and the IP (192.168.56.4). Hence our usual step of finding the IP Address isn’t needed and we can jump to Enumeration and Scanning.
Scanning & Enumeration
A simple all ports nmap scan using nmap -sV -A -p- $target gives us :

Version & Port Information
SSH
Version→ 8.2p1 Ubuntu 4ubuntu0.1 (Ubuntu Linux; protocol 2.0)
Port→ 22
Comments→N.A.
HTTP
Apache httpd Version→2.4.41
WordPress Version→5.4.2
Port→80
Comments →We see one disallowed entry, we should start from there :)
MYSQL
Version →Unknown
Port →33060
Comments →Usually MySQL services are run on 3306
Enumeration
HTTP Enumeration

Let us first see what is present at the secret location ‘/secret’, we saw it pop up in the scan and can verify by visiting the ‘/robots.txt’.

The double equals ( ‘==’ ) suggests that it might be base64 encoded, so we quickly copying the text and using echo <text> | base64 -d decode the text.

We see that the decoded text is an OpenSSH Private Key, we save it to openssh.key file.
We know that we can use this to ssh on the target machine using ssh -i openssh.key <user>@192.168.56.4 . So I randomly tried logging in using different user ids.

Maybe this was pure luck, but this is the proof:
I first tried with root, next with user, then I thought of using the box name i.e. oscp as the username, and bam! We see the permissions error, I quickly set the correct permissions for the private key, i.e. 600 and try to log in. And we’re in guys !

We need user password that we do not have to run sudo, seems like we are stuck here. Once we are in, we should try to explore more ..
For example, we did not know what SQL version was hosted on server
Privesc
Now that we know that we need to enumerate more, we can use ‘LinEnum.sh’, a script used to to enumerate the Linux machine on which we have a local shell, and are trying to get Privilege Escalation to.
Also, remember in the previous setting it was a guesswork about the username oscp. It seems that I had overlooked something that I should have noticed at first glance.

Okay, so once again we login on the machine, and try to enumerate.
LinEnum.sh Link : https://github.com/rebootuser/LinEnum/blob/master/LinEnum.sh
we view it in raw mode, i.e. using this URL https://raw.githubusercontent.com/rebootuser/LinEnum/master/LinEnum.sh or clicking on raw.
Copy this, and create a new script on the machine, ‘try.sh’ or any name should be fine. Change the permissions and run it. In the output there are lots of stuff, but the most interesting is:

There is a lot more info there, but in the interest of time and space, this particular entry was very juicy!

This bash binary is owned by root, and has setuid set, this means that we can run that command with an effective uid of root. I did not know about this. But what I did know was that having setuid bit set has some security issue. So I started googling, and this is what I found!

And we got root!
d73b04b0e696b0945283defa3eee4538
We now submit it to the TryHarder Bot!
