diff --git a/modules/exploits/aix/rpc_cmsd_opcode21.rb b/modules/exploits/aix/rpc_cmsd_opcode21.rb index 1cec6d4be0..a8fb6c4567 100644 --- a/modules/exploits/aix/rpc_cmsd_opcode21.rb +++ b/modules/exploits/aix/rpc_cmsd_opcode21.rb @@ -88,7 +88,7 @@ class Metasploit3 < Msf::Exploit::Remote begin if (not sunrpc_create('udp', 100068, 4)) - raise RuntimeError, 'sunrpc_create failed' + fail_with(Exploit::Failure::Unknown, 'sunrpc_create failed') end # spray the heap a bit (work around powerpc cache issues) diff --git a/modules/exploits/bsdi/softcart/mercantec_softcart.rb b/modules/exploits/bsdi/softcart/mercantec_softcart.rb index e8c20766ec..085b11fe93 100644 --- a/modules/exploits/bsdi/softcart/mercantec_softcart.rb +++ b/modules/exploits/bsdi/softcart/mercantec_softcart.rb @@ -77,7 +77,7 @@ class Metasploit3 < Msf::Exploit::Remote 'uri' => datastore['URI'] }, 5) @mercantec = (res and res.body and res.body =~ /Copyright.*Mercantec/) - raise RuntimeError, "The target is not a Mercantec CGI" if not @mercantec + fail_with(Exploit::Failure::NotFound, "The target is not a Mercantec CGI") if not @mercantec end buffer = diff --git a/modules/exploits/freebsd/ftp/proftp_telnet_iac.rb b/modules/exploits/freebsd/ftp/proftp_telnet_iac.rb index 107a1c26be..00ab7533ca 100644 --- a/modules/exploits/freebsd/ftp/proftp_telnet_iac.rb +++ b/modules/exploits/freebsd/ftp/proftp_telnet_iac.rb @@ -153,7 +153,7 @@ class Metasploit3 < Msf::Exploit::Remote print_status("FTP Banner: #{banner.strip}") version = m[1] else - raise RuntimeError, "No matching target" + fail_with(Exploit::Failure::NoTarget, "No matching target") end regexp = Regexp.escape(version) @@ -165,14 +165,14 @@ class Metasploit3 < Msf::Exploit::Remote end if (not @mytarget) - raise RuntimeError, "No matching target" + fail_with(Exploit::Failure::NoTarget, "No matching target") end print_status("Selected Target: #{@mytarget.name}") pl = exploit_regenerate_payload(@mytarget.platform, arch) if not pl - raise RuntimeError, 'Unable to regenerate payload!' + fail_with(Exploit::Failure::Unknown, 'Unable to regenerate payload!') end else print_status("Trying target #{@mytarget.name}...") diff --git a/modules/exploits/freebsd/telnet/telnet_encrypt_keyid.rb b/modules/exploits/freebsd/telnet/telnet_encrypt_keyid.rb index 42e6a06a62..1cdb253478 100644 --- a/modules/exploits/freebsd/telnet/telnet_encrypt_keyid.rb +++ b/modules/exploits/freebsd/telnet/telnet_encrypt_keyid.rb @@ -99,7 +99,7 @@ class Metasploit3 < Msf::Exploit::Remote loop do data = sock.get_once(-1, 5) rescue nil if not data - raise RuntimeError, "This system does not support encryption" + fail_with(Exploit::Failure::Unknown, "This system does not support encryption") end break if data.index("\xff\xfa\x26\x02\x01") end diff --git a/modules/exploits/linux/ftp/proftp_sreplace.rb b/modules/exploits/linux/ftp/proftp_sreplace.rb index 57646a8162..56615ba85b 100644 --- a/modules/exploits/linux/ftp/proftp_sreplace.rb +++ b/modules/exploits/linux/ftp/proftp_sreplace.rb @@ -170,7 +170,7 @@ class Metasploit3 < Msf::Exploit::Remote print_status("FTP Banner: #{banner.strip}") version = m[1] else - raise RuntimeError, "No matching target" + fail_with(Exploit::Failure::NoTarget, "No matching target") end regexp = Regexp.escape(version) @@ -182,7 +182,7 @@ class Metasploit3 < Msf::Exploit::Remote end if (not mytarget) - raise RuntimeError, "No matching target" + fail_with(Exploit::Failure::NoTarget, "No matching target") end print_status("Selected Target: #{mytarget.name}") @@ -198,7 +198,7 @@ class Metasploit3 < Msf::Exploit::Remote pwd = send_cmd(['PWD']) if pwd !~ /257\s\"(.+)\"/ - raise RuntimeError, "Unable to get current working directory" + fail_with(Exploit::Failure::Unknown, "Unable to get current working directory") end pwd = $1 pwd << "/" if pwd[-1,1] != "/" diff --git a/modules/exploits/linux/ftp/proftp_telnet_iac.rb b/modules/exploits/linux/ftp/proftp_telnet_iac.rb index 4a66140e0c..6704b33697 100644 --- a/modules/exploits/linux/ftp/proftp_telnet_iac.rb +++ b/modules/exploits/linux/ftp/proftp_telnet_iac.rb @@ -330,7 +330,7 @@ class Metasploit3 < Msf::Exploit::Remote print_status("FTP Banner: #{banner.strip}") version = m[1] else - raise RuntimeError, "No matching target" + fail_with(Exploit::Failure::NoTarget, "No matching target") end regexp = Regexp.escape(version) @@ -342,7 +342,7 @@ class Metasploit3 < Msf::Exploit::Remote end if (not mytarget) - raise RuntimeError, "No matching target" + fail_with(Exploit::Failure::NoTarget, "No matching target") end print_status("Selected Target: #{mytarget.name}") @@ -388,7 +388,7 @@ class Metasploit3 < Msf::Exploit::Remote # Make sure we didn't introduce instability addr_badchars = "\x09\x0a\x0b\x0c\x20" if idx = Rex::Text.badchar_index(addrs, addr_badchars) - raise RuntimeError, ("One or more address contains a bad character! (0x%02x @ 0x%x)" % [addrs[idx,1].unpack('C').first, idx]) + fail_with(Exploit::Failure::Unknown, ("One or more address contains a bad character! (0x%02x @ 0x%x)" % [addrs[idx,1].unpack('C').first, idx])) end buf << addrs @@ -437,7 +437,7 @@ class Metasploit3 < Msf::Exploit::Remote end if not session_created? - raise RuntimeError, "Unable to guess the cookie value, sorry :-/" + fail_with(Exploit::Failure::Unknown, "Unable to guess the cookie value, sorry :-/") end else sock.put(buf) diff --git a/modules/exploits/linux/imap/imap_uw_lsub.rb b/modules/exploits/linux/imap/imap_uw_lsub.rb index 553f7ecfa1..1e4bb47d06 100644 --- a/modules/exploits/linux/imap/imap_uw_lsub.rb +++ b/modules/exploits/linux/imap/imap_uw_lsub.rb @@ -79,7 +79,7 @@ class Metasploit3 < Msf::Exploit::Remote print_status("Trying 0x%.8x ..." % addresses['Ret']) if (not connect_login) - raise RuntimeError, "Unable to log in!" + fail_with(Exploit::Failure::Unknown, "Unable to log in!") end req = "a002 LSUB \"\" {%d}\r\n" % target['Offset'] diff --git a/modules/exploits/linux/mysql/mysql_yassl_getname.rb b/modules/exploits/linux/mysql/mysql_yassl_getname.rb index 0115b6833c..fcd1b00bf4 100644 --- a/modules/exploits/linux/mysql/mysql_yassl_getname.rb +++ b/modules/exploits/linux/mysql/mysql_yassl_getname.rb @@ -90,7 +90,7 @@ class Metasploit3 < Msf::Exploit::Remote if (buf = sock.get_once(-1, 5) || '') #print_status("\n" + Rex::Text.to_hex_dump(buf)) if (buf =~ /is not allowed to connect/) - raise RuntimeError, 'The server refused our connection!' + fail_with(Exploit::Failure::Unreachable, 'The server refused our connection!') end len1,cmd = buf[0,5].unpack('VC') @@ -114,7 +114,7 @@ class Metasploit3 < Msf::Exploit::Remote } if (not mytarget) - raise RuntimeError, 'Unable to detect target automatically' + fail_with(Exploit::Failure::NoTarget, 'Unable to detect target automatically') else print_status("Using automatically detected target: #{mytarget.name}") end diff --git a/modules/exploits/linux/samba/lsa_transnames_heap.rb b/modules/exploits/linux/samba/lsa_transnames_heap.rb index 514c7cd105..d985f735ce 100644 --- a/modules/exploits/linux/samba/lsa_transnames_heap.rb +++ b/modules/exploits/linux/samba/lsa_transnames_heap.rb @@ -239,7 +239,7 @@ class Metasploit3 < Msf::Exploit::Remote if ! @checked_peerlm if smb_peer_lm !~ /Samba 3\.0\.2[1234]/i - raise RuntimeError, "This target is not a vulnerable Samba server (#{smb_peer_lm})" + fail_with(Exploit::Failure::NoTarget, "This target is not a vulnerable Samba server (#{smb_peer_lm})") end end diff --git a/modules/exploits/linux/samba/trans2open.rb b/modules/exploits/linux/samba/trans2open.rb index 3dae2c66cd..a141e9a0a5 100644 --- a/modules/exploits/linux/samba/trans2open.rb +++ b/modules/exploits/linux/samba/trans2open.rb @@ -87,11 +87,11 @@ class Metasploit3 < Msf::Exploit::Remote if ! @checked_peerlm if smb_peer_lm !~ /samba/i - raise RuntimeError, "This target is not a Samba server (#{smb_peer_lm}" + fail_with(Exploit::Failure::NoTarget, "This target is not a Samba server (#{smb_peer_lm}") end if smb_peer_lm =~ /Samba [34]\./i - raise RuntimeError, "This target is not a vulnerable Samba server (#{smb_peer_lm})" + fail_with(Exploit::Failure::NoTarget, "This target is not a vulnerable Samba server (#{smb_peer_lm})") end end diff --git a/modules/exploits/linux/telnet/telnet_encrypt_keyid.rb b/modules/exploits/linux/telnet/telnet_encrypt_keyid.rb index 3629886e6b..6e997f8dc5 100644 --- a/modules/exploits/linux/telnet/telnet_encrypt_keyid.rb +++ b/modules/exploits/linux/telnet/telnet_encrypt_keyid.rb @@ -89,7 +89,7 @@ class Metasploit3 < Msf::Exploit::Remote loop do data = sock.get_once(-1, 5) rescue nil if not data - raise RuntimeError, "This system does not support encryption" + fail_with(Exploit::Failure::Unknown, "This system does not support encryption") end break if data.index("\xff\xfa\x26\x02\x01") end diff --git a/modules/exploits/multi/ftp/wuftpd_site_exec_format.rb b/modules/exploits/multi/ftp/wuftpd_site_exec_format.rb index effbd9d402..f7a1457894 100644 --- a/modules/exploits/multi/ftp/wuftpd_site_exec_format.rb +++ b/modules/exploits/multi/ftp/wuftpd_site_exec_format.rb @@ -145,7 +145,7 @@ class Metasploit3 < Msf::Exploit::Remote def exploit if (not connect_login) - raise RuntimeError, 'Unable to authenticate' + fail_with(Exploit::Failure::Unknown, 'Unable to authenticate') end # Use a copy of the target @@ -159,7 +159,7 @@ class Metasploit3 < Msf::Exploit::Remote print_status("FTP Banner: #{banner.strip}") version = m[1] else - raise RuntimeError, "No matching target" + fail_with(Exploit::Failure::NoTarget, "No matching target") end regexp = Regexp.escape(version) @@ -171,7 +171,7 @@ class Metasploit3 < Msf::Exploit::Remote end if (not mytarget) - raise RuntimeError, "No matching target" + fail_with(Exploit::Failure::NoTarget, "No matching target") end print_status("Selected Target: #{mytarget.name}") @@ -203,7 +203,7 @@ class Metasploit3 < Msf::Exploit::Remote # detect the number of pad bytes idx = stack_data.index("aaaabbbb") if not idx - raise RuntimeError, "Whoa, didn't find the static bytes on the stack!" + fail_with(Exploit::Failure::Unknown, "Whoa, didn't find the static bytes on the stack!") end num_pad = 0 num_pad = 4 - (idx % 4) if (idx % 4) > 0 @@ -263,7 +263,7 @@ class Metasploit3 < Msf::Exploit::Remote fmtbuf.gsub!(/\xff/, "\xff\xff") if ((res = send_cmd(['SITE', 'EXEC', fmtbuf], true))) if res[0,4] == "500 " - raise RuntimeError, "Crap! Something went wrong when uploading the payload..." + fail_with(Exploit::Failure::Unknown, "Crap! Something went wrong when uploading the payload...") end end end diff --git a/modules/exploits/multi/handler.rb b/modules/exploits/multi/handler.rb index dae7ce988d..05849ad767 100644 --- a/modules/exploits/multi/handler.rb +++ b/modules/exploits/multi/handler.rb @@ -52,7 +52,7 @@ class Metasploit3 < Msf::Exploit::Remote def exploit if not datastore['ExitOnSession'] and not job_id - raise RuntimeError, "Setting ExitOnSession to false requires running as a job (exploit -j)" + fail_with(Exploit::Failure::Unknown, "Setting ExitOnSession to false requires running as a job (exploit -j)") end stime = Time.now.to_f diff --git a/modules/exploits/multi/http/glassfish_deployer.rb b/modules/exploits/multi/http/glassfish_deployer.rb index 0bd38d8f8b..2cc1bf41e3 100644 --- a/modules/exploits/multi/http/glassfish_deployer.rb +++ b/modules/exploits/multi/http/glassfish_deployer.rb @@ -609,9 +609,9 @@ class Metasploit3 < Msf::Exploit::Remote print_status("Getting information to undeploy...") viewstate, entry = get_delete_info(session, version, app_base) if (not viewstate) - raise RuntimeError, "Unable to get viewstate" + fail_with(Exploit::Failure::Unknown, "Unable to get viewstate") elsif (not entry) - raise RuntimeError, "Unable to get entry" + fail_with(Exploit::Failure::Unknown, "Unable to get entry") end print_status("Undeploying #{app_base}...") diff --git a/modules/exploits/multi/http/jboss_bshdeployer.rb b/modules/exploits/multi/http/jboss_bshdeployer.rb index b93d5c6346..a11fd5bf8e 100644 --- a/modules/exploits/multi/http/jboss_bshdeployer.rb +++ b/modules/exploits/multi/http/jboss_bshdeployer.rb @@ -89,7 +89,7 @@ class Metasploit3 < Msf::Exploit::Remote if datastore['SHELL'] == 'auto' if verb != 'HEAD' if not (plat = detect_platform()) - raise RuntimeError, 'Unable to detect platform!' + fail_with(Exploit::Failure::NoTarget, 'Unable to detect platform!') end case plat @@ -101,7 +101,7 @@ class Metasploit3 < Msf::Exploit::Remote print_status("SHELL set to #{datastore['SHELL']}") else - raise RuntimeError, 'Platform detection with HEAD is not supported, please set SHELL manually' + fail_with(Exploit::Failure::NoTarget, 'Platform detection with HEAD is not supported, please set SHELL manually') end # Payload generation already happened, therefore SHELL will @@ -146,7 +146,7 @@ EOT print_status("Attempting to use '#{p}' as package") res = invoke_bshscript(bsh_script, p, verb) if !res - raise RuntimeError, "Unable to deploy WAR [No Response]" + fail_with(Exploit::Failure::Unknown, "Unable to deploy WAR [No Response]") end if (res.code < 200 || res.code >= 300) diff --git a/modules/exploits/multi/http/jboss_deploymentfilerepository.rb b/modules/exploits/multi/http/jboss_deploymentfilerepository.rb index 350953acd7..d480588587 100644 --- a/modules/exploits/multi/http/jboss_deploymentfilerepository.rb +++ b/modules/exploits/multi/http/jboss_deploymentfilerepository.rb @@ -70,7 +70,7 @@ class Metasploit3 < Msf::Exploit::Remote p = payload if datastore['SHELL'] == 'automatic' if not (plat = detect_platform()) - raise RuntimeError, 'Unable to detect platform!' + fail_with(Exploit::Failure::NoTarget, 'Unable to detect platform!') end case plat diff --git a/modules/exploits/multi/http/jboss_maindeployer.rb b/modules/exploits/multi/http/jboss_maindeployer.rb index 16c5eb8fa5..74422d90f9 100644 --- a/modules/exploits/multi/http/jboss_maindeployer.rb +++ b/modules/exploits/multi/http/jboss_maindeployer.rb @@ -103,7 +103,7 @@ class Metasploit3 < Msf::Exploit::Remote print_status("Attempting to automatically select a target...") if not (plat = detect_platform()) - raise RuntimeError, 'Unable to detect platform!' + fail_with(Exploit::Failure::NoTarget, 'Unable to detect platform!') end # TODO: detection requires HTML parsing @@ -137,7 +137,7 @@ class Metasploit3 < Msf::Exploit::Remote if (target.name =~ /Automatic/) mytarget = auto_target() if (not mytarget) - raise RuntimeError, "Unable to automatically select a target" + fail_with(Exploit::Failure::NoTarget, "Unable to automatically select a target") end print_status("Automatically selected target \"#{mytarget.name}\"") else @@ -148,7 +148,7 @@ class Metasploit3 < Msf::Exploit::Remote # Find out which shell if we're using a Java target if (mytarget.name =~ /Java/) if not (plat = detect_platform()) - raise RuntimeError, 'Unable to detect platform!' + fail_with(Exploit::Failure::NoTarget, 'Unable to detect platform!') end case plat @@ -235,14 +235,14 @@ class Metasploit3 < Msf::Exploit::Remote }) end if (! res) - raise RuntimeError, "Unable to deploy WAR archive [No Response]" + fail_with(Exploit::Failure::Unknown, "Unable to deploy WAR archive [No Response]") end if (res.code < 200 or res.code >= 300) case res.code when 401 print_error("Warning: The web site asked for authentication: #{res.headers['WWW-Authenticate'] || res.headers['Authentication']}") end - raise RuntimeError, "Upload to deploy WAR archive [#{res.code} #{res.message}]" + fail_with(Exploit::Failure::Unknown, "Upload to deploy WAR archive [#{res.code} #{res.message}]") end # wait for the data to be sent @@ -252,7 +252,7 @@ class Metasploit3 < Msf::Exploit::Remote select(nil, nil, nil, 1) waited += 1 if (waited > 30) - raise RuntimeError, 'Server did not request WAR archive -- Maybe it cant connect back to us?' + fail_with(Exploit::Failure::Unknown, 'Server did not request WAR archive -- Maybe it cant connect back to us?') end end diff --git a/modules/exploits/multi/http/sit_file_upload.rb b/modules/exploits/multi/http/sit_file_upload.rb index 5a6090233e..b2ec6f6c97 100644 --- a/modules/exploits/multi/http/sit_file_upload.rb +++ b/modules/exploits/multi/http/sit_file_upload.rb @@ -110,10 +110,10 @@ class Metasploit3 < Msf::Exploit::Remote print_status("Successfully retrieved cookie: #{session}") return session else - raise RuntimeError, "Error retrieving cookie!" + fail_with(Exploit::Failure::Unknown, "Error retrieving cookie!") end else - raise RuntimeError, "Error logging in." + fail_with(Exploit::Failure::Unknown, "Error logging in.") end end @@ -162,7 +162,7 @@ class Metasploit3 < Msf::Exploit::Remote print_status("Successfully uploaded #{newpage}") return res else - raise RuntimeError, "Error uploading #{newpage}" + fail_with(Exploit::Failure::Unknown, "Error uploading #{newpage}") end end @@ -176,7 +176,7 @@ class Metasploit3 < Msf::Exploit::Remote print_status("Successfully retrieved upload dir: #{upload_dir}") return upload_dir else - raise RuntimeError, "Error retrieving the upload dir" + fail_with(Exploit::Failure::Unknown, "Error retrieving the upload dir") end end diff --git a/modules/exploits/multi/http/splunk_mappy_exec.rb b/modules/exploits/multi/http/splunk_mappy_exec.rb index 5dd7457d98..a8a1d5bb00 100644 --- a/modules/exploits/multi/http/splunk_mappy_exec.rb +++ b/modules/exploits/multi/http/splunk_mappy_exec.rb @@ -139,7 +139,7 @@ class Metasploit3 < Msf::Exploit::Remote } } else - raise RuntimeError, "Unable to get session cookies" + fail_with(Exploit::Failure::NotFound, "Unable to get session cookies") end res = send_request_cgi( @@ -156,7 +156,7 @@ class Metasploit3 < Msf::Exploit::Remote }, 25) if not res or res.code != 303 - raise RuntimeError, "Unable to authenticate" + fail_with(Exploit::Failure::NoAccess, "Unable to authenticate") else session_id_port = '' session_id = '' diff --git a/modules/exploits/multi/http/struts_code_exec.rb b/modules/exploits/multi/http/struts_code_exec.rb index 27e451eef1..964246c8c8 100644 --- a/modules/exploits/multi/http/struts_code_exec.rb +++ b/modules/exploits/multi/http/struts_code_exec.rb @@ -151,7 +151,7 @@ class Metasploit3 < Msf::Exploit::Remote when 'win' windows_stager else - raise RuntimeError, 'Unsupported target platform!' + fail_with(Exploit::Failure::NoTarget, 'Unsupported target platform!') end handler diff --git a/modules/exploits/multi/http/struts_code_exec_exception_delegator.rb b/modules/exploits/multi/http/struts_code_exec_exception_delegator.rb index cd732eb105..5a07039eb5 100644 --- a/modules/exploits/multi/http/struts_code_exec_exception_delegator.rb +++ b/modules/exploits/multi/http/struts_code_exec_exception_delegator.rb @@ -202,7 +202,7 @@ class Metasploit3 < Msf::Exploit::Remote when 'java' java_stager else - raise RuntimeError, 'Unsupported target platform!' + fail_with(Exploit::Failure::NoTarget, 'Unsupported target platform!') end handler diff --git a/modules/exploits/multi/http/tomcat_mgr_deploy.rb b/modules/exploits/multi/http/tomcat_mgr_deploy.rb index ed3b505b82..0b5ccdebbf 100644 --- a/modules/exploits/multi/http/tomcat_mgr_deploy.rb +++ b/modules/exploits/multi/http/tomcat_mgr_deploy.rb @@ -176,7 +176,7 @@ class Metasploit3 < Msf::Exploit::Remote if (target.name =~ /Automatic/) mytarget = auto_target if (not mytarget) - raise RuntimeError, "Unable to automatically select a target" + fail_with(Exploit::Failure::NoTarget, "Unable to automatically select a target") end print_status("Automatically selected target \"#{mytarget.name}\"") else @@ -212,14 +212,14 @@ class Metasploit3 < Msf::Exploit::Remote 'data' => war, }, 20) if (! res) - raise RuntimeError, "Upload failed on #{path_tmp} [No Response]" + fail_with(Exploit::Failure::Unknown, "Upload failed on #{path_tmp} [No Response]") end if (res.code < 200 or res.code >= 300) case res.code when 401 print_error("Warning: The web site asked for authentication: #{res.headers['WWW-Authenticate'] || res.headers['Authentication']}") end - raise RuntimeError, "Upload failed on #{path_tmp} [#{res.code} #{res.message}]" + fail_with(Exploit::Failure::Unknown, "Upload failed on #{path_tmp} [#{res.code} #{res.message}]") end report_auth_info( diff --git a/modules/exploits/multi/http/wikka_spam_exec.rb b/modules/exploits/multi/http/wikka_spam_exec.rb index 86f0077c91..b088f14520 100644 --- a/modules/exploits/multi/http/wikka_spam_exec.rb +++ b/modules/exploits/multi/http/wikka_spam_exec.rb @@ -94,7 +94,7 @@ class Metasploit3 < Msf::Exploit::Remote if res and res.headers['Set-Cookie'] cookie = res.headers['Set-Cookie'].scan(/(\w+\=\w+); path\=.+$/).flatten[0] else - raise RuntimeError, "#{@peer} - No cookie found, will not continue" + fail_with(Exploit::Failure::Unknown, "#{@peer} - No cookie found, will not continue") end cookie @@ -121,7 +121,7 @@ class Metasploit3 < Msf::Exploit::Remote login[name] = value end else - raise RuntimeError, "#{@peer} - Unable to find the hidden fieldset required for login" + fail_with(Exploit::Failure::Unknown, "#{@peer} - Unable to find the hidden fieldset required for login") end # Add the rest of fields required for login @@ -148,7 +148,7 @@ class Metasploit3 < Msf::Exploit::Remote cookie_cred = "#{cookie}; #{user}; #{pass}" else cred = "#{datastore['USERNAME']}:#{datastore['PASSWORD']}" - raise RuntimeError, "#{@peer} - Unable to login with \"#{cred}\"" + fail_with(Exploit::Failure::Unknown, "#{@peer} - Unable to login with \"#{cred}\"") end return cookie_cred @@ -172,7 +172,7 @@ class Metasploit3 < Msf::Exploit::Remote fields[n] = v end else - raise RuntimeError, "#{@peer} - Cannot get necessary fields before posting a comment" + fail_with(Exploit::Failure::Unknown, "#{@peer} - Cannot get necessary fields before posting a comment") end # Generate enough URLs to trigger spam logging diff --git a/modules/exploits/multi/php/php_unserialize_zval_cookie.rb b/modules/exploits/multi/php/php_unserialize_zval_cookie.rb index 64c37467cc..b927a91c92 100644 --- a/modules/exploits/multi/php/php_unserialize_zval_cookie.rb +++ b/modules/exploits/multi/php/php_unserialize_zval_cookie.rb @@ -217,11 +217,11 @@ class Metasploit3 < Msf::Exploit::Remote uri_path = datastore['URI'] || target['DefaultURI'] if(not cookie_name) - raise RuntimeError, "The COOKIENAME option must be set" + fail_with(Exploit::Failure::Unknown, "The COOKIENAME option must be set") end if(not uri_path) - raise RuntimeError, "The URI option must be set" + fail_with(Exploit::Failure::Unknown, "The URI option must be set") end res = send_request_cgi({ @@ -321,11 +321,11 @@ class Metasploit3 < Msf::Exploit::Remote uri_path = datastore['URI'] || target['DefaultURI'] if(not cookie_name) - raise RuntimeError, "The COOKIENAME option must be set" + fail_with(Exploit::Failure::Unknown, "The COOKIENAME option must be set") end if(not uri_path) - raise RuntimeError, "The URI option must be set" + fail_with(Exploit::Failure::Unknown, "The URI option must be set") end # Generate and reuse the original buffer to save CPU @@ -423,7 +423,7 @@ class Metasploit3 < Msf::Exploit::Remote print_line("*" * 40) print_line('') - raise RuntimeError, "Exploit settings are probably wrong" + fail_with(Exploit::Failure::Unknown, "Exploit settings are probably wrong") end else print_status("No response from the server") diff --git a/modules/exploits/osx/browser/safari_file_policy.rb b/modules/exploits/osx/browser/safari_file_policy.rb index 38f5bafc5e..62ab1a5180 100644 --- a/modules/exploits/osx/browser/safari_file_policy.rb +++ b/modules/exploits/osx/browser/safari_file_policy.rb @@ -262,7 +262,7 @@ class Metasploit3 < Msf::Exploit::Remote # def use_zlib if (!Rex::Text.zlib_present? and datastore['HTTP::compression'] == true) - raise RuntimeError, "zlib support was not detected, yet the HTTP::compression option was set. Don't do that!" + fail_with(Exploit::Failure::Unknown, "zlib support was not detected, yet the HTTP::compression option was set. Don't do that!") end end diff --git a/modules/exploits/osx/browser/safari_metadata_archive.rb b/modules/exploits/osx/browser/safari_metadata_archive.rb index 327556b811..84a61f4a94 100644 --- a/modules/exploits/osx/browser/safari_metadata_archive.rb +++ b/modules/exploits/osx/browser/safari_metadata_archive.rb @@ -77,7 +77,7 @@ class Metasploit3 < Msf::Exploit::Remote def check_dependencies @zip = (Rex::FileUtils::find_full_path('7za') || Rex::FileUtils::find_full_path('7za.exe')) return if @zip - raise RuntimeError, "This exploit requires the zip command to be installed in your path" + fail_with(Exploit::Failure::Unknown, "This exploit requires the zip command to be installed in your path") end def on_request_uri(cli, request) diff --git a/modules/exploits/unix/smtp/exim4_string_format.rb b/modules/exploits/unix/smtp/exim4_string_format.rb index 38d923e4a1..ae7a6f10f2 100644 --- a/modules/exploits/unix/smtp/exim4_string_format.rb +++ b/modules/exploits/unix/smtp/exim4_string_format.rb @@ -115,11 +115,11 @@ class Metasploit3 < Msf::Exploit::Remote print_status("Server: #{self.banner.to_s.strip}") if self.banner.to_s !~ /Exim / disconnect - raise RuntimeError, "The target server is not running Exim!" + fail_with(Exploit::Failure::NoTarget, "The target server is not running Exim!") end if not datastore['SkipVersionCheck'] and self.banner !~ /Exim 4\.6\d+/i - raise RuntimeError, "Warning: This version of Exim is not exploitable" + fail_with(Exploit::Failure::Unknown, "Warning: This version of Exim is not exploitable") end ehlo_resp = raw_send_recv("EHLO #{ehlo}\r\n") @@ -158,7 +158,7 @@ class Metasploit3 < Msf::Exploit::Remote resp ||= 'no response' msg = "MAIL: #{resp.strip}" if not resp or resp[0,3] != '250' - raise RuntimeError, msg + fail_with(Exploit::Failure::Unknown, msg) else print_status(msg) end @@ -167,7 +167,7 @@ class Metasploit3 < Msf::Exploit::Remote resp ||= 'no response' msg = "RCPT: #{resp.strip}" if not resp or resp[0,3] != '250' - raise RuntimeError, msg + fail_with(Exploit::Failure::Unknown, msg) else print_status(msg) end @@ -176,7 +176,7 @@ class Metasploit3 < Msf::Exploit::Remote resp ||= 'no response' msg = "DATA: #{resp.strip}" if not resp or resp[0,3] != '354' - raise RuntimeError, msg + fail_with(Exploit::Failure::Unknown, msg) else print_status(msg) end @@ -289,7 +289,7 @@ class Metasploit3 < Msf::Exploit::Remote # Check output for success if second_result !~ /(MAIL|RCPT|sh: |sh-[0-9]+)/ print_error("Second result: #{second_result.inspect}") - raise RuntimeError, 'Something went wrong, perhaps this host is patched?' + fail_with(Exploit::Failure::Unknown, 'Something went wrong, perhaps this host is patched?') end resp = '' diff --git a/modules/exploits/unix/webapp/citrix_access_gateway_exec.rb b/modules/exploits/unix/webapp/citrix_access_gateway_exec.rb index 8ccfe2e8f0..d0fe3a3f62 100644 --- a/modules/exploits/unix/webapp/citrix_access_gateway_exec.rb +++ b/modules/exploits/unix/webapp/citrix_access_gateway_exec.rb @@ -111,7 +111,7 @@ class Metasploit3 < Msf::Exploit::Remote cmd = payload.encoded if not post(cmd, true) - raise RuntimeError, "Unable to execute the desired command" + fail_with(Exploit::Failure::Unknown, "Unable to execute the desired command") end end end diff --git a/modules/exploits/unix/webapp/coppermine_piceditor.rb b/modules/exploits/unix/webapp/coppermine_piceditor.rb index 27c7f7bb7c..e24b4b224f 100644 --- a/modules/exploits/unix/webapp/coppermine_piceditor.rb +++ b/modules/exploits/unix/webapp/coppermine_piceditor.rb @@ -115,7 +115,7 @@ class Metasploit3 < Msf::Exploit::Remote if (res and res.code == 200) print_status("Successfully POST'd exploit data") else - raise RuntimeError, "Error POSTing exploit data" + fail_with(Exploit::Failure::Unknown, "Error POSTing exploit data") end handler diff --git a/modules/exploits/unix/webapp/openx_banner_edit.rb b/modules/exploits/unix/webapp/openx_banner_edit.rb index 0bebff011c..7b4554ba48 100644 --- a/modules/exploits/unix/webapp/openx_banner_edit.rb +++ b/modules/exploits/unix/webapp/openx_banner_edit.rb @@ -122,7 +122,7 @@ class Metasploit3 < Msf::Exploit::Remote # Need to login first :-/ cookie = openx_login(uri_base) if (not cookie) - raise RuntimeError, 'Unable to login!' + fail_with(Exploit::Failure::Unknown, 'Unable to login!') end print_status("Logged in successfully (cookie: #{cookie})") @@ -130,7 +130,7 @@ class Metasploit3 < Msf::Exploit::Remote ids = openx_find_campaign(uri_base, cookie) if (not ids) # TODO: try to add an advertiser and/or campaign - raise RuntimeError, 'The system has no advertisers or campaigns!' + fail_with(Exploit::Failure::Unknown, 'The system has no advertisers or campaigns!') end adv_id = ids[0] camp_id = ids[1] @@ -139,14 +139,14 @@ class Metasploit3 < Msf::Exploit::Remote # Add the banner >:) ban_id = openx_upload_banner(uri_base, cookie, adv_id, camp_id, content) if (not ban_id) - raise RuntimeError, 'Unable to upload the banner!' + fail_with(Exploit::Failure::Unknown, 'Unable to upload the banner!') end print_status("Successfully uploaded the banner image with id #{ban_id}") # Find the filename ban_fname = openx_find_banner_filename(uri_base, cookie, adv_id, camp_id, ban_id) if (not ban_fname) - raise RuntimeError, 'Unable to find the banner filename!' + fail_with(Exploit::Failure::Unknown, 'Unable to find the banner filename!') end print_status("Resolved banner id to name: #{ban_fname}") diff --git a/modules/exploits/unix/webapp/oracle_vm_agent_utl.rb b/modules/exploits/unix/webapp/oracle_vm_agent_utl.rb index c66141b0af..52cd4fa554 100644 --- a/modules/exploits/unix/webapp/oracle_vm_agent_utl.rb +++ b/modules/exploits/unix/webapp/oracle_vm_agent_utl.rb @@ -158,7 +158,7 @@ EOS cmd ||= payload.encoded if not go(cmd) - raise RuntimeError, "Unable to execute the desired command" + fail_with(Exploit::Failure::Unknown, "Unable to execute the desired command") end handler diff --git a/modules/exploits/unix/webapp/php_vbulletin_template.rb b/modules/exploits/unix/webapp/php_vbulletin_template.rb index 8d6e9af143..d8985d25e4 100644 --- a/modules/exploits/unix/webapp/php_vbulletin_template.rb +++ b/modules/exploits/unix/webapp/php_vbulletin_template.rb @@ -87,9 +87,9 @@ class Metasploit3 < Msf::Exploit::Remote elsif datastore['HTTP::chunked'] == true b = /chunked Transfer-Encoding forbidden/.match(res.body) if b - raise RuntimeError, 'Target PHP installation does not support chunked encoding. ' + + fail_with(Exploit::Failure::Unknown, 'Target PHP installation does not support chunked encoding. ' + 'Support for chunked encoded requests was added to PHP on 12/15/2005. ' + - 'Try disabling HTTP::chunked and trying again.' + 'Try disabling HTTP::chunked and trying again.') end end end diff --git a/modules/exploits/unix/webapp/php_xmlrpc_eval.rb b/modules/exploits/unix/webapp/php_xmlrpc_eval.rb index 726ae05ffd..eab6532dff 100644 --- a/modules/exploits/unix/webapp/php_xmlrpc_eval.rb +++ b/modules/exploits/unix/webapp/php_xmlrpc_eval.rb @@ -92,9 +92,9 @@ class Metasploit3 < Msf::Exploit::Remote elsif datastore['HTTP::chunked'] == true b = /chunked Transfer-Encoding forbidden/.match(res.body) if b - raise RuntimeError, 'Target PHP installation does not support chunked encoding. ' + + fail_with(Exploit::Failure::BadConfig, 'Target PHP installation does not support chunked encoding. ' + 'Support for chunked encoded requests was added to PHP on 12/15/2005. ' + - 'Try disabling HTTP::chunked and trying again.' + 'Try disabling HTTP::chunked and trying again.') end end end diff --git a/modules/exploits/unix/webapp/tikiwiki_graph_formula_exec.rb b/modules/exploits/unix/webapp/tikiwiki_graph_formula_exec.rb index 755ddb5430..05d9b5c4ba 100644 --- a/modules/exploits/unix/webapp/tikiwiki_graph_formula_exec.rb +++ b/modules/exploits/unix/webapp/tikiwiki_graph_formula_exec.rb @@ -192,7 +192,7 @@ class Metasploit3 < Msf::Exploit::Remote # 3. cannot use `, ', ", or space if (f_val.index('\'') or f_val.index('"') or f_val.index('`') or f_val.index(' ')) - raise RuntimeError, "The value for the 'f' variable contains an invalid character!" + fail_with(Exploit::Failure::Unknown, "The value for the 'f' variable contains an invalid character!") end # 4. the function must be one of: diff --git a/modules/exploits/unix/webapp/trixbox_langchoice.rb b/modules/exploits/unix/webapp/trixbox_langchoice.rb index fd230a6473..23ea4e04d5 100644 --- a/modules/exploits/unix/webapp/trixbox_langchoice.rb +++ b/modules/exploits/unix/webapp/trixbox_langchoice.rb @@ -146,7 +146,7 @@ class Metasploit3 < Msf::Exploit::Remote # The call should return status code 200 if delivery_response.code != 200 - raise RuntimeError, "Server returned unexpected HTTP code #{delivery_response.code}" + fail_with(Exploit::Failure::NotFound, "Server returned unexpected HTTP code #{delivery_response.code}") end print_status "The server responded to POST with HTTP code #{delivery_response.code}" @@ -156,7 +156,7 @@ class Metasploit3 < Msf::Exploit::Remote # Make sure cookies were set if cookies.nil? - raise RuntimeError, 'The server did not set any cookies' + fail_with(Exploit::Failure::NotFound, 'The server did not set any cookies') end # Contents of PHPSESSID. About to be set. @@ -166,7 +166,7 @@ class Metasploit3 < Msf::Exploit::Remote if cookies =~ PHPSESSID_REGEX session_id = $1 else - raise RuntimeError, 'The cookie PHPSESSID was not set.' + fail_with(Exploit::Failure::NotFound, 'The cookie PHPSESSID was not set.') end print_status "We were assigned a session id (cookie PHPSESSID) of '#{session_id}'" diff --git a/modules/exploits/unix/webapp/twiki_history.rb b/modules/exploits/unix/webapp/twiki_history.rb index cd75932e27..60992ffeb8 100644 --- a/modules/exploits/unix/webapp/twiki_history.rb +++ b/modules/exploits/unix/webapp/twiki_history.rb @@ -126,7 +126,7 @@ class Metasploit3 < Msf::Exploit::Remote if (res and res.code == 200) print_status("Successfully sent exploit request") else - raise RuntimeError, "Error sending exploit request" + fail_with(Exploit::Failure::Unknown, "Error sending exploit request") end handler diff --git a/modules/exploits/unix/webapp/twiki_search.rb b/modules/exploits/unix/webapp/twiki_search.rb index 07ab33b384..8d53310d6c 100644 --- a/modules/exploits/unix/webapp/twiki_search.rb +++ b/modules/exploits/unix/webapp/twiki_search.rb @@ -122,7 +122,7 @@ class Metasploit3 < Msf::Exploit::Remote if (res and res.code == 200) print_status("Successfully sent exploit request") else - raise RuntimeError, "Error sending exploit request" + fail_with(Exploit::Failure::Unknown, "Error sending exploit request") end handler diff --git a/modules/exploits/windows/antivirus/ams_hndlrsvc.rb b/modules/exploits/windows/antivirus/ams_hndlrsvc.rb index 96282f0953..2e0bd31649 100644 --- a/modules/exploits/windows/antivirus/ams_hndlrsvc.rb +++ b/modules/exploits/windows/antivirus/ams_hndlrsvc.rb @@ -74,7 +74,7 @@ class Metasploit3 < Msf::Exploit::Remote connect if ( cmd.length > 128 ) - raise RuntimeError,"Command strings greater then 128 characters will not be processed!" + fail_with(Exploit::Failure::Unknown, "Command strings greater then 128 characters will not be processed!") end string_uno = Rex::Text.rand_text_alpha_upper(11) @@ -167,7 +167,7 @@ class Metasploit3 < Msf::Exploit::Remote when 'win' windows_stager else - raise RuntimeError, 'Target not supported.' + fail_with(Exploit::Failure::Unknown, 'Target not supported.') end handler diff --git a/modules/exploits/windows/antivirus/ams_xfr.rb b/modules/exploits/windows/antivirus/ams_xfr.rb index 7ae811ee0b..be629648df 100644 --- a/modules/exploits/windows/antivirus/ams_xfr.rb +++ b/modules/exploits/windows/antivirus/ams_xfr.rb @@ -108,7 +108,7 @@ class Metasploit3 < Msf::Exploit::Remote when 'win' windows_stager else - raise RuntimeError, 'Target not supported.' + fail_with(Exploit::Failure::Unknown, 'Target not supported.') end handler diff --git a/modules/exploits/windows/browser/java_codebase_trust.rb b/modules/exploits/windows/browser/java_codebase_trust.rb index 4387f7d4d7..37c85a0688 100644 --- a/modules/exploits/windows/browser/java_codebase_trust.rb +++ b/modules/exploits/windows/browser/java_codebase_trust.rb @@ -97,7 +97,7 @@ class Metasploit3 < Msf::Exploit::Remote @java_class = fd.read(fd.stat.size) } if not @java_class - raise RuntimeError, "Unable to load java class" + fail_with(Exploit::Failure::Unknown, "Unable to load java class") end super diff --git a/modules/exploits/windows/browser/java_ws_arginject_altjvm.rb b/modules/exploits/windows/browser/java_ws_arginject_altjvm.rb index 54875e68b5..da56d1f1f7 100644 --- a/modules/exploits/windows/browser/java_ws_arginject_altjvm.rb +++ b/modules/exploits/windows/browser/java_ws_arginject_altjvm.rb @@ -376,7 +376,7 @@ document.location = "#{js_uri}"; # def exploit if datastore['SRVPORT'].to_i != 80 || datastore['URIPATH'] != '/' - raise RuntimeError, 'Using WebDAV requires SRVPORT=80 and URIPATH=/' + fail_with(Exploit::Failure::Unknown, 'Using WebDAV requires SRVPORT=80 and URIPATH=/') end super diff --git a/modules/exploits/windows/browser/java_ws_vmargs.rb b/modules/exploits/windows/browser/java_ws_vmargs.rb index 875c578c13..49030be23c 100644 --- a/modules/exploits/windows/browser/java_ws_vmargs.rb +++ b/modules/exploits/windows/browser/java_ws_vmargs.rb @@ -323,7 +323,7 @@ EOS # def exploit if datastore['SRVPORT'].to_i != 80 || datastore['URIPATH'] != '/' - raise RuntimeError, 'Using WebDAV requires SRVPORT=80 and URIPATH=/' + fail_with(Exploit::Failure::Unknown, 'Using WebDAV requires SRVPORT=80 and URIPATH=/') end super diff --git a/modules/exploits/windows/browser/ms10_022_ie_vbscript_winhlp32.rb b/modules/exploits/windows/browser/ms10_022_ie_vbscript_winhlp32.rb index 63019a1439..bcf5104e9f 100644 --- a/modules/exploits/windows/browser/ms10_022_ie_vbscript_winhlp32.rb +++ b/modules/exploits/windows/browser/ms10_022_ie_vbscript_winhlp32.rb @@ -316,7 +316,7 @@ MsgBox "Welcome! Press F1 to dismiss this dialog.", ,"Welcome!", "#{unc}", 1 # def exploit if datastore['SRVPORT'].to_i != 80 || datastore['URIPATH'] != '/' - raise RuntimeError, 'Using WebDAV requires SRVPORT=80 and URIPATH=/' + fail_with(Exploit::Failure::Unknown, 'Using WebDAV requires SRVPORT=80 and URIPATH=/') end path = File.join(Msf::Config.install_root, "data", "exploits", "runcalc.hlp") diff --git a/modules/exploits/windows/browser/ms10_042_helpctr_xss_cmd_exec.rb b/modules/exploits/windows/browser/ms10_042_helpctr_xss_cmd_exec.rb index 92cf5856b7..4424e550ae 100644 --- a/modules/exploits/windows/browser/ms10_042_helpctr_xss_cmd_exec.rb +++ b/modules/exploits/windows/browser/ms10_042_helpctr_xss_cmd_exec.rb @@ -341,7 +341,7 @@ if (window.navigator.appName == "Microsoft Internet Explorer") { @img_file = rand_text_alpha(rand(2)+1) + ".gif" if datastore['SRVPORT'].to_i != 80 || datastore['URIPATH'] != '/' - raise RuntimeError, 'Using WebDAV requires SRVPORT=80 and URIPATH=/' + fail_with(Exploit::Failure::Unknown, 'Using WebDAV requires SRVPORT=80 and URIPATH=/') end super diff --git a/modules/exploits/windows/browser/ms10_046_shortcut_icon_dllloader.rb b/modules/exploits/windows/browser/ms10_046_shortcut_icon_dllloader.rb index 373bfc4fe1..86e7c70bf6 100644 --- a/modules/exploits/windows/browser/ms10_046_shortcut_icon_dllloader.rb +++ b/modules/exploits/windows/browser/ms10_046_shortcut_icon_dllloader.rb @@ -442,7 +442,7 @@ class Metasploit3 < Msf::Exploit::Remote @exploit_dll = rand_text_alpha(rand(8)+4) + ".dll" if datastore['SRVPORT'].to_i != 80 || datastore['URIPATH'] != '/' - raise RuntimeError, 'Using WebDAV requires SRVPORT=80 and URIPATH=/' + fail_with(Exploit::Failure::Unknown, 'Using WebDAV requires SRVPORT=80 and URIPATH=/') end print_status("Send vulnerable clients to #{@exploit_unc}.") diff --git a/modules/exploits/windows/browser/ms11_003_ie_css_import.rb b/modules/exploits/windows/browser/ms11_003_ie_css_import.rb index 194321e5f8..e46bbcc3ea 100644 --- a/modules/exploits/windows/browser/ms11_003_ie_css_import.rb +++ b/modules/exploits/windows/browser/ms11_003_ie_css_import.rb @@ -422,7 +422,7 @@ EOS rop_stack.map! { |e| if e.kind_of? String # Meta-replace (RVA) - raise RuntimeError, "Unable to locate key: \"#{e}\"" if not rvas[e] + fail_with(Exploit::Failure::BadConfig, "Unable to locate key: \"#{e}\"") if not rvas[e] rvas['BaseAddress'] + rvas[e] elsif e == :unused @@ -447,7 +447,7 @@ EOS end def rva2addr(rvas, key) - raise RuntimeError, "Unable to locate key: \"#{key}\"" if not rvas[key] + fail_with(Exploit::Failure::BadConfig, "Unable to locate key: \"#{key}\"") if not rvas[key] rvas['BaseAddress'] + rvas[key] end diff --git a/modules/exploits/windows/browser/webdav_dll_hijacker.rb b/modules/exploits/windows/browser/webdav_dll_hijacker.rb index 4bd1b40d62..663f51bb06 100644 --- a/modules/exploits/windows/browser/webdav_dll_hijacker.rb +++ b/modules/exploits/windows/browser/webdav_dll_hijacker.rb @@ -368,7 +368,7 @@ class Metasploit3 < Msf::Exploit::Remote @exploit_unc = "\\\\#{myhost}\\" if datastore['SRVPORT'].to_i != 80 || datastore['URIPATH'] != '/' - raise RuntimeError, 'Using WebDAV requires SRVPORT=80 and URIPATH=/' + fail_with(Exploit::Failure::Unknown, 'Using WebDAV requires SRVPORT=80 and URIPATH=/') end print_status("Exploit links are now available at #{@exploit_unc}#{datastore['SHARENAME']}\\") diff --git a/modules/exploits/windows/browser/wmi_admintools.rb b/modules/exploits/windows/browser/wmi_admintools.rb index 4d9284c0b0..d3304956d8 100644 --- a/modules/exploits/windows/browser/wmi_admintools.rb +++ b/modules/exploits/windows/browser/wmi_admintools.rb @@ -291,7 +291,7 @@ EOS rop_stack.map! { |e| if e.kind_of? String # Meta-replace (RVA) - raise RuntimeError, "Unable to locate key: \"#{e}\"" if not rvas[e] + fail_with(Exploit::Failure::BadConfig, "Unable to locate key: \"#{e}\"") if not rvas[e] rvas['BaseAddress'] + rvas[e] elsif e == :unused @@ -316,7 +316,7 @@ EOS end def rva2addr(rvas, key) - raise RuntimeError, "Unable to locate key: \"#{key}\"" if not rvas[key] + fail_with(Exploit::Failure::BadConfig, "Unable to locate key: \"#{key}\"") if not rvas[key] rvas['BaseAddress'] + rvas[key] end diff --git a/modules/exploits/windows/email/ms10_045_outlook_ref_only.rb b/modules/exploits/windows/email/ms10_045_outlook_ref_only.rb index 1a8f90c58c..3207600ac7 100644 --- a/modules/exploits/windows/email/ms10_045_outlook_ref_only.rb +++ b/modules/exploits/windows/email/ms10_045_outlook_ref_only.rb @@ -332,7 +332,7 @@ class Metasploit3 < Msf::Exploit::Remote @exploit_exe = rand_text_alpha(rand(8)+4) + ".exe" if datastore['SRVPORT'].to_i != 80 || datastore['URIPATH'] != '/' - raise RuntimeError, 'Using WebDAV requires SRVPORT=80 and URIPATH=/' + fail_with(Exploit::Failure::Unknown, 'Using WebDAV requires SRVPORT=80 and URIPATH=/') end msg = Rex::MIME::Message.new diff --git a/modules/exploits/windows/email/ms10_045_outlook_ref_resolve.rb b/modules/exploits/windows/email/ms10_045_outlook_ref_resolve.rb index eaf2688fd2..e999b8060f 100644 --- a/modules/exploits/windows/email/ms10_045_outlook_ref_resolve.rb +++ b/modules/exploits/windows/email/ms10_045_outlook_ref_resolve.rb @@ -330,7 +330,7 @@ class Metasploit3 < Msf::Exploit::Remote @exploit_exe = rand_text_alpha(rand(8)+4) + ".exe" if datastore['SRVPORT'].to_i != 80 || datastore['URIPATH'] != '/' - raise RuntimeError, 'Using WebDAV requires SRVPORT=80 and URIPATH=/' + fail_with(Exploit::Failure::Unknown, 'Using WebDAV requires SRVPORT=80 and URIPATH=/') end msg = Rex::MIME::Message.new diff --git a/modules/exploits/windows/fileformat/ms09_067_excel_featheader.rb b/modules/exploits/windows/fileformat/ms09_067_excel_featheader.rb index bf9a5ece0f..5645104a92 100644 --- a/modules/exploits/windows/fileformat/ms09_067_excel_featheader.rb +++ b/modules/exploits/windows/fileformat/ms09_067_excel_featheader.rb @@ -156,11 +156,11 @@ class Metasploit3 < Msf::Exploit::Remote out = File.expand_path(File.join(datastore['OUTPUTPATH'], datastore['FILENAME'])) stg = Rex::OLE::Storage.new(out, Rex::OLE::STGM_WRITE) if (not stg) - raise RuntimeError, 'Unable to create output file' + fail_with(Exploit::Failure::Unknown, 'Unable to create output file') end stm = stg.create_stream("Workbook") if (not stm) - raise RuntimeError, 'Unable to create workbook stream' + fail_with(Exploit::Failure::Unknown, 'Unable to create workbook stream') end stm << content stm.close diff --git a/modules/exploits/windows/fileformat/ms10_004_textbytesatom.rb b/modules/exploits/windows/fileformat/ms10_004_textbytesatom.rb index 88c146c439..c53609244e 100644 --- a/modules/exploits/windows/fileformat/ms10_004_textbytesatom.rb +++ b/modules/exploits/windows/fileformat/ms10_004_textbytesatom.rb @@ -227,13 +227,13 @@ class Metasploit3 < Msf::Exploit::Remote out = datastore['FILENAME'] stg = Rex::OLE::Storage.new(out, Rex::OLE::STGM_WRITE) if (not stg) - raise RuntimeError, 'Unable to create output file' + fail_with(Exploit::Failure::Unknown, 'Unable to create output file') end # PowerPoint Document stream stm = stg.create_stream("PowerPoint Document") if (not stm) - raise RuntimeError, 'Unable to create "PowerPoint Document" stream' + fail_with(Exploit::Failure::Unknown, 'Unable to create "PowerPoint Document" stream') end stm << content stm.close @@ -256,7 +256,7 @@ class Metasploit3 < Msf::Exploit::Remote stm = stg.create_stream("Current User") if (not stm) - raise RuntimeError, 'Unable to create "Current User" stream' + fail_with(Exploit::Failure::Unknown, 'Unable to create "Current User" stream') end stm << current_user_stream stm.close diff --git a/modules/exploits/windows/fileformat/ms11_006_createsizeddibsection.rb b/modules/exploits/windows/fileformat/ms11_006_createsizeddibsection.rb index c25be95639..b60b700e38 100644 --- a/modules/exploits/windows/fileformat/ms11_006_createsizeddibsection.rb +++ b/modules/exploits/windows/fileformat/ms11_006_createsizeddibsection.rb @@ -122,12 +122,12 @@ class Metasploit3 < Msf::Exploit::Remote out = ::File.expand_path(::File.join(datastore['OUTPUTPATH'], datastore['FILENAME'])) stg = Rex::OLE::Storage.new(out, Rex::OLE::STGM_WRITE) if (not stg) - raise RuntimeError, 'Unable to create output file' + fail_with(Exploit::Failure::BadConfig, 'Unable to create output file') end stm = stg.create_stream("\x05SummaryInformation") if (not stm) - raise RuntimeError, 'Unable to create SummaryInformation stream' + fail_with(Exploit::Failure::BadConfig, 'Unable to create SummaryInformation stream') end stm << generate_summaryinfo() stm.close @@ -295,7 +295,7 @@ class Metasploit3 < Msf::Exploit::Remote rop_stack.map! { |e| if e.kind_of? String # Meta-replace (RVA) - raise RuntimeError, "Unable to locate key: \"#{e}\"" if not rvas[e] + fail_with(Exploit::Failure::BadConfig, "Unable to locate key: \"#{e}\"") if not rvas[e] rvas['BaseAddress'] + rvas[e] elsif e == :unused @@ -312,7 +312,7 @@ class Metasploit3 < Msf::Exploit::Remote end def rva2addr(rvas, key) - raise RuntimeError, "Unable to locate key: \"#{key}\"" if not rvas[key] + fail_with(Exploit::Failure::BadConfig, "Unable to locate key: \"#{key}\"") if not rvas[key] rvas['BaseAddress'] + rvas[key] end diff --git a/modules/exploits/windows/fileformat/vlc_modplug_s3m.rb b/modules/exploits/windows/fileformat/vlc_modplug_s3m.rb index 8b88c89bea..2869e3eb69 100644 --- a/modules/exploits/windows/fileformat/vlc_modplug_s3m.rb +++ b/modules/exploits/windows/fileformat/vlc_modplug_s3m.rb @@ -228,7 +228,7 @@ EOS EOS copy_stage = Metasm::Shellcode.assemble(Metasm::Ia32.new, copy_stage).encode_string if (copy_stage.length % 4) > 0 - raise RuntimeError, "The copy stage is invalid" + fail_with(Exploit::Failure::Unknown, "The copy stage is invalid") end rop_stack = [ @@ -296,7 +296,7 @@ EOS rop_stack.map! { |e| if e.kind_of? String # Meta-replace (RVA) - raise RuntimeError, "Unable to locate key: \"#{e}\"" if not rvas[e] + fail_with(Exploit::Failure::Unknown, "Unable to locate key: \"#{e}\"") if not rvas[e] rvas['BaseAddress'] + rvas[e] elsif e == :unused @@ -313,7 +313,7 @@ EOS end def rva2addr(rvas, key) - raise RuntimeError, "Unable to locate key: \"#{key}\"" if not rvas[key] + fail_with(Exploit::Failure::Unknown, "Unable to locate key: \"#{key}\"") if not rvas[key] rvas['BaseAddress'] + rvas[key] end diff --git a/modules/exploits/windows/http/altn_securitygateway.rb b/modules/exploits/windows/http/altn_securitygateway.rb index 5b627060a5..e2eb512213 100644 --- a/modules/exploits/windows/http/altn_securitygateway.rb +++ b/modules/exploits/windows/http/altn_securitygateway.rb @@ -103,7 +103,7 @@ class Metasploit3 < Msf::Exploit::Remote print_status("Attempting to automatically select a target...") mytarget = auto_target if mytarget.nil? - raise RuntimeError, "Unable to automatically select a target" + fail_with(Exploit::Failure::NoTarget, "Unable to automatically select a target") end print_status("Automatically selected target \"#{mytarget.name}\"") end diff --git a/modules/exploits/windows/http/ca_totaldefense_regeneratereports.rb b/modules/exploits/windows/http/ca_totaldefense_regeneratereports.rb index 48ec7f969f..2f417cfedd 100644 --- a/modules/exploits/windows/http/ca_totaldefense_regeneratereports.rb +++ b/modules/exploits/windows/http/ca_totaldefense_regeneratereports.rb @@ -110,7 +110,7 @@ class Metasploit3 < Msf::Exploit::Remote if ( res and res.body =~ /SUCCESS/ ) #print_good("Executing command...") else - raise RuntimeError, 'Something went wrong.' + fail_with(Exploit::Failure::Unknown, 'Something went wrong.') end end @@ -128,7 +128,7 @@ class Metasploit3 < Msf::Exploit::Remote when 'win' windows_stager else - raise RuntimeError, 'Target not supported.' + fail_with(Exploit::Failure::Unknown, 'Target not supported.') end handler diff --git a/modules/exploits/windows/http/easyftp_list.rb b/modules/exploits/windows/http/easyftp_list.rb index a1be8431aa..e1695a4a3f 100644 --- a/modules/exploits/windows/http/easyftp_list.rb +++ b/modules/exploits/windows/http/easyftp_list.rb @@ -93,7 +93,7 @@ class Metasploit3 < Msf::Exploit::Remote def exploit if (payload.encoded.length > payload_space) - raise RuntimeError, "Insufficient space for payload, try using a staged, ORD and/or shell payload." + fail_with(Exploit::Failure::Unknown, "Insufficient space for payload, try using a staged, ORD and/or shell payload.") end # Fix up ESP, jmp to the beginning of the buffer diff --git a/modules/exploits/windows/http/hp_nnm_ovas.rb b/modules/exploits/windows/http/hp_nnm_ovas.rb index e4e3501030..4fc428c207 100644 --- a/modules/exploits/windows/http/hp_nnm_ovas.rb +++ b/modules/exploits/windows/http/hp_nnm_ovas.rb @@ -118,7 +118,7 @@ class Metasploit3 < Msf::Exploit::Remote when /NNM Release B.07.51/ targ = targets[2] else - raise RuntimeError, "Unable to determine a target automatically..." + fail_with(Exploit::Failure::NoTarget, "Unable to determine a target automatically...") # if snmp is running you could set the target based on community strings end @@ -177,7 +177,7 @@ class Metasploit3 < Msf::Exploit::Remote end if not resp.nil? - raise RuntimeError, "The server responded, that wasn't supposed to happen!" + fail_with(Exploit::Failure::Unknown, "The server responded, that wasn't supposed to happen!") end print_status("Malformed http request sent.") diff --git a/modules/exploits/windows/http/hp_nnm_ovwebsnmpsrv_main.rb b/modules/exploits/windows/http/hp_nnm_ovwebsnmpsrv_main.rb index 4bebd2168f..642cb0c93b 100644 --- a/modules/exploits/windows/http/hp_nnm_ovwebsnmpsrv_main.rb +++ b/modules/exploits/windows/http/hp_nnm_ovwebsnmpsrv_main.rb @@ -155,7 +155,7 @@ class Metasploit3 < Msf::Exploit::Remote end if not res - raise RuntimeError, "Eek! We didn't get a response.. Exploiting this vuln should return one!" + fail_with(Exploit::Failure::Unknown, "Eek! We didn't get a response.. Exploiting this vuln should return one!") end print_status(res.body) if datastore["NNM_DEBUG"] @@ -163,7 +163,7 @@ class Metasploit3 < Msf::Exploit::Remote if res.body =~ /graphing applet is being/ print_status("We got the body we were looking for, the session should be coming any second.") else - raise RuntimeError, "Eek, exploit likely failed. The body didn't contain what we expected." + fail_with(Exploit::Failure::Unknown, "Eek, exploit likely failed. The body didn't contain what we expected.") end handler diff --git a/modules/exploits/windows/http/hp_nnm_ovwebsnmpsrv_ovutil.rb b/modules/exploits/windows/http/hp_nnm_ovwebsnmpsrv_ovutil.rb index d5bfd57573..de3912f278 100644 --- a/modules/exploits/windows/http/hp_nnm_ovwebsnmpsrv_ovutil.rb +++ b/modules/exploits/windows/http/hp_nnm_ovwebsnmpsrv_ovutil.rb @@ -158,7 +158,7 @@ class Metasploit3 < Msf::Exploit::Remote end if not res - raise RuntimeError, "Eek! We didn't get a response.. Exploiting this vuln should return one!" + fail_with(Exploit::Failure::Unknown, "Eek! We didn't get a response.. Exploiting this vuln should return one!") end print_status(res.body) if datastore["NNM_DEBUG"] @@ -166,7 +166,7 @@ class Metasploit3 < Msf::Exploit::Remote if res.body =~ /graphing applet is being/ print_status("We got the body we were looking for, the session should be coming any second.") else - raise RuntimeError, "Eek, exploit likely failed. The body didn't contain what we expected." + fail_with(Exploit::Failure::Unknown, "Eek, exploit likely failed. The body didn't contain what we expected.") end handler diff --git a/modules/exploits/windows/http/httpdx_tolog_format.rb b/modules/exploits/windows/http/httpdx_tolog_format.rb index 701c732a23..82e3ef17eb 100644 --- a/modules/exploits/windows/http/httpdx_tolog_format.rb +++ b/modules/exploits/windows/http/httpdx_tolog_format.rb @@ -167,7 +167,7 @@ For now, that will have to be done manually. version = get_version if not version - raise RuntimeError, "The server doesn't appear to be running a vulnerable version of HTTPDX" + fail_with(Exploit::Failure::Unknown, "The server doesn't appear to be running a vulnerable version of HTTPDX") end re = Regexp.new(Regexp.escape(version)+' - ', true) @@ -179,7 +179,7 @@ For now, that will have to be done manually. end if (not mytarget) - raise RuntimeError, 'Unable to automatically detect exploitation parameters' + fail_with(Exploit::Failure::Unknown, 'Unable to automatically detect exploitation parameters') end print_status("Selected Target: #{mytarget.name}") diff --git a/modules/exploits/windows/http/integard_password_bof.rb b/modules/exploits/windows/http/integard_password_bof.rb index 9ef4706325..1207678638 100644 --- a/modules/exploits/windows/http/integard_password_bof.rb +++ b/modules/exploits/windows/http/integard_password_bof.rb @@ -101,7 +101,7 @@ class Metasploit3 < Msf::Exploit::Remote end if not mytarget - raise RuntimeError, "Unable to automatically detect the target version" + fail_with(Exploit::Failure::NoTarget, "Unable to automatically detect the target version") end print_status("Selected Target: #{mytarget.name}") diff --git a/modules/exploits/windows/http/novell_imanager_upload.rb b/modules/exploits/windows/http/novell_imanager_upload.rb index f6cef8f099..616e383419 100644 --- a/modules/exploits/windows/http/novell_imanager_upload.rb +++ b/modules/exploits/windows/http/novell_imanager_upload.rb @@ -94,7 +94,7 @@ class Metasploit3 < Msf::Exploit::Remote }, 5) handler else - raise RuntimeError, 'POST failed' + fail_with(Exploit::Failure::Unknown, 'POST failed') end end diff --git a/modules/exploits/windows/http/osb_uname_jlist.rb b/modules/exploits/windows/http/osb_uname_jlist.rb index 25f079bd25..2e77f702e3 100644 --- a/modules/exploits/windows/http/osb_uname_jlist.rb +++ b/modules/exploits/windows/http/osb_uname_jlist.rb @@ -110,7 +110,7 @@ class Metasploit3 < Msf::Exploit::Remote when 'win' windows_stager else - raise RuntimeError, 'Target not supported.' + fail_with(Exploit::Failure::Unknown, 'Target not supported.') end handler diff --git a/modules/exploits/windows/iis/ms01_026_dbldecode.rb b/modules/exploits/windows/iis/ms01_026_dbldecode.rb index bb4b815721..a700b41e53 100644 --- a/modules/exploits/windows/iis/ms01_026_dbldecode.rb +++ b/modules/exploits/windows/iis/ms01_026_dbldecode.rb @@ -173,7 +173,7 @@ class Metasploit3 < Msf::Exploit::Remote # try to detect the windows directory @win_dir = detect_windows_dir() if not @win_dir - raise RuntimeError, "Unable to detect the target host windows directory (maybe not vulnerable)!" + fail_with(Exploit::Failure::NoTarget, "Unable to detect the target host windows directory (maybe not vulnerable)!") end end print_status("Using windows directory \"#{@win_dir}\"") diff --git a/modules/exploits/windows/imap/eudora_list.rb b/modules/exploits/windows/imap/eudora_list.rb index 9b875e9e6f..56bfec8eb0 100644 --- a/modules/exploits/windows/imap/eudora_list.rb +++ b/modules/exploits/windows/imap/eudora_list.rb @@ -100,7 +100,7 @@ class Metasploit3 < Msf::Exploit::Remote if mytarget print_status("Automatically detected \"#{mytarget.name}\" ...") else - raise RuntimeError, 'Unable to automatically detect a target' + fail_with(Exploit::Failure::NoTarget, 'Unable to automatically detect a target') end else mytarget = target diff --git a/modules/exploits/windows/isapi/w3who_query.rb b/modules/exploits/windows/isapi/w3who_query.rb index f7ff09c881..8f7c40e291 100644 --- a/modules/exploits/windows/isapi/w3who_query.rb +++ b/modules/exploits/windows/isapi/w3who_query.rb @@ -105,7 +105,7 @@ class Metasploit3 < Msf::Exploit::Remote end if not mytarget - raise RuntimeError, "No valid target found" + fail_with(Exploit::Failure::NoTarget, "No valid target found") end buf = rand_text_english(8192, payload_badchars) diff --git a/modules/exploits/windows/lotus/lotusnotes_lzh.rb b/modules/exploits/windows/lotus/lotusnotes_lzh.rb index 517d696d2d..91a71e3077 100644 --- a/modules/exploits/windows/lotus/lotusnotes_lzh.rb +++ b/modules/exploits/windows/lotus/lotusnotes_lzh.rb @@ -157,7 +157,7 @@ class Metasploit3 < Msf::Exploit::Remote print_status("Waiting for a payload session (backgrounding)...") if not datastore['ExitOnSession'] and not job_id - raise RuntimeError, "Setting ExitOnSession to false requires running as a job (exploit -j)" + fail_with(Exploit::Failure::Unknown, "Setting ExitOnSession to false requires running as a job (exploit -j)") end stime = Time.now.to_f diff --git a/modules/exploits/windows/misc/hp_omniinet_1.rb b/modules/exploits/windows/misc/hp_omniinet_1.rb index 7d3947bb2d..acaa3e49b4 100644 --- a/modules/exploits/windows/misc/hp_omniinet_1.rb +++ b/modules/exploits/windows/misc/hp_omniinet_1.rb @@ -147,7 +147,7 @@ class Metasploit3 < Msf::Exploit::Remote disconnect if not resp - raise RuntimeError, "No version response returned." + fail_with(Exploit::Failure::Unknown, "No version response returned.") end resp = resp.unpack('v*').pack('C*') @@ -161,7 +161,7 @@ class Metasploit3 < Msf::Exploit::Remote end if (not mytarget) - raise RuntimeError, "No matching target" + fail_with(Exploit::Failure::NoTarget, "No matching target") end print_status("Selected Target: #{mytarget.name}") diff --git a/modules/exploits/windows/misc/hp_omniinet_2.rb b/modules/exploits/windows/misc/hp_omniinet_2.rb index 6c5dc2f0ff..406264f02f 100644 --- a/modules/exploits/windows/misc/hp_omniinet_2.rb +++ b/modules/exploits/windows/misc/hp_omniinet_2.rb @@ -147,7 +147,7 @@ class Metasploit3 < Msf::Exploit::Remote disconnect if not resp - raise RuntimeError, "No version response returned." + fail_with(Exploit::Failure::Unknown, "No version response returned.") end resp = resp.unpack('v*').pack('C*') @@ -161,7 +161,7 @@ class Metasploit3 < Msf::Exploit::Remote end if (not mytarget) - raise RuntimeError, "No matching target" + fail_with(Exploit::Failure::NoTarget, "No matching target") end print_status("Selected Target: #{mytarget.name}") diff --git a/modules/exploits/windows/mmsp/ms10_025_wmss_connect_funnel.rb b/modules/exploits/windows/mmsp/ms10_025_wmss_connect_funnel.rb index da5817d9d4..332719052b 100644 --- a/modules/exploits/windows/mmsp/ms10_025_wmss_connect_funnel.rb +++ b/modules/exploits/windows/mmsp/ms10_025_wmss_connect_funnel.rb @@ -150,7 +150,7 @@ class Metasploit3 < Msf::Exploit::Remote def make_tcpmsghdr(data) len = data.length # The server doesn't like packets that are bigger... - raise RuntimeError, 'Length too big' if (len > 0x1000) + fail_with(Exploit::Failure::BadConfig, 'Message length is too big') if (len > 0x1000) len /= 8 # Pack the pieces in ... diff --git a/modules/exploits/windows/mssql/ms09_004_sp_replwritetovarbin.rb b/modules/exploits/windows/mssql/ms09_004_sp_replwritetovarbin.rb index 8d03bda5f6..6b7117e7e2 100644 --- a/modules/exploits/windows/mssql/ms09_004_sp_replwritetovarbin.rb +++ b/modules/exploits/windows/mssql/ms09_004_sp_replwritetovarbin.rb @@ -287,7 +287,7 @@ class Metasploit3 < Msf::Exploit::Remote print_status("Attempting automatic target detection...") version = mssql_query_version - raise RuntimeError, "Unable to get version!" if not version + fail_with(Exploit::Failure::NoAccess, "Unable to retrieve version information") if not version if (version =~ /8\.00\.194/) mytarget = targets[1] @@ -308,7 +308,7 @@ class Metasploit3 < Msf::Exploit::Remote end if mytarget.nil? - raise RuntimeError, "Unable to automatically detect the target" + fail_with(Exploit::Failure::NoTarget, "Unable to determine target") else print_status("Automatically detected target \"#{mytarget.name}\"") end @@ -385,7 +385,7 @@ exec sp_executesql @z| # go! if (not mssql_login_datastore) - raise RuntimeError, "Unable to log in!" + fail_with(Exploit::Failure::NoAccess, "Unable to log in!") end begin mssql_query(runme, datastore['VERBOSE']) @@ -460,7 +460,7 @@ exec sp_executesql @z| end if (not logged_in) - raise RuntimeError, "Invalid SQL Server credentials" + fail_with(Exploit::Failure::NoAccess, "Invalid SQL Server credentials") end res = mssql_query("select @@version", datastore['VERBOSE']) disconnect @@ -471,7 +471,7 @@ exec sp_executesql @z| res[:errors].each do |err| errstr << err end - raise RuntimeError, errstr + fail_with(Exploit::Failure::Unknown, errstr) end if not res[:rows] or res[:rows].empty? diff --git a/modules/exploits/windows/mssql/ms09_004_sp_replwritetovarbin_sqli.rb b/modules/exploits/windows/mssql/ms09_004_sp_replwritetovarbin_sqli.rb index 350ba90f27..a710b73e6f 100644 --- a/modules/exploits/windows/mssql/ms09_004_sp_replwritetovarbin_sqli.rb +++ b/modules/exploits/windows/mssql/ms09_004_sp_replwritetovarbin_sqli.rb @@ -289,7 +289,7 @@ class Metasploit3 < Msf::Exploit::Remote print_status("Attempting automatic target detection...") version = mssql_query_version - raise RuntimeError, "Unable to get version!" if not version + fail_with(Exploit::Failure::NoAccess, "Unable to get version!") if not version if (version =~ /8\.00\.194/) mytarget = targets[1] @@ -310,7 +310,7 @@ class Metasploit3 < Msf::Exploit::Remote end if mytarget.nil? - raise RuntimeError, "Unable to automatically detect the target" + fail_with(Exploit::Failure::NoTarget, "Unable to automatically detect the target") else print_status("Automatically detected target \"#{mytarget.name}\"") end diff --git a/modules/exploits/windows/oracle/tns_auth_sesskey.rb b/modules/exploits/windows/oracle/tns_auth_sesskey.rb index ffc7432326..423ce99944 100644 --- a/modules/exploits/windows/oracle/tns_auth_sesskey.rb +++ b/modules/exploits/windows/oracle/tns_auth_sesskey.rb @@ -80,7 +80,7 @@ class Metasploit3 < Msf::Exploit::Remote def check version = tns_version if (not version) - raise RuntimeError, "Unable to detect the Oracle version!" + fail_with(Exploit::Failure::Unknown, "Unable to detect the Oracle version!") end print_status("Oracle version reply: " + version) return Exploit::CheckCode::Vulnerable if (version =~ /32-bit Windows: Version 10\.2\.0\.1\.0/) @@ -97,7 +97,7 @@ class Metasploit3 < Msf::Exploit::Remote version = tns_version if (not version) - raise RuntimeError, "Unable to detect the Oracle version!" + fail_with(Exploit::Failure::Unknown, "Unable to detect the Oracle version!") end if (version =~ /32-bit Windows: Version 10\.2\.0\.1\.0/) @@ -107,7 +107,7 @@ class Metasploit3 < Msf::Exploit::Remote end if (not mytarget) - raise RuntimeError, "Unable to automatically detect the target" + fail_with(Exploit::Failure::NoTarget, "Unable to automatically detect the target") end print_status("Automatically detected target \"#{mytarget.name}\"") @@ -151,7 +151,7 @@ class Metasploit3 < Msf::Exploit::Remote begin res = sock.get_once(-1, 1) rescue ::Errno::ECONNRESET, EOFError - raise RuntimeError, "OOPS, maybe the service hasn't started completely yet, try again..." + fail_with(Exploit::Failure::Unknown, "OOPS, maybe the service hasn't started completely yet, try again...") end #print_status(("received %u bytes:\n" % res.length) + Rex::Text.to_hex_dump(res)) @@ -236,7 +236,7 @@ class Metasploit3 < Msf::Exploit::Remote # expecting disconnect... if (res = sock.get_once(-1, 1)) print_status(("received %u bytes:\n" % res.length) + Rex::Text.to_hex_dump(res)) - raise RuntimeError, "Try to run the exploit again.. If that doesn't work, the target host may be patched :-/" + fail_with(Exploit::Failure::NoTarget, "Try to run the exploit again.. If that doesn't work, the target host may be patched :-/") end handler diff --git a/modules/exploits/windows/smb/ms06_070_wkssvc.rb b/modules/exploits/windows/smb/ms06_070_wkssvc.rb index ed446f0463..2fbc86ecba 100644 --- a/modules/exploits/windows/smb/ms06_070_wkssvc.rb +++ b/modules/exploits/windows/smb/ms06_070_wkssvc.rb @@ -103,13 +103,13 @@ class Metasploit3 < Msf::Exploit::Remote print_status("Detected a Windows XP SP0/SP1 target") rescue ::Rex::Proto::SMB::Exceptions::ErrorCode => e if (e.error_code == 0xc0000022) - raise RuntimeError, "Windows XP SP2 requires Administrator privileges!" + fail_with(Exploit::Failure::Unknown, "Windows XP SP2 requires Administrator privileges!") end print_status("Detected a Windows XP target (unknown patch level)") end mytarget = targets[2] else - raise RuntimeError, "No target detected for #{smb_peer_os()}/#{smb_peer_lm()}..." + fail_with(Exploit::Failure::NoTarget, "No target detected for #{smb_peer_os()}/#{smb_peer_lm()}...") end else mytarget = target diff --git a/modules/exploits/windows/smb/ms08_067_netapi.rb b/modules/exploits/windows/smb/ms08_067_netapi.rb index 0fca26511b..6f31d6bd3e 100644 --- a/modules/exploits/windows/smb/ms08_067_netapi.rb +++ b/modules/exploits/windows/smb/ms08_067_netapi.rb @@ -790,7 +790,7 @@ class Metasploit3 < Msf::Exploit::Remote # Bail early on unknown OS if(fprint['os'] == 'Unknown') - raise RuntimeError, "No matching target" + fail_with(Exploit::Failure::NoTarget, "No matching target") end # Windows 2000 is mostly universal @@ -845,7 +845,7 @@ class Metasploit3 < Msf::Exploit::Remote end if(not mytarget) - raise RuntimeError, "No matching target" + fail_with(Exploit::Failure::NoTarget, "No matching target") end print_status("Selected Target: #{mytarget.name}") @@ -1174,7 +1174,7 @@ class Metasploit3 < Msf::Exploit::Remote rop.map! { |e| if e.kind_of? String # Meta-replace (RVA) - raise RuntimeError, "Unable to locate key: \"#{e}\"" if not rvas[e] + fail_with(Exploit::Failure::BadConfig, "Unable to locate key: \"#{e}\"") if not rvas[e] module_base + rvas[e] elsif e == :unused diff --git a/modules/exploits/windows/smb/ms10_061_spoolss.rb b/modules/exploits/windows/smb/ms10_061_spoolss.rb index 5d5752359f..44e1d94079 100644 --- a/modules/exploits/windows/smb/ms10_061_spoolss.rb +++ b/modules/exploits/windows/smb/ms10_061_spoolss.rb @@ -143,7 +143,7 @@ class Metasploit3 < Msf::Exploit::Remote # Open the printer status,ph = open_printer_ex(pname) if status != 0 - raise RuntimeError, "Unable to open printer: #{Msf::WindowsError.description(status)}" + fail_with(Exploit::Failure::Unknown, "Unable to open printer: #{Msf::WindowsError.description(status)}") end print_status("Printer handle: %s" % ph.unpack('H*')) @@ -162,7 +162,7 @@ class Metasploit3 < Msf::Exploit::Remote # ClosePrinter status,ph = close_printer(ph) if status != 0 - raise RuntimeError, "Failed to close printer: #{Msf::WindowsError.description(status)}" + fail_with(Exploit::Failure::Unknown, "Failed to close printer: #{Msf::WindowsError.description(status)}") end break if session_created? @@ -180,7 +180,7 @@ class Metasploit3 < Msf::Exploit::Remote disconnect rescue ::Rex::Proto::SMB::Exceptions::ErrorCode, Rex::ConnectionError - raise RuntimeError, $!.message + fail_with(Exploit::Failure::Unknown, $!.message) end @@ -194,21 +194,21 @@ class Metasploit3 < Msf::Exploit::Remote # StartDocPrinter status,jobid = start_doc_printer(ph, doc, fname) if status != 0 or jobid < 0 - raise RuntimeError, "Unable to start print job: #{Msf::WindowsError.description(status)}" + fail_with(Exploit::Failure::Unknown, "Unable to start print job: #{Msf::WindowsError.description(status)}") end print_status("Job started: 0x%x" % jobid) # WritePrinter status,wrote = write_printer(ph, data) if status != 0 or wrote != data.length - raise RuntimeError, ('Failed to write %d bytes!' % data.length) + fail_with(Exploit::Failure::Unknown, ('Failed to write %d bytes!' % data.length)) end print_status("Wrote %d bytes to %%SystemRoot%%\\system32\\%s" % [data.length, fname]) # EndDocPrinter status = end_doc_printer(ph) if status != 0 - raise RuntimeError, "Failed to end print job: #{Msf::WindowsError.description(status)}" + fail_with(Exploit::Failure::Unknown, "Failed to end print job: #{Msf::WindowsError.description(status)}") end end