LogoLogo
NetExec Github
  • Welcome
  • News
    • 🕷️v1.0.0 Release!
    • 🔧v1.1.0 - nxc4u
    • 📡v1.2.0 - ItsAlwaysDNS
    • 🏎️v1.3.0 - NeedForSpeed
    • 🧈v1.4.0 - SmoothOperator
  • Logo & Banner
  • Getting Started
    • Installation
      • 🐧Installation for Unix
      • 🪟Installation for Windows
      • 🍎Installation for Mac
      • 🛠️Manually building the binary
      • ➡️Post Installation Setup
    • Selecting & Using a Protocol
    • Target Formats
    • Using Credentials
    • Using Kerberos
    • Using Certificates
    • Using Modules
    • 🆕DNS options
    • Database General Usage
    • BloodHound Integration
    • Audit Mode
    • Ignore OpSec Warnings
    • Logging
  • SMB protocol
    • Generate hosts file
    • Generate krb5.conf file
    • Generate TGT
    • Scan for Vulnerabilities
    • Enumeration
      • Enumerate Hosts
      • Enumerate Null Sessions
      • Enumerate Guest Logon
      • Enumerate Hosts with SMB Signing Not Required
      • Enumerate Active SMB Sessions
      • Enumerate Shares and Access
      • 🆕Enumerate Network Interfaces
      • Enumerate Disks
      • Enumerate Bitlocker
      • Enumerate Logged on Users
      • Enumerate Domain Users
      • Enumerate Users by Bruteforcing RID
      • Enumerate Domain Groups
      • Enumerate Local Groups
      • Enumerate Domain Password Policy
      • 🆕Enumerate Anti-Virus & EDR
    • Password Spraying
    • Authentication
      • Checking Credentials (Domain)
      • Checking Credentials (Local)
      • 🆕Delegation
    • Command Execution
      • Executing Remote Commands
        • Process Injection (pi module)
      • Getting Shells 101
    • Spidering Shares
    • Get and Put Files
    • Obtaining Credentials
      • Dump SAM
      • Dump LSA
      • Dump NTDS.dit
      • Dump LSASS
      • Dump DPAPI
      • 🆕Dump with BackupOperator Priv
      • 🆕Dump SCCM
      • 🆕Dump Token Broker Cache
      • Dump WIFI password
      • Dump KeePass
      • Dump Veeam
      • Dump WinSCP
      • 🆕Dump PuTTY
      • 🆕Dump VNC
      • 🆕Dump mRemoteNG
      • 🆕Dump Notepad
      • 🆕Dump Notepad++
      • 🆕Dump Remote Desktop Credential Manager
    • Defeating LAPS
    • Checking for Spooler & WebDav
    • Steal Microsoft Teams Cookies
    • 🆕Impersonate logged-on Users
    • 🆕Change User Password
    • 🆕Dump User Local Security Questions
  • LDAP protocol
    • Authentication
    • Enumerate Domain Users
    • Enumerate Domain Groups
    • 🆕Query LDAP
    • ASREPRoast
    • Find Domain SID
    • Kerberoasting
    • 🆕Find Misconfigured Delegation
    • Unconstrained Delegation
    • Admin Count
    • Machine Account Quota
    • Get User Descriptions
    • Dump gMSA
    • Exploit ESC8 (ADCS)
    • Extract Subnet
    • 🛠️Check LDAP Signing
    • Read DACL Rights
    • Extract gMSA Secrets
    • Bloodhound Ingestor
    • List DC IP
    • Enumerate Domain Trusts
    • 🆕Enumerate SCCM
  • WINRM protocol
    • Password Spraying
    • Authentication
    • Command Execution
    • 🆕Defeating LAPS
  • MSSQL protocol
    • Password Spraying
    • Authentication
    • MSSQL PrivEsc
    • MSSQL Command Execution
    • MSSQL Upload & Download
    • Execute via xp_cmdshell
    • 🆕Enumerate Users by Bruteforcing RID
  • SSH protocol
    • Password Spraying
    • Authentication
    • Command Execution
    • Get and Put Files
  • FTP protocol
    • Password Spraying
    • 🆕File Listing, etc
    • 🆕File Upload & Download
  • RDP Protocol
    • Password Spraying
    • Screenshot (connected)
    • Screenshot Without NLA (not connected)
  • WMI Protocol
    • Password Spraying
    • Authentication
    • Command Execution
  • NFS Protocol
    • 🆕Enumeration
    • Download and Upload Files
    • 🆕Escape to root file system
Powered by GitBook
On this page
  • Leveraging the root escape
  • Owning the system: Demo
  • Additional sources:

Was this helpful?

Edit on GitHub
  1. NFS Protocol

Escape to root file system

By default, NFS exports do not restrict access to files outside the exported directory. To access these files NFS needs the respective file handle. However, the root file handle / has a static value, which is file system dependend. Therefore, if one of the shares do not restrict access to the export directory by setting the "subtree_check" flag in their config, it is possible to query to root file system and from there every single file on the system.

NetExec automatically checks for this "escape to root" on connection, as can be seen by the flag:

NFS         <ip>  <port>  <ip>   [*] Supported NFS versions: (3, 4) (root escape:False)

This can be leveraged to access all files on the system which are not root:root owned, meaning all some non-root identity has read access to the file. A prominent example is the /etc/shadow file, which is owned by root:shadow. Furthermore, if the options "no_root_squash" is set, also root:root files can be read. In combination with the "rw" flag, anyone can also upload and overwrite any files on the system and therefore just add themselves as a user.

Recommendation: The file /etc/exports defines all exported directories with their config and is world readable. If you find a host where the root escape is possible, first download the file and check which options are available to you.

Leveraging the root escape

NetExec will automatically try to use the root escape if no share was specified in the command.

Example for --ls:

nxc nfs <ip> --ls '/'

# Example Output
NFS         <ip>  <port>  <ip>   [*] Supported NFS versions: (3, 4) (root escape:True)
NFS         <ip>  <port>  <ip>   [+] Successful escape on share: /var/nfs/general
NFS         <ip>  <port>  <ip>   UID        Perms  File Size     File Path
NFS         <ip>  <port>  <ip>   ---        -----  ---------     ---------
NFS         <ip>  <port>  <ip>   0          dr--   4.0KB         /.
NFS         <ip>  <port>  <ip>   0          dr--   4.0KB         /..
NFS         <ip>  <port>  <ip>   0          -rwx   7.0B          /bin
NFS         <ip>  <port>  <ip>   0          dr--   4.0KB         /boot
NFS         <ip>  <port>  <ip>   0          dr--   4.0KB         /dev
NFS         <ip>  <port>  <ip>   0          dr--   12.0KB        /etc
...

Owning the system: Demo

As mentioned above, when the options (rw,no_root_squash) are set, you can simply download the files /etc/shadow and /etc/passwd, add yourself and reupload them:

Additional sources:

PreviousDownload and Upload Files

Last updated 2 months ago

Was this helpful?

🆕
NFS Security: Identifying and Exploiting Misconfigurations
Owning a system with NFS
GitHub - hvs-consulting/nfs-security-toolingGitHub
Logo
Logo