很好!!
你已經來到第三關了,情況會越來越真實,項目也會越來越複雜!
但是別擔心,這些都會是寶貴的經驗!
題目-劇情描述
From: PeacePoetry
Message: I run this website where people can read and submit peace-related poetry. I am doing this out of good will towards others, and I don't see why I would be making enemies out of this, but some real ass hole hacked my website posting a bunch of ignorant aggressive propaganda on the front page. And I made that website a while ago, and I no longer have access to it. Do you think you can hack in and change it back? Please? Oh, and bonus points if you message me the name of the bastard who did this!
My website can be found here.
概念
由題目可以知道,這個網站是一個人們可以閱讀、可以提交和平相關的詩歌,主要因為被串改了首頁,希望可以改回來,這就想到頁面存取的問題,到底是怎樣的方式才可以改到首頁呢?
攻擊-Attack
由一個被竄改的首頁,其實看不出什麼所以然,畢竟都被竄改過了,還能期待對方留下什麼給你嗎!?
沒關係我們還有URL可以測試,想想看一個網站被換過,一般如果由程式置換的話,會變成backupindex.html 、 oldindex.html、bkindex.html?
都是試看看不就明白!,try it!
你會看到看起來像是首頁的首頁,有兩個連結可以點,提交跟觀看,從這裡就可以明白,該往那條路走了。
時間還夠的話,可以看看網站哪些東西。
我們就朝著提交前進吧!
這時你會看見兩個輸入框,看到輸入框就可以小試一下,雖然試了也沒啥反應,那我們要怎麼知道要怎麼操作?
就以這網站來說,最主要用意就是讓人提交詩歌文字,那在"Read The Poetry" 的項目這裡有藏一個提示
輸入一個文件!?
那就可以確定,Name of poem 就是輸入檔案位置的欄位,那Poem就是用來輸入內容的(這是廢話....)
要取回首頁,先在Name of poem輸入 index.html 試試看!
好像沒反應ㄟ.....
換個路徑試試看,../index.html
有反應了!!
但是訊息顯示
Sorry, you have the right idea how to beat the level, but the text you entered did not match the contents of the old website. You have to put the old website up, meaning putting up the old index.html
嗯嗯,離成功之差一步了,依照題目要求要將index.html換回正常版的
我們就試試看,複製oldindex.html的原始碼來貼上,你就會發現!
成功拉!
防禦-Defense
張貼文章,或是留言板的功能,都是漏洞的溫床,一不小心就會引發XSS攻擊,不過這個題目還沒有到那種程度。
但是能竄改檔案也足以引發大災難,被拿下主機也不意外!
至於要怎麼防範?
可以讓使用者張貼訊息,這本身就該限制只有文字,不能加上任何的html 程式碼,對於張貼路徑也要進行限制,不能跨路徑存取,建立存取規則的白名單只有在相關路徑下才能寫入
切記,在使用者輸入端,必須嚴加檢查!