Skip to content

Commit

Permalink
undo complexity change
Browse files Browse the repository at this point in the history
  • Loading branch information
Jared committed May 31, 2024
1 parent ea65b84 commit e14c388
Showing 1 changed file with 8 additions and 19 deletions.
27 changes: 8 additions & 19 deletions app/controllers/core.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,23 +71,6 @@ def saml_request?(effective_uri)
effective_uri.to_s.match?(/[?&]SAMLRequest/i)
end

# Builds the command to run the authenticated scan
#
# @param [ String ] cookie_string
# @param [ String ] target_url
#
# @return [ String ] The command to run
def build_command(cookie_string, target_url)
# Filter out --expect-saml, --cookie-string, and --no-banner flags from the original options
filtered_options = ARGV.reject do |arg|
arg.start_with?('--expect-saml', '--cookie-string', '--no-banner')
end.join(' ')

# Build the command
"wpscan --url #{target_url} --cookie-string '#{cookie_string}' --no-banner #{filtered_options}"
end


# Handle redirect if the target contains 'SAMLRequest', indicating a need for SAML authentication.
#
# @param [ Addressable::URI ] effective_uri
Expand All @@ -102,10 +85,16 @@ def handle_saml_authentication(effective_uri)

# Authenticate using the ferrum browser
cookie_string = BrowserAuthenticator.authenticate(effective_uri.to_s)
target_url = target.url # Needed for overriding in tests
command = build_command(cookie_string, target_url)

target_url = target.url # Needed for overriding in tests

# Filter out --expect-saml, --cookie-string, and --no-banner flags from the original options
filtered_options = ARGV.reject do |arg|
arg.start_with?('--expect-saml', '--cookie-string', '--no-banner')
end.join(' ')

# Restart the scan with the cookies set and pass in the original options filtered
command = "wpscan --url #{target_url} --cookie-string '#{cookie_string}' --no-banner #{filtered_options}"
raise Error::AuthenticatedRescanFailure, command unless Kernel.system(command)

exit(NS::ExitCode::OK)
Expand Down

0 comments on commit e14c388

Please sign in to comment.