@@ -79,7 +79,9 @@ def gather_prefetch_info(name_offset, hash_offset, lastrun_offset, runcount_offs
79
79
80
80
# Finds the filename from the prefetch file
81
81
client . railgun . kernel32 . SetFilePointer ( handle , name_offset , 0 , nil )
82
- name = client . railgun . kernel32 . ReadFile ( handle , 60 , 60 , 4 , nil )
82
+ fname = client . railgun . kernel32 . ReadFile ( handle , 60 , 60 , 4 , nil )
83
+ name = fname [ 'lpBuffer' ]
84
+ idx = name . index ( "\x00 \x00 " )
83
85
84
86
# Finds the run count from the prefetch file
85
87
client . railgun . kernel32 . SetFilePointer ( handle , runcount_offset , 0 , nil )
@@ -95,21 +97,17 @@ def gather_prefetch_info(name_offset, hash_offset, lastrun_offset, runcount_offs
95
97
# Finds the Creation timestamp (MACE)
96
98
ct = client . priv . fs . get_file_mace ( filename )
97
99
98
- # Next we check everything was read successfully and prepare the results
99
- if name . nil? or name . empty? or count . nil? or hash . nil? or lm . nil? or ct . nil?
100
-
101
- print_error ( "Read failed on file: %s" % filename )
100
+ # Checking and moving the values
101
+ if idx . nil? or count . nil? or hash . nil? or lm . nil? or ct . nil?
102
+ print_error ( "Error reading file (might be temporary): %s" % filename )
102
103
else
103
- # Preparing the values
104
- x = name [ 'lpBuffer' ]
105
- pname = Rex ::Text . to_ascii ( x . slice ( 0 ..x . index ( "\x00 \x00 " ) ) )
106
- #x = Rex::Text.to_ascii(name['lpBuffer'])
107
- #pname = x.slice(0..x.index(".EXE"))
104
+ pname = Rex ::Text . to_ascii ( name . slice ( 0 ..idx ) )
108
105
prun = count [ 'lpBuffer' ] . unpack ( 'L*' ) [ 0 ]
109
106
phash = hash [ 'lpBuffer' ] . unpack ( 'h*' ) [ 0 ] . reverse
110
107
lmod = lm [ 'Modified' ] . utc
111
108
creat = ct [ 'Created' ] . utc
112
109
end
110
+
113
111
table << [ lmod , creat , prun , phash , pname ]
114
112
client . railgun . kernel32 . CloseHandle ( handle )
115
113
end
@@ -191,7 +189,7 @@ def run
191
189
# Goes through the files in Prefetch directory, creates file paths for the
192
190
# gather_prefetch_info function that enumerates all the pf info
193
191
194
- getfile_prefetch_filenames = client . fs . file . search ( full_path , file_type , recurse = false , timeout = 10 )
192
+ getfile_prefetch_filenames = client . fs . file . search ( full_path , file_type , timeout = - 1 )
195
193
if getfile_prefetch_filenames . empty? or getfile_prefetch_filenames . nil?
196
194
print_error ( "Could not find/access any .pf files. Can't continue." )
197
195
return nil
0 commit comments