Article View: cu.decstation.managers
Article #1044SUMMARY: sendmail wrapper
From: Andrea Zuccollo
Date: Thu, 04 Jan 1996 00:00
Date: Thu, 04 Jan 1996 00:00
339 lines
12027 bytes
12027 bytes
This is a summary for the following:
Hello all,
Many months ago we installed a simple sendmail wrapper on one of our hosts;
the program simply checks the environment (IFS etc.) and then starts the
real sendmail (maybe doing little more); the wrapper is very small, but we
are now unable to retrieve the source; as we'd like to modify it, does anyone
know about this kind of program ? I know we could install other, e.g.
smtpd, but for now I'd like at least to found it; more, we don't want to
change the sendmail daemon on that host, so don't suggest this ;-)
As it turned out, the piece of software I was looking for is the
'sendmail_wrapper.c'; one also suggested to try 'smtpd'; I've downloaded it
many months ago, but I'm still in doubt whether to install it or not
I think that I'll make a simple modification to the wrapper to allow a quick
check on the incoming host; we've experienced a mailbomb, and this should be
a quick hack to stop connection from (temporary) 'bad hosts'
Thanks to all who replied,
andrea
From: Per Foreby <perf@efd.lth.se>
>
> Hello all,
>
> Many months ago we installed a simple sendmail wrapper on one of our hosts;
> the program simply checks the environment (IFS etc.) and then starts the
> real sendmail (maybe doing little more); the wrapper is very small, but we
> are now unable to retrieve the source; as we'd like to modify it, does anyone
> know about this kind of program ? I know we could install other, e.g.
> smtpd, but for now I'd like at least to found it; more, we don't want to
> change the sendmail daemon on that host, so don't suggest this ;-)
This is the wrapper recommended in the sendmail README file:
------------------- cut here -------------------------------
/*
** sendmail_wrapper.c - wrap sendmail to prevent newlines in command line
** and clean up the environment.
**
** - v1.2 prevent exploitation of '-oR' on SunOS 4.1.x
** - v1.3 update installation instructions
** - v1.4 Parse options for SunOS sendmail to prevent
** shell characters being passed to popen
** - v1.5 Stop core dumps if someone supplies silly args
**
** Authors: Eric Halil, Danny Smith
** AUSCERT
** c/o Prentice Centre
** The University of Queensland
** Qld. 4072.
** Australia
** 29-August-1995
** auscert@auscert.org.au
**
** Disclaimer: The use of this program is at your own risk. It is
** designed to combat a particular vulnerability, and may
** not combat other vulnerabilities, either past or future.
** The decision to use this program is yours, as are the
** consequences of its use.
**
** This program is designed to be an interim relief measure
** until appropriate patches can be obtained from your vendor.
**
** Installation instructions
** =========================
**
** 1. su to root.
**
** 2. Determine the location of sendmail. On SunOS and Ultrix
** systems, it is located in the /usr/lib directory. On BSDI
** systems, it is located in the /usr/sbin directory. For example
** purposes only, /usr/lib will be used in the following instructions
** steps.
**
** 3. Copy the sendmail program to sendmail.real. Change the permissions
** on the copy of sendmail.
**
** # cd /usr/lib
** # cp sendmail sendmail.real
** # chmod 0700 sendmail.real
**
** 4. Determine the permissions, owner, and group of sendmail. This
** information will be used later.
**
** For BSD users:
** # ls -lg sendmail
** For System V users:
** # ls -l sendmail
** 5. Edit this wrapper program and define REAL_SENDMAIL. By default,
** REAL_SENDMAIL is defined as "/usr/lib/sendmail.real".
**
** 6. Compile this program in a directory other than /usr/lib. For
** example to use /tmp, first copy this file into /tmp.
**
** # cd /tmp
** # cc -O -o sendmail sendmail_wrapper.c
**
** 7. Kill the sendmail daemon.
**
** For SunOS and Ultrix:
** # kill -9 `head -1 /etc/sendmail.pid`
** # /usr/lib/sendmail -bd -q1h
**
** For BSDI:
** # kill -9 `head -1 /var/run/sendmail.pid`
** # /usr/sbin/sendmail -bd -q1h
**
** 8. Kill all running sendmail processes.
**
** Follow your vendor's guidelines or use the following commands.
**
** For BSD based systems:
** # ps -auxw | grep sendmail | grep -v grep
** # kill -9 (process id numbers)
**
** For System V based systems:
** # ps -ef | grep sendmail | grep -v grep
** # kill -9 (process id numbers)
**
** 9. Copy this new wrapper program into the directory containing sendmail.
** Make sure this directory and its parent directories are protected so
** only root is able to make changes to files in the directory. This
** will replace the existing sendmail. The following steps should be
** executed quickly.
**
** Users will not be able to send e-mail during the time when the
** wrapper is copied into place until the chmod command has been
** executed. Use the information from step #4 and set the permissions
** owner, and group of the new sendmail. For example:
**
** # cp sendmail /usr/lib/sendmail
** # cd /usr/lib
** # chown root sendmail
** # chgrp wheel sendmail
** # chmod 4511 sendmail
**
** 10. Restart the sendmail daemon.
**
** Follow your vendor's guidelines or use the following command.
**
** # /usr/lib/sendmail -bd -q1h
**
** 11. Test that mail still works.
**
** Version 1.5 29-August-1995
*/
static char Version[] = "sendmail_wrapper V1.5 29-Aug-1995";
#include <stdio.h>
#ifdef sun
#include <syslog.h>
static char ok_chars[] = "1234567890!@%-_=+:,./\
abcdefghijklmnopqrstuvwxyz\
ABCDEFGHIJKLMNOPQRSTUVWXYZ";
#endif
/*
** REAL_SENDMAIL needs to be defined using the full pathname
** of the real sendmail. A few known locations have been defined.
*/
#ifdef sun
#define REAL_SENDMAIL "/usr/lib/sendmail.real"
#endif
#ifdef ultrix
#define REAL_SENDMAIL "/usr/lib/sendmail.real"
#endif
#if defined (__bsdi__) || defined(__386BSD__) || defined(__FreeBSD__) || defined
(__NetBSD__)
#define REAL_SENDMAIL "/usr/sbin/sendmail.real"
#endif
int main( argc, argv, envp)
int argc;
char *argv[];
char *envp[];
{
char *cp;
int i;
int j;
int status;
/*
** Ensure that there are no newlines in the arguments
*/
for ( i = 1; i < argc; i++)
{
#ifdef sun
if ( ( strncmp( argv[ i], "-f", 2) == 0) ||
( strncmp( argv[ i], "-r", 2) == 0))
{
if ( strlen( argv[ i]) > 2)
{
cp = argv[ i] + 2;
}
else
{
if ( ( i + 1) >= argc)
{
break;
}
cp = argv[ i + 1];
}
if ( strspn( cp, ok_chars) < strlen( cp))
{
syslog( LOG_MAIL | LOG_ERR, "Possible SunOS sendmail attack spec
ifying '-%c %s' by uid %d\n",
argv[ i][ 1], cp, getuid());
exit( 1);
}
}
#endif
for ( cp = argv[ i]; *cp != '\0'; cp++)
{
if ( ( *cp == '\r') || ( *cp == '\n'))
{
*cp = ' ';
}
}
}
/*
** While we are at it, let's clean up the environment
** Remove LD_*, IFS, and PATH environment variables before execing
*/
i = 0;
while( envp[ i] != NULL)
{
if ( strncmp( envp[ i], "LD_", 3) == 0)
{
j = i;
while ( envp[ j] != NULL)
{
envp[ j] = envp[ j + 1];
j++;
}
continue;
}
if ( strncmp( envp[ i], "IFS=", 4) == 0)
{
j = i;
while ( envp[ j] != NULL)
{
envp[ j] = envp[ j + 1];
j++;
}
continue;
}
if ( strncmp( envp[ i], "PATH=", 5) == 0)
{
j = i;
while ( envp[ j] != NULL)
{
envp[ j] = envp[ j + 1];
j++;
}
continue;
}
/*
** Now check for newlines in environment variables
*/
for ( cp = envp[ i]; *cp != '\0'; cp++)
{
if ( ( *cp == '\r') || ( *cp == '\n'))
{
*cp = ' ';
}
}
/*
** next environment variable
*/
i++;
}
/*
** exec the real sendmail now
*/
status = execve( REAL_SENDMAIL, argv, envp);
perror( "execve sendmail");
return( status);
}
From: Yiorgos Adamopoulos <adamo@dblab.ece.ntua.gr>
Hi,
I think you are refering to the sendmail_wrapper.c program which is available
at ftp://ftp.cs.berkeley.edu/ucb/sendmail/. If this is not what you are
looking for, then if you get any other feedback, please email me.
From: norman@hprc.utoronto.ca (Norman Wilson)
Date: Wed, 3 Jan 96 11:18:58 -0500
To: andrea@ing.unico.it
Subject: Looking for a sendmail wrapper
Status: OR
I have a somewhat more complicated sendmail wrapper, mainly to spot and
shield against certain kinds of breakin attempts (like the old sendmail
`DEBUG' hole). It affects only network connections; if someone runs
sendmail on your system, they still run the real sendmail. The idea is
that when someone calls the SMTP port on your system, they get smtpd
instead of sendmail; smtpd runs a simple SMTP session (it ignores all
but the most basic parts of the protocol), and watches for things that
look like breakin attempts. If all looks well, smtpd hands the mail
message to the real sendmail for delivery; if something suspicious turns
up, smtpd accepts the message, stores it away, and notifies the system
administrator, who can then take appropriate action (discarding the
message, delivering it by hand, notifying the authorities, or whatnot).
No changes to sendmail are needed; that's part of the point, in fact.
ftp://ftp.hprc.utoronto.ca/pub/smtpd
Norman Wilson
High Performance Research Computing, University of Toronto
norman@hprc.utoronto.ca
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Andrea Zuccollo is currently sitting at the Polytechnic of Milan
Como site, located in via Castelnovo 7, 22100 Como, Italy.
You can reach him by phone (+39 31 298 221), fax (+39 31 302 172) and
e-mail (andrea@ing.unico.it)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Technical Details
Message-ID:
<820743615.26702@news.Colorado.EDU>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1065d6,4b06f38986ec776c,start X-Google-Attributes: gid1065d6,public From: andrea@ing.unico.it (Andrea Zuccollo) Subject: SUMMARY: sendmail wrapper Date: 1996/01/04 Message-ID: <820743615.26702@news.Colorado.EDU> X-Deja-AN: 134086004 distribution: cu sender: daemon@lace.colorado.edu followup-to: poster content-type: text/plain; charset=US-ASCII x-note1: message-id generated by recnews x-note2: mail msgid was <9601040815.AA03577@varano.ing.unico.it> organization: University of Colorado at Boulder mime-version: 1.0 reply-to: andrea@ing.unico.it (Andrea Zuccollo) newsgroups: cu.decstation.managers x-mailer: ELM [version 2.4 PL23]