XSS跨站&浏览器UXSS&突变MXSS&Vue&React框架&JQuery库&写法和版本

Ethan医生4个月前WEB安全134

分类:

1、框架或三方库的XSS

2、浏览器或插件的XSS

3、客户端预览内核的XSS

说明:使用框架开发的或第三方库引用操作的,默认安全写法会自带过滤,所以测试此类的应用需存在漏洞版本或不安全写法导致XSS;同样UXSS也需要存在漏洞的浏览器版本或插件导致;MXSS也要不同环境下的转变解析导致,需多测试。

 

#Vue-XSS

搭建:

npm create vite@latest

cd vue-xss-demo

npm install

修改:

App.vue:

<template>

<div>

<h1>XSS 漏洞演示</h1>

<input v-model="userInput" placeholder="输入你的内容" />

<button @click="showContent">显示内容</button>

<div v-html="displayContent"></div>

</div>

</template>

 

<script>

export default {

data() {

return {

userInput: '', // 用户输入

displayContent: '' // 显示的内容

};

},

methods: {

showContent() {

// 直接将用户输入的内容渲染到页面

this.displayContent = this.userInput;

}

}

};

</script>

 

<style>

#app {

font-family: Avenir, Helvetica, Arial, sans-serif;

text-align: center;

margin-top: 60px;

}

</style>

 

启动:npm run dev

测试:<img src="x" onerror="alert('XSS')" />

修复:使用文本插值({{}})代替 v-html

 

#React-XSS

搭建:

npx create-react-app react-xss-example

cd react-xss-example

修改:

App.js

import React, { useState } from 'react';

import ReactDOM from 'react-dom';

 

function App() {

const [userInput, setUserInput] = useState('');

const [displayedInput, setDisplayedInput] = useState('');

 

const handleInputChange = (e) => {

setUserInput(e.target.value);

};

 

const displayInput = () => {

setDisplayedInput(userInput);

};

 

return (

<div>

<input type="text" value={userInput} onChange={handleInputChange} placeholder="输入内容" />

<button onClick={displayInput}>显示输入</button>

<div dangerouslySetInnerHTML={{__html: displayedInput}}/>

{/*<div>{displayedInput}</div>*/}

</div>

);

}

export default App;

启动:npm start

测试:<img src="x" onerror="alert('XSS')" />

修复:直接使用{displayedInput}来显示

 

#Electron-XSS

搭建:

mkdir electron-xss-example

cd electron-xss-example

npm init -y

安装修改:

npm install electron --save-dev

main.js 和 index.html 文件复制到项目根目录下

// main.js

const { app, BrowserWindow } = require('electron');

const path = require('path');

 

function createWindow() {

const win = new BrowserWindow({

width: 800,

height: 600,

webPreferences: {

nodeIntegration: true,

contextIsolation: false

}

});

 

win.loadFile('index.html');

}

 

app.whenReady().then(() => {

createWindow();

 

app.on('activate', function () {

if (BrowserWindow.getAllWindows().length === 0) createWindow();

});

});

 

app.on('window-all-closed', function () {

if (process.platform !== 'darwin') app.quit();

});

 

// index.html

<!DOCTYPE html>

<html>

 

<head>

<meta charset="UTF-8">

<title>Electron XSS Example</title>

</head>

 

<body>

<input type="text" id="userInput" placeholder="输入内容">

<button onclick="displayInput()">显示输入</button>

<div id="displayArea"></div>

<script>

function displayInput() {

const input = document.getElementById('userInput').value;

const displayArea = document.getElementById('displayArea');

displayArea.innerHTML = input;

}

</script>

</body>

 

</html>

配置package.json

{

"name": "electron-xss-example",

"version": "1.0.0",

"description": "",

"main": "main.js",

"scripts": {

"start": "electron ."

},

"keywords": [],

"author": "",

"license": "ISC",

"devDependencies": {

"electron": "^23.2.1"

}

}

启动:npm start

测试:<img src="x" onerror="alert('XSS')" />

修复:使用 textContent 代替 innerHTML 来显示文本

 

#JQuery XSS

参考:

水洞:https://mp.weixin.qq.com/s/FsFvQlVrb_J4wsyE8gpprA

介绍:https://mp.weixin.qq.com/s/EMsK1c901-bDYapvHxs-VQ

漏扫:

https://github.com/mahp/jQuery-with-XSS

https://github.com/honeyb33z/cve-2020-11023-scanner

 

#MXSS

参考:

https://mp.weixin.qq.com/s/31zaBzZ1e6rNobYCrn7Qhg

模拟:(见图)

https://portswigger-labs.net/mxss/

<math><mtext><table><mglyph><style><!--</style><img title="--&gt;&lt;img src=1 onerror=alert(1)&gt;">

复盘:

https://www.fooying.com/the-art-of-xss-1-introduction/

 

#UXSS:Universal Cross-Site Scripting

UXSS利用浏览器或者浏览器扩展漏洞来制造产生XSS并执行代码的攻击类型。

复盘:

MICROSOFT EDGE uXSS CVE-2021-34506

Edge浏览器翻译功能导致JS语句被调用执行

https://www.bilibili.com/video/BV1fX4y1c7rX

https://mp.weixin.qq.com/s/rR2feGeuRt3hOFPkV3_6Ow


相关文章

JAVA攻防-专题漏洞&SPEL表达式&SSTI模版&Swagger接口&Actuator泄露&Spring特检

➢ Java攻防-常规漏洞-注入&RCE&XXE➢ Java攻防-常规漏洞-跳转&SSRF&FILE➢ Java攻防-专题漏洞-SPEL&...

JAVA攻防-反序列化利用&JNDI注入&高版本绕过&依赖Jar包&gadge包链&自动Bypass

JAVA攻防-反序列化利用&JNDI注入&高版本绕过&依赖Jar包&gadge包链&自动Bypass

➢ Java攻防-JNDI注入-高版本的绕过Bypass#高版本JNDI绕过技术参考:https://tttang.com/archive/1405/RMI限制:com.sun.jndi.r...

JAVA攻防-常规漏洞&SQL注入四类型&XXE引用点&RCE原生&框架URL跳转&URL处理类

JAVA攻防-常规漏洞&SQL注入四类型&XXE引用点&RCE原生&框架URL跳转&URL处理类

➢ Java攻防-常规漏洞-注入&RCE&XXE➢ Java攻防-常规漏洞-跳转&SSRF&FILE#相关靶场:https://github.com...

Web攻防-访问控制篇&水平越权&垂直越权&未授权访问&级别架构&项目插件&SRC复盘

1、水平越权:同级别的用户之间权限的跨越2、垂直越权:低级别用户到高级别用户权限的跨越3、未授权访问:通过无级别用户能访问到需验证应用 实验:https://portswigger.net/...

Web攻防&身份验证篇&OAuth认证&授权分类及参数&重定向接管&State缺陷&Scope篡改

#解释OAuth:一种常用的授权框架,它允许网站和Web应用程序请求对另一个应用程序上的用户帐户的有限访问权限,像那种允许使用第三方账号(QQ、微信等)登录的网站,可能就是使用的OAuth框架。&nb...

JAVA攻防-Shiro专题&有key无利用链&JRMP协议&CC1&CB1链分析&Transform执行链

#Shrio有key无链:JRMP指的是Java远程方法协议(Java Remote Method Protocol)。它是 Java 对象实现远程通信的基础技术,也是Java RMI(Remote...

发表评论    

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。