SunRPC Portmap Program Enumerator - Metasploit


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

Module Overview


Name: SunRPC Portmap Program Enumerator
Module: auxiliary/scanner/misc/sunrpc_portmapper
Source code: modules/auxiliary/scanner/misc/sunrpc_portmapper.rb
Disclosure date: -
Last modification time: 2022-01-23 15:28:32 +0000
Supported architecture(s): -
Supported platform(s): -
Target service / protocol: -
Target network port(s): 111
List of CVEs: -

This module calls the target portmap service and enumerates all program entries and their running port numbers.

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/misc/sunrpc_portmapper
msf auxiliary(sunrpc_portmapper) > show options
    ... show and set options ...
msf auxiliary(sunrpc_portmapper) > set RHOSTS ip-range
msf auxiliary(sunrpc_portmapper) > exploit

Other examples of setting the RHOSTS option:

Example 1:

msf auxiliary(sunrpc_portmapper) > set RHOSTS 192.168.1.3-192.168.1.200 

Example 2:

msf auxiliary(sunrpc_portmapper) > set RHOSTS 192.168.1.1/24

Example 3:

msf auxiliary(sunrpc_portmapper) > 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


RPC Portmapper, or more recently renamed to rpcbind, is fairly common and this scanner searches for its existance. The idea behind rpcbind was to create a 'directory' that could be asked where a service is running (port). Having this single port/service be queryable meant, the services being managed by rpcbind could actually be running on any port or protocol, and rpdbind would be in charge of letting clients know where they were. This is more or less an outdated model/service, and NFS is arguably the most popular service still utilizing rpcbind. The following was done on Kali linux:

  1. Install rpcbind: apt-get install rpcbind
  2. Now now have rpcbind, but this gives us minimal services running on it. You may want to install additional:
    • NIS: apt-get install nis
      • Start the service: ypserv
    • NFS: apt-get install nfs-kernel-server
  3. Just to be safe, restart rpcbind: service rpcbind restart

Verification Steps


  1. Install and configure rpcbind
  2. Start msfconsole
  3. Do: use auxiliary/scanner/misc/sunrpc_portmapper
  4. Do: run

Scenarios


A run against the configuration from these docs

    msf > use auxiliary/scanner/misc/sunrpc_portmapper
    msf auxiliary(sunrpc_portmapper) > set rhosts 127.0.0.1
    rhosts => 127.0.0.1
    msf auxiliary(sunrpc_portmapper) > run

    [+] 127.0.0.1:111         - SunRPC Programs for 127.0.0.1
    =============================

     Name      Number  Version  Port   Protocol
     ----      ------  -------  ----   --------
     mountd    100005  1        60153  udp
     mountd    100005  1        39027  tcp
     mountd    100005  2        47725  udp
     mountd    100005  2        53055  tcp
     mountd    100005  3        49015  udp
     mountd    100005  3        47033  tcp
     nfs       100003  3        2049   tcp
     nfs       100003  4        2049   tcp
     nfs       100003  3        2049   udp
     nfs       100003  4        2049   udp
     nfs_acl   100227  3        2049   tcp
     nfs_acl   100227  3        2049   udp
     nlockmgr  100021  1        40970  udp
     nlockmgr  100021  3        40970  udp
     nlockmgr  100021  4        40970  udp
     nlockmgr  100021  1        42279  tcp
     nlockmgr  100021  3        42279  tcp
     nlockmgr  100021  4        42279  tcp
     rpcbind   100000  4        111    tcp
     rpcbind   100000  3        111    tcp
     rpcbind   100000  2        111    tcp
     rpcbind   100000  4        111    udp
     rpcbind   100000  3        111    udp
     rpcbind   100000  2        111    udp
     ypserv    100004  2        707    udp
     ypserv    100004  1        707    udp
     ypserv    100004  2        708    tcp
     ypserv    100004  1        708    tcp

    [*] Scanned 1 of 1 hosts (100% complete)
    [*] Auxiliary module execution completed

Confirming


Since rpc port mapper has been around since 1995, there are many tools which can also query it. The following are other industry tools which can also be used.

nmap

nmap -p 111 --script=rpcinfo 127.0.0.1

Starting Nmap 7.40 ( https://nmap.org ) at 2017-02-13 22:57 EST
Nmap scan report for localhost (127.0.0.1)
Host is up (0.000043s latency).
PORT    STATE SERVICE
111/tcp open  rpcbind
| rpcinfo: 
|   program version   port/proto  service
|   100000  2,3,4        111/tcp  rpcbind
|   100000  2,3,4        111/udp  rpcbind
|   100003  3,4         2049/tcp  nfs
|   100003  3,4         2049/udp  nfs
|   100004  1,2          707/udp  ypserv
|   100004  1,2          708/tcp  ypserv
|   100005  1,2,3      47033/tcp  mountd
|   100005  1,2,3      49015/udp  mountd
|   100021  1,3,4      40970/udp  nlockmgr
|   100021  1,3,4      42279/tcp  nlockmgr
|   100227  3           2049/tcp  nfs_acl
|_  100227  3           2049/udp  nfs_acl

rpcinfo

This is the standard package included with rpcbind to query the rpc interface.

rpcinfo -p 127.0.0.1
   program vers proto   port  service
    100000    4   tcp    111  portmapper
    100000    3   tcp    111  portmapper
    100000    2   tcp    111  portmapper
    100000    4   udp    111  portmapper
    100000    3   udp    111  portmapper
    100000    2   udp    111  portmapper
    100005    1   udp  60153  mountd
    100005    1   tcp  39027  mountd
    100005    2   udp  47725  mountd
    100005    2   tcp  53055  mountd
    100005    3   udp  49015  mountd
    100005    3   tcp  47033  mountd
    100003    3   tcp   2049  nfs
    100003    4   tcp   2049  nfs
    100227    3   tcp   2049
    100003    3   udp   2049  nfs
    100003    4   udp   2049  nfs
    100227    3   udp   2049
    100021    1   udp  40970  nlockmgr
    100021    3   udp  40970  nlockmgr
    100021    4   udp  40970  nlockmgr
    100021    1   tcp  42279  nlockmgr
    100021    3   tcp  42279  nlockmgr
    100021    4   tcp  42279  nlockmgr
    100004    2   udp    707  ypserv
    100004    1   udp    707  ypserv
    100004    2   tcp    708  ypserv
    100004    1   tcp    708  ypserv

Go back to menu.

Msfconsole Usage


Here is how the scanner/misc/sunrpc_portmapper auxiliary module looks in the msfconsole:

msf6 > use auxiliary/scanner/misc/sunrpc_portmapper

msf6 auxiliary(scanner/misc/sunrpc_portmapper) > show info

       Name: SunRPC Portmap Program Enumerator
     Module: auxiliary/scanner/misc/sunrpc_portmapper
    License: Metasploit Framework License (BSD)
       Rank: Normal

Provided by:
  tebo <[email protected]>

Check supported:
  No

Basic options:
  Name      Current Setting  Required  Description
  ----      ---------------  --------  -----------
  PROTOCOL  tcp              yes       Protocol to use (Accepted: tcp, udp)
  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 calls the target portmap service and enumerates all 
  program entries and their running port numbers.

References:
  http://www.ietf.org/rfc/rfc1057.txt

Module Options


This is a complete list of options available in the scanner/misc/sunrpc_portmapper auxiliary module:

msf6 auxiliary(scanner/misc/sunrpc_portmapper) > show options

Module options (auxiliary/scanner/misc/sunrpc_portmapper):

   Name      Current Setting  Required  Description
   ----      ---------------  --------  -----------
   PROTOCOL  tcp              yes       Protocol to use (Accepted: tcp, udp)
   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/misc/sunrpc_portmapper auxiliary module:

msf6 auxiliary(scanner/misc/sunrpc_portmapper) > show advanced

Module advanced options (auxiliary/scanner/misc/sunrpc_portmapper):

   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/misc/sunrpc_portmapper module can do:

msf6 auxiliary(scanner/misc/sunrpc_portmapper) > show actions

Auxiliary actions:

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

Evasion Options


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

msf6 auxiliary(scanner/misc/sunrpc_portmapper) > 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.

<PEER>: unknown protocol number for <THING>


Here is a relevant code snippet related to the "<PEER>: unknown protocol number for <THING>" error message:

65:	        if prot_num == 0x06
66:	          proto = 'tcp'
67:	        elsif prot_num == 0x11
68:	          proto = 'udp'
69:	        else
70:	          print_error("#{peer}: unknown protocol number for #{thing}")
71:	          next
72:	        end
73:	
74:	        resolved = progresolv(prog)
75:	        table << [ resolved, prog, vers, port, proto ]

Go back to menu.


References


See Also


Check also the following modules related to this module:

Authors


  • <tebo[at]attackresearch.com>

Version


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

Go back to menu.