缘由:做一个传参题目的时候,碰到了一点点小问题,始终没想出来哪点出了问题,后来经过对比,找出了原因,记录一下
GET和POST的报文对比
在一个GET传参的基础上,进行POST传参,只是在报文中将GET改为POST,添加POST报文内容是不够的,还需要添加一些其他的东西。
接下里进行一下对比:
以一道题目为例:BUU CODE REVIEW 1
<?php
/**
* Created by PhpStorm.
* User: jinzhao
* Date: 2019/10/6
* Time: 8:04 PM
*/
highlight_file(__FILE__);
class BUU {
public $correct = "";
public $input = "";
public function __destruct() {
try {
$this->correct = base64_encode(uniqid());
if($this->correct === $this->input) {
echo file_get_contents("/flag");
}
} catch (Exception $e) {
}
}
}
if($_GET['pleaseget'] === '1') {
if($_POST['pleasepost'] === '2') {
if(md5($_POST['md51']) == md5($_POST['md52']) && $_POST['md51'] != $_POST['md52']) {
unserialize($_POST['obj']);
}
}
}
题目中我们需要首先GET传参,然后POST传参,以下是报文对比
GET传参报文
POST传参报文
两者相比POST报文中增加的内容
相比GET传参报文,POST传参报文多的几个项:
GET
转为POST
Content-Type
:Content-Type: application/x-www-form-urlencodedContent-Length: 86
这个86是POST传参的内容长度Origin
: http://175caf72-e921-4de9-aa37-2d213c9444ef.node4.buuoj.cn:81Referer
: http://175caf72-e921-4de9-aa37-2d213c9444ef.node4.buuoj.cn:81/?pleaseget=1- POST传参的内容