fix host validation

host validation was buggy, fixed it
bug/bundler_fix
David Maloney 2014-04-21 11:34:40 -05:00
parent 9a15a2be04
commit 7571fe1f68
No known key found for this signature in database
GPG Key ID: DEDBA9DC3A913DB2
1 changed files with 7 additions and 3 deletions

View File

@ -57,7 +57,6 @@ module Metasploit
inclusion: { in: [:debug, :info, :warn, :error, :fatal] }
validates :stop_on_success,
presence: true,
inclusion: { in: [true, false] }
validates :host, presence: true
@ -140,7 +139,7 @@ module Metasploit
'USERNAME' => user,
'PASSWORD' => pass
}
session = Msf::Sessions::CommandShell.new(conn.lsock)
session.info = "SSH: #{user}:#{pass} (#{host}:#{port})"
@ -202,7 +201,12 @@ module Metasploit
errors.add(:host, "must be a string")
end
begin
::Rex::Socket.getaddress(value, true)
::Rex::Socket.getaddress(host, true)
if host =~ /^\d{1,3}(\.\d{1,3}){1,3}$/
unless host =~ Rex::Socket::MATCH_IPV4
errors.add(:host, "could not be resolved")
end
end
rescue
errors.add(:host, "could not be resolved")
end