NAT-PMP Port Mapper - Metasploit


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

Module Overview


Name: NAT-PMP Port Mapper
Module: auxiliary/admin/natpmp/natpmp_map
Source code: modules/auxiliary/admin/natpmp/natpmp_map.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): 5351
List of CVEs: -

Map (forward) TCP and UDP ports on NAT devices using NAT-PMP

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

Other examples of setting the RHOSTS option:

Example 1:

msf auxiliary(natpmp_map) > set RHOSTS 192.168.1.3-192.168.1.200 

Example 2:

msf auxiliary(natpmp_map) > set RHOSTS 192.168.1.1/24

Example 3:

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

Required Options


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

Go back to menu.

Msfconsole Usage


Here is how the admin/natpmp/natpmp_map auxiliary module looks in the msfconsole:

msf6 > use auxiliary/admin/natpmp/natpmp_map

msf6 auxiliary(admin/natpmp/natpmp_map) > show info

       Name: NAT-PMP Port Mapper
     Module: auxiliary/admin/natpmp/natpmp_map
    License: Metasploit Framework License (BSD)
       Rank: Normal

Provided by:
  Jon Hart <[email protected]>

Check supported:
  No

Basic options:
  Name            Current Setting        Required  Description
  ----            ---------------        --------  -----------
  CHOST                                  no        The local client address
  EXTERNAL_PORTS  0                      yes       The external ports to foward from (0 to let the target choose)
  INTERNAL_PORTS  22,135-139,80,443,445  yes       The internal ports to forward to
  LIFETIME        3600000                yes       Time in ms to keep this port forwarded (set to 0 to destroy a mapping)
  PROTOCOL        TCP                    yes       Protocol to forward (Accepted: TCP, UDP)
  RHOSTS                                 yes       The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>'
  RPORT           5351                   yes       The target port
  THREADS         1                      yes       The number of concurrent threads (max one per host)

Description:
  Map (forward) TCP and UDP ports on NAT devices using NAT-PMP

Module Options


This is a complete list of options available in the admin/natpmp/natpmp_map auxiliary module:

msf6 auxiliary(admin/natpmp/natpmp_map) > show options

Module options (auxiliary/admin/natpmp/natpmp_map):

   Name            Current Setting        Required  Description
   ----            ---------------        --------  -----------
   CHOST                                  no        The local client address
   EXTERNAL_PORTS  0                      yes       The external ports to foward from (0 to let the target choose)
   INTERNAL_PORTS  22,135-139,80,443,445  yes       The internal ports to forward to
   LIFETIME        3600000                yes       Time in ms to keep this port forwarded (set to 0 to destroy a mapping)
   PROTOCOL        TCP                    yes       Protocol to forward (Accepted: TCP, UDP)
   RHOSTS                                 yes       The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>'
   RPORT           5351                   yes       The target port
   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 admin/natpmp/natpmp_map auxiliary module:

msf6 auxiliary(admin/natpmp/natpmp_map) > show advanced

Module advanced options (auxiliary/admin/natpmp/natpmp_map):

   Name                 Current Setting  Required  Description
   ----                 ---------------  --------  -----------
   ShowProgress         true             yes       Display progress messages during a scan
   ShowProgressPercent  10               yes       The interval in percent that progress should be shown
   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 admin/natpmp/natpmp_map module can do:

msf6 auxiliary(admin/natpmp/natpmp_map) > show actions

Auxiliary actions:

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

Evasion Options


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

msf6 auxiliary(admin/natpmp/natpmp_map) > show evasion

Module evasion options:

   Name  Current Setting  Required  Description
   ----  ---------------  --------  -----------

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.

Invalid port specification <PORT_PART>


Here is a relevant code snippet related to the "Invalid port specification <PORT_PART>" error message:

33:	      if /^(?<port>\d+)$/ =~ port_part
34:	        ports << port.to_i
35:	      elsif /^(?<low>\d+)\s*-\s*(?<high>\d+)$/ =~ port_part
36:	        ports |= (low..high).to_a.map(&:to_i)
37:	      else
38:	        fail ArgumentError, "Invalid port specification #{port_part}"
39:	      end
40:	    end
41:	    ports
42:	  end
43:	

Too many external ports specified (<EXTERNAL_PORTS.SIZE>);


Here is a relevant code snippet related to the "Too many external ports specified (<EXTERNAL_PORTS.SIZE>);" error message:

45:	    super
46:	    @external_ports = build_ports(datastore['EXTERNAL_PORTS'])
47:	    @internal_ports = build_ports(datastore['INTERNAL_PORTS'])
48:	
49:	    if @external_ports.size > @internal_ports.size
50:	      fail ArgumentError, "Too many external ports specified (#{@external_ports.size}); " +
51:	        "must be one port (0) or #{@internal_ports.size} ports"
52:	    end
53:	
54:	    if @external_ports.size < @internal_ports.size
55:	      if @external_ports != [0]

Incorrect number of external ports specified (<EXTERNAL_PORTS.SIZE>);


Here is a relevant code snippet related to the "Incorrect number of external ports specified (<EXTERNAL_PORTS.SIZE>);" error message:

51:	        "must be one port (0) or #{@internal_ports.size} ports"
52:	    end
53:	
54:	    if @external_ports.size < @internal_ports.size
55:	      if @external_ports != [0]
56:	        fail ArgumentError, "Incorrect number of external ports specified (#{@external_ports.size}); " +
57:	          "must be one port (0) or #{@internal_ports.size} ports"
58:	      else
59:	        @external_ports = [0] * @internal_ports.size
60:	      end
61:	    end

<REQUESTED_FORWARDING> could not be forwarded


Here is a relevant code snippet related to the "<REQUESTED_FORWARDING> could not be forwarded" error message:

94:	            else
95:	              print_good("#{requested_forwarding} forwarded")
96:	            end
97:	          end
98:	        else
99:	          print_error("#{requested_forwarding} could not be forwarded")
100:	        end
101:	
102:	        report_service(
103:	          :host   => host,
104:	          :port   => datastore['RPORT'],

Unknown error: <E.CLASS> <E.BACKTRACE>


Here is a relevant code snippet related to the "Unknown error: <E.CLASS> <E.BACKTRACE>" error message:

108:	        )
109:	      end
110:	    rescue ::Interrupt
111:	      raise $!
112:	    rescue ::Rex::HostUnreachable, ::Rex::ConnectionTimeout, ::Rex::ConnectionRefused
113:	      nil
114:	    rescue ::Exception => e
115:	      print_error("Unknown error: #{e.class} #{e.backtrace}")
116:	    end
117:	  end
118:	end

Go back to menu.


Go back to menu.

See Also


Check also the following modules related to this module:

Authors


Jon Hart <jhart[at]spoofed.org>

Version


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

Go back to menu.