Kenobi

Date: 16, May, 2021

Author: Dhilip Sanjay S


Click Herearrow-up-right to go to the TryHackMe room.

Nmap Enumeration

Scan the machine with nmap, how many ports are open?

  • Answer: 7

  • Steps to Reproduce:

$ nmap -sC -sV 10.10.108.221 -oN nmap.out
Starting Nmap 7.91 ( https://nmap.org ) at 2021-05-16 22:10 IST

Nmap scan report for 10.10.108.221
Host is up (0.21s latency).
Not shown: 993 closed ports
PORT     STATE SERVICE     VERSION
21/tcp   open  ftp         ProFTPD 1.3.5
22/tcp   open  ssh         OpenSSH 7.2p2 Ubuntu 4ubuntu2.7 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey: 
|   2048 b3:ad:83:41:49:e9:5d:16:8d:3b:0f:05:7b:e2:c0:ae (RSA)
|   256 f8:27:7d:64:29:97:e6:f8:65:54:65:22:f7:c8:1d:8a (ECDSA)
|_  256 5a:06:ed:eb:b6:56:7e:4c:01:dd:ea:bc:ba:fa:33:79 (ED25519)
80/tcp   open  http        Apache httpd 2.4.18 ((Ubuntu))
| http-robots.txt: 1 disallowed entry 
|_/admin.html
|_http-server-header: Apache/2.4.18 (Ubuntu)
|_http-title: Site doesnt have a title (text/html).
111/tcp  open  rpcbind     2-4 (RPC #100000)
| rpcinfo: 
|   program version    port/proto  service
|   100000  2,3,4        111/tcp   rpcbind
|   100000  2,3,4        111/udp   rpcbind
|   100000  3,4          111/tcp6  rpcbind
|   100000  3,4          111/udp6  rpcbind
|   100003  2,3,4       2049/tcp   nfs
|   100003  2,3,4       2049/tcp6  nfs
|   100003  2,3,4       2049/udp   nfs
|   100003  2,3,4       2049/udp6  nfs
|   100005  1,2,3      47423/tcp   mountd
|   100005  1,2,3      50885/udp6  mountd
|   100005  1,2,3      58983/tcp6  mountd
|   100005  1,2,3      60290/udp   mountd
|   100021  1,3,4      34811/tcp6  nlockmgr
|   100021  1,3,4      45227/tcp   nlockmgr
|   100021  1,3,4      52659/udp   nlockmgr
|   100021  1,3,4      60533/udp6  nlockmgr
|   100227  2,3         2049/tcp   nfs_acl
|   100227  2,3         2049/tcp6  nfs_acl
|   100227  2,3         2049/udp   nfs_acl
|_  100227  2,3         2049/udp6  nfs_acl
139/tcp  open  netbios-ssn Samba smbd 3.X - 4.X (workgroup: WORKGROUP)
445/tcp  open  netbios-ssn Samba smbd 4.3.11-Ubuntu (workgroup: WORKGROUP)
2049/tcp open  nfs_acl     2-3 (RPC #100227)
Service Info: Host: KENOBI; OSs: Unix, Linux; CPE: cpe:/o:linux:linux_kernel

Host script results:
|_clock-skew: mean: 1h40m01s, deviation: 2h53m12s, median: 0s
|_nbstat: NetBIOS name: KENOBI, NetBIOS user: <unknown>, NetBIOS MAC: <unknown> (unknown)
| smb-os-discovery: 
|   OS: Windows 6.1 (Samba 4.3.11-Ubuntu)
|   Computer name: kenobi
|   NetBIOS computer name: KENOBI\x00
|   Domain name: \x00
|   FQDN: kenobi
|_  System time: 2021-05-16T11:41:09-05:00
| smb-security-mode: 
|   account_used: guest
|   authentication_level: user
|   challenge_response: supported
|_  message_signing: disabled (dangerous, but default)
| smb2-security-mode: 
|   2.02: 
|_    Message signing enabled but not required
| smb2-time: 
|   date: 2021-05-16T16:41:09
|_  start_date: N/A

Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 21.55 seconds

Enumerating Samba for Shares

  • Samba is the standard Windows interoperability suite of programs for Linux and Unix. It allows end users to access and use files, printers and other commonly shared resources on a companies intranet or internet. Its often referred to as a network file system.

  • SMB has two ports, 445 and 139.

Using the nmap command above, how many shares have been found?

  • Answer: 3

  • Steps to Reproduce:

What is the file can you see?

  • Answer: log.txt

  • Steps to Reproduce:

    • Connect to the anonymous SMB share with a blank password

Recursively download the SMB share using smbget

What port is FTP running on?

  • Answer: 21

What mount can we see?

  • Answer: /var

  • Steps to Reproduce:

    • Nmap port scan will have shown port 111 running the service rpcbind. This is just a server that converts remote procedure call (RPC) program number into universal addresses. When an RPC service is started, it tells rpcbind the address at which it is listening and the RPC program number its prepared to serve.

    • In our case, port 111 is access to a network file system. Lets use nmap to enumerate this.


Gain initial access with ProFtpd

What is the version of ProFtpd?

  • Answer: 1.3.5

  • Steps to Reproduce: Check out the nmap results or connect using nc <MACHINE_IP> 21.

How many exploits are there for the ProFTPd running?

  • Answer: 3

  • Steps to Reproduce:

    • By using searchsploit, we can find the exploits:

Using SITE CPFR & SITE CPTO

  • SITE CPFR - This SITE command specifies the source file/directory to use for copying from one place to another directly on the server.

  • SITE CPTO - This SITE command specifies the destination file/directory to use for copying from one place to another directly on the server.

Mounting the /var/tmp directory to our machine

  • Copy the Private SSH key in /var/tmp to local and then unmount the file system.

What is Kenobi's user flag (/home/kenobi/user.txt)?

  • Answer: d0b0f3f53b6caa532a83915e19224899

  • Steps to Reproduce:


Privilege Escalation with Path Variable Manipulation

  • SUID bits can be dangerous, some binaries such as passwd need to be run with elevated privileges (as its resetting your password on the system), however other custom files could that have the SUID bit can lead to all sorts of issues.

What file looks particularly out of the ordinary?

  • Answer: /usr/bin/menu

    • Usually in such vulnerable machines, we can find the binaries like /usr/bin/sudo and /usr/bin/su having SUID bit set! But we can't exploit this becuase, we don't have kenobi's password.

    • So, /usr/bin/menu seemed to be out of the ordinary.

Run the binary, how many options appear?

  • Answer: 3

  • Steps to Reproduce:

Finding the approriate binaries

  • On running the the various options of the /usr/bin/menu, we find that the three binaries are being run as root:

    • /usr/bin/curl (curl -I localhost)

    • /usr/bin/uname (uname -r)

    • /sbin/ifconfig (ipconfig)

Manipulating the Path Variable

  • Copy the /bin/sh binary to curl in the tmp directory: echo /bin/sh > curl

  • Change the permission to 777: chmod 777 curl.

  • Modify the PATH variable, so the /tmp directory is checked first.

Privilege Escalation

  • Execute the /usr/bin/menu binary and choose the option 1.

What is the root flag (/root/root.txt)?

  • Answer: 177b3cd8562289f37382721c28381f02

  • Steps to Reproduce:


References

Last updated