From 18075f9b689eef18db02b343838ce0155be63078 Mon Sep 17 00:00:00 2001 From: HD Moore Date: Tue, 16 Mar 2010 15:11:07 +0000 Subject: [PATCH] Store session UUID and username git-svn-id: file:///home/svn/framework3/trunk@8830 4d416f70-5f16-0410-b530-b9f4589650da --- lib/msf/core/framework.rb | 9 +++++++-- lib/msf/core/module.rb | 7 +++++++ lib/msf/core/session.rb | 17 +++++++++++++---- 3 files changed, 27 insertions(+), 6 deletions(-) diff --git a/lib/msf/core/framework.rb b/lib/msf/core/framework.rb index f94e9527c1..e2924cdd07 100644 --- a/lib/msf/core/framework.rb +++ b/lib/msf/core/framework.rb @@ -247,8 +247,13 @@ class FrameworkEventSubscriber :name => name, :host => address, :info => { - :session_id => session.sid, - :via_exploit => session.via_exploit + :session_id => session.sid, + :session_info => session.info, + :session_uuid => session.uuid, + :username => session.username, + :target_host => session.target_host, + :via_exploit => session.via_exploit, + :via_payload => session.via_payload }.merge(opts) } report_event(event) diff --git a/lib/msf/core/module.rb b/lib/msf/core/module.rb index fc4ee95aeb..b4393af882 100644 --- a/lib/msf/core/module.rb +++ b/lib/msf/core/module.rb @@ -308,6 +308,13 @@ class Module (framework.db and framework.db.active and framework.db.workspace and framework.db.workspace.name) end + # + # Returns the username that instantiated this module + # + def owner + self.datastore['MODULE_OWNER'] + end + # # Returns whether or not this module is compatible with the supplied # module. diff --git a/lib/msf/core/session.rb b/lib/msf/core/session.rb index 2fc9c43295..c6698c131d 100644 --- a/lib/msf/core/session.rb +++ b/lib/msf/core/session.rb @@ -61,6 +61,7 @@ module Session def initialize self.alive = true + self.uuid = Rex::Text.rand_text_alpha(32) end # Direct descendents @@ -190,12 +191,12 @@ module Session # exploit instance. # def set_from_exploit(m) - self.via = { - 'Exploit' => m.fullname, - 'Payload' => 'payload/' + m.datastore['PAYLOAD'].to_s - } + self.via = { 'Exploit' => m.fullname } + self.via['Payload'] = ('payload/' + m.datastore['PAYLOAD'].to_s) if m.datastore['PAYLOAD'] + self.target_host = m.target_host self.workspace = m.workspace + self.username = m.owner self.exploit_datastore = m.datastore self.user_input = m.user_input if m.user_input self.user_output = m.user_output if m.user_output @@ -275,6 +276,14 @@ module Session # The specific identified session info # attr_accessor :info + # + # The unique identifier of this session + # + attr_accessor :uuid + # + # The associated username + # + attr_accessor :username protected attr_accessor :via # :nodoc: