DVWA_XSS(DOM)


 

XSS(DOM)是一種基於DOM樹的一種代碼注入攻擊方式,可以是反射型的,也可以是存儲型的,所以它一直被划分第三種XSS

與前兩種XSS相比,它最大的特點就是不與后台服務器交互,只是通過瀏覽器的DOM樹解析產生

除了js,flash等腳本語言也有可能存在XSS漏洞

關於DOM,牆裂推薦《JavaScriptDOM編程藝術》,寫得真的很好

 

下面直接開始實踐吧!(所有攻擊都在火狐瀏覽器下進行的,谷歌做了XSS filter好煩、、、)

Low:

作者太皮了,居然沒有做任何的防護和過濾

Payload:?default=<script>alert("You have been hacked!");</script>

 

Medium:

PHP腳本代碼:

<?php 

// Is there any input? 
if ( array_key_exists( "default", $_GET ) && !is_null ($_GET[ 'default' ]) ) { 
    $default = $_GET['default']; 
     
    # Do not allow script tags 
    if (stripos ($default, "<script") !== false) { 
        header ("location: ?default=English"); 
        exit; 
    } 
} 

?> 

 前端代碼:

		<form name="XSS" method="GET">
			<select name="default">
				<script>
					if (document.location.href.indexOf("default=") >= 0) {
						var lang = document.location.href.substring(document.location.href.indexOf("default=")+8);
						document.write("<option value='" + lang + "'>" + decodeURI(lang) + "</option>");
						document.write("<option value='' disabled='disabled'>----</option>");
					}
					    
					document.write("<option value='English'>English</option>");
					document.write("<option value='French'>French</option>");
					document.write("<option value='Spanish'>Spanish</option>");
					document.write("<option value='German'>German</option>");
				</script>
			</select>
			<input type="submit" value="Select" />
		</form>

  此時作者對"<script>"標簽做了過濾,只能嘗試其他的標簽了,比如<img>的onerror屬性,即img引用出錯時會執行onerror中的內容

Payload:?default=English>/option></select><img src='x' onerror='alert(1)'>

注意要閉合了前面的標簽,當然了,也可以URL編碼之后在GET上去。

High:

<?php 

// Is there any input? 
if ( array_key_exists( "default", $_GET ) && !is_null ($_GET[ 'default' ]) ) { 

    # White list the allowable languages 
    switch ($_GET['default']) { 
        case "French": 
        case "English": 
        case "German": 
        case "Spanish": 
            # ok 
            break; 
        default: 
            header ("location: ?default=English"); 
            exit; 
    } 
} 

?> 

  URL中#號之后的內容,不會被提交到服務器,可以直接與瀏覽器進行交互

Payload:?default=English#<script>alert(1)</script>

Impossbile:

  作者太皮了,居然只告訴我了這一句話:# Don't need to do anything, protction handled on the client side 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM