Penetration Testing with Kali Linux
PWK - Copyright © 2023 OffSec Services Limited. All rights reserved.
241
When the admin loads the Visitors plugin dashboards that contains
the injected JavaScript, it
executes whatever we provided as a payload, be it an alert pop-up banner or a more complex
JavaScript function.
For
instance, we could craft a JavaScript function that adds another WordPress administrative
account, so that once the real administrator executes our injected code, the function will execute
behind the scenes.
In order to succeed with our attack angle, we need to cover another web application attack class.
To develop this attack, we’ll build a similar scenario as depicted by Shift8.
376
First, we’ll create a
JS function that fetches the WordPress admin
nonce
.
377
The nonce is a server-generated token that is included in each HTTP request to add randomness
and prevent
Cross-Site-Request-Forgery
(CSRF)
378
attacks.
A CSRF attack occurs via social engineering in which the victim clicks
on a malicious link that
performs a preconfigured action on behalf of the user.
The malicious link could be disguised by an apparently-harmless description, often luring the
victim to click on it.
Check out
these awesome cat memes!
Listing 123 - CSRF example attack
In the above example, the URL link is pointing to a Fake Crypto Bank website API, which performs
a bitcoin transfer to the attacker account. If this link was embedded into the HTML code of an
email, the user would be only able to see the link description, but not the actual HTTP resource it
is pointing to. This attack would be successful if the user is already logged in with a valid session
on the same website.
In our case, by including and checking the pseudo-random nonce, WordPress prevents this kind
of attack, since an attacker could not have prior knowledge of the token. However, as we’ll soon
explain, the nonce won’t be an obstacle for the stored XSS vulnerability
we discovered in the
plugin.
As mentioned, in order to perform any administrative action, we need to first gather the nonce.
We can accomplish this using the following JavaScript function:
var ajaxRequest = new XMLHttpRequest();
var requestURL = "/wp-admin/user-new.php";
var nonceRegex =
Yüklə
Dostları ilə paylaş: