Land #7556, Prevent psexec_command from dying when one host errors
commit
f50e609d12
|
@ -99,9 +99,9 @@ class MetasploitModule < Msf::Auxiliary
|
||||||
print_status("Executing the command...")
|
print_status("Executing the command...")
|
||||||
begin
|
begin
|
||||||
return psexec(execute)
|
return psexec(execute)
|
||||||
rescue Rex::Proto::DCERPC::Exceptions::Error, Rex::Proto::SMB::Exceptions::Error => exec_command_error
|
rescue Rex::Proto::DCERPC::Exceptions::Error, Rex::Proto::SMB::Exceptions::Error => e
|
||||||
elog("#{e.class} #{e.message}\n#{e.backtrace * "\n"}", 'rex', LEV_3)
|
elog("#{e.class} #{e.message}\n#{e.backtrace * "\n"}", 'rex', LEV_3)
|
||||||
print_error("Unable to execute specified command: #{exec_command_error}")
|
print_error("Unable to execute specified command: #{e}")
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -136,8 +136,13 @@ class MetasploitModule < Msf::Auxiliary
|
||||||
|
|
||||||
# check if our process is done using these files
|
# check if our process is done using these files
|
||||||
def exclusive_access(*files)
|
def exclusive_access(*files)
|
||||||
|
begin
|
||||||
simple.connect("\\\\#{@ip}\\#{@smbshare}")
|
simple.connect("\\\\#{@ip}\\#{@smbshare}")
|
||||||
files.each do |file|
|
rescue Rex::Proto::SMB::Exceptions::ErrorCode => accesserror
|
||||||
|
print_status("Unable to get handle: #{accesserror}")
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
files.each do |file|
|
||||||
begin
|
begin
|
||||||
print_status("checking if the file is unlocked")
|
print_status("checking if the file is unlocked")
|
||||||
fd = smb_open(file, 'rwo')
|
fd = smb_open(file, 'rwo')
|
||||||
|
@ -154,7 +159,12 @@ class MetasploitModule < Msf::Auxiliary
|
||||||
|
|
||||||
# Removes files created during execution.
|
# Removes files created during execution.
|
||||||
def cleanup_after(*files)
|
def cleanup_after(*files)
|
||||||
simple.connect("\\\\#{@ip}\\#{@smbshare}")
|
begin
|
||||||
|
simple.connect("\\\\#{@ip}\\#{@smbshare}")
|
||||||
|
rescue Rex::Proto::SMB::Exceptions::ErrorCode => accesserror
|
||||||
|
print_error("Unable to connect for cleanup: #{accesserror}. Maybe you'll need to manually remove #{files.join(", ")} from the target.")
|
||||||
|
return
|
||||||
|
end
|
||||||
print_status("Executing cleanup...")
|
print_status("Executing cleanup...")
|
||||||
files.each do |file|
|
files.each do |file|
|
||||||
begin
|
begin
|
||||||
|
|
Loading…
Reference in New Issue