WEB_HCTF_2018_WarmUp

news/2024/5/20 0:36:37 标签: ctf

Categories

web-代码审计

write up

source code

get source code
http://eb22847d-9f8a-4ecf-b972-5ecebfcf5faf.node3.buuoj.cn/source.php

<?php
    highlight_file(__FILE__);
    class emmm
    {
        public static function checkFile(&$page)
        {
            $whitelist = ["source"=>"source.php","hint"=>"hint.php"];
            if (! isset($page) || !is_string($page)) {
                echo "you can't see it";
                return false;
            }

            if (in_array($page, $whitelist)) {
                return true;
            }

            $_page = mb_substr(
                $page,
                0,
                mb_strpos($page . '?', '?')
            );
            if (in_array($_page, $whitelist)) {
                return true;
            }

            $_page = urldecode($page);
            $_page = mb_substr(
                $_page,
                0,
                mb_strpos($_page . '?', '?')
            );
            if (in_array($_page, $whitelist)) {
                return true;
            }
            echo "you can't see it";
            return false;
        }
    }

    if (! empty($_REQUEST['file'])
        && is_string($_REQUEST['file'])
        && emmm::checkFile($_REQUEST['file'])
    ) {
        include $_REQUEST['file'];
        exit;
    } else {
        echo "<br><img src=\"https://i.loli.net/2018/11/01/5bdb0d93dc794.jpg\" />";
    }  
?>

analysis

$whitelist = ["source"=>"source.php","hint"=>"hint.php"];
......

$_page = mb_substr(
    $page,
    0,
    mb_strpos($page . '?', '?')
);
if (in_array($_page, $whitelist)) {
    return true;
}

The code will cut the string you input by ?
$_REQUEST['file']through the cut and let string in whitelist
So,just
http://eb22847d-9f8a-4ecf-b972-5ecebfcf5faf.node3.buuoj.cn/source.php?file=hint.php?/../../../../ffffllllaaaagggg
We can bypass the chenk

flag

在这里插入图片描述


http://www.niftyadmin.cn/n/1352457.html

相关文章

arm-none-eabi-gcc 报错 undefined reference to `_exit'解决方案

Bug 使用arm-none-ebai-gcc出现如下报错 Reason ARM Compiler toolchain 提到一种semi-host机制&#xff0c;博主没仔细看&#xff0c;感觉大概是要么使用semi-host要么不使用。 Semihosting is a mechanism that enables code running on an ARM target to communicate an…

python将伪代码转为代码时容易遇到range使用不正确的问题

前言 算法课经常会将伪代码转成可运行代码&#xff0c;这时候如果遇到循环比较多的情况&#xff0c;容易搞不清楚for循环如何转成range()&#xff0c;导致数组越界问题&#xff0c;且较难排查&#xff0c;只能调试解决。 本文将分享我在转化的过程中遇到的问题。下图为本文的…

ARM中PC和x86中IP的区别

前言 最近在学ARM&#xff0c;对它的PC产生了疑惑&#xff0c;一开始是把PC类比成x86中的IP的&#xff0c;后面发现还是有点区别的 x86架构 在《深入理解计算机系统》一书中指出&#xff08;P6&#xff09; 从系统通电开始&#xff0c;直到系统断电&#xff0c;处理器一直在…

linux扩充磁盘空间

前言 应用场景&#xff1a;虚拟机扩充磁盘&#xff0c;实体机换新磁盘 本文主要介绍如何扩充根目录的空间 举例&#xff1a; /dev/sda1 空间为40G /dev/sda2 新增空间为160G 目的&#xff1a; 获得 /dev/sda1 200G空间 方法 使用下面命令 sudo fdisk /dev/sda # 以下命令…

gcc -m32报错解决

前言 在64位下使用gcc编译32位程序出现报错&#xff0c;一般解决方案是缺各种依赖&#xff0c;如果你安装了依赖就可以了&#xff0c;那出门右转谷歌或者百度即可&#xff0c;本文是解决安装依赖都不能解决的情况 error 报错代码如下 ubuntuubuntu ~/code/pwn gcc -m32 te…

栈溢出学习(一)之利用预留后门 return2shellcode

前言 栈溢出学习&#xff08;一&#xff09;&#xff0c;讲述栈溢出中利用预留后门 & return2shellcode及其实践方法 系列文章 栈溢出学习&#xff08;一&#xff09;之利用预留后门 & return2shellcode 栈溢出学习&#xff08;二&#xff09;之 jmp esp & retur…

ARM立即寻址中有效立即数的计算

前言 感觉这方面的计算参考书上也讲的比较模糊&#xff0c;在这里分享一下计算的方法 立即数寻址有效数的计算 &#xff08;一&#xff09;ARM立即数寻址的指令格式 &#xff08;二&#xff09;例1 汇编指令&#xff1a;mov R0, #0x00110000 转为机器码就是 机器码&#xf…

栈溢出学习(二)之 jmp esp return2libc

前言 栈溢出学习&#xff08;二&#xff09;&#xff0c;讲述jmp esp && return2libc原理及其实践方法 系列文章 栈溢出学习&#xff08;一&#xff09;之利用预留后门 & return2shellcode 栈溢出学习&#xff08;二&#xff09;之 jmp esp & return2libc 栈…