rsh Service Detection - Nessus

High   Plugin ID: 10245

This page contains detailed information about the rsh Service Detection Nessus plugin including available exploits and PoCs found on GitHub, in Metasploit or Exploit-DB for verifying of this vulnerability.

Plugin Overview


ID: 10245
Name: rsh Service Detection
Filename: rsh.nasl
Vulnerability Published: 1990-01-01
This Plugin Published: 1999-08-22
Last Modification Time: 2022-04-11
Plugin Version: 1.38
Plugin Type: remote
Plugin Family: Service detection
Dependencies: find_service2.nasl

Vulnerability Information


Severity: High
Vulnerability Published: 1990-01-01
Patch Published: N/A
CVE [?]: CVE-1999-0651
CPE [?]: N/A

Synopsis

The rsh service is running on the remote host.

Description

The rsh service is running on the remote host. This service is vulnerable since data is passed between the rsh client and server in cleartext. A man-in-the-middle attacker can exploit this to sniff logins and passwords. Also, it may allow poorly authenticated logins without passwords. If the host is vulnerable to TCP sequence number guessing (from any network) or IP spoofing (including ARP hijacking on a local network) then it may be possible to bypass authentication. Finally, rsh is an easy way to turn file-write access into full logins through the .rhosts or rhosts.equiv files.

Solution

Comment out the 'rsh' line in /etc/inetd.conf and restart the inetd process. Alternatively, disable this service and use SSH instead.

Public Exploits


Target Network Port(s): 514
Target Asset(s): Services/rsh
Exploit Available: True (Metasploit Framework)
Exploit Ease: Exploits are available

Here's the list of publicly known exploits and PoCs for verifying the rsh Service Detection vulnerability:

  1. Metasploit: auxiliary/scanner/rservices/rlogin_login
    [rlogin Authentication Scanner]
  2. Metasploit: auxiliary/scanner/rservices/rexec_login
    [rexec Authentication Scanner]
  3. Metasploit: auxiliary/scanner/rservices/rsh_login
    [rsh Authentication Scanner]

Before running any exploit against any system, make sure you are authorized by the owner of the target system(s) to perform such activity. In any other case, this would be considered as an illegal activity.

Risk Information


CVSS V2 Vector [?]: AV:N/AC:L/Au:N/C:P/I:P/A:P
CVSS Base Score:7.5 (High)
Impact Subscore:6.4
Exploitability Subscore:10.0
CVSS Temporal Score:NA (None)
CVSS Environmental Score:NA (None)
Modified Impact Subscore:NA
Overall CVSS Score:7.5 (High)

Go back to menu.

Plugin Source


This is the rsh.nasl nessus plugin source code. This script is Copyright (C) 1999-2022 Tenable Network Security, Inc.

#%NASL_MIN_LEVEL 70300
#
# (C) Tenable Network Security, Inc.
#

include('deprecated_nasl_level.inc');
include('compat.inc');

if (description)
{
  script_id(10245);
  script_version("1.38");
  script_set_attribute(attribute:"plugin_modification_date", value:"2022/04/11");

  script_cve_id("CVE-1999-0651");

  script_name(english:"rsh Service Detection");

  script_set_attribute(attribute:"synopsis", value:
"The rsh service is running on the remote host.");
  script_set_attribute(attribute:"description", value:
"The rsh service is running on the remote host. This service is
vulnerable since data is passed between the rsh client and server
in cleartext. A man-in-the-middle attacker can exploit this to sniff
logins and passwords. Also, it may allow poorly authenticated logins
without passwords. If the host is vulnerable to TCP sequence number
guessing (from any network) or IP spoofing (including ARP hijacking on
a local network) then it may be possible to bypass authentication.
Finally, rsh is an easy way to turn file-write access into full
logins through the .rhosts or rhosts.equiv files.");
  script_set_attribute(attribute:"solution", value:
"Comment out the 'rsh' line in /etc/inetd.conf and restart the inetd
process. Alternatively, disable this service and use SSH instead.");
  script_set_cvss_base_vector("CVSS2#AV:N/AC:L/Au:N/C:P/I:P/A:P");

  script_set_attribute(attribute:"exploitability_ease", value:"Exploits are available");
  script_set_attribute(attribute:"exploit_available", value:"true");
  script_set_attribute(attribute:"metasploit_name", value:'rlogin Authentication Scanner');
  script_set_attribute(attribute:"exploit_framework_metasploit", value:"true");

  script_set_attribute(attribute:"vuln_publication_date", value:"1990/01/01");
  script_set_attribute(attribute:"plugin_publication_date", value:"1999/08/22");

  script_set_attribute(attribute:"plugin_type", value:"remote");
  script_set_attribute(attribute:"thorough_tests", value:"true");
  script_end_attributes();

  script_category(ACT_GATHER_INFO);
  script_family(english:"Service detection");

  script_copyright(english:"This script is Copyright (C) 1999-2022 Tenable Network Security, Inc.");

  script_dependencies("find_service2.nasl");
  script_require_ports("Services/rsh", 514);

  exit(0);
}

#
# The script code starts here
#
include("global_settings.inc");
include("misc_func.inc");

function test(port)
{
 local_var	soc, s1, s2, c, r, a;
 local_var	from, user, ret, den;

 if (! get_port_state(port)) return 0;
 from = "root"; user = "root";
 ret = 0;
 soc = open_priv_sock_tcp(dport:port);
 if( !soc) return 0;
 s1 = '0\0';		# No separate channel for errors
 s2 = strcat(
	from, '\0',	# login from
	user, '\0',	# login as
	'id\0' );	# Command
  send(socket:soc, data:s1);
  send(socket:soc, data:s2);
  c = recv(socket: soc, length: 1);
  if (strlen(c) < 1)
    close(soc);
  else
  {
    r = recv(socket: soc, length: 8192);
    close(soc);
    a = strcat(c, r);
    set_kb_banner(port: port, type:"rsh", banner: a);
    if (strlen(r) > 0)
    {
      if (c == '\0') 	# Success
      {
        den = egrep(string: r, pattern: '(permission|access) (is )?denied', icase: 1);
        if (port == 514 || 
	    ereg(string: r, pattern: "uid=[0-9]") || 
	    strlen(den) > 0 ||	# Windows SFU answers "\0Access is denied"
	    'id:' >< r)		# Something like "Command not found"
	{
	  if (strlen(den) == 0)
	  {
	    set_kb_item(name: "rsh/login_from", value: from);
	    set_kb_item(name: "rsh/login_to", value: user);
	  }
	  return 1;
	}
      }
      else	# Failure
      {
        if (report_paranoia > 1 ||
	    'assword:' >< r ||
	    strlen(den) > 0)
	{
	  return 1;
	}
      }
    }
  }
  return 0;
}

# Main

ports_l = make_service_list(514, "Services/rsh");

foreach p (ports_l)
  if (! done[p])
  {
    if (test(port: p))
    {
      pci_report = 'The remote RSH service on port ' + p + ' accepts cleartext logins.';
      set_kb_item(name:"PCI/ClearTextCreds/" + p, value:pci_report);
      set_kb_item(name:"rsh/active", value:TRUE);
      register_service(port: p, proto: "rsh");
      security_hole(port: p);
    }
    done[p] = 1;
  }

if (! get_kb_item("global_settings/disable_service_discovery")
    && thorough_tests)
  foreach p (get_kb_list("Services/unknown"))
    if (! done[p] && service_is_unknown(port: p))
    {
      if (test(port: p))
      {
  pci_report = 'The remote RSH service on port ' + p + ' accepts cleartext logins.';
  set_kb_item(name:"PCI/ClearTextCreds/" + p, value:pci_report);
	set_kb_item(name:"rsh/active", value:TRUE);
	register_service(port: p, proto: "rsh");
	security_hole(port: p);
      }
      done[p] = 1;
    }

The latest version of this script can be found in these locations depending on your platform:

  • Linux / Unix:
    /opt/nessus/lib/nessus/plugins/rsh.nasl
  • Windows:
    C:\ProgramData\Tenable\Nessus\nessus\plugins\rsh.nasl
  • Mac OS X:
    /Library/Nessus/run/lib/nessus/plugins/rsh.nasl

Go back to menu.

How to Run


Here is how to run the rsh Service Detection as a standalone plugin via the Nessus web user interface (https://localhost:8834/):

  1. Click to start a New Scan.
  2. Select Advanced Scan.
  3. Navigate to the Plugins tab.
  4. On the top right corner click to Disable All plugins.
  5. On the left side table select Service detection plugin family.
  6. On the right side table select rsh Service Detection plugin ID 10245.
  7. Specify the target on the Settings tab and click to Save the scan.
  8. Run the scan.

Here are a few examples of how to run the plugin in the command line. Note that the examples below demonstrate the usage on the Linux / Unix platform.

Basic usage:

/opt/nessus/bin/nasl rsh.nasl -t <IP/HOST>

Run the plugin with audit trail message on the console:

/opt/nessus/bin/nasl -a rsh.nasl -t <IP/HOST>

Run the plugin with trace script execution written to the console (useful for debugging):

/opt/nessus/bin/nasl -T - rsh.nasl -t <IP/HOST>

Run the plugin with using a state file for the target and updating it (useful for running multiple plugins on the target):

/opt/nessus/bin/nasl -K /tmp/state rsh.nasl -t <IP/HOST>

Go back to menu.

References


See also: Similar and related Nessus plugins:
  • 10205 - rlogin Service Detection

Version


This page has been produced using Nessus Professional 10.1.2 (#68) LINUX, Plugin set 202205072148.
Plugin file rsh.nasl version 1.38. For more plugins, visit the Nessus Plugin Library.

Go back to menu.