eCPPTv2-PTP-Notes
HomeGitHubPortfolioTwitter/XMediumCont@ct
  • 📝eCPPTv2 / PTP - Notes
  • 1️⃣1 - ​System Security
    • 1.1 Architecture Foundamentals
    • 1.2 Assemblers and Tools
    • 1.3 Buffer Overflow
    • 1.4 Cryptography
    • 1.5 Malware
    • 1.6 Shellcoding
  • 2️⃣2 - Network Security
    • 2.1 System/Host Based Attacks
      • 2.1.1 Windows Vulnerabilities
    • 2.2 Network Based Attacks
    • 2.3 The Metasploit Framework (MSF)
      • MSF Introduction
      • Information Gathering & Enumeration
      • Vulnerability Scanning
      • Client-Side Attacks
      • Post Exploitation
      • Armitage
    • 2.4 Exploitation
    • 2.5 - Post Expolitation / Pivoting
      • 2.5.1 Pivoting Guidelines
      • 2.5.2 Pivoting Example (3 Targets)
    • 2.6 Social Engineering
  • 3️⃣3 - PowerShell for PT
    • 3.1 PowerShell
  • 4️⃣4 - Linux Exploitation
    • 4.1 Linux Vulnerabilities
    • 4.2 Linux Exploitation
    • 4.3 Linux Post-Exploitation
    • 4.4 Linux Privilege Escalation
      • 4.4.1 Kernel Exploitation
      • 4.4.2 SUID Exploitation
      • 4.4.3 CronJobs
  • 5️⃣5 - Web App Security
    • 5.1 - Web App Concepts
      • 5.1.1 HTTP/S Protocol
      • 5.1.2 Encoding
      • 5.1.3 Same Origin
      • 5.1.4 Cookies
      • 5.1.5 Session
      • 5.1.6 Web App Proxies
    • 5.2 - Information Gathering
      • 5.2.1 Gathering Information on Your Targets
      • 5.2.2 Infrastructure
      • 5.2.3 Fingerprinting Frameworks and Applications
      • 5.2.4 Fingerprinting Custom Applications
      • 5.2.5 Enumerating Resources
      • 5.2.6 Information Disclosure Through Misconfiguration
      • 5.2.7 Google Hacking
      • 5.2.8 Shodan HQ
    • 5.3 - Cross Site Scripting
      • 5.3.1 XSS Anatomy
      • 5.3.2 Reflected XSS
      • 5.3.3 Stored XSS
      • 5.3.4 DOM-Based XSS
      • 5.3.5 Identifying & Exploiting XSS with XSSer
    • 5.4 - SQL Injection
      • 5.4.1 Introduction to SQL Injection
      • 5.4.2 Finding SQL Injection
      • 5.4.3 Exploiting In-Band SQL Injection
      • 5.4.4 Exploiting Error-Based SQL Injection
      • 5.4.5 Exploiting Blind SQL Injection
      • 5.4.6 SQLMap
      • 5.4.7 Mitigation Strategies
      • 5.4.8 From SQLi to Server Takeover
    • 5.5 - Other Common Web Attacks
      • 5.5.1 Session Attacks
      • 5.5.2 CSRF
  • 6️⃣6 - ​Wi-Fi Security
    • 6.1 Traffic Analysis
  • 7️⃣7 - ​Metasploit & Ruby
    • 7.1 Metasploit
  • 📄Report
    • How to write a PT Report
  • 🛣️RoadMap & My Experience
  • 📔eCPPT Cheat Sheet
Powered by GitBook
On this page
  • DOM-Based XSS
  • Lab
  1. 5 - Web App Security
  2. 5.3 - Cross Site Scripting

5.3.4 DOM-Based XSS

Previous5.3.3 Stored XSSNext5.3.5 Identifying & Exploiting XSS with XSSer

Last updated 1 year ago

DOM-Based XSS

What is Document Object Model (DOM)?

Document Object Model (DOM) is a programming interface for web documents. It represents the structure of HTML and XML documents as a tree-like model where each node represents a part of the document, such as elements, attributes, and text.

In simpler terms, it's a way for programs and scripts to interact with the content of web pages. Web browsers use the DOM to render web pages, and developers can use JavaScript to manipulate the DOM dynamically, changing the structure, content, and style of web pages in response to user actions or other events.

DOM-based XSS vulnerabilities usually arise when JavaScript takes data from an attacker-controllable source, such as the URL, and passes it to a sink that supports dynamic code execution, such as eval() or innerHTML. This enables attackers to execute malicious JavaScript, which typically allows them to hijack other users' accounts.

To deliver a DOM-based XSS attack, you need to place data into a source so that it is propagated to a sink and causes execution of arbitrary JavaScript.

The most common source for DOM XSS is the URL, which is typically accessed with the window.location object. An attacker can construct a link to send a victim to a vulnerable page with a payload in the query string and fragment portions of the URL. In certain circumstances, such as when targeting a 404 page or a website running PHP, the payload can also be placed in the path.

Lab

This piece of code is vulnerable, because there's not input sanitisation

Executing JavaScript from a string is an enormous security risk. It is far too easy for a bad actor to run arbitrary code when you use eval(). See , below.

Starting of this URL: https://pentesteracademylab.appspot.com/lab/webapp/jfp/dom?statement= we can add code that will be executed using eval JS function with the document.getElementByID that will change the

5️⃣
Never use direct eval()!
DOM HTML attribute value
eval() - JavaScript | MDN
What is DOM-based XSS (cross-site scripting)? Tutorial & Examples | Web Security AcademyWebSecAcademy
Logo
DOM XSSHackTricks
Pentester Academy Lab
JavaScript DOM HTML
Logo
Logo
https://www.w3schools.com/js/js_htmldom.asp
https://www.researchgate.net/figure/DOM-based-XSS-Attack-Model_fig7_348065719
Logo
Logo