Skip to content

Commit d4440d0

Browse files
committed
Merge branch 'goliath' of github.com:clee-r7/metasploit-framework into goliath
2 parents 3005a8b + 88e7769 commit d4440d0

20 files changed

+208
-106
lines changed

lib/metasploit/framework/data_service/proxy/core.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,14 @@ def get_data_service
115115
return @current_data_service
116116
end
117117

118+
def log_error(exception, ui_message)
119+
elog "#{ui_message}: #{exception.message}"
120+
exception.backtrace.each { |line| elog "#{line}" }
121+
# TODO: We should try to surface the original exception, instead of just a generic one.
122+
# This should not display the full backtrace, only the message.
123+
raise Exception, "#{ui_message}: #{exception.message}. See log for more details."
124+
end
125+
118126
#######
119127
private
120128
#######

lib/metasploit/framework/data_service/proxy/credential_data_proxy.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ def create_credential(opts)
55
data_service = self.get_data_service()
66
data_service.create_credential(opts)
77
rescue Exception => e
8-
elog "Problem creating credential: #{e.message}"
8+
self.log_error(e, "Problem creating credential")
99
end
1010
end
1111

@@ -14,7 +14,7 @@ def creds(opts = {})
1414
data_service = self.get_data_service
1515
data_service.creds(opts)
1616
rescue Exception => e
17-
elog "Problem retrieving credentials: #{e.message}"
17+
self.log_error(e, "Problem retrieving credentials")
1818
end
1919
end
2020
end

lib/metasploit/framework/data_service/proxy/event_data_proxy.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ def report_event(opts)
55
data_service = self.get_data_service()
66
data_service.report_event(opts)
77
rescue Exception => e
8-
elog "Problem reporting event: #{e.message}"
8+
self.log_error(e, "Problem reporting event")
99
end
1010
end
1111

lib/metasploit/framework/data_service/proxy/exploit_data_proxy.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ def report_exploit_attempt(host, opts)
55
data_service = self.get_data_service()
66
data_service.report_exploit_attempt(host, opts)
77
rescue Exception => e
8-
elog "Problem reporting exploit attempt: #{e.message}"
8+
self.log_error(e, "Problem reporting exploit attempt")
99
end
1010
end
1111

@@ -14,7 +14,7 @@ def report_exploit_failure(opts)
1414
data_service = self.get_data_service()
1515
data_service.report_exploit_failure(opts)
1616
rescue Exception => e
17-
elog "Problem reporting exploit failure: #{e.message}"
17+
self.log_error(e, "Problem reporting exploit failure")
1818
end
1919
end
2020

@@ -23,7 +23,7 @@ def report_exploit_success(opts)
2323
data_service = self.get_data_service()
2424
data_service.report_exploit_success(opts)
2525
rescue Exception => e
26-
elog "Problem reporting exploit success: #{e.message}"
26+
self.log_error(e, "Problem reporting exploit success")
2727
end
2828
end
2929
end

lib/metasploit/framework/data_service/proxy/host_data_proxy.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def hosts(wspace = workspace, non_dead = false, addresses = nil, search_term = n
1010
opts[:search_term] = search_term
1111
data_service.hosts(opts)
1212
rescue Exception => e
13-
elog "Problem retrieving hosts: #{e.message}"
13+
self.log_error(e, "Problem retrieving hosts")
1414
end
1515
end
1616

@@ -27,7 +27,7 @@ def report_host(opts)
2727
data_service = self.get_data_service()
2828
data_service.report_host(opts)
2929
rescue Exception => e
30-
elog "Problem reporting host: #{e.message}"
30+
self.log_error(e, "Problem reporting host")
3131
end
3232
end
3333

@@ -36,7 +36,7 @@ def report_hosts(hosts)
3636
data_service = self.get_data_service()
3737
data_service.report_hosts(hosts)
3838
rescue Exception => e
39-
elog "Problem reporting hosts: #{e.message}"
39+
self.log_error(e, "Problem reporting hosts")
4040
end
4141
end
4242

@@ -45,7 +45,7 @@ def update_host(opts)
4545
data_service = self.get_data_service()
4646
data_service.update_host(opts)
4747
rescue Exception => e
48-
elog "Problem updating host: #{e.message}"
48+
self.log_error(e, "Problem updating host")
4949
end
5050
end
5151

@@ -54,7 +54,7 @@ def delete_host(opts)
5454
data_service = self.get_data_service()
5555
data_service.delete_host(opts)
5656
rescue Exception => e
57-
elog "Problem removing host: #{e.message}"
57+
self.log_error(e, "Problem deleting host")
5858
end
5959
end
6060

lib/metasploit/framework/data_service/proxy/loot_data_proxy.rb

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,34 @@ def report_loot(opts)
88
end
99
data_service.report_loot(opts)
1010
rescue Exception => e
11-
elog "Problem reporting loot: #{e.message}"
11+
self.log_error(e, "Problem reporting loot")
1212
end
1313
end
1414

15+
# TODO: Shouldn't this proxy to RemoteLootDataService#find_or_create_loot ?
16+
# It's currently skipping the "find" part
17+
def find_or_create_loot(opts)
18+
report_loot(opts)
19+
end
20+
1521
def loots(wspace, opts = {})
1622
begin
1723
data_service = self.get_data_service
1824
opts[:wspace] = wspace
1925
data_service.loot(opts)
2026
rescue Exception => e
21-
elog "Problem retrieving loot: #{e.message}"
27+
self.log_error(e, "Problem retrieving loot")
2228
end
2329
end
2430

2531
alias_method :loot, :loots
32+
33+
def update_loot(opts)
34+
begin
35+
data_service = self.get_data_service
36+
data_service.update_loot(opts)
37+
rescue Exception => e
38+
self.log_error(e, "Problem updating loot")
39+
end
40+
end
2641
end

lib/metasploit/framework/data_service/proxy/nmap_data_proxy.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ def import_nmap_xml_file(args = {})
55
data_service = self.get_data_service()
66
data_service.import_nmap_xml_file(args)
77
rescue Exception => e
8-
elog "Problem importing NMAP XML: #{e.message}"
8+
self.log_error(e, "Problem importing Nmap XML file")
99
end
1010
end
1111
end

lib/metasploit/framework/data_service/proxy/note_data_proxy.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ def report_note(opts)
44
data_service = self.get_data_service()
55
data_service.report_note(opts)
66
rescue Exception => e
7-
elog "Problem reporting note: #{e.message}"
7+
self.log_error(e, "Problem reporting note")
88
end
99
end
1010
end

lib/metasploit/framework/data_service/proxy/service_data_proxy.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ def report_service(opts)
55
data_service = self.get_data_service()
66
data_service.report_service(opts)
77
rescue Exception => e
8-
elog "Problem reporting service: #{e.message}"
8+
self.log_error(e, "Problem reporting service")
99
end
1010
end
1111

lib/metasploit/framework/data_service/proxy/session_data_proxy.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ def report_session(opts)
44
data_service = self.get_data_service()
55
data_service.report_session(opts)
66
rescue Exception => e
7-
elog "Problem reporting session: #{e.message}"
7+
self.log_error(e, "Problem reporting session")
88
end
99
end
1010
end

0 commit comments

Comments
 (0)