From 3b8d70b5674a3ab839267e925b300d410513a0e6 Mon Sep 17 00:00:00 2001 From: James Lee Date: Fri, 27 Mar 2015 11:34:32 -0500 Subject: [PATCH] host is always an Mdm::Host, don't look it up again --- lib/msf/core/db_manager/exploit_attempt.rb | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/lib/msf/core/db_manager/exploit_attempt.rb b/lib/msf/core/db_manager/exploit_attempt.rb index 5c9f694ece..23d5ddaba6 100644 --- a/lib/msf/core/db_manager/exploit_attempt.rb +++ b/lib/msf/core/db_manager/exploit_attempt.rb @@ -76,10 +76,10 @@ module Msf::DBManager::ExploitAttempt :username => username || "unknown", } - # Report a vuln_attempt if we found a match + # We have match, lets create a vuln_attempt record if vuln - vuln.vuln_attempts.create(attempt_info) attempt_info[:vuln_id] = vuln.id + vuln.vuln_attempts.create(attempt_info) end # Report an exploit attempt all the same @@ -99,8 +99,8 @@ module Msf::DBManager::ExploitAttempt end def report_exploit_success(opts) - ::ActiveRecord::Base.connection_pool.with_connection { + ::ActiveRecord::Base.connection_pool.with_connection { wspace = opts.delete(:workspace) || workspace mrefs = opts.delete(:refs) || return host = opts.delete(:host) @@ -113,14 +113,7 @@ module Msf::DBManager::ExploitAttempt username = opts.delete(:username) mname = opts.delete(:module) - # Look up or generate the host as appropriate - if not (host and host.kind_of? ::Mdm::Host) - if svc.kind_of? ::Mdm::Service - host = svc.host - else - host = report_host(:workspace => wspace, :address => host ) - end - end + # Bail if we dont have a host object return if not host @@ -150,13 +143,13 @@ module Msf::DBManager::ExploitAttempt :module => mname, :username => username || "unknown", } + attempt_info[:session_id] = opts[:session_id] if opts[:session_id] attempt_info[:loot_id] = opts[:loot_id] if opts[:loot_id] # We have match, lets create a vuln_attempt record if vuln attempt_info[:vuln_id] = vuln.id, - vuln.vuln_attempts.create(attempt_info) # Correct the vuln's associated service if necessary