Changed error handeling of command.rb module

unstable
Royce Davis 2012-11-07 15:03:31 -06:00
parent ac518f7091
commit d159aa6f9f
1 changed files with 8 additions and 7 deletions

View File

@ -73,14 +73,14 @@ class Metasploit3 < Msf::Auxiliary
end end
smbshare = datastore['SMBSHARE'] smbshare = datastore['SMBSHARE']
begin
execute_command(smbshare, ip, cmd, text, bat) if execute_command(smbshare, ip, cmd, text, bat)
get_output(smbshare, ip, text) get_output(smbshare, ip, text)
else
cleanup_after(smbshare, ip, cmd, text, bat) cleanup_after(smbshare, ip, cmd, text, bat)
rescue
# Something went terribly wrong
return return
end end
cleanup_after(smbshare, ip, cmd, text, bat)
end end
@ -95,9 +95,10 @@ class Metasploit3 < Msf::Auxiliary
simple.connect(smbshare) simple.connect(smbshare)
print_status("Executing your command on host: #{ip}") print_status("Executing your command on host: #{ip}")
psexec(smbshare, execute) psexec(smbshare, execute)
return True
rescue StandardError => execerror rescue StandardError => execerror
print_error("Unable to execute specified command: #{execerror}") print_error("#{ip} - Unable to execute specified command: #{execerror}")
return execerror return False
end end
end end
@ -120,7 +121,7 @@ class Metasploit3 < Msf::Auxiliary
print_good("Command completed successfuly! Output from: #{ip}\r\n#{output}") print_good("Command completed successfuly! Output from: #{ip}\r\n#{output}")
rescue StandardError => output_error rescue StandardError => output_error
print_error("#{ip} - Error getting command output. #{output_error.class}. #{output_error}.") print_error("#{ip} - Error getting command output. #{output_error.class}. #{output_error}.")
return return output_error
end end
end end