metasploit-framework/modules/post/windows/gather/ntds_location.rb

47 lines
1.5 KiB
Ruby
Raw Normal View History

2015-12-15 22:31:00 +00:00
##
# This module requires Metasploit: http://metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
##
2016-03-08 13:02:44 +00:00
class MetasploitModule < Msf::Post
2015-12-15 22:31:00 +00:00
include Msf::Post::File
include Msf::Post::Windows::Registry
def initialize(info = {})
super(update_info(info,
2015-12-18 05:25:15 +00:00
'Name' => 'Post Windows Gather NTDS.DIT Location',
'Description' => %q{
This module will find the location of the NTDS.DIT file (from the Registry),
check that it exists, and display its location on the screen, which is useful
if you wish to manually acquire the file using ntdsutil or vss.
},
'Author' => ['Stuart Morgan <stuart.morgan[at]mwrinfosecurity.com>'],
'License' => MSF_LICENSE,
'Platform' => ['win'],
'SessionTypes' => ['meterpreter']
))
2015-12-15 22:31:00 +00:00
end
def run
2015-12-18 05:25:15 +00:00
# Find the location of NTDS.DIT in the Registry
ntds = registry_getvaldata('HKLM\\SYSTEM\\CurrentControlSet\\Services\\NTDS\\Parameters', 'DSA Database file')
2015-12-15 23:12:14 +00:00
unless ntds
2015-12-18 05:25:15 +00:00
print_error('Unable to find the location of NTDS.DIT')
2015-12-15 23:12:14 +00:00
return
2015-12-15 23:10:06 +00:00
end
if file?(ntds)
2015-12-15 23:12:14 +00:00
f = client.fs.file.stat(ntds)
print_line("NTDS.DIT is located at: #{ntds}")
2015-12-15 23:13:02 +00:00
print_line(" Size: #{f.size.to_s} bytes")
print_line(" Created: #{f.ctime.to_s}")
print_line(" Modified: #{f.mtime.to_s}")
print_line(" Accessed: #{f.atime.to_s}")
2015-12-15 23:10:06 +00:00
else
2015-12-18 21:41:38 +00:00
print_error("NTDS.DIT is reportedly located at `#{ntds}', but the file does not appear to exist")
2015-12-15 23:10:06 +00:00
end
2015-12-15 22:31:00 +00:00
end
2015-12-18 05:25:15 +00:00
2015-12-15 22:31:00 +00:00
end