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

Ethan医生9个月前WEB安全336

分类:

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攻防-FastJson专题&各版本Gadget链&autoType开关&黑名单&依赖包&本地代码

#FastJson反序列化各版本利用链分析参考文章:https://xz.aliyun.com/news/14309参考文章:https://mp.weixin.qq.com/s/t8sjv0Zg8_...

JAVA攻防-专题漏洞&反序列化&原生类引用&三方组件&JNDI注入&版本限制&审计Sink

JAVA攻防-专题漏洞&反序列化&原生类引用&三方组件&JNDI注入&版本限制&审计Sink

➢ Java攻防-专题漏洞-原生类反序列化➢ Java攻防-专题漏洞-三方组件反序列化#Java安全-反序列化-原生类序列化是将Java对象转换成字节流的过程。而反序列化是将字节流...

PHP反序列化&原生内置&Exception类&SoapClient类&SimpleXMLElement

#原生自带类参考https://xz.aliyun.com/news/8792https://www.anquanke.com/post/id/264823https://blog.csdn.net/...

XML&XXE&上传解析&文件预览&接口服务&白盒审计&应用功能&SRC复盘

#黑盒功能点案例1、不安全的图像读取-SVG2、不安全的文档转换-DOCX3、不安全的传递服务-SOAPSOAP 的典型使用场景✅ 适合 SOAP 的情况:需要严格的数据契约(如金融交易、医...

Web攻防-业务逻辑篇&短信验证码&劫持爆破回显&图片验证码&识别复用绕过&接口滥用

#图片验证码:口令存在爆破,接口枚举调用,任意用户注册等安全问题https://github.com/sml2h3/ddddocrhttps://github.com/smxiazi/xp_CAPTC...

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

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

发表评论    

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