当前位置:网站首页>Security Fundamentals 8 --- XSS
Security Fundamentals 8 --- XSS
2022-08-03 21:13:00 【Hold the kitten】
目录
危害(The point of action varies)
XSS---跨站脚本攻击
产生原因
There is no filtering on the user's input,Malicious code was entered into the server in the data submitted by the user
分类
- 反射型XSS:危害不大,不持久,只能运行一次,will not enter the database,Only make popup windows on the front-end page
- DOM型XSS:Special reflection typeXSS,危害较小
- 存储型XSS:危害最大,能进入数据库,可以多次执行(危害:The background address can be obtained、管理员的cookies)(产生原因:没有对jsFilter by tags)
危害(The point of action varies)
- 盗取被攻击者的 cookie 值,进行身份冒充
- 网页篡改---js 中某些函数可以获取并且重新复制 HTML 的标签值
- 删除页面---By changing some values of the page(如:Change the value to null)Delete the page
- 流量劫持---如:Small pages are ways to increase traffic:1.正常操作---引流----送钱、打广告、 2.非常规(违法行为)---利用 XSS The vulnerability automatically requests traffic comparison Small websites or add QR codes on other websites
- 钓鱼网站
- 配合 CSRF 攻击---ajax、window.location
防御手段
- Filter by keywords
- 将特殊字符转换成字符串-->实体化编码
XSS paylaod
测试网站:http://test.attacker-domain.com/browserparsing/tests.html
1、
<a href="%6a%61%76%61%73%63%72%69%70%74:%61%6c%65%72%74%28%31%29"></a>
No encoding succeeded (解码顺序:先 实体编码-->Unicode-->js中的Unicode编码)
原因:There is no entity encoding-->进行Unicode编码,But the agreement can'tUnicode编码,URL规定协议、用户名、密码都必须是ASCII,否则识别不了
2、
<a href="javascript:%61%6c%65%72%74%28%32%29">Click me</a>
成功:Entity decoding is performed first --> href中为URL,URLModules can be differentJavaScript协议,进行URL解码 --> JSExecuted after module processing
3、
<a href="javascript%3aalert(3)">Click me</a>
失败:The protocol is encoded,UnicodeThe encoding does not recognize the protocol,So the popup failed
4、
<div><img src=x onerror=alert(4)></div>
<img src=x onerror=alert(4)>
失败,imgLabels are parseable under normal conditions,为什么imgThe tag cannot be parsed?
原因:is that the parser does not convert to after parsing this character reference"标签开始状态".正因为如此,就不会建立新标签.因此,我们能够利用字符实体编码这个行为来转义用户输入的数据从而确保用户输入的数据只能被解析成"数据".The tag did not enter the start state,The popup will not come out
5、
<textarea><script>alert(5)</script></textarea>
可以解析,The tag did not enter the start state
6、
<textarea><script>alert(6)</script></textarea>
原因:<title>和<textarea>标签中的字符引用会被HTML解析器解码.在解析这些字符引用的过程中不会进入“标签开始状态". <textarea>不能执行脚本,Can only hold text or character references
7、
<button onclick="confirm('7');">Button</button>
成功执行,Parse the entity code first,onclickThe value of the medium property will be removedHTML解码,Execute after successful identification
8、
<button onclick="confirm('8\u0027);">Button</button>
失败原因:使用js编码,js编码可以容纳Unicode编码,但是在js中不能编码符号(如:括号、等号.......)
9、
<script>alert(9);</script>
No pop-up reason:编码了alert,<script>The original text in the label,But raw text can only hold text,没有字符引用,无法执行
10、
<script>\u0061\u006c\u0065\u0072\u0074(10);</script>
成功,利用js中的Unicode编码,But only characters are encoded,可以成功
11、
<script>\u0061\u006c\u0065\u0072\u0074\u0028\u0031\u0031\u0029</script>
失败,利用js中的UnicodeBrackets are encoded
12、
<script>\u0061\u006c\u0065\u0072\u0074(\u0031\u0032)</script>
失败,js运行时,There are strings inside that need to be wrapped in quotes to run,js中使用UnicodeWhen encoding a number, it becomes a string after decoding,So it needs to be wrapped in quotes.
13、
<script>alert('13\u0027)</script>
失败,利用js中的UnicodeSymbols are encoded
14、
<script>alert('14\u000a')</script>
成功,编码没问题,都存在
15、
<a href="javascript:%5c%75%30%30&# x25;36%31%5c%75%30%30%36%63% 5;c%75%30%30%36%35%5c%75%30 %30%37%32%5c%75%30%30%37%&# x33;4(15)">Click me</a>
成功,先用HTML实体解码 --> JavaScript:head out --> 由href中url模块解码 --> 识别js协议--> js模块处理 --> 最后解码
注意
- HTML官网:w3c.org
- 解码顺序:先 实体编码 --> Unicode --> js中的Unicode编码
- <textarea>和<title>There will be no scripts that can be executed,Can only hold text or character references.无需进行测试
- div 、hrefand other attribute elements will haveHTML解码操作
- URL规定协议、用户名、密码都必须是ASCII
- JavaScript会对字符串和标识符Unicode解码
HTML实体编码
HTML 实体is a paragraph with a hyphen(&
)开头、以分号(;
)结尾的文本(字符串).实体常常用于显示保留字符(这些字符会被解析为 HTML 代码)和不可见的字符(如“不换行空格”)
- 不可分的空格:
<
(小于符号):<
>
(大于符号):>
&
(与符号):&
″
(双引号):"
'
(单引号):''
(版权符号)
©
边栏推荐
猜你喜欢
随机推荐
svg+js订单确认按钮动画js特效
用 setTimeout 来实现 setInterval
buildscript和allprojects的作用和区别是什么?
华为设备配置VRRP与BFD联动实现快速切换
《QDebug 2022年7月》
chart.js多条曲线图插件
开源一夏 |如何优化线上服务器
直播源码开发,各种常见的广告形式
基于DMS的数仓智能运维服务,知多少?
AWTK开发编译环境踩坑记录1(编译提示powershell.exe出错)
微信小程序 生成跳转体验版url,可直接跳转到体验版小程序(可通过此方法测试模板消息)
【kali-漏洞扫描】(2.1)Nessus解除IP限制、扫描快无结果、插件plugins被删除(中)
Engineering Effectiveness Governance for Agile Delivery
Transformer怎么入门?如何学习Transformer?
idea2021.1.3版本如何启动多个客户端程序
if _name_ == “__main__“:NameError: name ‘_name_‘ is not defined
迪赛智慧数——柱状图(多色柱状图):2021年我国城市住户存款排名
How can a cloud server safely use local AD/LDAP?
Lecture topics and guest blockbuster, TDengine developers conference to promote data technology "broken"
不专业面试官的经验总结