Skip to content

Commit 8fdae8f

Browse files
committed
Move protocol and lifetime to mixin, use correct map_target if CHOST
1 parent 07f2d4d commit 8fdae8f

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

lib/msf/core/auxiliary/natpmp.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ def initialize(info = {})
1818
register_options(
1919
[
2020
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)])
2224
],
2325
self.class
2426
)

modules/auxiliary/admin/natpmp/natpmp_map.rb

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@ def initialize
2323
register_options(
2424
[
2525
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'])
2927
],
3028
self.class
3129
)
@@ -87,7 +85,7 @@ def run_host(host)
8785
" -> " +
8886
"#{map_target}:#{internal_port}/#{protocol}"
8987
if actual_ext_port
90-
map_target = Rex::Socket.source_address(host)
88+
map_target = datastore['CHOST'] ? datastore['CHOST'] : Rex::Socket.source_address(host)
9189
actual_forwarding = "#{external_address}:#{actual_ext_port}/#{protocol}" +
9290
" -> " +
9391
"#{map_target}:#{internal_port}/#{protocol}"

modules/auxiliary/scanner/natpmp/natpmp_portscan.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ def initialize
2323

2424
register_options(
2525
[
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"])
2827
], self.class)
2928
end
3029

@@ -47,7 +46,7 @@ def run_host(host)
4746
end
4847

4948
# 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)
5150

5251
Rex::Socket.portspec_crack(datastore['PORTS']).each do |port|
5352
map_req = map_port_request(port, port, Rex::Proto::NATPMP.const_get(datastore['PROTOCOL']), 1)

0 commit comments

Comments
 (0)