4
4
# web site for more information on licensing and terms of use.
5
5
# http://metasploit.com/
6
6
##
7
-
8
7
require 'msf/core'
9
8
require 'rex'
10
9
require 'msf/core/post/windows/registry'
11
-
12
10
class Metasploit3 < Msf ::Post
13
- include Msf ::Post ::Windows ::Priv
14
-
15
- def initialize ( info = { } )
16
- super ( update_info ( info ,
17
- 'Name' => 'Windows Gather Prefetch File Information' ,
18
- 'Description' => %q{This module gathers prefetch file information from WinXP & Win7 systems.} ,
19
- 'License' => MSF_LICENSE ,
20
- 'Author' => [ 'TJ Glad <fraktaali[at]gmail.com>' ] ,
21
- 'Platform' => [ 'win' ] ,
22
- 'SessionType' => [ 'meterpreter' ]
23
- ) )
24
-
25
- end
11
+ include Msf ::Post ::Windows ::Priv
12
+
13
+ def initialize ( info = { } )
14
+ super ( update_info ( info ,
15
+ 'Name' => 'Windows Gather Prefetch File Information' ,
16
+ 'Description' => %q{This module gathers prefetch file information from WinXP & Win7 systems.} ,
17
+ 'License' => MSF_LICENSE ,
18
+ 'Author' => [ 'TJ Glad <fraktaali[at]gmail.com>' ] ,
19
+ 'Platform' => [ 'win' ] ,
20
+ 'SessionType' => [ 'meterpreter' ]
21
+ ) )
22
+ end
26
23
27
24
28
25
def prefetch_key_value ( )
@@ -73,7 +70,7 @@ def timezone_key_values(key_value)
73
70
def gather_prefetch_info ( name_offset , hash_offset , lastrun_offset , runcount_offset , filename , table )
74
71
75
72
# This function seeks and gathers information from specific offsets.
76
- h = client . railgun . kernel32 . CreateFileA ( filename , "GENERIC_READ" , "FILE_SHARE_DELETE|FILE_SHARE_READ|FILE_SHARE_WRITE" , nil , "OPEN_EXISTING" , "FILE_ATTRIBUTE_NORMAL " , 0 )
73
+ h = client . railgun . kernel32 . CreateFileA ( filename , "GENERIC_READ" , "FILE_SHARE_DELETE|FILE_SHARE_READ|FILE_SHARE_WRITE" , nil , "OPEN_EXISTING" , "FILE_ATTRIBUTE_READONLY " , nil )
77
74
78
75
if h [ 'GetLastError' ] != 0
79
76
print_error ( "Error opening a file handle." )
@@ -190,11 +187,14 @@ def run
190
187
191
188
# Goes through the files in Prefetch directory, creates file paths for the
192
189
# gather_prefetch_info function that enumerates all the pf info
190
+
193
191
getfile_prefetch_filenames = client . fs . file . search ( full_path , file_type , recurse = false , timeout = -1 )
194
192
getfile_prefetch_filenames . each do |file |
195
193
if file . empty? or file . nil?
196
194
print_error ( "Could not open file: %s." % file [ 'name' ] )
195
+
197
196
else
197
+
198
198
filename = File . join ( file [ 'path' ] , file [ 'name' ] )
199
199
gather_prefetch_info ( name_offset , hash_offset , lastrun_offset , runcount_offset , filename , table )
200
200
end
@@ -207,5 +207,6 @@ def run
207
207
print_line ( "\n " + results + "\n " )
208
208
print_status ( "Finished gathering information from prefetch files." )
209
209
print_status ( "Results stored in: #{ loot } " )
210
+
210
211
end
211
212
end
0 commit comments