Skip to content

Commit 7fa8717

Browse files
Royce DavisRoyce Davis
authored andcommitted
Fixed cleanup method to report an Error on command.rb
1 parent f9b4971 commit 7fa8717

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

modules/auxiliary/admin/smb/command.rb

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,11 @@ def cleanup_after(smbshare, ip, text, bat)
119119
simple.connect(smbshare)
120120
print_status("Executing cleanup on host: #{ip}")
121121
psexec(smbshare, cleanup)
122-
#if !check_cleanup(smbshare, ip, text)
123-
# print_error("#{ip} - Unable to cleanup. Need to manually remove #{text} and #{bat} from the target.")
124-
#end
122+
if !check_cleanup(smbshare, ip, text)
123+
print_error("#{ip} - Unable to cleanup. Need to manually remove #{text} and #{bat} from the target.")
124+
else
125+
print_status("#{ip} - Cleanup was successful")
126+
end
125127
rescue StandardError => cleanuperror
126128
print_error("Unable to processes cleanup commands: #{cleanuperror}")
127129
return cleanuperror
@@ -132,13 +134,18 @@ def cleanup_after(smbshare, ip, text, bat)
132134

133135
def check_cleanup(smbshare, ip, text)
134136
simple.connect("\\\\#{ip}\\#{smbshare}")
135-
if checktext = simple.open(text, 'ro')
136-
check = false
137-
else
138-
check = true
137+
begin
138+
if checktext = simple.open(text, 'ro')
139+
check = false
140+
else
141+
check = true
142+
end
143+
simple.disconnect("\\\\#{ip}\\#{smbshare}")
144+
return check
145+
rescue StandardError => check_error
146+
simple.disconnect("\\\\#{ip}\\#{smbshare}")
147+
return true
139148
end
140-
simple.disconnect("\\\\#{ip}\\#{smbshare}")
141-
return check
142149
end
143150

144151

0 commit comments

Comments
 (0)