Skip to content

Commit

Permalink
remove cookie management
Browse files Browse the repository at this point in the history
  • Loading branch information
Jared committed May 29, 2024
1 parent 9c9dd0b commit 11af9e2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 16 deletions.
21 changes: 8 additions & 13 deletions app/controllers/core.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,20 +80,11 @@ def saml_request?(effective_uri)
def handle_saml_authentication(effective_uri)
raise Error::SAMLAuthenticationRequired unless NS::ParsedCli.expect_saml

cookies = BrowserAuthenticator.authenticate(effective_uri.to_s)
# Authenticate using the ferrum browser
BrowserAuthenticator.authenticate(effective_uri.to_s)

# Extract name=value pairs and concatenate into a single string
cookie_string = cookies.map do |cookie|
cookie.split(';').first # Takes only the part before the first semicolon (name=value)
end.join('; ')

puts cookie_string

# Now, use these cookies for the scanning process
# NS::Browser.instance.headers['Cookie'] = cookie_string
# Continue scanning

raise Error::SAMLAuthenticationRequired
# Resume the scan by following the redirect
target.opts[:ignore_main_redirect] = true
end

# Checks for redirects, an out of scope redirect will raise an Error::HTTPRedirect
Expand All @@ -103,6 +94,10 @@ def handle_redirection(res)
effective_url = target.homepage_res.effective_url # Basically get and follow location of target.url
effective_uri = Addressable::URI.parse(effective_url)

if NS::ParsedCli.expect_saml && !saml_request?(effective_uri)
puts 'SAML authentication was expected but not required.'
end

handle_saml_authentication(effective_uri) if saml_request?(effective_uri)
handle_scheme_change(effective_url, effective_uri)
return if target.in_scope?(effective_url)
Expand Down
3 changes: 0 additions & 3 deletions lib/cms_scanner/browser_authenticator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ def self.authenticate(login_url)
puts 'Please log in through the opened browser window. Press enter once done.'
gets # Waits for user input

cookies = browser.cookies.all.to_a
browser.quit

cookies
end
end

0 comments on commit 11af9e2

Please sign in to comment.