Skip to content

Commit ed1a5d9

Browse files
committed
TeamCity: use vars_post for login request
1 parent 84cacb5 commit ed1a5d9

File tree

1 file changed

+8
-17
lines changed

1 file changed

+8
-17
lines changed

lib/metasploit/framework/login_scanner/teamcity.rb

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -59,22 +59,6 @@ def get_public_key(response)
5959
{ status: :success, proof: public_key_choices.first.value }
6060
end
6161

62-
# Create a login request body for the provided credentials.
63-
# @param [String] username The username to create the request body for.
64-
# @param [String] password The user's password.
65-
# @param [Object] public_key The public key to use when encrypting the password.
66-
def create_login_request_body(username, password, public_key)
67-
vars = {}
68-
vars['username'] = URI.encode_www_form_component(username)
69-
vars['remember'] = 'true'
70-
vars['_remember'] = ''
71-
vars['submitLogin'] = URI.encode_www_form_component('Log in')
72-
vars['publicKey'] = public_key
73-
vars['encryptedPassword'] = Rex::Proto::Teamcity::Rsa.encrypt_data(password, public_key)
74-
75-
vars.each.map { |key, value| "#{key}=#{value}" }.join('&')
76-
end
77-
7862
# Create a login request for the provided credentials.
7963
# @param [String] username The username to create the login request for.
8064
# @param [String] password The password to log in with.
@@ -85,7 +69,14 @@ def create_login_request(username, password, public_key)
8569
'method' => 'POST',
8670
'uri' => normalize_uri(@uri.to_s, SUBMIT_PAGE),
8771
'ctype' => 'application/x-www-form-urlencoded',
88-
'data' => create_login_request_body(username, password, public_key)
72+
'vars_post' => {
73+
username: username,
74+
remember: true,
75+
_remember: '',
76+
submitLogin: 'Log in',
77+
publicKey: public_key,
78+
encryptedPassword: Rex::Proto::Teamcity::Rsa.encrypt_data(password, public_key)
79+
}
8980
}
9081
end
9182

0 commit comments

Comments
 (0)