0x01 簡介
Web客戶端使用Server端腳本生成頁面為用戶提供數(shù)據(jù)時拟淮,如果未經(jīng)驗證的用戶數(shù)據(jù)被包含在頁面中而未經(jīng)HTML實體編碼,客戶端代碼便能夠注入到動態(tài)頁面中斟薇。
0x02 反射型xss-Low
構(gòu)造<script>alert(1);</script>
語句即可成功芝加,跟dom型xss攻擊方法一樣,畢竟dom型xss是特殊的反射型xss嘛低飒。
image.png
0x03 反射型xss-Medium
跟dom型一樣,<script也是被過濾了懂盐。重新構(gòu)造攻擊語句進行繞過吧
"></option></select><img src=a onerror="javascript:alert(1);"/>
image.png
0x04 反射型xss-High
high比medium的過濾更加嚴格了褥赊,來試試繞過吧
測試了<>沒有被過濾掉,然后測試得知單引號'和雙引號"也沒有被過濾掉莉恼。
構(gòu)造語句成功繞過"><img src=a onerror="alert(1);">
image.png
看看源代碼:
<?php
header ("X-XSS-Protection: 0");
// Is there any input?
if( array_key_exists( "name", $_GET ) && $_GET[ 'name' ] != NULL ) {
// Get input
$name = preg_replace( '/<(.*)s(.*)c(.*)r(.*)i(.*)p(.*)t/i', '', $_GET[ 'name' ] );
// Feedback for end user
echo "<pre>Hello ${name}</pre>";
}
?>
0x05 防御方法
- 對輸入(和URL參數(shù))進行過濾
- 對輸出進行編碼
- 白名單和黑名單結(jié)合過濾