#include /* module pass9 */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include union REGS inregs,outregs; /*****************************************************************************/ pass(void) /* create password */ { char string[20]; clkey(); if(inremote()) goto abort; if(inlog()||inhist()||insimu()) goto abort; strncpy(string,password,10); string[10]=0; brief(string); prompt("ENTER TEN-CHARACTER PASSWORD"); while(console()!=CR); if(keyboard[0]!=CR) strncpy(password,keyboard,10); prompt("ENTER REMOTE TIME-OUT PERIOD (MINUTES)"); clkey(); while(console()!=CR); if(keyboard[0]!=CR) counter[1]=atoi(keyboard); savemisc(); saveiden(); abort: refresh=1; } /*****************************************************************************/ overcode(void) /* change over-ride code */ { char string[10]; int i,k,hack=0; clkey(); if(inremote()) goto abort; if(inlog()||inhist()||insimu()) goto abort; boxit("ENTER OLD CIPHER"); for(i=0;i<=3;i++) { k=caps(); if(k!=codec[i]) hack=1; status[46]|=0x02; } if(hack) goto abort; loop: boxit("ENTER NEW CIPHER"); for(i=0;i<=3;i++) string[i]=caps(); boxit("AGAIN"); for(i=0;i<=3;i++) if(string[i]!=caps()) { warn("DID NOT MATCH"); goto loop; } for(i=0;i<=3;i++) codec[i]=string[i]; saveiden(); abort: refresh=1; return(hack); } /*****************************************************************************/ identity(void) /* create IDs */ { char string[10]; unsigned char mask; int i,k,l,m=0,n=0,mold=0,nold=0,x,dx,y,yold=440,index=0,maxi,color; clkey(); if(inremote()) goto abort; if(inlog()||inhist()||insimu()) goto abort; clear(); font(1); text(PALEBLUE,0,479,"SECURITY ID NAMES & PROHIBITED COMMANDS"); txnumber(); string[5]=0; rect(DARKGREY,0,445,30,45); for(i=0;i<=19;i++) /* identity names */ { y=440-20*i; itoa(i+1,numb,10); text(WHITE,5,y,numb); /* sequence */ strncpy(string,&idents[0]+5*i,5); text(PALEBLUE,80,y,string); } maxi=listm(160,80,440,20,20,cmdlist,index); loop: message(WHITE,"USE CURSOR KEYS OR CLICK LEFT TO SELECT, Esc TO EXIT"); onmouse(); while(!kbhit()) switch(click()) /* mouse button */ { case 1: /* left click */ x=outregs.x.cx; y=479-outregs.x.dx; m=(x-80)/80; if(m>5) m=0; n=(440-y)/20; if(n>19||n<0) n=0; goto exec; case 3: /* both click */ k=ESC; goto abort; } k=caps(); if(k>128) cursor: switch(k) { case LEFT: --m; if(m==-1) m=5; /* wrap */ break; case RIGHT: ++m; if(m==6) m=0; /* wrap */ break; case UP: --n; if(n==-1) n=19; /* wrap */ break; case DOWN: ++n; if(n==20) n=0; /* wrap */ break; case HOME: n=0; break; case END: n=19; break; default: goto key; } else { key: keyboard[0]=k; if(k<128) prompt(keyboard); goto abort; } exec: if(m==5&&n==19) n=maxi-1; /* fix wrap */ if(m==5&&n>=maxi) /* fix short column */ n=0; offmouse(); x=80+80*mold; y=440-20*nold; rect(BLACK,x-2,y+2,x+60,y-12); if(mold) /* is it locked out */ { mask=1; l=20*(mold-1)+nold; l=l%8; mask=mask<5) m=0; n=(440-y)/20; if(n>19||n<0) n=0; goto exec; case 2: if(m) { k=CR; goto exec2; } case 3: /* both click */ k=ESC; goto abort; } k=caps(); if(k>128) goto cursor; if(k==ESC) goto abort; exec2: offmouse(); if(!m) { keyboard[0]=k; string[0]=k; string[1]=0; prompt(string); /* echo first char */ while(console()!=CR); keyboard[5]=0; rect(BLACK,80,y,150,y-10); /* erase old value */ strcpy(&idents[0]+5*n,keyboard); text(GREEN,80,y,keyboard); /* display new value */ } else { i=index*10+(20*(m-1)+n)/8; prohibs[i]=prohibs[i]^mask; /* exclusive or */ color=GREEN; if(prohibs[i]&mask) { frame(DARKBLUE,x-2,y+2,x+40,y-12); color=GREY; } text(color,x,y,cmdlist[n+20*(m-1)]); } goto loop; abort: saveiden(); /* update hard drive */ refresh=1; } /****************************************************************************/ inremote(void) /* is ops mode switch in remote? */ { int prohibit; if(prohibit=!(status[26]&0x10)) warn("MUST BE IN LOCAL CONTROL MODE"); return(prohibit); } /**************************************************************************/ exiterm(void) /* log off remote terminal */ { clkey(); counter[15]=0; brief("REMOTE TERMINAL LOGGED OUT"); status[37]&=0xE0; refresh=1; } /****************************************************************************/ security(void) /* security check */ /* this routine is invoked in the local computer when a remote computer has sent a command, but has not yet passed the security checks, as evidenced in status[37]. Remote commands are received over COM3. */ { char master[10],passkey[10],id[5]; int ch,i,j,fail=0; strcpy(master,"G BINGEMAN"); clrbuf2(); /* clear MCOM buffer */ if(fail=string2("ENTER PASSWORD\r")) /* prompt for password */ goto abort; for(i=0;i<=9;i++) /* get ten password chars */ { ch=com2inw(3000); if(fail=(ch&0xFF00)) goto abort; passkey[i]=ch; } for(i=0;i<=9;i++) /* check for master key */ if(passkey[i]!=master[i]) goto test; status[37]|=21; /* GRANT */ goto abort; /* passed */ test: for(i=0;i<=9;i++) /* check password */ if(passkey[i]!=password[i]) { fail=1; goto abort; } if(fail=string2("ENTER ID\r")) /* prompt for ID */ goto abort; for(i=0;i<=4;i++) /* get five ID chars */ { ch=com2inw(3000); if(fail=(ch&0xFF00)) goto abort; id[i]=ch; } for(j=0;j<=19;j++) /* check 20 ID names for match */ { fail=0; for(i=0;i<=4;i++) /* check five chars */ if(id[i]!=idents[i+5*j]) fail=1; /* not a match */ if(!fail) /* match */ { status[37]|=(j+1); /* ID number */ goto abort; } } abort: if(fail) { clkey(); string2("NOT RECOGNIZED\r"); status[35]|=0x08; /* pass failure */ } else string2("WELCOME TO THE 723\r"); return(fail); } /****************************************************************************/ secure(void) /* security checkin window */ /* this is a flag to notify the local computer operator that someone has just logged in from a remote location. It is called by the "SECU" command. */ { getimage(100,100,540,200); boxit("REMOTE LOG-IN"); pause(3); putimage(100,100,540,200); clkey(); } /****************************************************************************/ checkin(void) /* security check in */ /* this routine runs at boot in the remote computer, and responds to the security routine running in the host computer. The remote computer uses COM1 and the local computer uses COM2. */ { int delay,i,fail=0; unsigned int k; clrbuf1(); /* clear MCOM buffer */ clcom1(); command("SECU"); /* ask host for security check */ startim(); loop3: k=console1(); /* display password prompt */ if(k==CR) goto ding1; /* end of prompt */ odapc(); delay=delta(); if(delay<5000) goto loop3; fail=1; goto abort; ding1: ding(3); for(i=0;i<=9;i++) /* ten password chars */ { startim(); loop: odapc(); if(_bios_keybrd(_NKEYBRD_READY)) /* is char avail? */ { k=_bios_keybrd(_NKEYBRD_READ); /* wait for keyboard entry */ com1out(k); /* send to host */ } else { if(delta()>3000) { fail=1; goto abort; } else goto loop; } } clcom1(); /* erase buffer */ startim(); loop4: k=console1(); /* display password prompt */ odapc(); if(k==CR) goto ding2; /* end of prompt */ delay=delta(); if(delay<5000) goto loop4; fail=1; goto abort; ding2: ding(3); if(localbuf[0]=='N') /* not recognized */ { fail=1; goto abort; } for(i=0;i<=4;i++) /* five ID chars */ { startim(); loop2: odapc(); if(_bios_keybrd(_NKEYBRD_READY)) /* is char avail? */ { k=_bios_keybrd(_NKEYBRD_READ); /* wait for keyboard entry */ com1out(k); /* send to host */ } else { if(delta()>3000) { fail=1; goto abort; } else goto loop2; } } clcom1(); startim(); while(delta()<2000) { odapc(); if(console1()==CR) break; /* display result */ } if(localbuf[0]=='N') /* not recognized */ fail=1; abort: return(fail); }