Skip to content

Commit 95c1df2

Browse files
committed
Merge pull request rapid7#1908 from dmaloney-r7/feature/task_sssoc/sessions
Specs and functional tests passing, PT #51076813
2 parents 55af517 + 2e26256 commit 95c1df2

File tree

5 files changed

+26
-4
lines changed

5 files changed

+26
-4
lines changed

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ group :db do
1515
# Needed for Msf::DbManager
1616
gem 'activerecord'
1717
# Database models shared between framework and Pro.
18-
gem 'metasploit_data_models', '~> 0.16.0'
18+
gem 'metasploit_data_models', '~> 0.16.1'
1919
# Needed for module caching in Mdm::ModuleDetails
2020
gem 'pg', '>= 0.11'
2121
end

Gemfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ GEM
2323
i18n (0.6.1)
2424
json (1.7.7)
2525
metaclass (0.0.1)
26-
metasploit_data_models (0.16.0)
26+
metasploit_data_models (0.16.1)
2727
activerecord (>= 3.2.13)
2828
activesupport
2929
pg
@@ -65,7 +65,7 @@ DEPENDENCIES
6565
database_cleaner
6666
factory_girl (>= 4.1.0)
6767
json
68-
metasploit_data_models (~> 0.15.2)
68+
metasploit_data_models (~> 0.16.1)
6969
msgpack
7070
nokogiri
7171
pcaprub

db/schema.rb

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#
1212
# It's strongly recommended to check this file into your version control system.
1313

14-
ActiveRecord::Schema.define(:version => 20130531144949) do
14+
ActiveRecord::Schema.define(:version => 20130604145732) do
1515

1616
create_table "api_keys", :force => true do |t|
1717
t.text "token"
@@ -440,6 +440,13 @@
440440
t.datetime "updated_at", :null => false
441441
end
442442

443+
create_table "task_sessions", :force => true do |t|
444+
t.integer "task_id", :null => false
445+
t.integer "session_id", :null => false
446+
t.datetime "created_at", :null => false
447+
t.datetime "updated_at", :null => false
448+
end
449+
443450
create_table "tasks", :force => true do |t|
444451
t.integer "workspace_id", :default => 1, :null => false
445452
t.string "created_by"

lib/msf/core/db.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -786,6 +786,14 @@ def report_session(opts)
786786
s = ::Mdm::Session.new(sess_data)
787787
s.save!
788788

789+
if session and session.exploit_task and session.exploit_task.record
790+
session_task = session.exploit_task.record
791+
if session_task.class == Mdm::Task
792+
Mdm::TaskSession.create(:task => session_task, :session => s )
793+
end
794+
end
795+
796+
789797
if opts[:session]
790798
session.db_record = s
791799
end

lib/msf/core/session.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,9 @@ def set_from_exploit(m)
270270
self.user_output = m.user_output if m.user_output
271271
self.exploit_uuid = m.uuid
272272
self.exploit = m
273+
if m[:task]
274+
self.exploit_task = m[:task]
275+
end
273276
end
274277

275278
#
@@ -365,6 +368,10 @@ def alive?
365368
# The datastore of the exploit that created this session
366369
#
367370
attr_accessor :exploit_datastore
371+
#
372+
# The task that ran the exploit that got the session (that swallowed the fly)
373+
#
374+
attr_accessor :exploit_task
368375
#
369376
# The specific identified session info
370377
#

0 commit comments

Comments
 (0)