Skip to content

Commit e2b9225

Browse files
committed
Fix rapid7#7022, Failing to find wpnonce in fetch_ninja_form_nonce
This patch fixes a problem when the module is used against an older version of ninja forms (such as 2.9.27), the nonce is found in a hidden input instead of the JavaScript code, which actually causes an undefined method 'gsub' bug in the module. Fix rapid7#7022
1 parent 55457ef commit e2b9225

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

modules/exploits/unix/webapp/wp_ninja_forms_unauthenticated_file_upload.rb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,13 @@ 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+
res.body[/var nfFrontEnd = \{"ajaxNonce":"([a-zA-Z0-9]+)"/i, 1] || form_wpnonce
110115
end
111116

112117
def upload_payload(data)

0 commit comments

Comments
 (0)