Windows Gather Prefetch File Information - Metasploit
This page contains detailed information about how to use the post/windows/gather/enum_prefetch metasploit module. For list of all metasploit modules, visit the Metasploit Module Library.
Module Overview
Name: Windows Gather Prefetch File Information
Module: post/windows/gather/enum_prefetch
Source code: modules/post/windows/gather/enum_prefetch.rb
Disclosure date: -
Last modification time: 2021-10-06 13:43:31 +0000
Supported architecture(s): -
Supported platform(s): Windows
Target service / protocol: -
Target network port(s): -
List of CVEs: -
This module gathers prefetch file information from WinXP, Win2k3 and Win7 systems and current values of related registry keys. From each prefetch file we'll collect filetime (converted to utc) of the last execution, file path hash, run count, filename and the execution path.
Module Ranking and Traits
Module Ranking:
- normal: The exploit is otherwise reliable, but depends on a specific version and can't (or doesn't) reliably autodetect. More information about ranking can be found here.
Basic Usage
There are two ways to execute this post module.
From the Meterpreter prompt
The first is by using the "run" command at the Meterpreter prompt. It allows you to run the post module against that specific session:
meterpreter > run post/windows/gather/enum_prefetch
From the msf prompt
The second is by using the "use" command at the msf prompt. You will have to figure out which session ID to set manually. To list all session IDs, you can use the "sessions" command.
msf > use post/windows/gather/enum_prefetch
msf post(enum_prefetch) > show options
... show and set options ...
msf post(enum_prefetch) > set SESSION session-id
msf post(enum_prefetch) > exploit
If you wish to run the post against all sessions from framework, here is how:
1 - Create the following resource script:
framework.sessions.each_pair do |sid, session|
run_single("use post/windows/gather/enum_prefetch")
run_single("set SESSION #{sid}")
run_single("run")
end
2 - At the msf prompt, execute the above resource script:
msf > resource path-to-resource-script
Required Options
- SESSION: The session to run this module on.
Go back to menu.
Msfconsole Usage
Here is how the windows/gather/enum_prefetch post exploitation module looks in the msfconsole:
msf6 > use post/windows/gather/enum_prefetch
msf6 post(windows/gather/enum_prefetch) > show info
Name: Windows Gather Prefetch File Information
Module: post/windows/gather/enum_prefetch
Platform: Windows
Arch:
Rank: Normal
Provided by:
TJ Glad <[email protected]>
Compatible session types:
Basic options:
Name Current Setting Required Description
---- --------------- -------- -----------
SESSION yes The session to run this module on.
Description:
This module gathers prefetch file information from WinXP, Win2k3 and
Win7 systems and current values of related registry keys. From each
prefetch file we'll collect filetime (converted to utc) of the last
execution, file path hash, run count, filename and the execution
path.
Module Options
This is a complete list of options available in the windows/gather/enum_prefetch post exploitation module:
msf6 post(windows/gather/enum_prefetch) > show options
Module options (post/windows/gather/enum_prefetch):
Name Current Setting Required Description
---- --------------- -------- -----------
SESSION yes The session to run this module on.
Advanced Options
Here is a complete list of advanced options supported by the windows/gather/enum_prefetch post exploitation module:
msf6 post(windows/gather/enum_prefetch) > show advanced
Module advanced options (post/windows/gather/enum_prefetch):
Name Current Setting Required Description
---- --------------- -------- -----------
VERBOSE false no Enable detailed status messages
WORKSPACE no Specify the workspace for this module
Post Actions
This is a list of all post exploitation actions which the windows/gather/enum_prefetch module can do:
msf6 post(windows/gather/enum_prefetch) > show actions
Post actions:
Name Description
---- -----------
Evasion Options
Here is the full list of possible evasion options supported by the windows/gather/enum_prefetch post exploitation module in order to evade defenses (e.g. Antivirus, EDR, Firewall, NIDS etc.):
msf6 post(windows/gather/enum_prefetch) > show evasion
Module evasion options:
Name Current Setting Required Description
---- --------------- -------- -----------
Go back to menu.
Error Messages
This module may fail with the following error messages:
- EnablePrefetcher Value: (0) = Disabled (Non-Default).
- No value or unknown value. Results might vary.
- Couldn't read file: <FILENAME>
- You don't have enough privileges. Try getsystem.
- No offsets for the target Windows version. Currently works only on WinXP, Win2k3 and Win7.
- Could not find/access any .pf files. Can't continue. (Might be temporary error..)
Check for the possible causes from the code snippets below found in the module source code. This can often times help in identifying the root cause of the problem.
EnablePrefetcher Value: (0) = Disabled (Non-Default).
Here is a relevant code snippet related to the "EnablePrefetcher Value: (0) = Disabled (Non-Default)." error message:
29:
30: def print_prefetch_key_value()
31: # Checks if Prefetch registry key exists and what value it has.
32: prefetch_key_value = registry_getvaldata("HKLM\\SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Memory Management\\PrefetchParameters", "EnablePrefetcher")
33: if prefetch_key_value == 0
34: print_error("EnablePrefetcher Value: (0) = Disabled (Non-Default).")
35: elsif prefetch_key_value == 1
36: print_good("EnablePrefetcher Value: (1) = Application launch prefetching enabled (Non-Default).")
37: elsif prefetch_key_value == 2
38: print_good("EnablePrefetcher Value: (2) = Boot prefetching enabled (Non-Default, excl. Win2k3).")
39: elsif prefetch_key_value == 3
No value or unknown value. Results might vary.
Here is a relevant code snippet related to the "No value or unknown value. Results might vary." error message:
37: elsif prefetch_key_value == 2
38: print_good("EnablePrefetcher Value: (2) = Boot prefetching enabled (Non-Default, excl. Win2k3).")
39: elsif prefetch_key_value == 3
40: print_good("EnablePrefetcher Value: (3) = Applaunch and boot enabled (Default Value, excl. Win2k3).")
41: else
42: print_error("No value or unknown value. Results might vary.")
43: end
44: end
45:
46: def print_timezone_key_values(key_value)
47: # Looks for timezone information from registry.
Couldn't read file: <FILENAME>
Here is a relevant code snippet related to the "Couldn't read file: <FILENAME>" error message:
65: # Collects the desired information from each prefetch file found
66: # from the system.
67:
68: prefetch_file = read_file(filename)
69: if prefetch_file.blank?
70: print_error("Couldn't read file: #{filename}")
71: return nil
72: else
73: # First we extract the saved filename
74: pf_filename = prefetch_file[name_offset, 60]
75: idx = pf_filename.index("\x00\x00")
You don't have enough privileges. Try getsystem.
Here is a relevant code snippet related to the "You don't have enough privileges. Try getsystem." error message:
129: # Tested on WinXP, Win2k3 and Win7 systems.
130: # http://www.forensicswiki.org/wiki/Prefetch
131: # http://www.forensicswiki.org/wiki/Windows_Prefetch_File_Format
132:
133: sysnfo = client.sys.config.sysinfo['OS']
134: error_msg = "You don't have enough privileges. Try getsystem."
135:
136: if sysnfo =~ /(Windows XP|2003|.NET)/
137:
138: if not is_admin?
139: print_error(error_msg)
No offsets for the target Windows version. Currently works only on WinXP, Win2k3 and Win7.
Here is a relevant code snippet related to the "No offsets for the target Windows version. Currently works only on WinXP, Win2k3 and Win7." error message:
162: runcount_offset = 0x98
163: filetime_offset = 0x78
164: # Registry key for timezone
165: key_value = "TimeZoneKeyName"
166: else
167: print_error("No offsets for the target Windows version. Currently works only on WinXP, Win2k3 and Win7.")
168: return nil
169: end
170:
171: table = Rex::Text::Table.new(
172: 'Header' => "Prefetch Information",
Could not find/access any .pf files. Can't continue. (Might be temporary error..)
Here is a relevant code snippet related to the "Could not find/access any .pf files. Can't continue. (Might be temporary error..)" error message:
192: # Goes through the files in Prefetch directory, creates file paths for the
193: # gather_pf_info function that enumerates all the pf info
194:
195: getfile_prefetch_filenames = client.fs.file.search(full_path, file_type)
196: if getfile_prefetch_filenames.empty? or getfile_prefetch_filenames.nil?
197: print_error("Could not find/access any .pf files. Can't continue. (Might be temporary error..)")
198: return nil
199: else
200: getfile_prefetch_filenames.each do |file|
201: if file.empty? or file.nil?
202: next
Go back to menu.
Related Pull Requests
- #8338 Merged Pull Request: Fix msf/core and self.class msftidy warnings
- #7200 Merged Pull Request: Rex::Ui::Text cleanup
- #6655 Merged Pull Request: use MetasploitModule as a class name
- #6648 Merged Pull Request: Change metasploit class names
- #2782 Merged Pull Request: Stop abusing expand path
- #2738 Merged Pull Request: Update for enum_prefetch post module
- #2525 Merged Pull Request: Change module boilerplate
- #2304 Merged Pull Request: Fix load order in posts, hopefully forever
- #2108 Merged Pull Request: Feature/prefetch gather
Go back to menu.
See Also
Check also the following modules related to this module:
- post/windows/gather/enum_ad_bitlocker
- post/windows/gather/enum_ad_computers
- post/windows/gather/enum_ad_groups
- post/windows/gather/enum_ad_managedby_groups
- post/windows/gather/enum_ad_service_principal_names
- post/windows/gather/enum_ad_to_wordlist
- post/windows/gather/enum_ad_user_comments
- post/windows/gather/enum_ad_users
- post/windows/gather/enum_applications
- post/windows/gather/enum_artifacts
- post/windows/gather/enum_av
- post/windows/gather/enum_av_excluded
- post/windows/gather/enum_chocolatey_applications
- post/windows/gather/enum_chrome
- post/windows/gather/enum_computers
- post/windows/gather/enum_db
- post/windows/gather/enum_devices
- post/windows/gather/enum_dirperms
- post/windows/gather/enum_domain
- post/windows/gather/enum_domain_group_users
- post/windows/gather/enum_domains
- post/windows/gather/enum_domain_tokens
- post/windows/gather/enum_domain_users
- post/windows/gather/enum_emet
- post/windows/gather/enum_files
- post/windows/gather/enum_hostfile
- post/windows/gather/enum_hyperv_vms
- post/windows/gather/enum_ie
- post/windows/gather/enum_logged_on_users
- post/windows/gather/enum_ms_product_keys
- post/windows/gather/enum_muicache
- post/windows/gather/enum_onedrive
- post/windows/gather/enum_patches
- post/windows/gather/enum_powershell_env
- post/windows/gather/enum_proxy
- post/windows/gather/enum_putty_saved_sessions
- post/windows/gather/enum_services
- post/windows/gather/enum_shares
- post/windows/gather/enum_snmp
- post/windows/gather/enum_termserv
- post/windows/gather/enum_tokens
- post/windows/gather/enum_tomcat
- post/windows/gather/enum_trusted_locations
- post/windows/gather/enum_unattend
Authors
- TJ Glad <tjglad[at]cmail.nu>
Version
This page has been produced using Metasploit Framework version 6.1.41-dev. For more modules, visit the Metasploit Module Library.
Go back to menu.