加入收藏 | 设为首页 | 会员中心 | 我要投稿 西安站长网 (https://www.029zz.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 建站 > 正文

PHP反序列化漏洞简介及相关技巧小结

发布时间:2019-08-12 10:06:03 所属栏目:建站 来源:xiaopan233
导读:副标题#e# 要学习PHP反序列漏洞,先了解下PHP序列化和反序列化是什么东西。 php程序为了保存和转储对象,提供了序列化的方法,php序列化是为了在程序运行的过程中对对象进行转储而产生的。序列化可以将对象转换成字符串,但仅保留对象里的成员变量,不保留

源码很简单:

  1. <?php  
  2. error_reporting(0);  
  3. class come{      
  4.    private $method;  
  5.    private $args;  
  6.    function __construct($method, $args) {  
  7.        $this->method = $method;  
  8.        $this->args = $args;  
  9.     }  
  10.    function __wakeup(){  
  11.        foreach($this->args as $k => $v) {  
  12.            $this->args[$k] = $this->waf(trim($v));  
  13.        }  
  14.     }  
  15.    function waf($str){  
  16.        $str=preg_replace("/[<>*;|?n ]/","",$str);  
  17.        $str=str_replace('flag','',$str);  
  18.        return $str;  
  19.    }             
  20.    function echos($host){  
  21.        system("echos $host".$host);  
  22.     } 
  23.    function __destruct(){  
  24.        if (in_array($this->method, array("echos"))) {  
  25.            call_user_func_array(array($this, $this->method), $this->args);  
  26.        }  
  27.     }  
  28. }  
  29. $first='hi';  
  30. $var='var';  
  31. $bbb='bbb';  
  32. $ccc='ccc';  
  33. $i=1;  
  34. foreach($_GET as $key => $value) {  
  35.        if($i===1)  
  36.        { 
  37.             $i++;     
  38.            $$key = $value;  
  39.        }  
  40.        else{break;}  
  41. }  
  42. if($first==="doller")  
  43. {  
  44.    @parse_str($_GET['a']);  
  45.    if($var==="give")  
  46.     {  
  47.        if($bbb==="me") 
  48.        {  
  49.            if($ccc==="flag")  
  50.            { 
  51.                  echo"<br>welcome!<br>";  
  52.                 $come=@$_POST['come'];  
  53.                 unserialize($come);   
  54.            }  
  55.        }  
  56.        else  
  57.        {echo "<br>think about it<br>";}  
  58.     }  
  59.    else  
  60.     {  
  61.        echo "NO";  
  62.     }  
  63. }  
  64. else  
  65. {  
  66.    echo "Can you hack me?<br>";  
  67. }  
  68. ?> 

(编辑:西安站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

热点阅读