基于libvncclient实现XWIN密码自动代填(模拟键盘输入键值)

  1. 基于fbInitClient(rfb_client, (int *)6, extArgv)函数传参传入用户名和密码;
   char* extArgv[5] = {"192.168.60.115", "1024x768", "24" ,username, paaword};
   if (rfbInitClient(rfb_client, (int *)5, extArgv))
  1. 在if (rfbInitClient函数中接收传入得参数
  if(argc == (int *)5){// int * argc , can not be 3 
	strcpy(vap_xwin_args.addr , argv[0]);
	strcpy(vap_xwin_args.wxh , argv[1]);
	strcpy(vap_xwin_args.bpp , argv[2]);

	strcpy(client->username , argv[3]);
	strcpy(client->password , argv[4]);
  1. 在SetFormatAndEncodings函数中添加一个线程
  pthread_t tid;
  pthread_create(&tid, NULL, passwd_thread, client);
  pthread_detach(tid);

  1. 编写线程函数
void *passwd_thread(rfbClient *cl)
{


  int i = 0;
  
  printf("==============================\n");
  printf("cl->username =  %s\n", cl->username);
  printf("cl->password =  %s\n", cl->password);
  sleep(2);
  SendKeyEvent(cl, XK_Page_Down, TRUE);
  sleep(1);
  SendKeyEvent(cl, XK_KP_Enter, TRUE);
  sleep(2);
  for (i = 0; i < strlen(cl->username); i++)
  {
    SendKeyEvent(cl, cl->username[i], TRUE);
    sleep(1);
  }
 
  SendKeyEvent(cl, XK_KP_Enter, TRUE);
  sleep(2);
 
  for (i = 0; i < strlen(cl->password); i++)
  {
    SendKeyEvent(cl, cl->password[i], TRUE);
    sleep(1);
  }
  SendKeyEvent(cl, XK_KP_Enter, TRUE);
  printf("==================================\n");
  return NULL;
}

你可能感兴趣的:(c语言)