Skip to content

Commit

Permalink
Address previous TeamCity PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
sjanusz-r7 committed Nov 27, 2024
1 parent 7577d04 commit 2d14593
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/metasploit/framework/login_scanner/teamcity.rb
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ def try_login(username, password, public_key, retry_counter = 0)
# Currently, those building blocks are not available, so this is the approach I have implemented.
timeout = res.body.match(/login only in (?<timeout>\d+)s/)&.named_captures&.dig('timeout')&.to_i
if timeout
framework_module.print_status "User '#{username}' locked out for #{timeout} seconds. Sleeping, and retrying..."
framework_module.print_status "#{framework_module.peer} - User '#{username}:#{password}' locked out for #{timeout} seconds. Sleeping, and retrying..."
sleep(timeout + 1) # + 1 as TeamCity is off-by-one when reporting the lockout timer.
result = try_login(username, password, public_key, retry_counter + 1)
return result
Expand All @@ -220,7 +220,11 @@ def try_login(username, password, public_key, retry_counter = 0)
raise DecryptionError, 'The server failed to decrypt the encrypted password' if res.body.match?('DecryptionFailedException')
raise PublicKeyExpiredError, 'The server public key has expired' if res.body.match?('publicKeyExpired')

{ status: :success, proof: res }
successful_login_body = %r(^<response><redirect>\/favorite\/projects<\/redirect><user id="[0-9]+" \/><errors \/><\/response>$)
return { status: :success, proof: res } if res.body.match?(successful_login_body)

# Default to incorrect login.
{ status: ::Metasploit::Model::Login::Status::INCORRECT, proof: res }
end

# Send a logout request for the provided user's headers.
Expand Down

0 comments on commit 2d14593

Please sign in to comment.