美文网首页
DVWA 跨站请求伪造漏洞中级

DVWA 跨站请求伪造漏洞中级

作者: 与狼共舞666 | 来源:发表于2022-08-27 15:59 被阅读0次
    <?php
    
    if( isset( $_GET[ 'Change' ] ) ) {
        // Checks to see where the request came from
        if( stripos( $_SERVER[ 'HTTP_REFERER' ] ,$_SERVER[ 'SERVER_NAME' ]) !== false ) {
            // Get input
            $pass_new  = $_GET[ 'password_new' ];
            $pass_conf = $_GET[ 'password_conf' ];
    
            // Do the passwords match?
            if( $pass_new == $pass_conf ) {
                // They do!
                $pass_new = ((isset($GLOBALS["___mysqli_ston"]) && is_object($GLOBALS["___mysqli_ston"])) ? mysqli_real_escape_string($GLOBALS["___mysqli_ston"],  $pass_new ) : ((trigger_error("[MySQLConverterToo] Fix the mysql_escape_string() call! This code does not work.", E_USER_ERROR)) ? "" : ""));
                $pass_new = md5( $pass_new );
    
                // Update the database
                $insert = "UPDATE `users` SET password = '$pass_new' WHERE user = '" . dvwaCurrentUser() . "';";
                $result = mysqli_query($GLOBALS["___mysqli_ston"],  $insert ) or die( '<pre>' . ((is_object($GLOBALS["___mysqli_ston"])) ? mysqli_error($GLOBALS["___mysqli_ston"]) : (($___mysqli_res = mysqli_connect_error()) ? $___mysqli_res : false)) . '</pre>' );
    
                // Feedback for the user
                $html .= "<pre>Password Changed.</pre>";
            }
            else {
                // Issue with passwords matching
                $html .= "<pre>Passwords did not match.</pre>";
            }
        }
        else {
            // Didn't come from a trusted source
            $html .= "<pre>That request didn't look correct.</pre>";
        }
    
        ((is_null($___mysqli_res = mysqli_close($GLOBALS["___mysqli_ston"]))) ? false : $___mysqli_res);
    }
    
    ?>
    
    image.png
    image.png
    构造利用请求连接,打开新的浏览器tab。再请求http://172.18.0.13/vulnerabilities/csrf/?password_new=123456&password_conf=123456&Change=Change#
    image.png

    相关文章

      网友评论

          本文标题:DVWA 跨站请求伪造漏洞中级

          本文链接:https://www.haomeiwen.com/subject/xwefnrtx.html