百度质量部面试笔试体验之—三面

时间:2024-09-22 08:43:36 资料大全 我要投稿
  • 相关推荐

百度质量部面试笔试体验之—三面

  1.有过什么实习经历啊?

百度质量部面试笔试体验之—三面

  1.1安天实验室

  在哈尔滨安天实验室,我在CERT组实习,跟过两个大神,一个是胡哥,部门技术经理,在异常分析方面很犀利,

百度质量部面试笔试体验之—三面

。一个是swordlea,对李哥的印象就是C++大神,同时他也是CERT老大。当时的项目是做一个whois的查询插件,VC++编写。当然的组件功能是输入一个IP地址,能够查询出它的whois信息,因为有点久了,当时也是借鉴网上代码写出来的,自己的代码找不到了(当然怎么就没备份呢),就拿网上的代码凑合一下:

  /*

  * @brief

  * Whois client program

  *

  * @details

  * This program shall fetch whois data for a IPv4 address.

  *

  * @author Silver Moon ( m00n.silv3r@gmail.com )

  * */

  #include //scanf , printf

  #include //strtok

  #include //realloc

  #include //socket

  #include //sockaddr_in

  #include //getsockname

  #include //hostent

  #include //close

  int main(int argc , char *argv[])

  {

  char ip[100] , *data = NULL;

  printf("Enter ip address to whois : ");

  scanf("%s" , ip);

  get_whois(ip , &data);

  printf("\n\n");

  puts(data);

  free(data);

  return 0;

  }

  /**

  Get the whois content of an ip

  by Selecting the correct server

  */

  void get_whois(char *ip , char **data)

  {

  char *wch = NULL, *pch , *response = NULL;

  if(whois_query("whois.iana.org" , ip , &response))

  {

  printf("Whois query failed");

  }

  pch = strtok(response , "\n");

  while(pch != NULL)

  {

  //Check if whois line

  wch = strstr(pch , "whois.");

  if(wch != NULL)

  {

  break;

  }

  //Next line please

  pch = strtok(NULL , "\n");

  }

  if(wch != NULL)

  {

  printf("\nWhois server is : %s" , wch);

  whois_query(wch , ip , data);

  }

  else

  {

  *data = malloc(100);

  strcpy(*data , "No whois data");

  }

  return;

  }

  /*

  * Perform a whois query to a server an d record the response

  * */

  int whois_query(char *server , char *query , char **response)

  {

  char ip[32] , message[100] , buffer[1500];

  int sock , read_size , total_size = 0;

  struct sockaddr_in dest;

  sock = socket(AF_INET , SOCK_STREAM , IPPROTO_TCP);

  //Prepare connection structures :)

  memset( &dest , 0 , sizeof(dest) );

  dest.sin_family = AF_INET;

  printf("\nResolving %s..." , server);

  if(hostname_to_ip(server , ip))

  {

  printf("Failed");

  return 1;

  }

  printf("%s" , ip);

  dest.sin_addr.s_addr = inet_addr( ip );

  dest.sin_port = htons( 43 );

  //Now connect to remote server

  if(connect( sock , (const struct sockaddr*) &dest , sizeof(dest) ) < 0)

  {

  perror("connect failed");

  }

  //Now send some data or message

  printf("\nQuerying for ... %s ..." , query);

  sprintf(message , "%s\r\n" , query);

  if( send(sock , message , strlen(message) , 0) < 0)

  {

  perror("send failed");

  }

  //Now receive the response

  while( (read_size = recv(sock , buffer , sizeof(buffer) , 0) ) )

  {

  *response = realloc(*response , read_size + total_size);

  if(*response == NULL)

  {

  printf("realloc failed");

  }

  memcpy(*response + total_size , buffer , read_size);

  total_size += read_size;

  }

  printf("Done");

  fflush(stdout);

  *response = realloc(*response , total_size + 1);

  *(*response + total_size) = ”\”;

  close(sock);

  return 0;

  }

  /*

  * @brief

  * Get the ip address of a given hostname

  *

  * */

  int hostname_to_ip(char * hostname , char* ip)

  {

  struct hostent *he;

  struct in_addr **addr_list;

  int i;

  if ( (he = gethostbyname( hostname ) ) == NULL)

  {

  // get the host info

  herror("gethostbyname");

  return 1;

  }

  addr_list = (struct in_addr **) he->h_addr_list;

  for(i = 0; addr_list[i] != NULL; i++)

  {

  //Return the first one;

  strcpy(ip , inet_ntoa(*addr_list[i]) );

  return 0;

  }

  return 0;

  }

  1.2 大连东软

【百度质量部面试笔试体验之—三面】相关文章:

百度质量部测试开发面试笔试经验09-03

百度笔试题目10-26

百度校园招聘笔试题精选07-22

百度网络笔试题目07-19

百度软件测试常见笔试题09-06

百度上海产品运营笔试经验10-25

趋势科技笔试面试08-31

TNT笔试面试归来08-21

HuLu笔试面试经验06-13

电装招聘笔试+面试05-20