Skip to content

Commit 42aa2e5

Browse files
David MaloneyDavid Maloney
authored andcommitted
add some attempts at debugging to ntds
add some logging and more status outputs to the NTDS domain hasdump. Also force the encoding on strings to UTF8
1 parent 91c337b commit 42aa2e5

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

lib/metasploit/framework/ntds/account.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ def get_int(data)
137137
end
138138

139139
def get_string(data,length)
140-
data.slice!(0,length).gsub(/\x00/,'')
140+
data.slice!(0,length).force_encoding("UTF-8").gsub(/\x00/,'')
141141
end
142142

143143
def uac_string

lib/metasploit/framework/ntds/parser.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,13 @@ def each_account
5050

5151
def pull_batch
5252
if channel.cid.nil?
53+
dlog("NTDS Parser Channel was closed, reopening")
5354
reopen_channel
5455
end
5556
begin
5657
raw_batch_data = channel.read(BATCH_SIZE)
57-
rescue EOFError
58+
rescue EOFError => e
59+
elog("NTDS Parser: Error pulling batch - #{e}")
5860
raw_batch_data = nil
5961
end
6062
raw_batch_data

modules/post/windows/gather/credentials/domain_hashdump.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,13 @@ def run
3333
if preconditions_met?
3434
ntds_file = copy_database_file
3535
unless ntds_file.nil?
36+
file_stat = client.fs.file.stat(ntds_file)
37+
print_status "NTDS File Size: #{file_stat.size.to_s} bytes"
3638
print_status "Repairing NTDS database after copy..."
3739
print_status repair_ntds(ntds_file)
3840
realm = sysinfo["Domain"]
3941
ntds_parser = Metasploit::Framework::NTDS::Parser.new(client, ntds_file)
42+
print_status "Started up NTDS channel. Preparing to stream results..."
4043
ntds_parser.each_account do |ad_account|
4144
print_good ad_account.to_s
4245
report_hash(ad_account.ntlm_hash.downcase, ad_account.name, realm)
@@ -46,6 +49,7 @@ def run
4649
report_hash(hash_string.downcase,ad_account.name, realm)
4750
end
4851
end
52+
print_status "Deleting backup of NTDS.dit at #{ntds_file}"
4953
rm_f(ntds_file)
5054
end
5155
end

0 commit comments

Comments
 (0)