From 7e10b38421ce2159c7bba6cc79430561f9acbf35 Mon Sep 17 00:00:00 2001 From: Matthew Kienow Date: Fri, 21 Dec 2018 21:37:42 -0500 Subject: [PATCH] Add events method --- .../framework/data_service/proxy/event_data_proxy.rb | 11 +++++++++++ .../remote/http/remote_event_data_service.rb | 10 ++++++++++ .../data_service/stubs/event_data_service.rb | 5 ++++- 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/lib/metasploit/framework/data_service/proxy/event_data_proxy.rb b/lib/metasploit/framework/data_service/proxy/event_data_proxy.rb index ea57b0198d..d24e073c62 100644 --- a/lib/metasploit/framework/data_service/proxy/event_data_proxy.rb +++ b/lib/metasploit/framework/data_service/proxy/event_data_proxy.rb @@ -1,5 +1,16 @@ module EventDataProxy + def events(opts = {}) + begin + self.data_service_operation do |data_service| + add_opts_workspace(opts) + data_service.events(opts) + end + rescue => e + self.log_error(e, "Problem retrieving events") + end + end + def report_event(opts) begin self.data_service_operation do |data_service| diff --git a/lib/metasploit/framework/data_service/remote/http/remote_event_data_service.rb b/lib/metasploit/framework/data_service/remote/http/remote_event_data_service.rb index 26b878420f..748131c92a 100644 --- a/lib/metasploit/framework/data_service/remote/http/remote_event_data_service.rb +++ b/lib/metasploit/framework/data_service/remote/http/remote_event_data_service.rb @@ -1,5 +1,15 @@ +require 'metasploit/framework/data_service/remote/http/response_data_helper' + module RemoteEventDataService + include ResponseDataHelper + EVENT_API_PATH = '/api/v1/events' + EVENT_MDM_CLASS = 'Mdm::Event' + + def events(opts) + path = get_path_select(opts, EVENT_API_PATH) + json_to_mdm_object(self.get_data(path, nil, opts), EVENT_MDM_CLASS, []) + end def report_event(opts) self.post_data_async(EVENT_API_PATH, opts) diff --git a/lib/metasploit/framework/data_service/stubs/event_data_service.rb b/lib/metasploit/framework/data_service/stubs/event_data_service.rb index 72511ea8cb..fb37c3e1e7 100644 --- a/lib/metasploit/framework/data_service/stubs/event_data_service.rb +++ b/lib/metasploit/framework/data_service/stubs/event_data_service.rb @@ -1,7 +1,10 @@ module EventDataService + def events(opts) + raise 'EventDataService#events is not implemented' + end + def report_event(opts) raise 'EventDataService#report_event is not implemented' end - end \ No newline at end of file