Skip to content

Commit 0bb03db

Browse files
committed
Rework vuln lookup logic to account for vuln with no service (nexpose import vuln with -1 port)
MSP-13234
1 parent e88a14a commit 0bb03db

File tree

4 files changed

+5
-8
lines changed

4 files changed

+5
-8
lines changed

lib/msf/base/simple/exploit.rb

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ def setup_fail_detail_from_exception e
165165
self.error = e
166166

167167
# Record the detailed reason
168-
self.exploit.fail_detail ||= e.to_s
168+
self.fail_detail ||= e.to_s
169169
msg
170170
end
171171

@@ -175,9 +175,6 @@ def setup_fail_detail_from_exception e
175175
def handle_exception e
176176
msg = setup_fail_detail_from_exception e
177177

178-
require 'pry'
179-
binding.pry
180-
181178
case e
182179
when Msf::Exploit::Complete
183180
# Nothing to show in this case
@@ -235,8 +232,6 @@ def handle_exception e
235232
dlog("Call stack:\n#{e.backtrace.join("\n")}", 'core', LEV_3)
236233
end
237234

238-
239-
240235
# Record the error to various places
241236
self.framework.events.on_module_error(self, msg)
242237

lib/msf/core/db_manager/exploit_attempt.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ def do_report_failure_or_success(opts)
119119
username = opts[:username]
120120
mname = opts[:module]
121121

122+
122123
if vuln.nil?
123124
ref_names = mrefs.map { |ref|
124125
if ref.respond_to?(:ctx_id) and ref.respond_to?(:ctx_val)

lib/msf/core/db_manager/vuln.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ def find_vuln_by_details(details_map, host, service=nil)
4646

4747
def find_vuln_by_refs(refs, host, service=nil)
4848
ref_ids = refs.find_all { |ref| ref.name.starts_with? 'CVE-'}
49-
host.vulns.includes(:refs).where(service_id: service.try(:id), refs: { id: ref_ids}).first
49+
relation = host.vulns.includes(:refs)
50+
relation.where(service_id: service.try(:id), refs: { id: ref_ids}).first || relation.where(refs: { id: ref_ids}).first
5051
end
5152

5253
def get_vuln(wspace, host, service, name, data='')

lib/msf/core/exploit.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1260,7 +1260,6 @@ def fail_with(reason,msg=nil)
12601260
end
12611261

12621262
def report_failure
1263-
12641263
return unless framework.db and framework.db.active
12651264

12661265
info = {
@@ -1293,6 +1292,7 @@ def report_failure
12931292
)
12941293
end
12951294

1295+
12961296
framework.db.report_exploit_failure(info)
12971297
end
12981298

0 commit comments

Comments
 (0)