Fix report_session_event with remote data service

Modify DBManager method to allow session ID retrieval from a Hash
GSoC/Meterpreter_Web_Console
Matthew Kienow 2018-05-23 15:05:22 -04:00
parent 111536bf49
commit 2c92e85494
No known key found for this signature in database
GPG Key ID: 40787F8B1EAC6E41
2 changed files with 18 additions and 7 deletions

View File

@ -17,7 +17,7 @@ module SessionEventServlet
lambda {
begin
opts = parse_json_request(request, false)
data = get_db().session_events(opts)
data = get_db.session_events(opts)
set_json_response(data)
rescue => e
set_error_on_response(e)
@ -27,10 +27,14 @@ module SessionEventServlet
def self.report_session_event
lambda {
job = lambda { |opts|
opts[:session] = open_struct(opts[:session][:table])
get_db().report_session_event(opts) }
exec_report_job(request, &job)
begin
job = lambda { |opts|
get_db.report_session_event(opts)
}
exec_report_job(request, &job)
rescue => e
set_error_on_response(e)
end
}
end
end

View File

@ -11,7 +11,7 @@ module Msf::DBManager::SessionEvent
# Record a session event in the database
#
# opts MUST contain one of:
# +:session+:: the Msf::Session OR the ::Mdm::Session we are reporting
# +:session+:: the Msf::Session, Mdm::Session or Hash representation of Mdm::Session we are reporting
# +:etype+:: event type, enum: command, output, upload, download, filedelete
#
# opts may contain
@ -46,7 +46,14 @@ module Msf::DBManager::SessionEvent
event_data = { :created_at => opts[:created_at] }
end
event_data[:session_id] = session.id
session_id = nil
if session.kind_of?(Mdm::Session)
session_id = session.id
elsif session.is_a?(Hash) && session.key?(:id)
session_id = session[:id]
end
event_data[:session_id] = session_id
[:remote_path, :local_path, :output, :command, :etype].each do |attr|
event_data[attr] = opts[attr] if opts[attr]
end