From: sw4847@gemini
Subject: Fake mail
Reply-To: sw4847@gemini
Organization: University of Albany, SUNY
Date: Thu, 28 Jan 93 06:25:34 GMT

Can fake mail from telneting to port 25 or from the program below be traced?
How does the program below send the mail message?

1  %TITLE 'MAIL SUBROUTINE'

   SUB MAILT( STRING NODE, &
       STRING FROM_NAME, &
       STRING TO_LIST(), &
       STRING TO_SHOW, &
       STRING SUBJECT, &
       STRING TEXT() )

   OPTION TYPE = INTEGER

   DECLARE INTEGER FUNCTION &
     PUT_MSG

   DECLARE STRING FUNCTION &
     GET_MSG, &
     GET_INPUT

   DECLARE INTEGER CONSTANT &
     TRUE = -1, &
     FALSE = 0
   Net_Link_Open = FALSE

   input 'Please enter a node name (default = {anything}) ';node_name$
   if node_name$ = "" then 
      node_name$ = "{anything}"
   end if
   ON ERROR GOTO Mail_Net_Error
   MAIL_CHANNEL = 12
   OPEN NODE_NAME$ + '::"27="' AS FILE MAIL_CHANNEL

   Net_Link_Open = TRUE

   input 'Please enter from_name ';from_name$
   STS = PUT_MSG( FROM_NAME$ )
   IF STS <> 0 THEN
     GOTO ERROR_DONE
   END IF
   RECEIVERS = 0
   TO_COUNT = 1

Mail_Recipients:
   print ''
   print 'You are allowed to sent to more than one person '
   input 'Please enter id actually sent to, <cr> to exit ';to_list$
   if to_list$ = "" then 
      goto end_of_line
   end if
   STS = PUT_MSG( EDIT$( TO_LIST$ , 32 ) )
   IF STS <> 0 THEN
     GOTO Error_Done
   END IF
   GOSUB Errchk
   IF LINK_ERR <> 0 THEN
     GOTO Error_Done
   END IF

   IF ( ERRSTS AND 1 ) = 0 THEN
     GOTO Error_Done
   END IF

   TO_COUNT = TO_COUNT + 1
   GOTO Mail_Recipients

END_OF_LINE:
   STS = PUT_MSG( CHR$(0) )
   IF STS <> 0 THEN
     GOTO Error_Done
   END IF
   IF RECEIVERS = 0 THEN
     GOTO Mail_Done
   END IF

   print ''
   input 'Please enter the to address that is shown ';to_show$
   STS = PUT_MSG( TO_SHOW$ )
   IF STS <> 0 THEN
     GOTO Error_Done
   END IF

   print ''
   input 'Please type in the subject ';subject$
   STS = PUT_MSG( SUBJECT$ )
   IF STS <> 0 THEN
     GOTO Error_Done
   END IF

   print ''
   print 'Please type in your message, type return on a blank line to finish '
   loopx:
   input text$ 
   if text$ = "" then 
	goto cont
   end if
     STS = PUT_MSG( TEXT$ )
     IF STS <> 0 THEN
       GOTO Error_Done
     END IF
   goto loopx
   cont:
   STS = PUT_MSG( CHR$(0) )
   IF STS <> 0 THEN
     GOTO Error_Done
   END IF
   SAVE_COUNT = RECEIVERS
   INDEX = 0

Delivery_Check:
   GOSUB Errchk
   IF LINK_ERR <> 0 THEN
     GOTO Error_Done
   END IF
   INDEX = INDEX + 1
   IF INDEX <> SAVE_COUNT THEN
     GOTO Delivery_Check
   END IF
   GOTO Mail_Done

Errchk:
   MAIL_STS = ASCII( GET_MSG )
   IF LINK_ERR <> 0 THEN
     ERRSTS = LINK_ERR
     RETURN
   END IF
   IF ( MAIL_STS AND 1 ) = 1 THEN
     Receivers = Receivers + 1
     ERRSTS = MAIL_STS
     RETURN
   END IF

Errmsg:
   MAIL_ERR$ = GET_MSG
   IF LINK_ERR <> 0 THEN
     ERRSTS = LINK_ERR
     RETURN
   END IF
   IF LEN( MAIL_ERR$ ) <> 1 THEN
     PRINT MAIL_ERR$
     GOTO Errmsg
   END IF
   IF ASCII( MAIL_ERR$ ) = 0 THEN
     RETURN
   ELSE
     GOTO Errmsg
   END IF

   DEF INTEGER PUT_MSG( STRING M )
   ON ERROR GOTO 1550
   MLEN = LEN( M )
   MOVE TO # MAIL_CHANNEL , M = MLEN
   PUT # MAIL_CHANNEL, COUNT MLEN
   PUT_MSG = 0
   EXIT DEF

1550 RESUME 1555

1555 PUT_MSG = ERR
     END DEF

   DEF STRING GET_INPUT( INTEGER C )
   EOF = FALSE
   ON ERROR GOTO 1650
   GET # C
   R = RECOUNT
   MOVE FROM #C , TEMP$ = R
   GET_INPUT = TEMP$
   EXIT DEF

1650 RESUME 1655

1655 EOF = TRUE
     END DEF

   DEF STRING GET_MSG
   ON ERROR GOTO 1750
   GET # MAIL_CHANNEL
   R = RECOUNT
   MOVE FROM # MAIL_CHANNEL , TEMP$ = R
   GET_MSG = TEMP$
   LINK_ERR = 0
   EXIT DEF

1750 RESUME

1755 LINK_ERR = ERR
     END DEF

Mail_Net_Error:
  RESUME 1900

1900 PRINT "%Network communications error."

Error_Done:

Mail_Done:
   IF Net_Link_Open THEN
     CLOSE MAIL_CHANNEL
   END IF

   END SUB

								Scott Weinstein