3.5 PortScan_UDP

所属分类:网络编程
开发工具:Visual C++
文件大小:30322KB
下载次数:2
上传日期:2017-10-10 23:25:54
上 传 者@@强
说明:  可以实现对UDP端口的扫描,可以帮助新手学习扫描UDP端口
(TCP port can be achieved scanning, you can help beginners learn to scan the TCP port)

文件列表:
3.5 PortScan_UDP (0, 2017-10-01)
3.5 PortScan_UDP\Debug (0, 2017-10-01)
3.5 PortScan_UDP\Debug\cl.command.1.tlog (2910, 2017-10-01)
3.5 PortScan_UDP\Debug\CL.read.1.tlog (28760, 2017-10-01)
3.5 PortScan_UDP\Debug\CL.write.1.tlog (2388, 2017-10-01)
3.5 PortScan_UDP\Debug\link-cvtres.read.1.tlog (2, 2017-10-01)
3.5 PortScan_UDP\Debug\link-cvtres.write.1.tlog (2, 2017-10-01)
3.5 PortScan_UDP\Debug\link.command.1.tlog (2112, 2017-10-01)
3.5 PortScan_UDP\Debug\link.read.1.tlog (5866, 2017-10-01)
3.5 PortScan_UDP\Debug\link.write.1.tlog (1916, 2017-10-01)
3.5 PortScan_UDP\Debug\mt.command.1.tlog (656, 2017-10-01)
3.5 PortScan_UDP\Debug\mt.read.1.tlog (664, 2017-10-01)
3.5 PortScan_UDP\Debug\mt.write.1.tlog (574, 2017-10-01)
3.5 PortScan_UDP\Debug\PortScan.exe (381440, 2017-10-01)
3.5 PortScan_UDP\Debug\PortScan.exe.embed.manifest (667, 2017-10-01)
3.5 PortScan_UDP\Debug\PortScan.exe.embed.manifest.res (732, 2017-10-01)
3.5 PortScan_UDP\Debug\PortScan.exe.intermediate.manifest (381, 2017-10-01)
3.5 PortScan_UDP\Debug\PortScan.ilk (1094744, 2017-10-01)
3.5 PortScan_UDP\Debug\PortScan.lastbuildstate (177, 2017-10-01)
3.5 PortScan_UDP\Debug\PortScan.log (5353, 2017-10-01)
3.5 PortScan_UDP\Debug\PortScan.obj (28202, 2017-10-01)
3.5 PortScan_UDP\Debug\PortScan.pch (22937600, 2017-10-01)
3.5 PortScan_UDP\Debug\PortScan.pdb (4467712, 2017-10-01)
3.5 PortScan_UDP\Debug\PortScan.res (248424, 2017-10-01)
3.5 PortScan_UDP\Debug\PortScan.write.1.tlog (0, 2017-10-01)
3.5 PortScan_UDP\Debug\PortScanDlg.obj (86275, 2017-10-01)
3.5 PortScan_UDP\Debug\PortScan_manifest.rc (212, 2017-10-01)
3.5 PortScan_UDP\Debug\rc.command.1.tlog (1480, 2017-10-01)
3.5 PortScan_UDP\Debug\rc.read.1.tlog (3980, 2017-10-01)
3.5 PortScan_UDP\Debug\rc.write.1.tlog (862, 2017-10-01)
3.5 PortScan_UDP\Debug\StdAfx.obj (644652, 2017-10-01)
3.5 PortScan_UDP\Debug\vc100.idb (1158144, 2017-10-01)
3.5 PortScan_UDP\Debug\vc100.pdb (2699264, 2017-10-01)
3.5 PortScan_UDP\PortScan.aps (268124, 2011-10-08)
3.5 PortScan_UDP\PortScan.clw (1839, 2011-10-18)
3.5 PortScan_UDP\PortScan.cpp (2152, 2011-07-23)
3.5 PortScan_UDP\PortScan.dsp (4395, 2011-06-22)
3.5 PortScan_UDP\PortScan.dsw (541, 2011-06-22)
3.5 PortScan_UDP\PortScan.h (1346, 2011-06-22)
3.5 PortScan_UDP\PortScan.ini (81, 2017-10-01)
... ...

UINT ThreadUDPScan2(LPVOID pParam) { THREADPARAM* threadparam=(THREADPARAM*)pParam; CString strIP=threadparam->strIP; UINT uPort=threadparam->uPort; CPortScanDlg *ptr=threadparam->ptr; HTREEITEM TreeItem=threadparam->TreeItem; BOOL bNoOrder=threadparam->bNoOrder; struct timeval tv; fd_set select_fd; UINT uPortCurr; char buff[MAXBUFF]; struct sockaddr_in send_sa; // 发送端地址信息 memset(&send_sa, 0, sizeof(send_sa)); send_sa.sin_family = AF_INET; send_sa.sin_addr.s_addr = inet_addr(strIP); SOCKET sockSend = socket(AF_INET, SOCK_DGRAM, 0); // 发送用的描述符 if (sockSend<0) { //AfxMessageBox("Socket 创建失败。"); return -1; } SOCKET sockRecv = socket(AF_INET, SOCK_RAW, IPPROTO_ICMP); // 接收用的描述符 if (sockRecv<0) { //AfxMessageBox("RAW Socket 创建失败。"); closesocket(sockSend); return -2; } g_iTotalThreadCount++; if (bNoOrder) Sleep(rand()%3000); CString strTemp; for (uPortCurr=ptr->m_uPortBegin;uPortCurr<=ptr->m_uPortEnd;uPortCurr++) { strTemp.Format("正在扫描端口:%d",uPortCurr); ptr->DoEvent(strTemp); if (!g_bRunning) break; fflush(stdout); send_sa.sin_port = htons(uPortCurr); int res = sendto(sockSend,NULL,0,0,(struct sockaddr *)&send_sa,sizeof(send_sa)); tv.tv_sec = 1; tv.tv_usec = 0; while (g_bRunning) { FD_ZERO(&select_fd); FD_SET(sockRecv, &select_fd); if (select(sockRecv + 1, &select_fd, NULL, NULL, &tv) > 0) { struct ip *ip; struct icmp *icmp; int hlen; UINT port; memset(&ip, 0, sizeof(ip)); if (recvfrom(sockRecv, buff, MAXBUFF, 0, NULL, NULL) != 56) continue; ip = (struct ip *)buff; hlen = ip->ip_hl<<2; icmp = (struct icmp *)(buff+hlen); port = (UINT)ntohs(*(u_short *)(buff+20+8+20+2)); if ((ip->ip_src.s_addr != send_sa.sin_addr.s_addr) || (icmp->icmp_type != ICMP_UNREACH) || (icmp->icmp_code != ICMP_UNREACH_PORT) || (port != uPortCurr)) continue; } else { CString strTemp; if (uPortCurr<1024) { struct servent *se; se = getservbyport(htons(uPortCurr), "udp"); if (se != NULL) strTemp.Format("%d %s",uPortCurr,se->s_name); else strTemp.Format("%d",uPortCurr); } else { strTemp.Format("%d %s",uPortCurr,ptr->GetPortName(uPortCurr,FALSE)); } ptr->m_ctlTreeResult.InsertItem(strTemp,TreeItem); }//end if break; }//end while }//end for closesocket(sockSend); closesocket(sockRecv); g_iTotalThreadCount--; return 0; }

近期下载者

相关文件


收藏者