当前位置:网站首页>Finally understand the difference between DOM XSS and reflection XSS
Finally understand the difference between DOM XSS and reflection XSS
2022-06-29 01:08:00 【zkzq】
Zero basic hacker , Search official account : White hat left
author :lryfish
Original address :https://www.freebuf.com/articles/web/318982.html
Preface
xss The principle of vulnerability is actually very simple , Types are also divided into three categories , reflective 、 Storage and dom type .
But just touched xss I don't understand what is dom type xss, Cannot distinguish between reflective and dom type , I seldom meet , Now through this article, we can give Xiaobai a better understanding xss Loophole , This article also consolidates my understanding of xss The understanding of the .
DOM Contrast diagram of type and reflection type
Two simple pictures help you compare the similarities and differences


reflective xss analysis
First of all, I would like to briefly introduce xss The most common type : reflective
adopt pikachu Range to do simple demonstration analysis
You can see that the data we entered is passed through html The page echoes , This means that we can try to construct closure to inject the code we want

Check the web source code , In this position (20 This field shows the length of the input data , Just change it )

Insert this code to test xss Loophole :, Pop up window

Analyze the code
$html='';
if(isset($_GET['submit'])){
if(empty($_GET['message'])){
$html.="<p class='notice'> Input 'kobe' try -_-</p>";
}else{
if($_GET['message']=='kobe'){
$html.="<p class='notice'> May you and {$_GET['message']} equally , Forever young , Always blood boiling !</p><img src='{$PIKA_ROOT_DIR}assets/images/nbaplayer/kobe.png' />";
}else{
$html.="<p class='notice'>who is {$_GET['message']},i don't care!</p>";
}
}
}
First, through GET receive message String to back end , And then to $html This variable
<
div id="xssr_main">
<p class="xssr_title">Which NBA player do you like?</p>
<form method="get">
<input class="xssr_in" type="text" maxlength="20" name="message" />
<input class="xssr_submit" type="submit" name="submit" value="submit" />
</form>
<?php echo $html;?>
</div>
Then output to the front-end page through this variable , Then the code just entered will be executed on the page , The final web page code is changed through the server logic
DOM type xss analysis
DOM type xss And others xss The biggest difference is that it does not go through the server , Just through the web page itself JavaScript For rendering triggers
Let's take a look at a typical DOM type xss Example , Copy the following sentence to Youdao dictionary for translation , I believe you will soon understand
This is a test about xss
online translation _ youdao (https://fanyi.youdao.com/)

Look at this sentence in html Position in

In this case xss Statements are simply parsed at the front end , Without going through the back end , Security vulnerability of the front end itself .
pikachu shooting range
Re pass pikachu Range to learn more about DOM type xss
This is the front-end interface

This is the source code , Next, analyze the source code
<div id="xssd_main">
<script>
function domxss(){
var str = document.getElementById("text").value;
document.getElementById("dom").innerHTML = "<a href='"+str+"'>what do you see?</a>";
}
</script>
<input id="text" name="text" type="text" value="" />
<input id="button" type="button" value="click me!" onclick="domxss()" />
<div id="dom"></div>
</div>
We go through <input id=“text” name=“text” type=“text” value="" / > Assign a string to text
then JavaScript var str = document.getElementById(“text”).value; Got it text Value
then document.getElementById(“dom”).innerHTML = “< a href=’”+str+"’>what do you see?< /a > "; Put this text String integration into a In this label href I'll do it again a Labels are written to dom In this label .
Last < div id=“dom” >< /div > Execute this dom label
When the input 123 The source code shows this

But when you enter :#'οnclick=“alert(‘1_Ry’)”> when

Keep clicking and playing , Use at the same time burpsuite If you grab a bag, you can't catch anything , Because there is no interaction with the server , Just through the front end js Rendering to change the final web page code
DOM type & reflective XSS Exploit scenarios
There is no difference between the two attacks , All of them are sent by e-mail and other means, including our structure payload Of URL To target users , When the target user can access the link , The server receives the request from the target user and processes it
And then the server puts it with XSS The data of the code is sent to the browser of the target user , The browser parses this section with XSS After the malicious script of the code , It will trigger XSS Loophole , Generally used to get the other party cookies value
xss Defense methods
Filtering input data , Include ‘ 、“、<、>、on* Illegal characters such as
Encode and convert the data output to the page , Include HTML Entity encoding 、 Properties and URL Request parameters
Set up cookie Of HttpOnly attribute


边栏推荐
- 流媒体集群应用与配置:如何在一台服务器部署多个EasyCVR?
- Depth first search to realize the problem of catching cattle
- 戴口罩人臉數據集和戴口罩人臉生成方法
- 不同的子序列问题I
- PR 2021 quick start tutorial, how to use audio editing in PR?
- [agile 5.1] core of planning: user stories
- How can multidimensional analysis pre summary work?
- Daily English articles, reading accumulation
- UI高度自适应的修改方案
- Précautions d'installation et d'utilisation des joints rotatifs
猜你喜欢

Successfully solved (machine learning data segmentation problem): modulenotfounderror: no module named 'sklearn cross_ validation‘

立创eda学习笔记:铺铜死区?孤岛?死铜?

Redis是什么

戴口罩人脸数据集和戴口罩人脸生成方法
![[gym 102423]-elven efficiency | thinking](/img/cf/b65f3db1580a83478f8351cea22040.png)
[gym 102423]-elven efficiency | thinking

Seven mistakes in IT Governance and how to avoid them

EasyCVR播放视频出现卡顿花屏时如何解决?

统计学习方法(2/22)感知机

Analysis Framework -- establishment of user experience measurement data system

BMFONT制作位图字体并在CocosCreator中使用
随机推荐
同期群分析是什么?教你用 SQL 来搞定
be based on. NETCORE development blog project starblog - (13) add friendship link function
UI高度自适应的修改方案
[MCU club] design of classroom number detection based on MCU [simulation design]
华泰证券安全吗
【Proteus仿真】4x4矩阵键盘中断方式扫描 +数码管显示
利用kubernetes资源锁完成自己的HA应用
旋转接头安装使用注意事项
Sampling with VerilogA module
PR 2021 quick start tutorial, how to use audio editing in PR?
Uvm:field automation mechanism
[eight part essay] MySQL
Mapbox GL loading local publishing DEM data
Maximum path and problem (cherry picking problem)
What is the difference between immunohistochemistry and immunohistochemistry?
Check the open source projects of yyds in June!
Is Huatai Securities safe
Count the number of different palindrome subsequences in the string
be based on. NETCORE development blog project starblog - (13) add friendship link function
Pytorch -- use and modification of existing network model