Ejemplo n.º 1
5
// =========================================================================
// 函数功能:处理客户端对挑战信息的响应
// 输入参数:待交流的客户端cl
// 输出参数:
// 返回值  :
// 说明    :当响应消息失败时,3.7以上的版本会发送失败的原因,而3.7及其以下会直接
//          关闭客户端
// =========================================================================
void rfbAuthProcessClientMessage(rfbClientPtr cl)
{
    char *passwd="123";
    int n;
    u8 response[CHALLENGESIZE];
    u32 authResult;

    if ((n = ReadExact(cl, (char *)response, CHALLENGESIZE)) <= 0) {
        if (n != 0)
            debug_printf("rfbAuthProcessClientMessage: read");
        rfbCloseClient(cl);
        return;
    }
     rfbEncryptBytes(cl->authChallenge, passwd);


    if (memcmp(cl->authChallenge, response, CHALLENGESIZE) != 0) {
        debug_printf("rfbAuthProcessClientMessage: authentication failed from %s\n",
               cl->host);

        authResult = Swap32IfLE(rfbVncAuthFailed);

        if (WriteExact(cl, (char *)&authResult, 4) < 0) {
            debug_printf("rfbAuthProcessClientMessage: write");
            rfbClientSendString(cl,"challengdge failed\n");
        }
        rfbCloseClient(cl);
        return;
    }
    else
    {
        debug_printf("challendge success ---cl=%s",cl->host);

    }

    authResult = Swap32IfLE(rfbVncAuthOK);

    if (WriteExact(cl, (char *)&authResult, 4) < 0) {
        debug_printf("rfbAuthProcessClientMessage: write");
        rfbCloseClient(cl);
        return;
    }

    cl->state = RFB_INITIALISATION;
}
Ejemplo n.º 2
3
/* response is cl->authChallenge vncEncrypted with passwd */
static rfbBool rfbDefaultPasswordCheck(rfbClientPtr cl,const char* response,int len)
{
  int i;
  char *passwd=rfbDecryptPasswdFromFile(cl->screen->authPasswdData);

  if(!passwd) {
    rfbErr("Couldn't read password file: %s\n",cl->screen->authPasswdData);
    return(FALSE);
  }

  rfbEncryptBytes(cl->authChallenge, passwd);

  /* Lose the password from memory */
  for (i = strlen(passwd); i >= 0; i--) {
    passwd[i] = '\0';
  }

  free(passwd);

  if (memcmp(cl->authChallenge, response, len) != 0) {
    rfbErr("authProcessClientMessage: authentication failed from %s\n",
	   cl->host);
    return(FALSE);
  }

  return(TRUE);
}
Ejemplo n.º 3
0
/* for this method, authPasswdData is really a pointer to an array
   of char*'s, where the last pointer is 0. */
rfbBool rfbCheckPasswordByList(rfbClientPtr cl,const char* response,int len)
{
  char **passwds;
  int i=0;

  for(passwds=(char**)cl->screen->authPasswdData;*passwds;passwds++,i++) {
    uint8_t auth_tmp[CHALLENGESIZE];
    memcpy((char *)auth_tmp, (char *)cl->authChallenge, CHALLENGESIZE);
    rfbEncryptBytes(auth_tmp, *passwds);

    if (memcmp(auth_tmp, response, len) == 0) {
      if(i>=cl->screen->authPasswdFirstViewOnly)
	cl->viewOnly=TRUE;
      return(TRUE);
    }
  }

  rfbErr("authProcessClientMessage: authentication failed from %s\n",
	 cl->host);
  return(FALSE);
}