Space University of Interior Design

SUID and Sudo misconfigurations

Description

Storytelling is the root of interior design.

nc 20.198.209.142 55022

The flag is in the flag format: STC{...}

Author: zeyu2001

Solution

We start off as a guest user, and need to escalate our privileges to get the flag.

$ id
uid=1001(guest) gid=1001(guest) groups=1001(guest)

Let's find all files with SUID permissions.

$ find / -perm /4000 
/bin/umount
/bin/ping
/bin/mount
/bin/su
/usr/bin/newgrp
/usr/bin/chfn
/usr/bin/chsh
/usr/bin/gpasswd
/usr/bin/passwd
/usr/bin/python3.7
/usr/bin/sudo

We find that Python has SUID permissions. Refer to https://gtfobins.github.io/gtfobins/python/.

This allows us to gain the privileges of the file owner.

Use the following command, and observe that our EUID has changed to that of jared.

Without having the true UID set to that of jared, we cannot sudo. But while we were previously unable to view jared's files, we can now view them.

There is an interesting file in jared's directory.

We found jared's credentials. Now, we can su to gain full permissions. Observe that the true UID is now that of jared.

If we check our sudo privileges, we find that we can execute query_db.py with elevated privileges.

This Python file queries the chinook.db database, and allows a --row argument.

If we refer to https://gtfobins.github.io/gtfobins/sqlite3/, we can find some payloads to help us. Here are two working payloads to get the flag.

Payload 1

sqlite3 has the .shell command, which allows you to run system commands.

We can use this to run cat /root/flag.txt.

Payload 2

We can alternatively use .import to import data from a file into a table.

Both are equally valid! The flag is STC{sud0_4nd_su1d_ea4b1d43ddf99e0c8f3338c8e33d5808}.

Last updated

Was this helpful?