Skip to content

Commit b02e21a

Browse files
committed
Land rapid7#2779, @wchen-r7's mod to raise Msf::OptionValidateError when PORTS is invalid
2 parents c2783c2 + ee87f35 commit b02e21a

File tree

8 files changed

+14
-12
lines changed

8 files changed

+14
-12
lines changed

modules/auxiliary/bnat/bnat_scan.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@ def run_host(ip)
7777

7878
ports = Rex::Socket.portspec_crack(datastore['PORTS'])
7979

80+
if ports.empty?
81+
raise Msf::OptionValidateError.new(['PORTS'])
82+
end
83+
8084
ports.each_with_index do |port,i|
8185
p.tcp_dst = port
8286
p.tcp_src = rand(64511)+1024

modules/auxiliary/scanner/http/squid_pivot_scanning.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ def run_host(target_host)
5656
dead = false
5757
portlist = Rex::Socket.portspec_crack(datastore['PORTS'])
5858

59+
if portlist.empty?
60+
raise Msf::OptionValidateError.new(['PORTS'])
61+
end
62+
5963
vprint_status("[#{rhost}] Verifying manual testing is not required...")
6064

6165
manual = false

modules/auxiliary/scanner/portscan/ack.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,7 @@ def run_batch(hosts)
5050
ports = Rex::Socket.portspec_crack(datastore['PORTS'])
5151

5252
if ports.empty?
53-
print_error("Error: No valid ports specified")
54-
return
53+
raise Msf::OptionValidateError.new(['PORTS'])
5554
end
5655

5756
to = (datastore['TIMEOUT'] || 500).to_f / 1000.0

modules/auxiliary/scanner/portscan/ftpbounce.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,7 @@ def run_host(ip)
4343
ports = Rex::Socket.portspec_crack(datastore['PORTS'])
4444

4545
if ports.empty?
46-
print_error("Error: No valid ports specified")
47-
return
46+
raise Msf::OptionValidateError.new(['PORTS'])
4847
end
4948

5049
datastore['RHOST'] = datastore['BOUNCEHOST']

modules/auxiliary/scanner/portscan/syn.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,7 @@ def run_batch(hosts)
4848
ports = Rex::Socket.portspec_crack(datastore['PORTS'])
4949

5050
if ports.empty?
51-
print_error("Error: No valid ports specified")
52-
return
51+
raise Msf::OptionValidateError.new(['PORTS'])
5352
end
5453

5554
to = (datastore['TIMEOUT'] || 500).to_f / 1000.0

modules/auxiliary/scanner/portscan/tcp.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@ def run_host(ip)
4141
ports = Rex::Socket.portspec_crack(datastore['PORTS'])
4242

4343
if ports.empty?
44-
print_error("Error: No valid ports specified")
45-
return
44+
raise Msf::OptionValidateError.new(['PORTS'])
4645
end
4746

4847
while(ports.length > 0)

modules/auxiliary/scanner/portscan/xmas.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,7 @@ def run_batch(hosts)
5050
ports = Rex::Socket.portspec_crack(datastore['PORTS'])
5151

5252
if ports.empty?
53-
print_error("Error: No valid ports specified")
54-
return
53+
raise Msf::OptionValidateError.new(['PORTS'])
5554
end
5655

5756
to = (datastore['TIMEOUT'] || 500).to_f / 1000.0

modules/auxiliary/scanner/sap/sap_router_portscanner.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,8 +282,7 @@ def run_host(ip)
282282
ports = build_sap_ports(ports)
283283

284284
if ports.empty?
285-
print_error('Error: No valid ports specified')
286-
return
285+
raise Msf::OptionValidateError.new(['PORTS'])
287286
end
288287

289288
print_status("Scanning #{ip}")

0 commit comments

Comments
 (0)