当前位置:网站首页>Reproduce 20 character short domain name bypass and XSS related knowledge points
Reproduce 20 character short domain name bypass and XSS related knowledge points
2022-07-29 03:16:00 【Jige yyds】
HTML Introduction to entity code
stay XHTML in , These reserved characters will immediately report an error if they appear in the label , however HTML The parser is too lazy , High fault tolerance , There will be no syntax errors
To use safely <,&,>," Equal character , You need to use a set of entity codes (entity encoding) Simple coding strategy
This set of HTML Entity coding strategy is based on & Symbol at the beginning , With ; Semicolon ending
stay XML There are only a few such codes in , And in the HTML in , There are hundreds of such entity codes , And common browsers support this usage
HTML There are several ways to encode
HTML Entity encoding , Format With & Symbol at the beginning , With ; Semicolon ending
HTML Entity coding reference manual
<textarea name="" id="textarea" cols="30" rows="10">
<img src="localhost">
</textarea>
The result is :
<img src="localhost">
Decimal ASCLL code , Format : To sign &# start , A semicolon ; ending
ascll Coding comparison table
<textarea name="" id="textarea" cols="30" rows="10">
<img src="localhost">
</textarea>
The result is :
<img src="localhost">
Unicode Character encoding , Format : To sign &# start , A semicolon ; ending
in addition , Below unicode The numbers of the coding reference table correspond to hexadecimal , But we need to convert it to decimal before displaying !
unicode Code reference
First turn on the 0022 The conversion to decimal is 0034;003D The conversion to decimal is 0061
<textarea name="" id="textarea" cols="30" rows="10">
<img src="localhost">
</textarea>
The result is :
<img src="localhost">
Hexadecimal ascll code , Format : With &#x start , A semicolon ; ending
Refer to the above ascll surface , But note that it needs to be converted to hexadecimal .
<textarea name="" id="textarea" cols="30" rows="10">
<img src="localhost">
</textarea>
The result is :
<img src="localhost">
Finally, take a look at several ways of writing
<textarea name="" id="textarea" cols="30" rows="10">
<@!<>
</textarea>
Last in textarea It shows that
<@!<>
That is to say < Is interpreted as "<“;@ Is interpreted as ”@“;! Is interpreted as ”!“;< Is interpreted as ”<“;> Is interpreted as ”>"
HTML Entity coding uses
Use inside the double quotation marks of the label
HTML Entity codes are not available for javascript
HTML The scope of entity code is HTML file , barring javscript execution environment , because javascript The parser of the execution environment is not HTML Parser !
Next, let's look at the code
document.write('<img src=@ οnerrοr=alert(123) />') // <img [email protected] οnerrοr=alert(123) />
console.log('<img src=@ οnerrοr=alert(123) />') // <img [email protected] οnerrοr=alert(123) />
console.log('\<img [email protected] οnerrοr=alert(123) \/\>') // <img [email protected] οnerrοr=alert(123) />_
- document.write Because the last string is output to html page , So it will still be html The entity is decoded into the corresponding tag
2. Because it's just js Print in the environment , So in the end, there was no html Entity encoding , The string doesn't change
3. because js The self decoding mechanism of will add backslashes to pure escape characters , So it is finally resolved to the form without backslash
URL analysis
URL The parser is also a state machine model , Characters coming in from the input stream can be guided URL The parser transitions to different states ;
URL Resource type must be ASCII Letter , Otherwise, it will enter “ No type ” state . Simply put, you can't write the protocol into code ; And in URL Use... During coding utf-8 Encoding type to encode every character , If you try to URL The connection is encoded by other encoding types ,URL The parser will not recognize correctly .
JavaScript analysis
JavaScript Analytical process and HTML The parsing process is a little different .JavaScript Language is a language whose content is irrelevant to language .
image \uXXXX The same characters are called Unicode Escape sequences . Escape sequences can be divided into 3 Parts of : Namely :
In a string : When Unicode When the escape sequence exists in the string , He will only be interpreted as a regular character , Not single quotes , Double quotation marks and other characters that can break the context of a string .
Identifier name : It will be decoded and interpreted as part of the identifier name .
Unicode Escape sequences are also allowed to be used in token names , As a character in the name ; But put the symbol before Unicode The escape sequence string cannot be used as a character in the identifier name . And will Unicode It is illegal to put an escape sequence string in an identifier name .
Control characters : For example, single quotation mark 、 Double quotes 、 Parentheses, etc. are not interpreted as control characters , It is decoded and parsed into an indicator name or string constant .7
So the conclusion is :Unicode Escape sequences are not treated as strings only in identifier names , And the encoded characters in the identifier name can be parsed normally .
from XSS Payload Learn browser decoding
(1)
<a href="%6a%61%76%61%73%63%72%69%70%74:%61%6c%65%72%74%28%31%29"></a>
Here the URL The encoding method will javascript:alert(1) Turned into the above
(2)
<a href="javascript:%61%6c%65%72%74%28%32%29">
First HTML Decoding in progress URL decode
<a href="javascript:alert(2)">
(3)
<a href="javascript%3aalert(3)"></a>
Use as before URL code
(4)
<div><img src=x οnerrοr=alert(4)></div>
It contains HTML Code content , In turn, think from the perspective of developers ,HTML Encoding is to display these special characters , Without interfering with normal DOM analysis , So the content in this will not become a img Elements , It's not going to be implemented .
(5)
<textarea><script>alert(5)</script></textarea>
<
yes RCDATA Elements (RCDATA elements), Can hold text and character references , Note that other elements cannot be accommodated ,HTML Decode and display directly RCDATA Elements (RCDATA elements) Include textarea and title, So I won't pop up(6)
<textarea><script>alert(6)</script></textarea>
Like the fifth ,textarea and title There will be HTML Decoding operation , But there will be no child elements , So I won't pop up
(7)
<button onclick="confirm('7');">Button</button>
here onclick Is the attribute value of the tag ( analogy 2 Medium href), Will be HTML decode , obtain
<button onclick="confirm('7');">Button</button>
(8)
<button onclick="confirm('8\u0027);">Button</button>
onclick The value in will be given to JS Handle , stay JS Only strings and identifiers can be used in Unicode Express , Nor can you encode symbols ,' Obviously not. ,JS Execution failure , So I won't pop up
(9)
<script>alert(9)</script>
script Belongs to the original text element (Raw text elements), Only text can be accommodated , Note that there are no character references , So directly by JS Handle , Here's all to the composition book ,,JS I can't recognize it , Execution failure , So you can't pop up
Original text elements (Raw text elements) Yes
(10)
<script>\u0061\u006c\u0065\u0072\u0074(10);</script>
Same as the second one above , Function name alert Belongs to identifier , Characters encoded without encoding symbols , Directly be JS perform , So you can pop up
(11)
<script>\u0061\u006c\u0065\u0072\u0074\u0028\u0031\u0031\u0029</script>
stay JS Only strings and identifiers can be used in Unicode Express , This encodes symbols ,JS Execution failure , Don't pop up
(12)
<script>\u0061\u006c\u0065\u0072\u0074(\u0031\u0032)</script>
There seems to be nothing wrong here , But here \u0031\u0032 When decoding, it will be decoded into a string 12, Notice the string , Not numbers , Words obviously need quotation marks ,JS Execution failure
(13)
<script>alert('13\u0027)</script>
Coded ‘ It's a symbol , So I can't pop up
(14)
<script>alert('14\u000a')</script>
\u000a stay JavaScript Inside is a new line , Namely \n, Although the line changed , But the quotation marks are all , Not encoded , It can be executed directly , So you can pop up
(15)
<a
href="javascript:%5c%75%30%30%36%31%5c%75%30%30%36%63%5c%75%30%30%36%35%5c%75%30%30%37%32%5c%75%30%30%37%34(15)"></a>
First use HTML Decoding and URL decode
javascript:\u0061\u006c\u0065\u0072\u0074(15)
distinguish JS agreement , Then from JS Module processing , Decode to get
javascript:alert(15)
summary
<script> and <style> Data can only have text , There will be no HTML Decoding and URL Decoding operation
<textarea> and <title> There will be HTML Decoding operation , But there will be no child elements
Other element data ( Such as div) And element attribute data ( Such as href) There will be HTML Decoding operation
Some properties ( Such as href) There will be URL Decoding operation , but URL The agreement in must be ASCII
JavaScript String and identifier Unicode decode
3. This machine builds galleryCMS Server for
open PHPstudy, take galleryCMS Put the file under the root file , And modify the configuration file
Open database , Add database galleryCMS Go to the browser and refresh , Get into galleryCMS Webpage
In the source code, we change the limit length to 35
although xss-clean Filter a lot of tags , But he hasn't filtered it out < svg > label , So we use < svg> Label a test .
We found that we added successfully , So we use svg Tag to bypass , The next step is to solve the problem of character length
We can see that this is all 29 A character. , So we can only modify the length of the domain name , Replace three characters with one character , Used to bypass short domain names .
℠ expands to sm
㏛ expands to sr
st expands to st
㎭ expands to rad
℡ expands to tel
ff expands to ff
When I was there kali Prepare to install beef-xss When , Errors always occur during installation , I also tried to use apt-get update to update
But the update speed is too slow , Then I gave up ......
边栏推荐
- 13_ UE4 advanced_ Montage animation realizes attack while walking
- 数字图像处理 第10章——图像分割
- Why did I choose the test when the development salary was high?
- C陷阱与缺陷 第3章 语义“陷阱” 3.8 运算符&&、||和!
- Verilog's time system tasks - $time, $stime, $realtime
- 接口自动化测试实践指导(上):接口自动化需要做哪些准备工作
- C traps and defects Chapter 3 semantic "traps" 3.2 pointers to non arrays
- 一种简单通用的获取函数栈空间大小的方法
- 【FreeSwitch开发实践】media bug获取通话语音流
- C语言基础知识点汇总
猜你喜欢
【FreeSwitch开发实践】media bug获取通话语音流
MySQL忘记密码怎么办
Example analysis of while, repeat and loop loops in MySQL process control
[robot learning] matlab kinematics and ADMAS dynamics analysis of manipulator gripper
融云 IM & RTC 能力上新盘点
01-SDRAM:初始化模块的代码
Design of smoke temperature, humidity and formaldehyde monitoring based on single chip microcomputer
万字详解 Google Play 上架应用标准包格式 AAB
mysql的timestamp存在的时区问题怎么解决
Summarize the knowledge points of the ten JVM modules. If you don't believe it, you still don't understand it
随机推荐
【C】 Array
[open the door to the new world] see how the old bird of testing plays API testing between applause
MYSQL入门与进阶(十三)
[freeswitch development practice] unimrcp compilation and installation
年内首个“三连跌” 95号汽油回归“8元时代“
13_ue4进阶_蒙太奇动画实现一边走一边攻击
Introduction and advanced level of MySQL (11)
Principle knowledge is useful
Implement Lmax disruptor queue from scratch (VI) analysis of the principle of disruptor solving pseudo sharing and consumers' elegant stopping
Shell programming specifications and variables
Redis配置缓存过期监听事件触发
MySQL忘记密码怎么办
[QNX hypervisor 2.2 user manual]9.11 RAM (under update)
C traps and defects Chapter 3 semantic "traps" 3.8 operators &, |, and!
SAP 中国本地化内容汇总
Apache文件管理自学笔记——映射文件夹和基于单ip多域名配置apache虚拟机
ShardingSphere之水平分表实战(三)
Flask的创建的流程day05-06之创建项目
Detailed steps for installing MySQL 8.0 under Linux
Design of smoke temperature, humidity and formaldehyde monitoring based on single chip microcomputer