Pentesting Notes
Cross-Site Scripting

Basic Knowledge:
- JavaScript (helpful, but not essential)
- Client-Server requests and responses
XSS Explained:
- XSS is an injection attack where malicious JavaScript is injected into a web application to be executed by users.
- Attackers aim to steal data, redirect users, or perform other malicious actions.
XSS Payloads:
- Payload: The JavaScript code designed to achieve a specific goal (e.g., stealing cookies).
- Payload Intention: What the attacker wants the script to do (e.g., show an alert, steal cookies).
- Payload Modification: Adapting the code to bypass filters and function correctly.
س
Payload Examples:
- Proof of Concept (PoC): Simple alert box to demonstrate XSS vulnerability.
- Session Stealing: Steals user's session cookie for account takeover.
- Key Logging: Captures every keystroke typed on the webpage.
- Business Logic: Modifies user data or performs actions (e.g., changing email address).
Types of XSS Vulnerabilities:
- Reflected XSS: User-supplied data is reflected without validation, allowing script injection.
- Stored XSS: Malicious script is stored on the server and executed when other users visit the affected page.
- DOM-Based XSS: Script execution happens directly in the browser without loading new pages.
- Blind XSS: Payload is stored but attacker cannot directly confirm successful execution.
Testing for XSS:
- Identify potential entry points for user-controlled data (URLs, forms, headers).
- Test these points with crafted payloads to see if script execution is possible.
Mitigating XSS:
- Input Validation: Sanitize and validate user input to prevent script injection.
- Content Security Policy (CSP): Restricts sources allowed to load scripts on a webpage.
- HttpOnly Flag: Prevents client-side script access to cookies.
Bypassing Mitigation Techniques:
- Attackers may employ various techniques to bypass filtering and security measures.
Source file in my repo: Cross-Site Scripting.md