Skip to content

Commit b325976

Browse files
committed
Finally working.
1 parent 5f3d3a3 commit b325976

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

modules/post/windows/gather/enum_prefetch.rb

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,9 @@ def gather_prefetch_info(name_offset, hash_offset, lastrun_offset, runcount_offs
7979

8080
# Finds the filename from the prefetch file
8181
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")
8385

8486
# Finds the run count from the prefetch file
8587
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
9597
# Finds the Creation timestamp (MACE)
9698
ct = client.priv.fs.get_file_mace(filename)
9799

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)
102103
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))
108105
prun = count['lpBuffer'].unpack('L*')[0]
109106
phash = hash['lpBuffer'].unpack('h*')[0].reverse
110107
lmod = lm['Modified'].utc
111108
creat = ct['Created'].utc
112109
end
110+
113111
table << [lmod,creat,prun,phash,pname]
114112
client.railgun.kernel32.CloseHandle(handle)
115113
end
@@ -191,7 +189,7 @@ def run
191189
# Goes through the files in Prefetch directory, creates file paths for the
192190
# gather_prefetch_info function that enumerates all the pf info
193191

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)
195193
if getfile_prefetch_filenames.empty? or getfile_prefetch_filenames.nil?
196194
print_error("Could not find/access any .pf files. Can't continue.")
197195
return nil

0 commit comments

Comments
 (0)