zoukankan      html  css  js  c++  java
  • sql注入-基于布尔型的盲注入门

     0-SQL盲注的手工注入测试
        确定字段长度
            1' and length(user())>12#
        确定字段内容
            1' and substring(user(),1,1)>'a'#
            这里的substring()函数的作用是提取字符串中的字符.例如:
            substring('abcd',1,1)返回a
            substring('abcd',3,1)返回c
            substring('abcd',3,2)返回cd
                    基于MYSQL的SQL注入常用函数
                    find_in_set()
    length()
    user()
    version()
    database()
    left()
    right()
    substring()
    count()
    rand()
    floor()
    concat()
    group_concat()
    limit()
    1-配合burpsuite进行SQL盲注攻击
        使用BurpSuite更改了http请求报文,测试出了SQL盲注漏洞,原理与上一节中SQL盲注的手工注入测试一样
        
    2-特殊页面下的SQL盲注入
                         
         <?php
        if( isset( $_COOKIE[ 'id' ] ) ) {
            // Get input
            $id = $_COOKIE[ 'id' ];
            // Check database
            $getid  = "SELECT first_name, last_name FROM users WHERE user_id = '$id' LIMIT 1;";//依旧是没有对用户的输入进行过滤,直接就放进数据库执行去了。
            $result = mysql_query( $getid ); // 返回数据库的执行结果。
            // Get results
            $num = @mysql_numrows( $result ); // 返回结果集中行的数目。@表示不显示错,即有错误返回空。
            if( $num > 0 ) {
                // 数据库有返回消息
                echo '<pre>User ID exists in the database.</pre>';
            }
            else {
                // 随机休眠,防止暴力输入PAYLOAD
                if( rand( 0, 5 ) == 3 ) {
                    sleep( rand( 2, 4 ) );
                }
                header( $_SERVER[ 'SERVER_PROTOCOL' ] . ' 404 Not Found' );
                // 返回没有该用户
                echo '<pre>User ID is MISSING from the database.</pre>';
            }
            mysql_close();
        }
        ?>
        
    RM-Anton原创,转载请注明。

    繁华都市中的隐者
  • 相关阅读:
    【NOIP 2003】 加分二叉树
    【POJ 1655】 Balancing Act
    【HDU 3613】Best Reward
    【POJ 3461】 Oulipo
    【POJ 2752】 Seek the Name, Seek the Fame
    【POJ 1961】 Period
    【POJ 2406】 Power Strings
    BZOJ3028 食物(生成函数)
    BZOJ5372 PKUSC2018神仙的游戏(NTT)
    BZOJ4836 二元运算(分治FFT)
  • 原文地址:https://www.cnblogs.com/RM-Anton/p/9102031.html
Copyright © 2011-2022 走看看