DVWA——CSRF(low)

CSRF

界面

在这里插入图片描述

源代码

<?php

if( isset( $_GET[ 'Change' ] ) ) {
    
    
    // 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
        echo "<pre>Password Changed.</pre>";
    }
    else {
    
    
        // Issue with passwords matching
        echo "<pre>Passwords did not match.</pre>";
    }

    ((is_null($___mysqli_res = mysqli_close($GLOBALS["___mysqli_ston"]))) ? false : $___mysqli_res);
}

?>

代码分析

       通过获取change表格里的新密码,以及重复的新密码,比较这两个是否一致,若一致,则修改密码,若不一致,则提示输入错误

渗透步骤

       第一步:点击change按钮,使用burp suite进行liuliangbao 捕获。观察流量包,发现是使用get请求
在这里插入图片描述
       第二步:构造get请求参数,将password_new以及passwprd_conf后面的参数写入新的密码,进行密码篡改
在这里插入图片描述
       第三步:测试旧的密码,发现登录失败,密码以被篡改
在这里插入图片描述

应用场景

通过在别的页面构造超链接,引诱用户点击使用户的密码改变

猜你喜欢

转载自blog.csdn.net/qq_37589805/article/details/112198585