wh0_d0ne_17 CTF and Cyber Blog

Documenting the journey

View on GitHub

UDCTF 2023

I created 9 challenges for the CTF. Here are the problems and intended solutions for 2. I may get to the remaining 7 later. Enjoy :)

1 of 2: SIMP

This challenge takes a newbie through their first directory brute force, ssh private key theft, and privesc through exploiting a root cronjob (or Pwnkit), and a reverse shell.

Alt text

Recon

(Alt text

Notice two TCP ports, 22 and 8000. 8000 is an alternate http service so lets check it out.

Alt text Its a webpage… but a placeholder webpage in development. Lets run dirbuster to se eif there’s anything interesting in the serving directory.

Alt text Big uh-oh on the devs part, see the .ssh directory is accessible (maybe)

Initial Exploitaiton

Lets use that stolen private ssh key to log in to the web server.

Alt text On the web page, the email dave@corpo.com was present. This may be the account for which the stolen key belongs to.

Alt text Bingo. There’s our initial access.

SIMP II (continuation of SIMP I)

image

Privilege Escalation

Now we need to find a way to root.

Alt text On the target machine in dave’s home directory, we see a few files. One of which is send_logs.py

Notice the file computes the md5 file hash of /etc/shadow

ROOT is required to do so. THAT is interesting. AND…

Alt text

We’re able to edit the send_logs.py file. So I want to add a line to the end to create a file called 'cronjob?' with whoami echoed to the contents.

Alt text

Add a reverse shell payload to the send_logs.py file:

Alt text

And we wait…

Alt text

And there it is

Alt text

2 of 2: SQL 4 Dummies

An easy SQL injection. The challenge: break into rickjames account.

Alt text

The authentication page:

Alt text

Enter some creds to see what happens.

Alt text

The username is read back to us.

Alt text

Try to end the sql variable with ‘ and negate the remaining query with a comment char –

Alt text

The input was filtered

Alt text

Try the same combo of chars inside the same combo of chars

Alt text

bingo!

Alt text