zoukankan      html  css  js  c++  java
  • DVWA-8.4 SQL Injection (Blind)(SQL盲注)-Impossible

    Impossible Level

    查看源码

    <?php
    
    if( isset( $_GET[ 'Submit' ] ) ) {
        // Check Anti-CSRF token
        checkToken( $_REQUEST[ 'user_token' ], $_SESSION[ 'session_token' ], 'index.php' );
    
        // Get input
        $id = $_GET[ 'id' ];
    
        // Was a number entered?
        if(is_numeric( $id )) {
            // Check the database
            $data = $db->prepare( 'SELECT first_name, last_name FROM users WHERE user_id = (:id) LIMIT 1;' );
            $data->bindParam( ':id', $id, PDO::PARAM_INT );
            $data->execute();
    
            // Get results
            if( $data->rowCount() == 1 ) {
                // Feedback for end user
                $html .= '<pre>User ID exists in the database.</pre>';
            }
            else {
                // User wasn't found, so the page wasn't!
                header( $_SERVER[ 'SERVER_PROTOCOL' ] . ' 404 Not Found' );
    
                // Feedback for end user
                $html .= '<pre>User ID is MISSING from the database.</pre>';
            }
        }
    }
    
    // Generate Anti-CSRF token
    generateSessionToken();
    
    ?>

    可以看到,Impossible级别的代码采用了PDO技术,划清了代码与数据的界限,有效防御SQL注入,Anti-CSRF token机制的加入了进一步提高了安全性。

    参考:https://www.freebuf.com/articles/web/120985.html

  • 相关阅读:
    AutoLISP引线序号球
    2011年4月1日星期五
    AutoLISP绘制表格
    AutoLISP绘制玻璃门
    AutoLISPDCL对话框设计
    AutoLISP虚拟线变化图
    AutoLISP切圆动画
    盖章
    AutoLISP第一个DCL窗体
    jquery cookie插件使用
  • 原文地址:https://www.cnblogs.com/zhengna/p/12778075.html
Copyright © 2011-2022 走看看