2005-11-30 22:11:15 by: h4x0r

SaForums论坛拿Webshell

Font Size: Large | Medium | Small
SaForums论坛结合APACHE扩展名解释漏洞获得WEBSHELL

SaForums是angle[安全天使]基于Discuz 2.2F修改的论坛,过滤的比较严格,相对还是比较安全的。但是在APACHE中可以结合扩展名解释漏洞上传文件来获取WEBSHELL。

APACHE在解释扩展名的时候不是从文件名最后开始算,而是只要文件名中包含扩展名就会进行解释。例如aaa.php.rar会被当成php脚本来执行。

SaForums默认是允许用户上传图片的,并且把上传的文件名进行一些处理:
in include\post.php
if(in_array($extension, array('php', 'php3', 'jsp', 'asp', 'cgi', 'pl'))) {
 $extension = '_'.$extension;
}

$attach_fname .= random(4)."_$filename.file"; //防止上传可以执行的文件 by angel

但是这样判断是不完全的,如果我们上传一个名为h4x0r.php.gif的图片文件,会被重命名为XXXX_h4x0r.php.file,这个文件在APACHE环境下仍然被当成php来解释执行。所以只要我们上传的h4x0r.php.gif有正确的gif文件头就可以绕过检测来执行php代码了。

修补方法:
去掉文件名中的"."字符:
$filename = str_replace('.', '_', $filename);
[Last Modified By h4x0r, at 2005-12-03 13:20:40]
Comments Feed Comments Feed: http://www.4evil.org/feed.asp?q=comment&id=214

There is no comment on this article.

Post Comment
Smilies
[smile] [confused] [cool] [cry]
[eek] [angry] [wink] [sweat]
[lol] [stun] [razz] [redface]
[rolleyes] [sad] [yes] [no]
[heart] [star] [music] [idea]
Enable UBB Codes
Auto Convert URL
Show Smilies
Hidden Comment
Username:   Password:   Register Now?
Security Code * Please Enter the Security Code