php新手入门

首页 > 教育培训 > 作者:YD1662023-06-20 17:21:21

<?php include('phar://sd.gif'); class TestObject { function __destruct() { echo $this->data; } } ?>

php新手入门,(13)

成功将meta-data中data数据反序列化出来

总结

利用条件:

  1. phar文件要能够上传到服务器端。
  2. 要有可用的魔术方法作为“跳板”。
  3. 文件操作函数的参数可控,且:、/、phar等特殊字符没有被过滤。

WeCenter3.3.4反序列化造成sql注入

这个洞有点老了,但不影响学习分析

cms下载地址:

http://www.wecenter.com/downloads/

在这个版本的cms中存在多个反序列化POP链,如果我们想利用这些 POP 链,就必须找到可控的反序列化点。WeCenter 中就存在可控的文件名,能够利用phar伪协议

定位到漏洞文件./system/aws_model.inc.php

php新手入门,(14)

析构函数遍历了$this->_shutdown_query变量,然后带入了$this->query()函数,跟一下

public function query($sql, $limit = null, $offset = null, $where = null) { $this->slave(); if (!$SQL) { throw new Exception('Query was empty.'); } if ($where) { $sql .= ' WHERE ' . $where; } if ($limit) { $sql .= ' LIMIT ' . $limit; } if ($offset) { $sql .= ' OFFSET ' . $offset; } if (AWS_APP::config()->get('system')->debug) { $start_time = microtime(TRUE); } try { $result = $this->db()->query($sql); } catch (Exception $e) { show_error("Database error\n------\n\nSQL: {$sql}\n\nError Message: " . $e->getMessage(), $e->getMessage()); } if (AWS_APP::config()->get('system')->debug) { AWS_APP::debug_log('database', (microtime(TRUE) - $start_time), $sql); } return $result; }

并没有任何的过滤,如果$this->_shutdown_query变量参数可控,那么就可以造成sql注入

利用反序列化的方式,可以重置$this->_shutdown_query的值。

再看./models/account.php

public function associate_remote_avatar($uid, $headimgurl) { if (!$headimgurl) { return false; } if (!$user_info = $this->get_user_info_by_uid($uid)) { return false; } if ($user_info['avatar_file']) { return false; } if (!$avatar_stream = file_get_contents($headimgurl)) { return false; } $avatar_location = get_setting('upload_dir') . '/avatar/' . $this->get_avatar($uid, ''); $avatar_dir = dirname($avatar_location) . '/'; if (!file_exists($avatar_dir)) { make_dir($avatar_dir); }

associate_remote_avatar函数将传进来的$headimgurl没有经过任何过滤直接传入了文件操作函数file_get_contents中,这个系统函数正好就在受影响的范围之内。全局搜索associate_remote_avatar

./app/account/ajax.php

php新手入门,(15)

这个函数调用了associate_remote_avatar,$headimgurl 值来源于 $wxuser['headimgurl'],这个$wxuser实际上是数据库users_weixin 表中的相关数据,如果有insert,update就好了

./models/openid/weixin/weixin.php

php新手入门,(16)

上一页12345下一页

栏目热文

文档排行

本站推荐

Copyright © 2018 - 2021 www.yd166.com., All Rights Reserved.