題目:https://ctflearn.com/challenge/88
SELECT * FROM webfour.webfour where name = '$input'
此 SQL 透過限定 name 來查詢資料,比如當 $input 是 Alice Bob 時,就會顯示 name 是 Alice Bob 的資料,因此可以猜測當 name 正確時,就能拿到本題的 flag。
因為使用者輸入的 $input 是以字串方式直接包含在 SQL 中,因此 $input 的值會成為最終執行 SQL 的一部分,此時就能透過特定 $input 來執行想要的 SQL。
在不知道正確的 name 前,讓 SQL 回傳所有資料同樣能達到目標,因此可以試著擴展 where 的條件,比如當 $input 是 ' OR '' = ' 時,執行的 SQL 會是 SELECT * FROM webfour.webfour where name = '' OR '' = '' ,where 的 '' = '' 對所有欄位都是 true,因此能拿到所有資料,也就能拿到本題的 flag。
