阅读 152

VC++实现局域网嗅探QQ号

VC++实现局域网嗅探QQ号    


 #include

 

#include

#include

#pragma comment(lib,"vfw32.lib")
#pragma comment(lib,"winmm.lib")
         #define MAX_HOSTNAME_LAN 255
         #define SIO_RCVALL _WSAIOW(IOC_VENDOR,1)
         #define MAX_ADDR_LEN 16
         struct ipheader {
                  unsigned char ip_hl:4, ip_v:4; /* this means that each member is 4 bits */
                  unsigned char ip_tos;
                  unsigned short int ip_len;
                  unsigned short int ip_id;
                  unsigned short int ip_off;
                  unsigned char ip_ttl;
                  unsigned char ip_p;
                  unsigned short int ip_sum;
                  unsigned int ip_src;
                  unsigned int ip_dst;
         }; /* total ip header length: 20 bytes (=160 bits) */
         typedef struct udphdr {         
                  unsigned short sport;
                  unsigned short dport;
                  unsigned short len;
                  unsigned short cksum;
         }UDP_HDR;
         void main()
         {
                  SOCKET sock;
                  WSADATA wsd;
                  DWORD dwBytesRet;
                  unsigned int optval = 1;
                  unsigned char *dataudp,*pUdpData;
                  int QQ,iUdpDataLen;
                  SOCKADDR_IN sa,saSource, saDest;
                  struct hostent FAR * pHostent;
                  char FAR name[MAX_HOSTNAME_LAN];
                  char szSourceIP[MAX_ADDR_LEN],RecvBuf[65535] = {0};
                  struct udphdr *pUdpheader;
                  struct ipheader *pIpheader;
                  WSAStartup(MAKEWORD(2,1),&wsd);
                  if ((sock = socket(AF_INET, SOCK_RAW, IPPROTO_IP))==SOCKET_ERROR)exit(1);
                  gethostname(name, MAX_HOSTNAME_LAN);
                  pHostent = gethostbyname(name);
                  sa.sin_family = AF_INET;
                  sa.sin_port = htons(6000);
                  memcpy(&sa.sin_addr.S_un.S_addr, pHostent->h_addr_list[0], pHostent->h_length);
                  bind(sock, (SOCKADDR *)&sa, sizeof(sa));
                  if ((WSAGetLastError())==10013)exit(1);
                  WSAIoctl(sock, SIO_RCVALL, &optval, sizeof(optval), NULL, 0, &dwBytesRet, NULL, NULL);
                  pIpheader = (struct ipheader *)RecvBuf;
                  pUdpheader = (struct udphdr *) (RecvBuf+ sizeof(struct ipheader ));
                  printf("QQ sniffer V1.1 code powerd by cooldiyer/r/n");
                  while (1)
                  {
                           memset(RecvBuf, 0, sizeof(RecvBuf));
                           recv(sock, RecvBuf, sizeof(RecvBuf), 0);
                           saSource.sin_addr.s_addr = pIpheader->ip_src;
                           strncpy(szSourceIP, inet_ntoa(saSource.sin_addr), MAX_ADDR_LEN);
                           iUdpDataLen =(ntohs(pIpheader->ip_len)-(sizeof(struct ipheader)+sizeof(struct udphdr)));
                           if((pIpheader->ip_p)==IPPROTO_UDP&&iUdpDataLen!=0)
                           {
                                   pUdpData=(unsigned char *) RecvBuf+sizeof(struct ipheader)+sizeof(struct udphdr);
                                   iUdpDataLen=ntohs(pIpheader->ip_len)-(sizeof(struct ipheader)+sizeof(struct udphdr));
                                   if(ntohs(pUdpheader->dport)==8000)
                                           if(iUdpDataLen%4==0 && iUdpDataLen>0)
                                                     if(pUdpData[0]==0x02 && pUdpData[3]==0x00 && pUdpData[iUdpDataLen-1]==0x03)
                                                     {
                                                             QQ = (pUdpData[7]&0xff);
                                                             QQ = (QQ<<8) + (pUdpData[8]&0xff);
                                                             QQ = (QQ<<8) + (pUdpData[9]&0xff);
                                                             QQ = (QQ<<8) + (pUdpData[10]&0xff);
                                                             printf("IP:%s QQ:%d/r",szSourceIP,QQ);
                                                     }
                           }
                  }
         }

需要源码的请留下E-mail,我给你们发



©著作权归作者所有:来自51CTO博客作者yinchengmvp的原创作品,如需转载,请注明出处,否则将追究法律责任


文章分类
后端
版权声明:本站是系统测试站点,无实际运营。本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 XXXXXXo@163.com 举报,一经查实,本站将立刻删除。
相关推荐