Penetration Testing with Kali Linux
PWK - Copyright © 2023 OffSec Services Limited. All rights reserved.
234
the key is that DOM-based XSS attacks occur when a browser parses the page’s content and
inserted JavaScript is executed.
No matter how the XSS payload is delivered and executed, the injected scripts run under the
context of the user visiting the affected page. This means that the user’s browser, not the web
application, executes the XSS payload. These attacks can be nevertheless significant, with
impacts including session hijacking, forced redirection to malicious pages, execution of local
applications as that user, or even trojanized web applications. In the following sections, we will
explore some of these attacks.
8.4.2
JavaScript Refresher
JavaScript is a high-level programming language that has become one of the main components
of modern web applications. All modern browsers include a JavaScript engine that runs
JavaScript code from within the browser itself.
When a browser processes a server’s HTTP response containing HTML, the browser creates a
DOM tree and renders it. The DOM is comprised of all forms, inputs, images, etc. related to the
web page.
JavaScript’s role is to access and modify the page’s DOM, resulting in a more interactive user
experience. From an attacker’s perspective, this also means that if we can inject JavaScript code
into the application, we can access and modify the page’s DOM. With access to the DOM, we can
redirect login forms, extract passwords, and steal session cookies.
Like many other programming languages, JavaScript can combine a set of instructions into a
function.
364
function multiplyValues(x,y) {
return x * y;
}
let a = multiplyValues(3, 5)
console.log(a)
Yüklə
Dostları ilə paylaş: