GK2020-CVE簽到題 CVE-2020-7066 PHP7.x get_headers()

前言

  來源 https://security-tracker.debian.org/tracker/CVE-2020-7066

  翻譯 https://bugs.php.net/bug.php?id=79329

 

get_headers()

  get_headers():可以通過服務器的響應頭來判斷遠程文件是否存在

array get_headers ( string $url [, int $format = 0 ] )

  判斷網站是否存在例子

<?php
var_dump( get_headers('https://www.baidu.com'));
?>

 

   get_headers()函數沒有設置參數,所以返回的數組中鍵值都是默認的。

 

get_headers()安全

  get_headers()會截斷URL中空字符後的內容,這是在php7.3中發現的 ,但是一直有這個漏洞,測試腳本顯示這會讓惡意腳本獲取意外域名的header 。這些header可能泄露敏感信息或者意外地包含攻擊者控制的數據。

  在低於7.2.29的PHP版本7.2.x,低於7.3.16的7.3.x和低於7.4.4的7.4.x中,將get_headers()與用戶提供的URL一起使用時,如果URL包含零(\ 0)字符,則URL將被靜默地截斷。這可能會導致某些軟件對get_headers()的目標做出錯誤的假設,並可能將某些信息發送到錯誤的服務器。

<?php
// user input
$_GET['url'] = "http://localhost\0.example.com";

$host = parse_url($_GET['url'], PHP_URL_HOST);
if (substr($host, -12) !== '.example.com') {
    die();
}
$headers = get_headers($_GET['url']);
var_dump($headers);

  預期結果

 

 

 

GK2020-CVE簽到題

  訪問題目,給的提示是CVE-2020-7066

 

   F12得到提示,flag在localhost,localhost不是單指127.0.0.1,而是符合127.0.0.0/24這一網段的IP地址,比如127.0.0.100也可以叫localhost

 

 

  再點擊鏈接,發現有傳參

 

   綜上,就是參數要是localhost且用\0截斷,這裏用%00截斷

 

   最後需要123

 

 

參考鏈接

  https://blog.csdn.net/qq_45521281/article/details/106425266

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章