Raise Msf::OptionValidateError when the PORTS option is invalid

Instead of print_error for invalid ports, modules should be raising
Msf::OptionValidateError to warn the user about the invalid input.
This commit is contained in:
sinn3r 2013-12-18 15:04:53 -06:00
parent 8af81c98c8
commit ee87f357b0
8 changed files with 14 additions and 12 deletions

View File

@ -77,6 +77,10 @@ class Metasploit3 < Msf::Auxiliary
ports = Rex::Socket.portspec_crack(datastore['PORTS'])
if ports.empty?
raise Msf::OptionValidateError.new(['PORTS'])
end
ports.each_with_index do |port,i|
p.tcp_dst = port
p.tcp_src = rand(64511)+1024

View File

@ -56,6 +56,10 @@ class Metasploit3 < Msf::Auxiliary
dead = false
portlist = Rex::Socket.portspec_crack(datastore['PORTS'])
if portlist.empty?
raise Msf::OptionValidateError.new(['PORTS'])
end
vprint_status("[#{rhost}] Verifying manual testing is not required...")
manual = false

View File

@ -50,8 +50,7 @@ class Metasploit3 < Msf::Auxiliary
ports = Rex::Socket.portspec_crack(datastore['PORTS'])
if ports.empty?
print_error("Error: No valid ports specified")
return
raise Msf::OptionValidateError.new(['PORTS'])
end
to = (datastore['TIMEOUT'] || 500).to_f / 1000.0

View File

@ -43,8 +43,7 @@ class Metasploit3 < Msf::Auxiliary
ports = Rex::Socket.portspec_crack(datastore['PORTS'])
if ports.empty?
print_error("Error: No valid ports specified")
return
raise Msf::OptionValidateError.new(['PORTS'])
end
datastore['RHOST'] = datastore['BOUNCEHOST']

View File

@ -48,8 +48,7 @@ class Metasploit3 < Msf::Auxiliary
ports = Rex::Socket.portspec_crack(datastore['PORTS'])
if ports.empty?
print_error("Error: No valid ports specified")
return
raise Msf::OptionValidateError.new(['PORTS'])
end
to = (datastore['TIMEOUT'] || 500).to_f / 1000.0

View File

@ -41,8 +41,7 @@ class Metasploit3 < Msf::Auxiliary
ports = Rex::Socket.portspec_crack(datastore['PORTS'])
if ports.empty?
print_error("Error: No valid ports specified")
return
raise Msf::OptionValidateError.new(['PORTS'])
end
while(ports.length > 0)

View File

@ -50,8 +50,7 @@ class Metasploit3 < Msf::Auxiliary
ports = Rex::Socket.portspec_crack(datastore['PORTS'])
if ports.empty?
print_error("Error: No valid ports specified")
return
raise Msf::OptionValidateError.new(['PORTS'])
end
to = (datastore['TIMEOUT'] || 500).to_f / 1000.0

View File

@ -282,8 +282,7 @@ class Metasploit3 < Msf::Auxiliary
ports = build_sap_ports(ports)
if ports.empty?
print_error('Error: No valid ports specified')
return
raise Msf::OptionValidateError.new(['PORTS'])
end
print_status("Scanning #{ip}")