### 简要描述: IIS || Apache。 ### 详细说明: http://bbs.qibosoft.com/down2.php?v=news1.0#down 下载地址。 在news/member/post.php中 ``` require_once(Mpath."inc/check.postarticle.php"); if($job=='postnew') { if($step=='post') { post_new(); //生成静态 make_article_html("$Murl/member/post.php?job=endHTML&aid=$aid"); $mid && $mid<106 && $none='none'; refreshto("?job=postnew&fid=$fid","<CENTER>[<A HREF='?job=postnew&fid=$fid'>继续发表新主题</A>] <span style='display:$none;'>[<A HREF='?job=post_more&fid=$fid&aid=$aid'>续发本主题</A>]</span> [<A HREF='myarticle.php?job=myarticle&fid=$fid'>返回主题列表</A>] [<A HREF='$Mdomain/bencandy.php?fid=$fid&aid=$aid' target=_blank>查看主题</A>] [<A HREF='?job=edit&aid=$aid'>点击修改</A>]</CENTER>",60); } $MSG='新发表内容'; $select_fid=$Guidedb->SelectIn("{$_pre}sort",0,$fid); require(ROOT_PATH."member/head.php"); require(dirname(__FILE__)."/template/post.htm"); require(ROOT_PATH."member/foot.php"); ``` 包含了这个进来inc/check.postarticle.php 进去看看。 ``` $postdb[title]=filtrate($postdb[title]);...
### 简要描述: IIS || Apache。 ### 详细说明: http://bbs.qibosoft.com/down2.php?v=news1.0#down 下载地址。 在news/member/post.php中 ``` require_once(Mpath."inc/check.postarticle.php"); if($job=='postnew') { if($step=='post') { post_new(); //生成静态 make_article_html("$Murl/member/post.php?job=endHTML&aid=$aid"); $mid && $mid<106 && $none='none'; refreshto("?job=postnew&fid=$fid","<CENTER>[<A HREF='?job=postnew&fid=$fid'>继续发表新主题</A>] <span style='display:$none;'>[<A HREF='?job=post_more&fid=$fid&aid=$aid'>续发本主题</A>]</span> [<A HREF='myarticle.php?job=myarticle&fid=$fid'>返回主题列表</A>] [<A HREF='$Mdomain/bencandy.php?fid=$fid&aid=$aid' target=_blank>查看主题</A>] [<A HREF='?job=edit&aid=$aid'>点击修改</A>]</CENTER>",60); } $MSG='新发表内容'; $select_fid=$Guidedb->SelectIn("{$_pre}sort",0,$fid); require(ROOT_PATH."member/head.php"); require(dirname(__FILE__)."/template/post.htm"); require(ROOT_PATH."member/foot.php"); ``` 包含了这个进来inc/check.postarticle.php 进去看看。 ``` $postdb[title]=filtrate($postdb[title]); $postdb[subhead]=filtrate($postdb[subhead]); $postdb[keywords]=filtrate($postdb[keywords]); $postdb[smalltitle]=filtrate($postdb[smalltitle]); $postdb[picurl]=filtrate($postdb[picurl]); //$postdb[description]=filtrate($postdb[description]); $postdb[author]=filtrate($postdb[author]); $postdb[copyfrom]=filtrate($postdb[copyfrom]); $postdb[copyfromurl]=filtrate($postdb[copyfromurl]); $postdb[description]=preg_replace('/javascript/i','java script',$postdb[description]); $postdb[description]=preg_replace('/<iframe ([^<>]+)>/i','<iframe \\1>',$postdb[description]); //针对火狐浏览器做的处理 $postdb[content]=str_replace("=\\\"../$webdb[updir]/","=\\\"$webdb[www_url]/$webdb[updir]/",$postdb[content]); if(!$groupdb[PostNoDelCode]){ $postdb[content]=preg_replace('/javascript/i','java script',$postdb[content]); $postdb[content]=preg_replace('/<iframe ([^<>]+)>/i','<iframe \\1>',$postdb[content]); } //采集外部图片 $postdb[content]=get_outpic($postdb[content],$fid,$GetOutPic); ``` 跟这函数来看看。get_outpic ``` function get_outpic($str,$fid=0,$getpic=1){ global $webdb,$lfjuid,$_pre; if(!$getpic){ return $str; } preg_match_all("/http:\/\/([^ '\"<>]+)\.(gif|jpg|png)/is",$str,$array); $filedb=$array[0]; foreach( $filedb AS $key=>$value){ if( strstr($value,$webdb[www_url]) ){ continue; } $listdb["$value"]=$value; } unset($filedb); foreach( $listdb AS $key=>$value){ $filedb[]=$value; $name=$lfjuid.'_'.rands(5)."__".basename($value); if(!is_dir(ROOT_PATH."$webdb[updir]/$_pre/$fid")){ makepath(ROOT_PATH."$webdb[updir]/$_pre/$fid"); } $ck=0; if( @copy($value,ROOT_PATH."$webdb[updir]/$_pre/$fid/$name") ){ $ck=1; }elseif($filestr=file_get_contents($value)){ $ck=1; write_file(ROOT_PATH."$webdb[updir]/$_pre/$fid/$name",$filestr); } ``` ``` preg_match_all("/http:\/\/([^ '\"<>]+)\.(gif|jpg|png)/is",$str,$array); $filedb=$array[0]; foreach( $filedb AS $key=>$value){ if( strstr($value,$webdb[www_url]) ){ continue; } $listdb["$value"]=$value; } unset($filedb); ``` 这里匹配了 http://xxxx.com/xx.jpg|png|gif 这种的 匹配出来后 循环赋值 然后又再把数组$listdb循环出来 ``` foreach( $listdb AS $key=>$value){ $filedb[]=$value; $name=$lfjuid.'_'.rands(5)."__".basename($value); ``` 然后拼接成$name 最后 $name做了文件的名字。然后再file get contents 就write file了。 由于这里匹配的时候限制匹配到.jpg 结束 所以要利用一下解析漏洞 这里先说下解析漏洞。 IIS6解析漏洞:yu.php;1.jpg 这样是可以当php文件来执行的。 Apache解析漏洞:yu.php.jpg (当最后一个后缀无法解析的时候也就是.jpg无法解析的时候 就会向上来解析就解析成了.php. 当服务器是windows的时候jpg是会被识别的所以这样解析无效, 当linux时 jpg无法解析 就会解析成.php了) ### 漏洞证明: 发表文章的时候抓个包。 ``` function get_outpic($str,$fid=0,$getpic=1){ global $webdb,$lfjuid,$_pre; if(!$getpic){ return $str; } ``` 由于这里当这变量为false的时候就直接返回了。 结合qibocms的伪全局机智 直接post提交下就行了。 $name=$lfjuid.'_'.rands(5)."__".basename($value); 这里文件名的名字是由uid_随机5个字符__拼接的名字 这里uid 和名字我们自己都能知道 但是随机的5个字符不太清楚 但是后面有函数会帮忙。 ``` gdpic(ROOT_PATH."$webdb[updir]/$postdb[picurl]",$Newpicpath,$picWidth?$picWidth:300,$picHeight?$picHeight:225,$webdb[autoCutSmallPic]?array('fix'=>1):''); //多生成一张3:4的图片,方便标签调用 gdpic(ROOT_PATH."$webdb[updir]/$postdb[picurl]","$Newpicpath.jpg",$picHeight?$picHeight:225,$picWidth?$picWidth:300,$webdb[autoCutSmallPic]?array('fix'=>1):''); //多生成一张1:1的图片,方便标签调用 gdpic(ROOT_PATH."$webdb[updir]/$postdb[picurl]","$Newpicpath.jpg.jpg",$picWidth?$picWidth:300,$picWidth?$picWidth:300,$webdb[autoCutSmallPic]?array('fix'=>1):''); ``` 在这里 调用了这个函数 ``` function gdpic($srcFile,$dstFile,$width,$height,$type=''){ require_once(ROOT_PATH."inc/waterimage.php"); if(is_array($type)){ //截取一部分,以满足匹配尺寸 cutimg($srcFile,$dstFile,$x=$type[x]?$type[x]:0,$y=$type[y]?$type[y]:0,$width,$height,$x2=$type[x2]?$type[x2]:0,$y2=$type[y2]?$type[y2]:0,$scale=$type[s]?$type[s]:100,$fix=$type[fix]?$type[fix]:''); }elseif($type==1){ //成比例的缩放 ResizeImage($srcFile,$dstFile,$width,$height); }else{ //与尺寸不匹配时.用色彩填充 gdfillcolor($srcFile,$dstFile,$width,$height); ``` 继续跟 ``` function cutimg($srcimgurl,$endimgurl,$x,$y,$endimg_w,$endimg_h,$border_w,$border_h,$scale=100,$fix=0){ $path = dirname ($endimgurl); if (!is_dir($path)) { if(!@mkdir ($path, 0777)){ showerr("{$path} 此目录不能创建,文件创建失败"); } } $ground_info = getimagesize($srcimgurl); switch($ground_info[2]){ case 1:$im = imagecreatefromgif($srcimgurl);break; case 2:$im = imagecreatefromjpeg($srcimgurl);break; case 3:$im = imagecreatefrompng($srcimgurl);break; default:die("图片格式不允许$srcimgurl"); ``` 当cut失败的时候 会直接透漏出文件的名字。 [<img src="https://images.seebug.org/upload/201406/22145720230ae9c7fc8e70b3c7902791308043ee.jpg" alt="qn1.jpg" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201406/22145720230ae9c7fc8e70b3c7902791308043ee.jpg) [<img src="https://images.seebug.org/upload/201406/22150038f9ba50b8b24433843430c6894c015f06.jpg" alt="qn2.jpg" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201406/22150038f9ba50b8b24433843430c6894c015f06.jpg) 这种格式的文件在iis 或者 apache下是能解析的。