xSS-Reflected

反射性(非持久性XSS),藏在URL中

一般用户访问恶意链接执行

 

Low

php

header ("X-XSS-Protection: 0");

// Is there any input?
if( array_key_exists( "name", $_GET ) && $_GET[ 'name' ] != NULL ) {
    // Feedback for end user
    echo '
Hello ' . $_GET[ 'name' ] . '
'; } ?>

没有进行任何过滤     payload:

 xSS-Reflected_第1张图片

 

Medium

php

header ("X-XSS-Protection: 0");

// Is there any input?
if( array_key_exists( "name", $_GET ) && $_GET[ 'name' ] != NULL ) {
    // Get input
    $name = str_replace( '

xSS-Reflected_第2张图片

 

或者采用大小写绕过

xSS-Reflected_第3张图片

 

High

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 "
Hello ${name}
"; } ?>

过滤script,但是并没有过滤其他的事件,可以用 img svg  iframe等绕过

先将前面的标签闭合

payload:


xSS-Reflected_第4张图片

 

a

xSS-Reflected_第5张图片

 

 Impossible

php

// Is there any input?
if( array_key_exists( "name", $_GET ) && $_GET[ 'name' ] != NULL ) {
    // Check Anti-CSRF token
    checkToken( $_REQUEST[ 'user_token' ], $_SESSION[ 'session_token' ], 'index.php' );

    // Get input
    $name = htmlspecialchars( $_GET[ 'name' ] );

    // Feedback for end user
    echo "
Hello ${name}
"; } // Generate Anti-CSRF token generateSessionToken();
htmlspecialchars函数将字符转义成HTML实体
&:转换为&
":转换为"
':转换为成为 '
<:转换为<
>:转换为>

同时采用token来验证身份,从而防止XSS攻击和CSRF攻击

 

转载于:https://www.cnblogs.com/gaonuoqi/p/11391602.html

你可能感兴趣的:(xSS-Reflected)