当前位置:网站首页>XSS攻击
XSS攻击
2022-06-25 10:14:00 【m0_49471668】
得分点 XSS是跨站脚本攻击、向目标网站插入恶意代码、大量用户访问网站时运行恶意脚本获取信息 标准回答
XSS是跨站脚本攻击(Cross Site Scripting),不写为CSS是为了避免和层叠样式表(Cascading Style Sheets)的缩写混淆,所以将跨站脚本攻击写为XSS。攻击者可以通过向Web页面里面插入script代码,当用户浏览这个页面时,就会运行被插入的script代码,达到攻击者的目的。

XSS的危害一般是泄露用户的登录信息cookie,攻击者可以通过cookie绕过登录步骤直接进入站点。XSS的分类分为反射型和存储型。反射型就是临时通过url访问网站,网站服务端将恶意代码从url中取出,拼接在HTML中返回给浏览器,用户就会执行恶意代码。存储型就是将恶意代码以留言的形式保存在服务器数据库,任何访问网站的人都会受到攻击。预防XSS攻击的方案基本是对数据进行严格的输出编码,比如HTML元素的编码,JavaScript编码,css编码,url编码等等。
加分回答 XSS的危害:
- 获取cookie:网站中的登录一般都是用cookie作为某个用户的身份证明,这是服务器端返回的一串字符。如果cookie被攻击者拿到,那么就可以绕过密码登录。当空间、论坛如果可以被插入script代码,那么进入空间或者论坛的人的账号就可以轻易被攻击者获取。 - 恶意跳转:直接在页面中插入window.location.href进行跳转。
XSS的分类:
- 反射型XSS(非持久型XSS):通过URL参数直接注入
- 存储型XSS(持久型XSS):存储到数据库后读取时注入 XSS的预防:
- 浏览器的防御和“X-XSS-Protection”有关,默认值为1,即默认打开XSS防御,可以防御反射型的XSS,不过作用有限,只能防御注入到HTML的节点内容或属性的XSS,例如URL参数中包含script标签。不建议只依赖此防御手段。
- 防御HTML节点内容,通过转义<为<以及>为>来实现防御HTML节点内容。
- 预防HTML属性,通过转义"->&quto来实现防御,一般不转义空格,但是这要求属性必须带引号。
- 预防JavaScript代码,通过将数据进行JSON序列化。
- 防御富文本是比较复杂的工程,因为富文本可以包含HTML和script,这些难以预测与防御,建议是通过白名单的方式来过滤允许的HTML标签和标签的属性来进行防御,大概的实现方式是: - 将HTML代码段转成树级结构的数据 - 遍历树的每一个节点,过滤节点的类型和属性,或进行特殊处理 - 处理完成后,将树级结构转化成HTML代码 - 开启浏览器XSS防御:Http Only cookie,禁止 JavaScript 读取某些敏感 Cookie,攻击者完成XSS注入后也无法窃取此 Cookie。
边栏推荐
- Deep understanding of JVM - JVM memory model
- 一文了解Prometheus
- ES 学习
- ShardingSphere-Proxy 5.0 分库分表(一)
- MCU development -- face recognition application based on esp32-cam
- Shardingsphere proxy 5.0 sub database and sub table (I)
- Flask blog practice - realize personal center and authority management
- 学会自学【学会学习本身,比学什么都重要】
- 好好思考
- Tutorial on installing SSL certificates in Microsoft Exchange Server 2007
猜你喜欢
![[paper reading | depth] role based network embedding via structural features reconstruction with degree regulated](/img/70/31a4eaec3f517089b220b35af2f3b7.png)
[paper reading | depth] role based network embedding via structural features reconstruction with degree regulated

单片机开发---基于ESP32-CAM的人脸识别应用

Kotlin arrays and collections (1) {create arrays, use arrays, use for in loops to traverse arrays, use array indexes, and multi-dimensional arrays}

ShardingSphere-Proxy 4.1 分库分表

【历史上的今天】6 月 24 日:网易成立;首届消费电子展召开;世界上第一次网络直播

P2P network core technology: Gossip protocol

【论文阅读|深度】Role-based network embedding via structural features reconstruction with degree-regularized

How to do the wechat selling applet? How to apply for applets

我希望按照我的思路尽可能将canvas基础讲明白

Basic use and cluster construction of consult
随机推荐
Flask blog practice - realize the latest articles and search in the sidebar
Linked list delete nodes in the linked list
I'm afraid of the goose factory!
Kotlin Foundation
Kotlin keyword and operator
【RPC】I/O模型——BIO、NIO、AIO及NIO的Rector模式
Macro application connector\
tokenizers>=0.11.1,!=0.11.3,<0.13 is required for a normal functioning of this module,
Shardingsphere proxy 5.0 sub database and sub table (I)
Detailed explanation of Android interview notes handler
Identityserver4 definition concept
This is enough for request & response
Comparison and evaluation of digicert and globalsign single domain ov SSL certificates
Floating window --- create an activity floating window (can be dragged)
ShardingSphere-Proxy 4.1 分库分表
【OpenCV 例程200篇】210. 绘制直线也会有这么多坑?
NFC read / write mode development - book summary
How much does a small program cost? How much does a small program cost? It's clear at a glance
性能之内存篇
指南针在上面开股票账户安全吗?