[SWPUCTF 2021 新生赛]jicao WP

ae230b53-3b0f-42b0-9f41-92fb3dc71ec0

代码审计

 <?php
highlight_file('index.php');
include("flag.php");
$id=$_POST['id'];
$json=json_decode($_GET['json'],true);
if ($id=="wllmNB"&&$json['x']=="wllm")
{echo $flag;}
?>

post传参一个id让它等于wllmNB,get传参一个json并且让他经过json_decode处理

json_decode

$jsonStr = '{"name":"小黑客","age":18}';
$data = json_decode($jsonStr, true);  // 第二个参数 true 表示转为关联数组
print_r($data);
// 输出: Array ( [name] => 小黑客 [age] => 18 )

常见参数

  • 第一个参数:待解码的 JSON 字符串
  • 第二个参数:true 返回关联数组,false(默认)返回 stdClass 对象
  • 返回值:解码成功返回数组/对象,失败返回 null

让经过json_decode之后键x对应的值为wllm

所以构造payload

get
?json={"x":"wllm"}
post
id=wllmNB

得到flag

posted on 2026-04-29 21:19  雪落沧州前  阅读(18)  评论(0)    收藏  举报