Skip to content

Commit 69dd7f5

Browse files
David MaloneyDavid Maloney
authored andcommitted
Update Mdm and Add Task stuff to report
make report_* methods aware of Tasks [Story #49167601]
1 parent 882c550 commit 69dd7f5

File tree

4 files changed

+88
-18
lines changed

4 files changed

+88
-18
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.14.3'
18+
gem 'metasploit_data_models', '~> 0.15.0'
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.14.3)
26+
metasploit_data_models (0.15.0)
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.14.3)
68+
metasploit_data_models (~> 0.15.0)
6969
msgpack
7070
nokogiri
7171
pcaprub

lib/msf/core/auxiliary/report.rb

Lines changed: 59 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,17 @@ def db
2121

2222
def myworkspace
2323
@myworkspace = framework.db.find_workspace(self.workspace)
24-
end
24+
end
25+
26+
def mytask
27+
if self[:task]
28+
return self[:task].record
29+
elsif @task && @task.class == Mdm::Task
30+
return @task
31+
else
32+
return nil
33+
end
34+
end
2535

2636
def inside_workspace_boundary?(ip)
2737
return true if not framework.db.active
@@ -41,7 +51,10 @@ def inside_workspace_boundary?(ip)
4151
#
4252
def report_host(opts)
4353
return if not db
44-
opts = {:workspace => myworkspace}.merge(opts)
54+
opts = {
55+
:workspace => myworkspace,
56+
:task => mytask
57+
}.merge(opts)
4558
framework.db.report_host(opts)
4659
end
4760

@@ -63,7 +76,10 @@ def get_host(opts)
6376
#
6477
def report_client(opts={})
6578
return if not db
66-
opts = {:workspace => myworkspace}.merge(opts)
79+
opts = {
80+
:workspace => myworkspace,
81+
:task => mytask
82+
}.merge(opts)
6783
framework.db.report_client(opts)
6884
end
6985

@@ -78,63 +94,93 @@ def get_client(opts={})
7894
#
7995
def report_service(opts={})
8096
return if not db
81-
opts = {:workspace => myworkspace}.merge(opts)
97+
opts = {
98+
:workspace => myworkspace,
99+
:task => mytask
100+
}.merge(opts)
82101
framework.db.report_service(opts)
83102
end
84103

85104
def report_note(opts={})
86105
return if not db
87-
opts = {:workspace => myworkspace}.merge(opts)
106+
opts = {
107+
:workspace => myworkspace,
108+
:task => mytask
109+
}.merge(opts)
88110
framework.db.report_note(opts)
89111
end
90112

91113
def report_auth_info(opts={})
92114
return if not db
93-
opts = {:workspace => myworkspace}.merge(opts)
115+
opts = {
116+
:workspace => myworkspace,
117+
:task => mytask
118+
}.merge(opts)
94119
framework.db.report_auth_info(opts)
95120
end
96121

97122
def report_vuln(opts={})
98123
return if not db
99-
opts = {:workspace => myworkspace}.merge(opts)
124+
opts = {
125+
:workspace => myworkspace,
126+
:task => mytask
127+
}.merge(opts)
100128
framework.db.report_vuln(opts)
101129
end
102130

103131
# This will simply log a deprecation warning, since report_exploit()
104132
# is no longer implemented.
105133
def report_exploit(opts={})
106134
return if not db
107-
opts = {:workspace => myworkspace}.merge(opts)
135+
opts = {
136+
:workspace => myworkspace,
137+
:task => mytask
138+
}.merge(opts)
108139
framework.db.report_exploit(opts)
109140
end
110141

111142
def report_loot(opts={})
112143
return if not db
113-
opts = {:workspace => myworkspace}.merge(opts)
144+
opts = {
145+
:workspace => myworkspace,
146+
:task => mytask
147+
}.merge(opts)
114148
framework.db.report_loot(opts)
115149
end
116150

117151
def report_web_site(opts={})
118152
return if not db
119-
opts = {:workspace => myworkspace}.merge(opts)
153+
opts = {
154+
:workspace => myworkspace,
155+
:task => mytask
156+
}.merge(opts)
120157
framework.db.report_web_site(opts)
121158
end
122159

123160
def report_web_page(opts={})
124161
return if not db
125-
opts = {:workspace => myworkspace}.merge(opts)
162+
opts = {
163+
:workspace => myworkspace,
164+
:task => mytask
165+
}.merge(opts)
126166
framework.db.report_web_page(opts)
127167
end
128168

129169
def report_web_form(opts={})
130170
return if not db
131-
opts = {:workspace => myworkspace}.merge(opts)
171+
opts = {
172+
:workspace => myworkspace,
173+
:task => mytask
174+
}.merge(opts)
132175
framework.db.report_web_form(opts)
133176
end
134177

135178
def report_web_vuln(opts={})
136179
return if not db
137-
opts = {:workspace => myworkspace}.merge(opts)
180+
opts = {
181+
:workspace => myworkspace,
182+
:task => mytask
183+
}.merge(opts)
138184
framework.db.report_web_vuln(opts)
139185
end
140186

lib/msf/core/db.rb

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,13 @@ def report_host(opts)
376376
host.save!
377377
end
378378

379+
if opts[:task]
380+
Mdm::TaskHost.new(
381+
:task => opts[:task],
382+
:host => host
383+
)
384+
end
385+
379386
host
380387
}
381388
end
@@ -592,7 +599,15 @@ def report_service(opts)
592599
if (service and service.changed?)
593600
msf_import_timestamps(opts,service)
594601
service.save!
595-
end
602+
end
603+
604+
if opts[:task]
605+
Mdm::TaskService.new(
606+
:task => opts[:task],
607+
:service => service
608+
)
609+
end
610+
596611
ret[:service] = service
597612
}
598613
end
@@ -1588,7 +1603,16 @@ def report_auth_info(opts={})
15881603
unless opts[:updated_at] || opts["updated_at"]
15891604
cred.updated_at = Time.now.utc
15901605
cred.save!
1591-
end
1606+
end
1607+
1608+
if opts[:task]
1609+
require 'pry'
1610+
binding.pry
1611+
Mdm::TaskCred.new(
1612+
:task => opts[:task],
1613+
:cred => cred
1614+
)
1615+
end
15921616

15931617
ret[:cred] = cred
15941618
end

0 commit comments

Comments
 (0)