NFS Mount Scanner - Metasploit


This page contains detailed information about how to use the auxiliary/scanner/nfs/nfsmount metasploit module. For list of all metasploit modules, visit the Metasploit Module Library.

Module Overview


Name: NFS Mount Scanner
Module: auxiliary/scanner/nfs/nfsmount
Source code: modules/auxiliary/scanner/nfs/nfsmount.rb
Disclosure date: -
Last modification time: 2017-07-24 06:26:21 +0000
Supported architecture(s): -
Supported platform(s): -
Target service / protocol: -
Target network port(s): 111
List of CVEs: CVE-1999-0170

This module scans NFS mounts and their permissions.

Module Ranking and Traits


Module Ranking:

  • normal: The exploit is otherwise reliable, but depends on a specific version and can't (or doesn't) reliably autodetect. More information about ranking can be found here.

Basic Usage


This module is a scanner module, and is capable of testing against multiple hosts.

msf > use auxiliary/scanner/nfs/nfsmount
msf auxiliary(nfsmount) > show options
    ... show and set options ...
msf auxiliary(nfsmount) > set RHOSTS ip-range
msf auxiliary(nfsmount) > exploit

Other examples of setting the RHOSTS option:

Example 1:

msf auxiliary(nfsmount) > set RHOSTS 192.168.1.3-192.168.1.200 

Example 2:

msf auxiliary(nfsmount) > set RHOSTS 192.168.1.1/24

Example 3:

msf auxiliary(nfsmount) > set RHOSTS file:/tmp/ip_list.txt

Required Options


  • RHOSTS: The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>'

Knowledge Base


Vulnerable Application


NFS is very common, and this scanner searches for a mis-configuration, not a vulnerable software version. Installation instructions for NFS can be found for every operating system. The Ubuntu 14.04 instructions can be used as an example for installing and configuring NFS. The following was done on Kali linux:

  1. apt-get install nfs-kernel-server
  2. Create 2 folders to share: mkdir /tmp/open_share mkdir /tmp/closed_share
  3. Add them to the list of shares: echo "/tmp/closed_share 10.1.2.3(ro,sync,no_root_squash)" >> /etc/exports echo "/tmp/open_share *(rw,sync,no_root_squash)" >> /etc/exports
  4. Restart the service: service nfs-kernel-server restart

In this scenario, closed_share is set to read only, and only mountable by the IP 10.1.2.3. open_share is mountable by anyone (*) in read/write mode.

Verification Steps


  1. Install and configure NFS
  2. Start msfconsole
  3. Do: use auxiliary/scanner/nfs/nfsmount
  4. Do: run

Scenarios


A run against the configuration from these docs

    msf > use auxiliary/scanner/nfs/nfsmount
    msf auxiliary(nfsmount) > set rhosts 127.0.0.1
    rhosts => 127.0.0.1
    msf auxiliary(nfsmount) > run

    [+] 127.0.0.1:111         - 127.0.0.1 NFS Export: /tmp/open_share [*]
    [+] 127.0.0.1:111         - 127.0.0.1 NFS Export: /tmp/closed_share [10.1.2.3]
    [*] Scanned 1 of 1 hosts (100% complete)
    [*] Auxiliary module execution completed

Another example can be found at this source:

    [*] Scanned  24 of 240 hosts (10% complete)
    [+] 10.10.xx.xx NFS Export: /data/iso [0.0.0.0/0.0.0.0]
    [*] Scanned  48 of 240 hosts (20% complete)
    [+] 10.10.xx.xx NFS Export: /DataVolume/Public [*]
    [+] 10.10.xx.xx NFS Export: /DataVolume/Download [*]
    [+] 10.10.xx.xx NFS Export: /DataVolume/Softshare [*]
    [*] Scanned  72 of 240 hosts (30% complete)
    [+] 10.10.xx.xx NFS Export: /var/ftp/pub [10.0.0.0/255.255.255.0]
    [*] Scanned  96 of 240 hosts (40% complete)
    [+] 10.10.xx.xx NFS Export: /common []

Confirming


Since NFS has been around since 1989, with modern NFS(v4) being released in 2000, there are many tools which can also be used to verify this configuration issue. The following are other industry tools which can also be used.

nmap

nmap -p 111 --script=nfs-showmount 127.0.0.1

Starting Nmap 7.40 ( https://nmap.org ) at 2017-02-12 19:41 EST
Nmap scan report for localhost (127.0.0.1)
Host is up (0.000037s latency).
PORT    STATE SERVICE
111/tcp open  rpcbind
| nfs-showmount: 
|   /tmp/open_share *
|_  /tmp/closed_share 10.1.2.3

Nmap done: 1 IP address (1 host up) scanned in 0.32 seconds

showmount

showmount is a part of the nfs-common package for debian.

showmount -e 127.0.0.1
Export list for 127.0.0.1:
/tmp/open_share   *
/tmp/closed_share 10.1.2.3

Exploitation


Exploiting this mis-configuration is trivial, however exploitation doesn't necessarily give access (command execution) to the system. If a share is mountable, ie you either are the IP listed in the filter (or could assume it through a DoS), or it is open (*), mounting is trivial. The following instructions were written for Kali linux.

  1. Create a new directory to mount the remote volume to: mkdir /mnt/remote
  2. Use mount to link the remote volume to the local folder: mount -t nfs 127.0.0.1:/tmp/open_share /mnt/remote

The mount and its writability can now be tested:

  1. Write a file: echo "hello" > /mnt/remote/test
  2. The remote end now has the file locally: cat /tmp/open_share/test hello

  3. To unmount: umount /mnt/remote

At this point, its time to hope for a file of value. Maybe code with hardcoded credentials, a passwords.txt, or an id_rsa.

Go back to menu.

Msfconsole Usage


Here is how the scanner/nfs/nfsmount auxiliary module looks in the msfconsole:

msf6 > use auxiliary/scanner/nfs/nfsmount

msf6 auxiliary(scanner/nfs/nfsmount) > show info

       Name: NFS Mount Scanner
     Module: auxiliary/scanner/nfs/nfsmount
    License: Metasploit Framework License (BSD)
       Rank: Normal

Provided by:
  tebo <[email protected]>

Check supported:
  No

Basic options:
  Name      Current Setting  Required  Description
  ----      ---------------  --------  -----------
  PROTOCOL  udp              yes       The protocol to use (Accepted: udp, tcp)
  RHOSTS                     yes       The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>'
  RPORT     111              yes       The target port (TCP)
  THREADS   1                yes       The number of concurrent threads (max one per host)

Description:
  This module scans NFS mounts and their permissions.

References:
  https://nvd.nist.gov/vuln/detail/CVE-1999-0170
  http://www.ietf.org/rfc/rfc1094.txt

Module Options


This is a complete list of options available in the scanner/nfs/nfsmount auxiliary module:

msf6 auxiliary(scanner/nfs/nfsmount) > show options

Module options (auxiliary/scanner/nfs/nfsmount):

   Name      Current Setting  Required  Description
   ----      ---------------  --------  -----------
   PROTOCOL  udp              yes       The protocol to use (Accepted: udp, tcp)
   RHOSTS                     yes       The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>'
   RPORT     111              yes       The target port (TCP)
   THREADS   1                yes       The number of concurrent threads (max one per host)

Advanced Options


Here is a complete list of advanced options supported by the scanner/nfs/nfsmount auxiliary module:

msf6 auxiliary(scanner/nfs/nfsmount) > show advanced

Module advanced options (auxiliary/scanner/nfs/nfsmount):

   Name                 Current Setting  Required  Description
   ----                 ---------------  --------  -----------
   CHOST                                 no        The local client address
   CPORT                                 no        The local client port
   ConnectTimeout       10               yes       Maximum number of seconds to establish a TCP connection
   Proxies                               no        A proxy chain of format type:host:port[,type:host:port][...]
   SSL                  false            no        Negotiate SSL/TLS for outgoing connections
   SSLCipher                             no        String for SSL cipher - "DHE-RSA-AES256-SHA" or "ADH"
   SSLVerifyMode        PEER             no        SSL verification method (Accepted: CLIENT_ONCE, FAIL_IF_NO_PEER_CERT, NONE, PEER)
   SSLVersion           Auto             yes       Specify the version of SSL/TLS to be used (Auto, TLS and SSL23 are auto-negotiate) (Accepted: Auto, TLS, SSL23, SSL3, TLS1, TLS1.1, TLS1.2)
   ShowProgress         true             yes       Display progress messages during a scan
   ShowProgressPercent  10               yes       The interval in percent that progress should be shown
   TIMEOUT              10               yes       Number of seconds to wait for responses to RPC calls
   VERBOSE              false            no        Enable detailed status messages
   WORKSPACE                             no        Specify the workspace for this module

Auxiliary Actions


This is a list of all auxiliary actions that the scanner/nfs/nfsmount module can do:

msf6 auxiliary(scanner/nfs/nfsmount) > show actions

Auxiliary actions:

   Name  Description
   ----  -----------

Evasion Options


Here is the full list of possible evasion options supported by the scanner/nfs/nfsmount auxiliary module in order to evade defenses (e.g. Antivirus, EDR, Firewall, NIDS etc.):

msf6 auxiliary(scanner/nfs/nfsmount) > show evasion

Module evasion options:

   Name                               Current Setting  Required  Description
   ----                               ---------------  --------  -----------
   ONCRPC::tcp_request_fragmentation  false            no        Enable fragmentation of TCP ONC/RPC requests
   TCP::max_send_size                 0                no        Maxiumum tcp segment size.  (0 = disable)
   TCP::send_delay                    0                no        Delays inserted before every send.  (0 = disable)

Go back to menu.

Error Messages


This module may fail with the following error messages:

Check for the possible causes from the code snippets below found in the module source code. This can often times help in identifying the root cause of the problem.

<IP> - No exported directories


Here is a relevant code snippet related to the "<IP> - No exported directories" error message:

70:	          :type => 'nfs.exports',
71:	          :data => { :exports => shares },
72:	          :update => :unique_data
73:	        )
74:	      elsif(exports == 0x00)
75:	        vprint_status("#{ip} - No exported directories")
76:	      end
77:	
78:	      sunrpc_destroy
79:	    rescue ::Rex::Proto::SunRPC::RPCTimeout, ::Rex::Proto::SunRPC::RPCError => e
80:	      vprint_error(e.to_s)

Go back to menu.


References


See Also


Check also the following modules related to this module:

Related Nessus plugins:

Authors


  • <tebo[at]attackresearch.com>

Version


This page has been produced using Metasploit Framework version 6.1.24-dev. For more modules, visit the Metasploit Module Library.

Go back to menu.