⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ckctel.c

📁 KERMIT工具 这在办公室下载不了,很多人都没有载不到.
💻 C
📖 第 1 页 / 共 5 页
字号:
#endif /* CK_SSL */    nchannel = htons(channel);    p = (unsigned char *) &nchannel;    i = 0;    sb_out[i++] = (CHAR) IAC;                 /* I Am a Command */    sb_out[i++] = (CHAR) SB;                  /* Subnegotiation */    sb_out[i++] = TELOPT_FORWARD_X;           /* Forward X */    sb_out[i++] = FWDX_OPEN;                  /* Open */    sb_out[i++] = p[0];                       /* First Byte of Channel */    if ( p[0] == IAC )        sb_out[i++] = IAC;    sb_out[i++] = p[1];                       /* Second Byte of Channel */    if ( p[1] == IAC )        sb_out[i++] = IAC;    sb_out[i++] = (CHAR) IAC;                 /* End of Subnegotiation */    sb_out[i++] = (CHAR) SE;                  /* marked by IAC SE */#ifdef DEBUG    if (deblog || tn_deb || debses) {        ckmakxmsg(fwdx_msg_out,TN_MSG_LEN,"TELNET SENT SB ",                  TELOPT(TELOPT_FORWARD_X),                  " OPEN CHANNEL=",ckitoa(channel)," IAC SE",                  NULL,NULL,NULL,NULL,NULL,NULL,NULL);    }#endif /* DEBUG */#ifdef OS2    RequestTelnetMutex( SEM_INDEFINITE_WAIT );#endif#ifdef DEBUG    debug(F100,fwdx_msg_out,"",0);    if (tn_deb || debses) tn_debug(fwdx_msg_out);#endif /* DEBUG */    rc = (ttol((CHAR *)sb_out,i) < 0);        /* Send it. */#ifdef OS2    ReleaseTelnetMutex();#endif    if (rc)      return(-1);    return(0);}int#ifdef CK_ANSICfwdx_client_reply_options(char *opts, int n)#elsefwdx_client_reply_options(opts, n) char *opts; int n;#endif /* CK_ANSIC */{    int i,j,rc;#ifdef CK_SSL    if (TELOPT_SB(TELOPT_START_TLS).start_tls.me_follows) {        return(0);    }#endif /* CK_SSL */    i = 0;    sb_out[i++] = (CHAR) IAC;                 /* I Am a Command */    sb_out[i++] = (CHAR) SB;                  /* Subnegotiation */    sb_out[i++] = TELOPT_FORWARD_X;           /* Forward X */    sb_out[i++] = FWDX_OPTIONS;               /* Options */    /* Look for the options we recognize and will support for this session */    /* and reply with their bytes set                                      */    for (j=0; j<n; j++,i++) {        sb_out[i] = FWDX_OPT_NONE;          /* Add zero byte - no options */#ifdef COMMENT        /* If we had any options to support, this is how we would do it */        if ( j == 0 ) {            if (opts[j] & FWDX_OPT_XXXX) {                /* set flag to remember option is in use */                flag = 1;                sb_out[i] |= FWDX_OPT_XXXX;            }        }#endif /* COMMENT */    }    sb_out[i++] = (CHAR) IAC;                 /* End of Subnegotiation */    sb_out[i++] = (CHAR) SE;                  /* marked by IAC SE */#ifdef DEBUG    if (deblog || tn_deb || debses) {        ckmakxmsg(fwdx_msg_out,TN_MSG_LEN,"TELNET SENT SB ",                  TELOPT(TELOPT_FORWARD_X),                  " OPTIONS ",ckctox(sb_out[4],1)," IAC SE",                  NULL,NULL,NULL,NULL,NULL,NULL,NULL);    }#endif /* DEBUG */#ifdef OS2    RequestTelnetMutex( SEM_INDEFINITE_WAIT );#endif#ifdef DEBUG    debug(F100,fwdx_msg_out,"",0);    if (tn_deb || debses) tn_debug(fwdx_msg_out);#endif /* DEBUG */    rc = (ttol((CHAR *)sb_out,i) < 0);        /* Send it. */#ifdef OS2    ReleaseTelnetMutex();#endif    if (rc)      return(-1);    return(0);}intfwdx_send_options() {    int i, rc;#ifdef CK_SSL    if (TELOPT_SB(TELOPT_START_TLS).start_tls.me_follows) {        return(0);    }#endif /* CK_SSL */    i = 0;    sb_out[i++] = (CHAR) IAC;               /* I Am a Command */    sb_out[i++] = (CHAR) SB;                /* Subnegotiation */    sb_out[i++] = TELOPT_FORWARD_X;         /* Forward X */    sb_out[i++] = FWDX_OPTIONS;             /* Options */    sb_out[i]   = FWDX_OPT_NONE;    /* activate options here */    i++;    sb_out[i++] = (CHAR) IAC;                 /* End of Subnegotiation */    sb_out[i++] = (CHAR) SE;                  /* marked by IAC SE */#ifdef DEBUG    if (deblog || tn_deb || debses) {        ckmakmsg(fwdx_msg_out,TN_MSG_LEN,"TELNET SENT SB ",                 TELOPT(TELOPT_FORWARD_X),                 " OPTIONS 00 IAC SE",NULL);    }#endif /* DEBUG */#ifdef OS2    RequestTelnetMutex( SEM_INDEFINITE_WAIT );#endif#ifdef DEBUG    debug(F100,fwdx_msg_out,"",0);    if (tn_deb || debses) tn_debug(fwdx_msg_out);#endif /* DEBUG */    rc = (ttol((CHAR *)sb_out,i) < 0);        /* Send it. */#ifdef OS2    ReleaseTelnetMutex();#endif    if (rc)      return(-1);    return(0);}int#ifdef CK_ANSICfwdx_send_data_from_channel(int channel, char * data, int len)#elsefwdx_send_data_from_channel(channel, data, len)    int channel; char * data; int len;#endif{    unsigned short nchannel;    /* static */ CHAR sb_priv[2048];    CHAR * p;    int i, j, j_sav, rc;    unsigned int tmp;    debug(F111,"fwdx_send_data_from_channel()","channel",channel);#ifdef CK_SSL    if (TELOPT_SB(TELOPT_START_TLS).start_tls.me_follows) {        return(0);    }#endif /* CK_SSL */    nchannel = htons(channel);    p = (unsigned char *) &nchannel;    j = 0;    sb_priv[j++] = (CHAR) IAC;                 /* I Am a Command */    sb_priv[j++] = (CHAR) SB;                  /* Subnegotiation */    sb_priv[j++] = TELOPT_FORWARD_X;           /* Forward X */    sb_priv[j++] = FWDX_DATA;                  /* Data */    sb_priv[j++] = p[0];                       /* First Byte of Channel */    if ( p[0] == IAC )        sb_priv[j++] = IAC;    sb_priv[j++] = p[1];                       /* Second Byte of Channel */    if ( p[1] == IAC )        sb_priv[j++] = IAC;    j_sav = j;    for (i = 0; i < len; i++) {        tmp = (unsigned int)data[i];        if ( tmp == IAC ) {            sb_priv[j++] = IAC;            sb_priv[j++] = IAC;        } else {            sb_priv[j++] = tmp;        }        if ( j >= 2045 && (i < len-1) ) {            sb_priv[j++] = (CHAR) IAC;  /* End of Subnegotiation */            sb_priv[j++] = (CHAR) SE;   /* marked by IAC SE */#ifdef DEBUG            if (deblog || tn_deb || debses) {                ckmakxmsg( fwdx_msg_out,TN_MSG_LEN,"TELNET SENT SB ",                           TELOPT(TELOPT_FORWARD_X),                           " DATA CHANNEL=",ckitoa(channel)," ",                           NULL,NULL,NULL,NULL,NULL,NULL,NULL );                tn_hex(fwdx_msg_out,TN_MSG_LEN,&sb_priv[j_sav],j-(j_sav+2));                ckstrncat(fwdx_msg_out," IAC SE",TN_MSG_LEN);            }#endif /* DEBUG */#ifdef OS2            RequestTelnetMutex( SEM_INDEFINITE_WAIT );#endif#ifdef DEBUG            debug(F100,fwdx_msg_out,"",0);            if (tn_deb || debses) tn_debug(fwdx_msg_out);#endif /* DEBUG */            rc = (ttol(sb_priv,j) < 0);                /* Send it. */#ifdef OS2            ReleaseTelnetMutex();#endif            if (rc) {                debug(F110,"fwdx_send_data_from_channel()","ttol() failed",0);                return(-1);            }            j = 0;            sb_priv[j++] = (CHAR) IAC;                 /* I Am a Command */            sb_priv[j++] = (CHAR) SB;                  /* Subnegotiation */            sb_priv[j++] = TELOPT_FORWARD_X;           /* Forward X */            sb_priv[j++] = FWDX_DATA;                  /* Data */            sb_priv[j++] = p[0];                       /* First Byte of Channel */            if ( p[0] == IAC )                sb_priv[j++] = IAC;            sb_priv[j++] = p[1];                       /* Second Byte of Channel */            if ( p[1] == IAC )                sb_priv[j++] = IAC;        }    }    sb_priv[j++] = (CHAR) IAC;                 /* End of Subnegotiation */    sb_priv[j++] = (CHAR) SE;                  /* marked by IAC SE */#ifdef DEBUG    if (deblog || tn_deb || debses) {        ckmakxmsg( fwdx_msg_out,TN_MSG_LEN,                   "TELNET SENT SB ",TELOPT(TELOPT_FORWARD_X),                   " DATA ",ckctox(p[0],1)," ",ckctox(p[1],1)," ",                   NULL,NULL,NULL,NULL,NULL);        tn_hex(fwdx_msg_out,TN_MSG_LEN,&sb_priv[6],j-8);        ckstrncat(fwdx_msg_out," IAC SE",TN_MSG_LEN);    }#endif /* DEBUG */#ifdef OS2    RequestTelnetMutex( SEM_INDEFINITE_WAIT );#endif#ifdef DEBUG    debug(F100,fwdx_msg_out,"",0);    if (tn_deb || debses) tn_debug(fwdx_msg_out);#endif /* DEBUG */    rc = (ttol(sb_priv,j) < 0);                /* Send it. */#ifdef OS2    ReleaseTelnetMutex();#endif    if ( rc ) {        debug(F110,"fwdx_send_data_from_channel()","ttol() failed",0);        return(-1);    }    return(0);}static unsigned char *#ifdef CK_ANSICfwdx_add_quoted_twobyte(unsigned char *p, unsigned short twobyte)#elsefwdx_add_quoted_twobyte(p, twobyte)    unsigned char *p; unsigned short twobyte;#endif /* CK_ANSIC *//* adds the IAC quoted (MSB) representation of 'channel' at buffer pointer 'p', * returning pointer to new buffer position. NO OVERFLOW CHECK! */{    *p++ = (unsigned char)((twobyte >> 8) & 0xFF);    if (*(p - 1) == 0xFF)        *p++ = 0xFF;    *p++ = (unsigned char)(twobyte & 0xFF);    if (*(p - 1) == 0xFF)        *p++ = 0xFF;    return p;}int#ifdef CK_ANSICfwdx_create_fake_xauth(char *name, int name_len, int data_len)#elsefwdx_create_fake_xauth(name, name_len, data_len)    char *name; int name_len; int data_len;#endif /* CK_ANSIC */{    char stackdata[256];    unsigned int c, n;    if (!name_len || !data_len)        return 1;    fake_xauth.name = malloc(name_len);    fake_xauth.data = malloc(data_len);    if (!fake_xauth.name || !fake_xauth.data)        return 2;    fake_xauth.name_length = name_len;    memcpy(fake_xauth.name, name, name_len);    fake_xauth.data_length = data_len;    /* try to make a random unsigned int to feed srand() */    c = time(NULL);    c *= getpid();    for (n = 0; n < sizeof(stackdata); n++)        c += stackdata[n];    srand((unsigned int)c);    for (c = 0; c < data_len; c++)        fake_xauth.data[c] = (unsigned char)rand();    return 0;}#ifdef COMMENT/* No longer used */intfwdx_send_xauth(void){    int c, err, dpynum, family, sb_len, rc;    char *display, *host = NULL;    unsigned char *sb_priv, *p;    /* parse the local DISPLAY env var */    if (!(display = tn_get_display()))        return (-1);    if (fwdx_parse_displayname(display, &family, &host, &dpynum, NULL, NULL)) {        char * disp_no = ckitoa(dpynum);        if (family == FamilyLocal) {            /* call with address = "<local host name>" */            char address[300] = "localhost";            gethostname(address, sizeof(address) - 1);            real_xauth = XauGetAuthByAddr(family,                                          strlen(address),                                          address,                                          strlen(disp_no),                                          disp_no, 0, NULL                                          );        }        else if (family == FamilyInternet) {            /* call with address = 4 bytes numeric ip addr (MSB) */            struct hostent *hi;            if (hi = gethostbyname(host))                real_xauth = XauGetAuthByAddr(family, 4,                                              hi->h_addr,                                              strlen(disp_no),                                              disp_no, 0, NULL                                              );        }    }    if (host) {        free(host);        host = NULL;    }    if (real_xauth)        err = fwdx_create_fake_xauth(real_xauth->name,                                     real_xauth->name_length,                                     real_xauth->data_length                                     );    else      err = fwdx_create_fake_xauth("MIT-MAGIC-COOKIE-1",                                   strlen("MIT-MAGIC-COOKIE-1"), 16);    if (err)        return(-1);    /* allocate memory for the SB block, alloc for worst case              */    /* the following sprintf() calls are safe due to length checking       */    /* buffer is twice as big as the input just in case every byte was IAC */    sb_len = 5 + 2 + 2 + fake_xauth.name_length + fake_xauth.data_length + 2;    if (!(sb_priv = malloc(2 * sb_len)))        return(-1);    p = sb_priv;    sprintf(p, "%c%c%c%c%c", IAC, SB, TELOPT_FORWARD_X,            FWDX_OPT_DATA, FWDX_OPT_XAUTH);    p += 5;    p = fwdx_add_quoted_twobyte(p, fake_xauth.name_length);    p = fwdx_add_quoted_twobyte(p, fake_xauth.data_length);    for (c = 0; c < fake_xauth.name_length; c++) {        *p++ = fake_xauth.name[c];        if ((unsigned char)fake_xauth.name[c] == 0xFF)            *p++ = 0xFF;    }    for (c = 0; c < fake_xauth.data_length; c++) {        *p++ = fake_xauth.data[c];        if ((unsigned char)fake_xauth.data[c] == 0xFF)            *p++ = 0xFF;    }    sprintf(p, "%c%c", IAC, SE);    p += 2;#ifdef DEBUG    if (deblog || tn_deb || debses) {        sprintf(fwdx_msg_out,"TELNET SENT SB %s OPTION_DATA XAUTH ",                 TELOPT(TELOPT_FORWARD_X));        tn_hex(fwdx_msg_out,TN_MSG_LEN,&sb_priv[5],(p-sb_priv)-7);        ckstrncat(fwdx_msg_out," IAC SE",TN_MSG_LEN);    }#endif /* DEBUG */    /* Add Telnet Debug info here */#ifdef OS2    R

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -