what you don't know can hurt you
Home Files News &[SERVICES_TAB]About Contact Add New

f-13wr.ciac-sendmail-wrapper.c

f-13wr.ciac-sendmail-wrapper.c
Posted Sep 23, 1999

f-13wr.ciac-sendmail-wrapper.c

SHA-256 | 0f6dfd3aab4c74f5bf970a5ce1ba772c3bd1290fa574a19cbb1ce590f384c71e

f-13wr.ciac-sendmail-wrapper.c

Change Mirror Download
/*
** sendmail_wrapper.c - wrap sendmail to prevent newlines in command line
** and clean up the environment.
**
** Authors: Eric Halil, Danny Smith
** AUSCERT
** c/o Prentice Centre
** The University of Queensland
** Qld. 4072.
** Australia
** 22-Feb-1995
**
** 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. 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.
**
** # cp sendmail /usr/lib/sendmail
** # cd /usr/lib
** # chown root sendmail
** # chmod 4511 sendmail
**
** 8. Kill the running sendmail process and start the new sendmail.
**
** 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
**
** For other systems, follow your vendors guidelines or use the
** following command. Kill the processes and start the new sendmail.
** # ps -auxw | grep sendmail | grep -v grep
** # kill -9 (process id numbers)
** # ./sendmail -bd -q1h
**
** 9. Test that mail still works.

** Version 1.1 22-Feb-1995.
*/

#include <stdio.h>

/*
** 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++)
{
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 enviroment 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);
}
Login or Register to add favorites

File Archive:

April 2024

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Apr 1st
    10 Files
  • 2
    Apr 2nd
    26 Files
  • 3
    Apr 3rd
    40 Files
  • 4
    Apr 4th
    6 Files
  • 5
    Apr 5th
    26 Files
  • 6
    Apr 6th
    0 Files
  • 7
    Apr 7th
    0 Files
  • 8
    Apr 8th
    22 Files
  • 9
    Apr 9th
    14 Files
  • 10
    Apr 10th
    10 Files
  • 11
    Apr 11th
    13 Files
  • 12
    Apr 12th
    14 Files
  • 13
    Apr 13th
    0 Files
  • 14
    Apr 14th
    0 Files
  • 15
    Apr 15th
    30 Files
  • 16
    Apr 16th
    10 Files
  • 17
    Apr 17th
    22 Files
  • 18
    Apr 18th
    45 Files
  • 19
    Apr 19th
    0 Files
  • 20
    Apr 20th
    0 Files
  • 21
    Apr 21st
    0 Files
  • 22
    Apr 22nd
    0 Files
  • 23
    Apr 23rd
    0 Files
  • 24
    Apr 24th
    0 Files
  • 25
    Apr 25th
    0 Files
  • 26
    Apr 26th
    0 Files
  • 27
    Apr 27th
    0 Files
  • 28
    Apr 28th
    0 Files
  • 29
    Apr 29th
    0 Files
  • 30
    Apr 30th
    0 Files

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2022 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close