Welcome to the writeup of Kenobi room from TryHackMe - CTF.
Welcome to the writeup of Kenobi room from TryHackMe. | |||||||||||||||||||||||||||||||||
It's another room from a famous franchise (Star Wars), but it's lesss themed than the Biohazard room - here is my Biohazard Walkthrough - so this will be a direct wireteup. | |||||||||||||||||||||||||||||||||
Here we go... | |||||||||||||||||||||||||||||||||
"Description: This room will cover accessing a Samba share, manipulating a vulnerable version of proftpd to gain initial access and escalate your privileges to root via an SUID binary." | |||||||||||||||||||||||||||||||||
IP: 10.10.128.132 | |||||||||||||||||||||||||||||||||
Enumeration | |||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||
There is some ports that we could identify with NMAP, but we will not stop here with the NMAP... let's use some scripts | |||||||||||||||||||||||||||||||||
Nmap - SMB | |||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||
With "smb-enum" scritps, we could found shares that we can try to access and explore using smbclient. | |||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||
Exploring this "configuration" we got some interesting informations about a SSH key and the FTP server through the log.txt file. | |||||||||||||||||||||||||||||||||
Nmap - RPC | |||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||
With "nfs" scripts, we could enumerate a network file system and now we can try to mount it. | |||||||||||||||||||||||||||||||||
Exploitation | |||||||||||||||||||||||||||||||||
Through the ProFTPd version running on the server we could explore a module using the "SITE CPFR" and "SITE CPTO" commands, which can be used to copy files/directories from one place to another on the server. Using the information existing in log.txt was possible to determine the location of the SSH key and copy it to the mount share. | |||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||
After explored and copied the SSH key to the file where we have access through the mount, we can mount the share and have a direct access to the key. | |||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||
Now we can log in the server using the SSH key. | |||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||
With the access in the machine as "Kenobi" user, was possible to found the "user flag". | |||||||||||||||||||||||||||||||||
Privilege Escalation | |||||||||||||||||||||||||||||||||
Checking for misconfigurations to privilege escalation we found the binary /user/bin/menu as SUID, what allows us to use it as root. | |||||||||||||||||||||||||||||||||
find / -perm -u=s -type f 2>/dev/null | |||||||||||||||||||||||||||||||||
But we need to know how the binary works to exlore it. So, let's run it. | |||||||||||||||||||||||||||||||||
He appear to call some commands as "curl" and "ifconfig" in the respective options "1" and "3" and running running without a full path (/usr/bin/curl). So we can configure the PATH variable stating a path that we have control to create an "archive" with the same command name called for the script /usr/bin/menu, but with another function/code :D | |||||||||||||||||||||||||||||||||
Example: | |||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||
How this binary run as root (SUID), the command "/bin/sh or /bin/bash" (in our file and defined path) will be run as root too... With that, choosing the option referring to the generated file we become root \o/ | |||||||||||||||||||||||||||||||||
Now we have full control of this machine and is possible to read the root flag at /root/root.txt. | |||||||||||||||||||||||||||||||||
Thanks for reading and feel free to pingback a coffee ;D | |||||||||||||||||||||||||||||||||
naP0 | |||||||||||||||||||||||||||||||||
Give a Pingback |