The 'Security Digest' Archives (TM)

Archive: About | Browse | Search | Contributions | Feedback
Site: Help | Index | Search | Contact | Notices | Changes

ARCHIVE: 'Phage List' - Archives (1988 - 1989)
DOCUMENT: phage #404 [Automatic sendmail tester] (1 message, 2468 bytes)
SOURCE: http://securitydigest.org/exec/display?f=phage/archive/404.txt&t=text/plain
NOTICE: securitydigest.org recognises the rights of all third-party works.

START OF DOCUMENT

From: budd@bu-it.bu.edu
To: phage
Date: Mon 18:28:18 07/11/1988 EST
Subject: Automatic sendmail tester
References: [Thread Prev: 130] [Thread Next: 406] [Message Prev: 403] [Message Next: 129]

Here is a C program and A Shell script to drive it that we used on
campus to verify that all sendmail's had been patched.

Please feel free to redistribute it!

	Phil Budne
	Boston University

#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of shell archive."
# Contents:  README check.c DOCHECK
# Wrapped by budd@buit2 on Mon Nov  7 18:27:03 1988
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f README -a "${1}" != "-c" ; then
  echo shar: Will not over-write existing file \"README\"
else
echo shar: Extracting \"README\" \(193 characters\)
sed "s/^X//" >README <<'END_OF_README'
XHere is a C program and A Shell script to drive it that we used on
Xcampus to verify that all sendmail's had been patched.
X
XPlease feel free to redistribute it!
X
X	Phil Budne
X	Boston University
X
END_OF_README
if test 193 -ne `wc -c <README`; then
    echo shar: \"README\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f check.c -a "${1}" != "-c" ; then
  echo shar: Will not over-write existing file \"check.c\"
else
echo shar: Extracting \"check.c\" \(3324 characters\)
sed "s/^X//" >check.c <<'END_OF_check.c'
X/*
X *	check.c -- check SMTP listeners for sendmail debug bug
X *	a quick slash of my SMTP verify/expand hack
X *
X *	Copyright (c) 1988 Philip L. Budne
X *
X *	You may freely use, distribute, whatever as long
X *	as this notice and the above copyright remain intact.
X *
X */
X
X# include <stdio.h>
X# include <sys/types.h>
X# include <sys/socket.h>
X# include <netinet/in.h>
X# include <strings.h>
X# include <netdb.h>
X
Xchar *prog;
Xshort port;				/* htons(IPPORT_SMTP)??? */
Xint sock = -1;
Xchar *service = "smtp";
X
Xmain( argc, argv )
X    int argc;
X    char *argv[];
X{
X    struct servent *sp;
X    int c;
X
X    if( (prog = rindex( argv[0], '/' )) != NULL )
X	prog++;
X    else
X	prog = argv[0];
X
X    if( (sp = getservbyname( service, "tcp" )) != NULL )
X	port = sp->s_port;
X    else if( (port = atoi( service )) != 0 )
X	port = htons( port );
X    else {
X	fprintf( stderr, "%s: cannot find service named %s/tcp\n",
X		prog, service );
X	exit( 1 );
X    }
X
X    argc--;
X    argv++;
X    while( argc-- > 0 )
X	doit( *argv++ );
X} /* main */
X
Xdoit( host )
X    char *host;
X{
X    char buf[ 1024 ];
X    struct sockaddr_in dest;
X    struct hostent *h;
X
X    if( (h = gethostbyname( host )) != NULL )
X	bcopy( h->h_addr, &dest.sin_addr, h->h_length );
X    else if( *host >= '0' && *host <= '9' )
X	dest.sin_addr.s_addr = inet_addr( host );
X    else {
X	printf("Unknown host %s\n", host );
X	fflush( stdout );
X	return( -1 );
X    }
X
X    dest.sin_port = port;
X    dest.sin_family = AF_INET;
X    sock = socket( AF_INET, SOCK_STREAM, 0 ); /* TCP */
X    if( sock < 0 ) {
X	err( host, "socket" );
X	return( -1 );
X    }
X    if( connect( sock, &dest, sizeof(dest) ) < 0) {
X	err( host, "connect" );
X	close( sock );
X	return( -1 );
X    }
X    do				/* inhale salutation */
X	getline( sock, buf, sizeof( buf ) );
X    while( buf[3] == '-' );
X
X    strcpy( buf, "debug\r\n" );
X    if( write( sock, buf, strlen( buf ) ) < 0 ) {
X	perror( "write" );
X	return( -1 );
X    }
X    flush();
X    do {
X	if( getline( sock, buf, sizeof( buf ) ) < 0 ) {
X	    close( sock );
X	    sock = -1;
X	    return( -1 );
X	}
X    } while( buf[3] == '-' );
X
X    if( buf[0] == '5' )
X	printf("Host %s OK\n", host );
X    else
X	printf("HOST %s HAS BUG\n", host );
X    fflush( stdout );
X
X    strcpy( buf, "quit\r\n" );
X    if( write( sock, buf, strlen( buf ) ) < 0 ) {
X	close( sock );
X	return( -1 );
X    }
X    flush();
X    do {
X	if( getline( sock, buf, sizeof( buf ) ) < 0 )
X	    break;
X    } while( buf[3] == '-' );
X    close( sock);
X    sock = -1;
X} /* doit */
X
Xchar buffer[ 8192 ];
Xchar *bp;
Xint count = 0;
X
Xflush() {
X    count = 0;
X}
X
Xgetline( sock, dest, size )
X    int sock, size;
X    char *dest;
X{
X    register char *dp;
X    register i;
X
X    dp = dest;
X    i = size - 1;
X    while( i-- > 0 ) {
X	if( --count <= 0 ) {
X	    count = read( sock, buffer, sizeof( buffer ) );
X	    if( count < 0 )
X		return( count );
X	    bp = buffer;
X	}
X	if( *bp != '\r' )
X	    *dp++ = *bp;
X	if( *bp++ == '\n' )
X	    break;
X    } /* while */
X    *dp = '\0';
X    return( 1 );
X}
X
Xerr(host, call)
Xchar *host, *call;
X{
X    extern int errno, sys_nerr;
X    extern char *sys_errlist[];
X    char *e, buf[12];
X
X    if( errno == 0 )
X	e = "No error";
X    else if( errno > sys_nerr ) {
X	sprintf( buf, "error %d", errno );
X	e = buf;
X    }
X    else
X	e = sys_errlist[ errno ];
X
X    printf( "%s: %s: %s\n", host, call, e );
X    fflush (stdout );
X}
X
X   
END_OF_check.c
if test 3324 -ne `wc -c <check.c`; then
    echo shar: \"check.c\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f DOCHECK -a "${1}" != "-c" ; then
  echo shar: Will not over-write existing file \"DOCHECK\"
else
echo shar: Extracting \"DOCHECK\" \(330 characters\)
sed "s/^X//" >DOCHECK <<'END_OF_DOCHECK'
X#!/bin/sh
XT=/tmp/hhh$$
Xgrep -v '^#' /usr/public/hosts/export/buhosts.nomx | \
X   egrep -v '(bunseg-|IBM-PC|ANNEX|KINETICS|MACINTOSH|LOCALHOST|PROTEON|3090|CISCO|XEROX-1108|ATT-3B2|LMI-LAMBDA|SYMBOLICS)' | awk '{ print $2 }' | sort -u > $T
XLLL=`cat $T`
Xrm $T
X# echo "Total hosts:"
X# echo $LLL | wc -w
X/usr2/ucs/dsg/budd/check $LLL
END_OF_DOCHECK
if test 330 -ne `wc -c <DOCHECK`; then
    echo shar: \"DOCHECK\" unpacked with wrong size!
fi
chmod +x DOCHECK
# end of overwriting check
fi
echo shar: End of shell archive.
exit 0

END OF DOCUMENT