11## Vulnerable Application
22
3- 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.
4- The [ Ubuntu 14.04] ( https://help.ubuntu.com/14.04/serverguide/network-file-system.html ) instructions can be used as an example for installing and configuring NFS. The
3+ NFS is very common, and this scanner searches for a mis-configuration, not a vulnerable software version.
4+ Installation instructions for NFS can be found for every operating system.
5+ The [ Ubuntu] ( https://ubuntu.com/server/docs/service-nfs )
6+ instructions can be used as an example for installing and configuring NFS. The
57following was done on Kali linux:
6-
7- 1 . ` apt-get install nfs-kernel-server `
8- 2 . Create 2 folders to share:
9- ```
10- mkdir /tmp/open_share
11- mkdir /tmp/closed_share
12- ```
13- 3. Add them to the list of shares:
14- ```
15- echo "/tmp/closed_share 10.1.2.3(ro,sync,no_root_squash)" >> /etc/exports
16- echo "/tmp/open_share * (rw,sync,no_root_squash)" >> /etc/exports
17- ```
18- 4. Restart the service: `service nfs-kernel-server restart`
19-
20- 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.
8+
9+ 1 . ` apt-get install nfs-kernel-server `
10+ 2 . Create folders to share and add them to exports (adjust 192.168.1.x as needed):
11+ ```
12+ mkdir /tmp/star
13+ echo "/tmp/star *(rw,no_subtree_check)" >> /etc/exports
14+ mkdir /tmp/not_us_hostname
15+ echo "/tmp/not_us_hostname foo(rw,no_subtree_check)" >> /etc/exports
16+ mkdir /tmp/us_hostname
17+ echo "/tmp/us_hostname bar(rw,no_subtree_check)" >> /etc/exports
18+ mkdir /tmp/not_us_ip
19+ echo "/tmp/not_us_ip 1.1.1.1(rw,no_subtree_check)" >> /etc/exports
20+ mkdir /tmp/us_ip
21+ echo "/tmp/us_ip 192.168.1.111(rw,no_subtree_check)" >> /etc/exports
22+ mkdir /tmp/not_us_subnet
23+ echo "/tmp/not_us_subnet 1.1.1.1/24(rw,no_subtree_check)" >> /etc/exports
24+ mkdir /tmp/us_subnet
25+ echo "/tmp/us_subnet 192.168.1.1/24(rw,no_subtree_check)" >> /etc/exports
26+ mkdir /tmp/not_us_netmask
27+ echo "/tmp/not_us_netmask 1.1.1.1/255.255.255.0(rw,no_subtree_check)" >> /etc/exports
28+ mkdir /tmp/us_netmask
29+ echo "/tmp/us_netmask 192.168.1.1/255.255.255.0(rw,no_subtree_check)" >> /etc/exports
30+ mkdir /tmp/empty
31+ echo "/tmp/empty (rw,no_subtree_check)" >> /etc/exports
32+ ```
33+ 3 . Restart the service: ` service nfs-kernel-server restart `
34+
35+ ## Options
36+
37+ ### PROTOCOL
38+ Which networking protocol to use. Options are ` udp ` and ` tcp ` . Defaults to ` udp ` .
39+
40+ ### LHOST
41+ IP to match shares against if ` Mountable ` is true. Defaults to the detected local IP address.
42+
43+ ### HOSTNAME
44+ Hostname to match shares against if ` Mountable ` is true. Defaults to `` (empty string)
45+
46+ ## Advanced Options
47+
48+ ### Mountable
49+
50+ Determine if an export is mountable based on ` LHOST ` and ` HOSTNAME ` . Defaults to ` true ` . Pre 2022 behavior was ` false `
2151
2252## Verification Steps
2353
24- 1. Install and configure NFS
25- 2. Start msfconsole
26- 3. Do: `use auxiliary/scanner/nfs/nfsmount`
27- 4. Do: `run`
54+ 1 . Install and configure NFS
55+ 2 . Start msfconsole
56+ 3 . Do: ` use auxiliary/scanner/nfs/nfsmount `
57+ 4 . Do: ` run `
2858
2959## Scenarios
3060
31- A run against the configuration from these docs
32-
33- ```
34- msf > use auxiliary/scanner/nfs/nfsmount
35- msf auxiliary(nfsmount) > set rhosts 127.0.0.1
36- rhosts => 127.0.0.1
37- msf auxiliary(nfsmount) > run
38-
39- [+] 127.0.0.1:111 - 127.0.0.1 NFS Export: /tmp/open_share [*]
40- [+] 127.0.0.1:111 - 127.0.0.1 NFS Export: /tmp/closed_share [10.1.2.3]
41- [*] Scanned 1 of 1 hosts (100% complete)
42- [*] Auxiliary module execution completed
43- ```
44-
45- Another example can be found at this [source](http://bitvijays.github.io/blog/2016/03/03/learning-from-the-field-basic-network-hygiene/):
46-
47- ```
48- [*] Scanned 24 of 240 hosts (10% complete)
49- [+] 10.10.xx.xx NFS Export: /data/iso [0.0.0.0/0.0.0.0]
50- [*] Scanned 48 of 240 hosts (20% complete)
51- [+] 10.10.xx.xx NFS Export: /DataVolume/Public [*]
52- [+] 10.10.xx.xx NFS Export: /DataVolume/Download [*]
53- [+] 10.10.xx.xx NFS Export: /DataVolume/Softshare [*]
54- [*] Scanned 72 of 240 hosts (30% complete)
55- [+] 10.10.xx.xx NFS Export: /var/ftp/pub [10.0.0.0/255.255.255.0]
56- [*] Scanned 96 of 240 hosts (40% complete)
57- [+] 10.10.xx.xx NFS Export: /common []
58- ```
61+ A run against the configuration from these docs
62+
63+ ```
64+ msf > use auxiliary/scanner/nfs/nfsmount
65+ msf auxiliary(nfsmount) > set rhosts 127.0.0.1
66+ rhosts => 127.0.0.1
67+ msf auxiliary(nfsmount) > run
68+
69+ [+] 127.0.0.1:111 - 127.0.0.1 NFS Export: /tmp/empty [*]
70+ [+] 127.0.0.1:111 - 127.0.0.1 NFS Export: /tmp/star [*]
71+ [+] 127.0.0.1:111 - 127.0.0.1 NFS Export: /tmp/us_netmask [10.1.1.1/255.255.255.0]
72+ [*] 127.0.0.1:111 - 127.0.0.1 NFS Export: /tmp/not_us_netmask [1.1.1.1/255.255.255.0]
73+ [+] 127.0.0.1:111 - 127.0.0.1 NFS Export: /tmp/us_subnet [10.1.1.1/24]
74+ [*] 127.0.0.1:111 - 127.0.0.1 NFS Export: /tmp/not_us_subnet [1.1.1.1/24]
75+ [+] 127.0.0.1:111 - 127.0.0.1 NFS Export: /tmp/us_ip [192.168.1.111]
76+ [*] 127.0.0.1:111 - 127.0.0.1 NFS Export: /tmp/not_us_ip [1.1.1.1]
77+ [*] 127.0.0.1:111 - Scanned 1 of 1 hosts (100% complete)
78+ [*] Auxiliary module execution completed
79+ ```
80+
81+ Another example can be found at this [ source] ( http://bitvijays.github.io/blog/2016/03/03/learning-from-the-field-basic-network-hygiene/ ) :
82+
83+ ```
84+ [*] Scanned 24 of 240 hosts (10% complete)
85+ [+] 10.10.xx.xx NFS Export: /data/iso [0.0.0.0/0.0.0.0]
86+ [*] Scanned 48 of 240 hosts (20% complete)
87+ [+] 10.10.xx.xx NFS Export: /DataVolume/Public [*]
88+ [+] 10.10.xx.xx NFS Export: /DataVolume/Download [*]
89+ [+] 10.10.xx.xx NFS Export: /DataVolume/Softshare [*]
90+ [*] Scanned 72 of 240 hosts (30% complete)
91+ [+] 10.10.xx.xx NFS Export: /var/ftp/pub [10.0.0.0/255.255.255.0]
92+ [*] Scanned 96 of 240 hosts (40% complete)
93+ [+] 10.10.xx.xx NFS Export: /common []
94+ ```
5995
6096## Confirming
6197
62- 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.
98+ 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
99+ verify this configuration issue.
63100The following are other industry tools which can also be used.
64101
65102### [ nmap] ( https://nmap.org/nsedoc/scripts/nfs-showmount.html )
@@ -73,8 +110,14 @@ Host is up (0.000037s latency).
73110PORT STATE SERVICE
74111111/tcp open rpcbind
75112| nfs-showmount:
76- | /tmp/open_share *
77- |_ /tmp/closed_share 10.1.2.3
113+ | /tmp/empty *
114+ | /tmp/star *
115+ | /tmp/us_netmask 10.1.1.1/255.255.255.0
116+ | /tmp/not_us_netmask 1.1.1.1/255.255.255.0
117+ | /tmp/us_subnet 10.1.1.1/24
118+ | /tmp/not_us_subnet 1.1.1.1/24
119+ | /tmp/us_ip 192.168.1.111
120+ |_ /tmp/not_us_ip 1.1.1.1
78121
79122Nmap done: 1 IP address (1 host up) scanned in 0.32 seconds
80123```
@@ -86,14 +129,21 @@ showmount is a part of the `nfs-common` package for debian.
86129```
87130showmount -e 127.0.0.1
88131Export list for 127.0.0.1:
89- /tmp/open_share *
90- /tmp/closed_share 10.1.2.3
132+ /tmp/empty *
133+ /tmp/star *
134+ /tmp/us_netmask 10.1.1.1/255.255.255.0
135+ /tmp/not_us_netmask 1.1.1.1/255.255.255.0
136+ /tmp/us_subnet 10.1.1.1/24
137+ /tmp/not_us_subnet 1.1.1.1/24
138+ /tmp/us_ip 192.168.1.111
139+ /tmp/not_us_ip 1.1.1.1
91140```
92141
93142## Exploitation
94143
95144Exploiting this mis-configuration is trivial, however exploitation doesn't necessarily give access (command execution) to the system.
96- 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.
145+ If a share is mountable, ie you either are the IP listed in the filter (or could assume it through a DoS),
146+ or it is open (* ), mounting is trivial.
97147The following instructions were written for Kali linux.
98148
991491 . Create a new directory to mount the remote volume to: ` mkdir /mnt/remote `
0 commit comments