web98笔记(三目运算符和取地址+post覆盖了get)

Notice: Undefined index: flag in /var/www/html/index.php on line 15

Notice: Undefined index: flag in /var/www/html/index.php on line 16

Notice: Undefined index: HTTP_FLAG in /var/www/html/index.php on line 17
<?php

/*
# -*- coding: utf-8 -*-
# @Author: h1xa
# @Date:   2020-09-16 11:25:09
# @Last Modified by:   h1xa
# @Last Modified time: 2020-09-18 21:39:27
# @link: https://ctfer.com

*/

include("flag.php");
$_GET?$_GET=&$_POST:'flag';
$_GET['flag']=='flag'?$_GET=&$_COOKIE:'flag';
$_GET['flag']=='flag'?$_GET=&$_SERVER:'flag';
highlight_file($_GET['HTTP_FLAG']=='flag'?$flag:__FILE__);

?>

这里是三目运算符和取地址,第三行和第四行是无用的,因为用不到,所以我们分析一下第二行和第五行

第一行:如果存在get传参,则把post传参地址给get,可以简单理解为post覆盖了get
第四行,如果get参数HTTP_FLAG的值为flag,就读取文件,也就是输出flag

所以思路也就出来了,payload为  (GET随便)

GET:?1=2

POST:HTTP_FLAG=flag

GET: ?a=b
POST:HTTP_FLAG=flag

 

posted @ 2025-03-18 11:44  justdoIT*  阅读(11)  评论(0)    收藏  举报