From 7571fe1f6877284f8c3feda1f4cc860c21069d84 Mon Sep 17 00:00:00 2001 From: David Maloney Date: Mon, 21 Apr 2014 11:34:40 -0500 Subject: [PATCH] fix host validation host validation was buggy, fixed it --- lib/metasploit/framework/login_scanner/ssh.rb | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/metasploit/framework/login_scanner/ssh.rb b/lib/metasploit/framework/login_scanner/ssh.rb index 8acbdc069d..67f2caeeaa 100644 --- a/lib/metasploit/framework/login_scanner/ssh.rb +++ b/lib/metasploit/framework/login_scanner/ssh.rb @@ -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