📄 ckuath.c
字号:
g_kstream->encrypt(&i, NULL);#ifdef DEBUG hexdump("to cyphertext", s, n);#endif } else debug(F101,"ck_tn_encrypt not encrypting","",n);#endif /* ENCRYPTION */}/* C K _ K R B _ D E C R Y P T * decrypts n characters in s if we are decrypting */VOID#ifdef CK_ANSICck_tn_decrypt( char * s, int n )#elseck_tn_decrypt( s,n ) char * s; int n;#endif{#ifdef CK_ENCRYPTION struct kstream_data_block i; if (g_kstream->decrypt && encrypt_is_decrypting()) {#ifdef DEBUG hexdump("from cyphertext", s, n);#endif i.ptr = s; i.length = n; g_kstream->decrypt(&i, NULL);#ifdef DEBUG hexdump("to plaintext", s, n);#endif } else debug(F101,"ck_tn_decrypt not decrypting","",n);#endif /* ENCRYPTION */}/* S E N D K 5 A U T H S B * Send a Kerberos 5 Authentication Subnegotiation to host and * output appropriate Telnet Debug messages * * type - Sub Negotiation type * data - ptr to buffer containing data * len - len of buffer if not NUL terminated * * returns number of characters sent or error value */static int#ifdef CK_ANSICSendK5AuthSB(int type, void *data, int len)#elseSendK5AuthSB(type,data,len) int type; void *data; int len;#endif{ int rc; unsigned char *p = str_data + 3; unsigned char *cd = (unsigned char *)data; extern int sstelnet;#ifdef CK_SSL if (TELOPT_SB(TELOPT_START_TLS).start_tls.me_follows) { if (ttchk() < 0) return(0); else return(1); }#endif /* CK_SSL */ if ( type < 0 || type > 6 ) /* Check for invalid values */ return(0); if (!cd) { cd = (unsigned char *)""; len = 0; } if (len == -1) /* Use strlen() for len */ len = strlen((char *)cd); /* Construct Message */ *p++ = sstelnet ? TELQUAL_REPLY : TELQUAL_IS; *p++ = AUTHTYPE_KERBEROS_V5; *p = AUTH_CLIENT_TO_SERVER; *p |= auth_how;#ifdef CK_ENCRYPTION *p |= auth_crypt;#endif#ifdef USE_INI_CRED_FWD if (auth_fwd) *p |= INI_CRED_FWD_ON;#endif /* USE_INI_CRED_FWD */ p++; *p++ = type; while (len-- > 0) { if ((*p++ = *cd++) == IAC) *p++ = IAC; } *p++ = IAC; *p++ = SE; /* Handle Telnet Debugging Messages */ if (deblog || tn_deb || debses) { int i; int deblen=p-str_data-2; char *s=NULL; int mode = AUTH_CLIENT_TO_SERVER | (auth_how & AUTH_HOW_MASK) | (auth_crypt?AUTH_ENCRYPT_USING_TELOPT:AUTH_ENCRYPT_OFF)#ifdef USE_INI_CRED_FWD | (auth_fwd?INI_CRED_FWD_ON:INI_CRED_FWD_OFF)#endif /* USE_INI_CRED_FWD */ ; switch (type) { case 0: s = "AUTH"; break; case 1: s = "REJECT"; break; case 2: s = "ACCEPT"; break; case 3: s = "RESPONSE"; break; case 4: s = "FORWARD"; break; case 5: s = "FORWARD_ACCEPT"; break; case 6: s = "FORWARD_REJECT"; break; } sprintf(tn_msg,"TELNET SENT SB %s %s %s %s %s ", TELOPT(TELOPT_AUTHENTICATION), str_data[3] == TELQUAL_IS ? "IS" : str_data[3] == TELQUAL_REPLY ? "REPLY" : "???", authtype_names[authentication_version], authmode_names[mode], s);#ifdef HEXDISP { int was_hex = 1; for ( i=7;i<deblen;i++ ) { if ( str_data[i] < 32 || str_data[i] >= 127) { sprintf(hexbuf,"%s%02X ",was_hex?"":"\" ",str_data[i]); was_hex = 1; } else { sprintf(hexbuf,"%s%c",was_hex?"\"":"",str_data[i]); was_hex = 0; } strcat(tn_msg,hexbuf); } if ( !was_hex ) strcat(tn_msg,"\" "); }#else /* HEXDISP */ memcpy(hexbuf,&str_data[7],deblen-7); hexbuf[deblen-7] = ' '; hexbuf[deblen-6] = '\0'; strcat(tn_msg,hexbuf);#endif /* HEXDISP */ strcat(tn_msg,"IAC SE"); debug(F100,tn_msg,"",0); if (tn_deb || debses) tn_debug(tn_msg); } /* Send data */ rc = ttol((CHAR *)str_data, p - str_data); debug(F111,"SendK5AuthSB","ttol()",rc); return(rc);}/* S E N D K 4 A U T H S B * Send a Kerberos 4 Authentication Subnegotiation to host and * output appropriate Telnet Debug messages * * type - Sub Negotiation type * data - ptr to buffer containing data * len - len of buffer if not NUL terminated * * returns number of characters sent or error value */static int#ifdef CK_ANSICSendK4AuthSB(int type, void *data, int len)#elseSendK4AuthSB(type,data,len) int type; void *data; int len;#endif{ int rc; unsigned char *p = str_data + 3; unsigned char *cd = (unsigned char *)data; extern int sstelnet; int mode = (auth_how & AUTH_HOW_MASK) | (auth_crypt?AUTH_ENCRYPT_USING_TELOPT:AUTH_ENCRYPT_OFF) ; if ( type < 0 || type > 4 ) /* Check for invalid values */ return(0);#ifdef CK_SSL if (TELOPT_SB(TELOPT_START_TLS).start_tls.me_follows) { if (ttchk() < 0) return(0); else return(1); }#endif /* CK_SSL */ if (!cd) { cd = (unsigned char *)""; len = 0; } if (len == -1) /* Use strlen() for len */ len = strlen((char *)cd); /* Construct Message */ *p++ = sstelnet ? TELQUAL_REPLY : TELQUAL_IS; *p++ = AUTHTYPE_KERBEROS_V4; *p = AUTH_CLIENT_TO_SERVER; *p |= mode; p++; *p++ = type; while (len-- > 0) { if ((*p++ = *cd++) == IAC) *p++ = IAC; } *p++ = IAC; *p++ = SE; /* Handle Telnet Debugging Messages */ if (deblog || tn_deb || debses) { int i; int deblen=p-str_data-2; char *s=NULL; switch (type) { case 0: s = "AUTH"; break; case 1: s = "REJECT"; break; case 2: s = "ACCEPT"; break; case 3: s = "CHALLENGE"; break; case 4: s = "RESPONSE"; break; } sprintf(tn_msg,"TELNET SENT SB %s %s %s %s %s ", TELOPT(TELOPT_AUTHENTICATION), str_data[3] == TELQUAL_IS ? "IS" : (str_data[3] == TELQUAL_REPLY ? "REPLY" : "???"), authtype_names[authentication_version], authmode_names[mode], s);#ifdef HEXDISP { int was_hex = 1; for ( i=7;i<deblen;i++ ) { if ( str_data[i] < 32 || str_data[i] >= 127) { sprintf(hexbuf,"%s%02X ",was_hex?"":"\" ",str_data[i]); was_hex = 1; } else { sprintf(hexbuf,"%s%c",was_hex?"\"":"",str_data[i]); was_hex = 0; } strcat(tn_msg,hexbuf); } if ( !was_hex ) strcat(tn_msg,"\" "); }#else /* HEXDISP */ memcpy(hexbuf,&str_data[7],deblen-7); hexbuf[deblen-7] = ' '; hexbuf[deblen-6] = '\0'; strcat(tn_msg,hexbuf);#endif /* HEXDISP */ strcat(tn_msg,"IAC SE"); debug(F100,tn_msg,"",0); if (tn_deb || debses) tn_debug(tn_msg); } /* Send data */ rc = ttol((CHAR *)str_data, p - str_data); debug(F111,"SendK4AuthSB","ttol()",rc); return(rc);}/* S E N D S R P A U T H S B * Send a SRP Authentication Subnegotiation to host and * output appropriate Telnet Debug messages * * type - Sub Negotiation type * data - ptr to buffer containing data * len - len of buffer if not NUL terminated * * returns number of characters sent or error value */static int#ifdef CK_ANSICSendSRPAuthSB(int type, void *data, int len)#elseSendSRPAuthSB(type,data,len) int type; void *data; int len;#endif{ int rc; unsigned char *p = str_data + 3; unsigned char *cd = (unsigned char *)data; extern int sstelnet; /* Check for invalid values */ if ( type != SRP_EXP && type != SRP_RESPONSE && type != SRP_REJECT && type != SRP_ACCEPT && type != SRP_CHALLENGE && type != SRP_PARAMS && type != SRP_AUTH) return(0); if (len == -1) /* Use strlen() for len */ len = strlen((char *)cd); /* Construct Message */ *p++ = sstelnet ? TELQUAL_REPLY : TELQUAL_IS; *p++ = AUTHTYPE_SRP; *p = AUTH_CLIENT_TO_SERVER; *p |= auth_how;#ifdef CK_ENCRYPTION *p |= auth_crypt;#endif p++; *p++ = type; while (len-- > 0) { if ((*p++ = *cd++) == IAC) *p++ = IAC; } *p++ = IAC; *p++ = SE; /* Handle Telnet Debugging Messages */ if (deblog || tn_deb || debses) { int i; int deblen=p-str_data-2; char *s=NULL; int mode = AUTH_CLIENT_TO_SERVER | (auth_how & AUTH_HOW_MASK) | (auth_crypt?AUTH_ENCRYPT_USING_TELOPT:AUTH_ENCRYPT_OFF); switch (type) { case 0: s = "AUTH"; break; case 1: s = "REJECT"; break; case 2: s = "ACCEPT"; break; case 3: s = "CHALLENGE"; break; case 4: s = "RESPONSE"; break; case 5: s = "FORWARD"; break; case 6: s = "FORWARD_ACCEPT"; break; case 7: s = "FORWARD_REJECT"; break; case 8: s = "EXP"; break; case 9: s = "PARAMS"; break; } sprintf(tn_msg,"TELNET SENT SB %s %s %s %s %s ", TELOPT(TELOPT_AUTHENTICATION), str_data[3] == TELQUAL_REPLY ? "REPLY" : str_data[3] == TELQUAL_IS ? "IS" : "???", authtype_names[authentication_version], authmode_names[mode], s);#ifdef HEXDISP { int was_hex = 1; for ( i=7;i<deblen;i++ ) { if ( str_data[i] < 32 || str_data[i] >= 127) { sprintf(hexbuf,"%s%02X ",was_hex?"":"\" ",str_data[i]); was_hex = 1; } else { sprintf(hexbuf,"%s%c",was_hex?"\"":"",str_data[i]); was_hex = 0; } strcat(tn_msg,hexbuf); } if ( !was_hex ) strcat(tn_msg,"\" "); }#else /* HEXDISP */ memcpy(hexbuf,&str_data[7],deblen-7); hexbuf[deblen-7] = ' '; hexbuf[deblen-6] = '\0'; strcat(tn_msg,hexbuf);#endif /* HEXDISP */ strcat(tn_msg,"IAC SE"); debug(F100,tn_msg,"",0); if (tn_deb || debses) tn_debug(tn_msg); } /* Send data */ rc = ttol((CHAR *)str_data, p - str_data); return(rc);}#ifdef CK_ENCRYPTION/* * Function: Enable or disable the encryption process. * * Parameters: * enable - TRUE to enable, FALSE to disable. */static VOID#ifdef CK_ANSICauth_encrypt_enable(BOOL enable)#else
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -