【bWAPP】0X03 HTML Injection - Stored (Blog)

HTML注入-存儲型

 

 

這是一個存儲型的漏洞,有一個留言功能,能夠嘗試xss彈窗html

在level low下sql

輸入<script>alert(/bee/)</script>後點擊提交,就會執行該語句並顯示彈窗cookie

也能夠讀取用戶cookie,<script>alert(document.cookie)</script>less

 

 

 根據源碼找到了數據存儲的地方xss

 

 

 (已經被我刪了)函數

 

 

 在查看源碼後,三個級別都使用了sqli_check_3函數進行語句轉義this

 

 

 

下列字符受影響:spa

\x00
\n
\r
\
'
"
\x1a
若是成功,則該函數返回被轉義的字符串。若是失敗,則返回 false。code

 

當設置等級爲medium時,調用xss_check_4進行防xss保護htm

1 function xss_check_4($data)
2 {
3     // addslashes - returns a string with backslashes before characters that need to be quoted in database queries etc.
4     // These characters are single quote ('), double quote ("), backslash (\) and NUL (the NULL byte).
5     // Do NOT use this for XSS or HTML validations!!!    
6     return addslashes($data);    
7 }

 (不管是medium級別仍是high級別均沒法進行注入)

當設置等級爲high時,調用xss_check_3進行防xss保護

 1 function xss_check_3($data, $encoding = "UTF-8")
 2 {
 3     // htmlspecialchars - converts special characters to HTML entities    
 4     // '&' (ampersand) becomes '&amp;' 
 5     // '"' (double quote) becomes '&quot;' when ENT_NOQUOTES is not set
 6     // "'" (single quote) becomes '&#039;' (or &apos;) only when ENT_QUOTES is set
 7     // '<' (less than) becomes '&lt;'
 8     // '>' (greater than) becomes '&gt;'     
 9     return htmlspecialchars($data, ENT_QUOTES, $encoding);      
10 }
相關文章
相關標籤/搜索