Lucene search

K
openvasThis script is Copyright (C) 2001 Renaud DeraisonOPENVAS:80049
HistoryOct 24, 2008 - 12:00 a.m.

SysV /bin/login buffer overflow (telnet)

2008-10-2400:00:00
This script is Copyright (C) 2001 Renaud Deraison
plugins.openvas.org
22

0.974 High

EPSS

Percentile

99.9%

The remote /bin/login seems to crash when it receives too many
environment variables.

An attacker may use this flaw to gain a root shell on this system.

# OpenVAS Vulnerability Test
# $Id: binlogin_overflow_telnet.nasl 3854 2016-08-18 13:15:25Z teissa $
# Description: SysV /bin/login buffer overflow (telnet)
#
# Authors:
# Renaud Deraison <[email protected]>
#
# Copyright:
# Copyright (C) 2001 Renaud Deraison
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2,
# as published by the Free Software Foundation
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#

tag_summary = "The remote /bin/login seems to crash when it receives too many
environment variables.

An attacker may use this flaw to gain a root shell on this system.";

tag_solution = "Contact your vendor for a patch (or read the CERT advisory)";

# Sun's patch makes /bin/login exits when it receives too many arguments,
# hence making the detection of the flaw difficult. Our logic is the
# following :
#
# Username: "openvas" -> should not crash
# Username: "openvas A=B..... x 61"  -> should not crash
# Username: "openvas A=B..... x 100" -> should crash

if (description) {
   script_id(80049);;
   script_version("$Revision: 3854 $");
   script_tag(name:"last_modification", value:"$Date: 2016-08-18 15:15:25 +0200 (Thu, 18 Aug 2016) $");
   script_tag(name:"creation_date", value:"2008-10-24 23:33:44 +0200 (Fri, 24 Oct 2008)");
   script_xref(name:"IAVA", value:"2001-a-0014");
   script_bugtraq_id(3681, 7481);
   script_cve_id("CVE-2001-0797");
   script_xref(name:"IAVA", value:"2002-A-0004");
   script_tag(name:"cvss_base", value:"10.0");
   script_tag(name:"cvss_base_vector", value:"AV:N/AC:L/Au:N/C:C/I:C/A:C");
  name = "SysV /bin/login buffer overflow (telnet)";
  script_name(name);
 
 
  script_category(ACT_DESTRUCTIVE_ATTACK);
  script_tag(name:"qod_type", value:"remote_vul");
 
  script_copyright("This script is Copyright (C) 2001 Renaud Deraison");

  family = "Gain a shell remotely";
  script_family(family);

  script_dependencies("find_service1.nasl");
  script_require_ports("Services/telnet", 23);
   script_tag(name : "solution" , value : tag_solution);
   script_tag(name : "summary" , value : tag_summary);
   script_xref(name : "URL" , value : "http://www.cert.org/advisories/CA-2001-34.html");
  exit(0);
}


include('telnet_func.inc');
port = get_kb_item("Services/telnet");
if(!port) port = 23;
if(!get_port_state(port))exit(0);

function login(env, try)
{
  local_var	i, soc, r, buffer;

  # if (try <= 0) try = 1;
  for (i = 0; i < try; i ++)
  {
    sleep(i);
    soc = open_sock_tcp(port);
    if (soc) break;
  }

   if (soc)
   {

 buffer = telnet_negotiate(socket:soc);
 send(socket:soc, data:string("openvas ", env, "\r\n"));
 r = recv(socket:soc, length:4096);
 close(soc);
 if("word:" >< r)
  {
	return(1);
  }
 }
 return(0);
}



if(login(env:"", try: 1))
{
 my_env = crap(data:"A=B ", length:244);
 res = login(env:my_env);
 if(res)
 {
  my_env = crap(data:"A=B ", length:400);
  res = login(env:my_env, try: 4);
  if(!res)security_message(port);
 }
}