Browse Source

Move protocol and lifetime to mixin, use correct map_target if CHOST

Jon Hart 5 years ago
parent
commit
8fdae8fbfb

+ 3
- 1
lib/msf/core/auxiliary/natpmp.rb View File

@@ -18,7 +18,9 @@ module Auxiliary::NATPMP
18 18
     register_options(
19 19
       [
20 20
         Opt::RPORT(Rex::Proto::NATPMP::DefaultPort),
21
-        Opt::CHOST
21
+        Opt::CHOST,
22
+        OptInt.new('LIFETIME', [true, "Time in ms to keep this port forwarded (set to 0 to destroy a mapping)", 3600000]),
23
+        OptEnum.new('PROTOCOL', [true, "Protocol to forward", 'TCP', %w(TCP UDP)])
22 24
       ],
23 25
       self.class
24 26
     )

+ 2
- 4
modules/auxiliary/admin/natpmp/natpmp_map.rb View File

@@ -23,9 +23,7 @@ class Metasploit3 < Msf::Auxiliary
23 23
     register_options(
24 24
       [
25 25
         OptString.new('EXTERNAL_PORTS', [true, 'The external ports to foward from (0 to let the target choose)', 0]),
26
-        OptString.new('INTERNAL_PORTS', [true, 'The internal ports to forward to', '22,135-139,80,443,445']),
27
-        OptInt.new('LIFETIME', [true, "Time in ms to keep this port forwarded (set to 0 to destroy a mapping)", 3600000]),
28
-        OptEnum.new('PROTOCOL', [true, "Protocol to forward", 'TCP', %w(TCP UDP)]),
26
+        OptString.new('INTERNAL_PORTS', [true, 'The internal ports to forward to', '22,135-139,80,443,445'])
29 27
       ],
30 28
       self.class
31 29
     )
@@ -87,7 +85,7 @@ class Metasploit3 < Msf::Auxiliary
87 85
                               " -> " +
88 86
                               "#{map_target}:#{internal_port}/#{protocol}"
89 87
         if actual_ext_port
90
-          map_target = Rex::Socket.source_address(host)
88
+          map_target = datastore['CHOST'] ? datastore['CHOST'] : Rex::Socket.source_address(host)
91 89
           actual_forwarding = "#{external_address}:#{actual_ext_port}/#{protocol}" +
92 90
                                 " -> " +
93 91
                                 "#{map_target}:#{internal_port}/#{protocol}"

+ 2
- 3
modules/auxiliary/scanner/natpmp/natpmp_portscan.rb View File

@@ -23,8 +23,7 @@ class Metasploit3 < Msf::Auxiliary
23 23
 
24 24
     register_options(
25 25
       [
26
-        OptString.new('PORTS', [true, "Ports to scan (e.g. 22-25,80,110-900)", "1-1000"]),
27
-        OptEnum.new('PROTOCOL', [true, "Protocol to scan", 'TCP', %w(TCP UDP)]),
26
+        OptString.new('PORTS', [true, "Ports to scan (e.g. 22-25,80,110-900)", "1-1000"])
28 27
       ], self.class)
29 28
   end
30 29
 
@@ -47,7 +46,7 @@ class Metasploit3 < Msf::Auxiliary
47 46
       end
48 47
 
49 48
       # clear all mappings
50
-      map_port(udp_sock, host, datastore['RPORT'], 0, 0, Rex::Proto::NATPMP.const_get(protocol), lifetime)
49
+      map_port(udp_sock, host, datastore['RPORT'], 0, 0, Rex::Proto::NATPMP.const_get(protocol), 0)
51 50
 
52 51
       Rex::Socket.portspec_crack(datastore['PORTS']).each do |port|
53 52
         map_req = map_port_request(port, port, Rex::Proto::NATPMP.const_get(datastore['PROTOCOL']), 1)

Loading…
Cancel
Save