天天看點

xctf攻防世界mark_loves_cat wp

xctf攻防世界mark_loves_cat wp

通路題目位址

xctf攻防世界mark_loves_cat wp

掃描發現/.git/傳回 403,使用Githack把源碼down下來

flag.php
<?php
$flag = file_get_contents('/flag');
           
index.php
<?php

include 'flag.php';

$yds = "dog";
$is = "cat";
$handsome = 'yds';

foreach($_POST as $x => $y){
    $$x = $y;
}

foreach($_GET as $x => $y){
    $$x = $$y;
}

foreach($_GET as $x => $y){
 if($_GET['flag'] === $x && $x !== 'flag'){
 exit($handsome);
 }
}

if(!isset($_GET['flag']) && !isset($_POST['flag'])){
 exit($yds);
}

if($_POST['flag'] === 'flag' || $_GET['flag'] === 'flag'){
 exit($is);
}



echo "the flag is: ".$flag;
           

看到了熟悉的

$$變量

,本題的思路就是用可控變量覆寫一些,變量最終構造出

$flag

變量:

GET yds=flag POST $flag=flag

這樣也滿足了第一個 if 的條件,exit 出 flag 的内容

xctf攻防世界mark_loves_cat wp

拿到flag

cyberpeace{3b5b4a30d92c8cb486f1182eeddd052c}