VC 实现局域网嗅探QQ号计算机二级考试
文章作者 100test 发表时间 2009:06:15 10:08:12
来源 100Test.Com百考试题网
编辑特别推荐:
全国计算机等级考试(等考)指定教材
全国计算机等级考试学习视频
全国计算机等级考试网上辅导招生
全国计算机等级考试时间及科目预告
百考试题教育全国计算机等级考试在线测试平台
全国计算机等级考试资料下载
全国计算机等级考试论坛
计算机等级考试四级应用题解析汇总
2009年下半年全国计算机二级考试报名时间从6月1日起已经开始报名。详情点击:2009年下半年全国计算机等级考试各地报名点汇总。2009年下半年全国计算机二级考试时间是2009年9月19日至23日。更多优质资料尽在百考试题论坛 百考试题在线题库。
#include <.afxsock.h>.
#include<.winsock2.h>.
#pragma comment(lib,"ws2_32.lib")
#include <.ras.h>.
#include <.raserror.h>.
#pragma comment(lib, "rasapi32.lib")
#include <.WinInet.h>.
#pragma comment(lib, "WinInet.LIB")
#include <.Dlgs.h>.
#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 start\r\n").
while (1)
{
memset(RecvBuf, 0, sizeof(RecvBuf)).
recv(sock, RecvBuf, sizeof(RecvBuf), 0).
saSource.sin_addr.s_addr = pIpheader->.ip_src.
strncpy_s(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).
}
}
}
}
2009年9月全国计算机等级考试时间及科目预告
2009年NCRE考试有新变化
2009年全国计算机等级考试-大纲
全国计算机等级考试历年真题及答案
2009年上半年全国计算机等级考试试题及答案