Fix CSRF regular expressions as per review

unstable
Ramon de C Valle 2013-07-22 13:10:56 -03:00
parent 11ef4263a4
commit 04e9398ddd
1 changed files with 8 additions and 2 deletions

View File

@ -83,8 +83,14 @@ class Metasploit4 < Msf::Exploit::Remote
if res.headers['Location'] =~ /users\/login$/ if res.headers['Location'] =~ /users\/login$/
fail_with(Exploit::Failure::UnexpectedReply, 'Failed to retrieve the CSRF token') fail_with(Exploit::Failure::UnexpectedReply, 'Failed to retrieve the CSRF token')
else else
csrf_param = $1 if res.body =~ /<meta[ ]+content="(.*)"[ ]+name="csrf-param"[ ]+\/?>/ csrf_param = $1 if res.body =~ /<meta[ ]+content="(.*)"[ ]+name="csrf-param"[ ]*\/?>/i
csrf_token = $1 if res.body =~ /<meta[ ]+content="(.*)"[ ]+name="csrf-token"[ ]+\/?>/ csrf_token = $1 if res.body =~ /<meta[ ]+content="(.*)"[ ]+name="csrf-token"[ ]*\/?>/i
if csrf_param.nil? || csrf_token.nil?
csrf_param = $1 if res.body =~ /<meta[ ]+name="csrf-param"[ ]+content="(.*)"[ ]*\/?>/i
csrf_token = $1 if res.body =~ /<meta[ ]+name="csrf-token"[ ]+content="(.*)"[ ]*\/?>/i
end
fail_with(Exploit::Failure::UnexpectedReply, 'Failed to retrieve the CSRF token') if csrf_param.nil? || csrf_token.nil? fail_with(Exploit::Failure::UnexpectedReply, 'Failed to retrieve the CSRF token') if csrf_param.nil? || csrf_token.nil?
end end