资源简介
基于vc6.0开发网络扫描工具,利用select+connect进行TCP端口扫描,利用ICMP端口不可达报文进行UDP端口扫描,可以完成对TCP、UDP端口的探测,ICMP你懂的。利用GetBestRoute和GetIpAddrTable来判定使用本地接口IP,不修改IP头,摆脱windows操作系统对rawsocket的限制。自定义ping函数实现以上功能,你可以在代码中包含此.h和.cpp文件,直接调用此函数。

代码片段和文件信息
// DetectDlg.cpp : implementation file
//
#include “stdafx.h“
#include “NetTest.h“
#include “DetectDlg.h“
#include “ping.h“
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDetectDlg dialog
CDetectDlg::CDetectDlg(CWnd* pParent /*=NULL*/)
: CDialog(CDetectDlg::IDD pParent)
{
//{{AFX_DATA_INIT(CDetectDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void CDetectDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDetectDlg)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDetectDlg CDialog)
//{{AFX_MSG_MAP(CDetectDlg)
ON_WM_CLOSE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDetectDlg message handlers
BOOL CDetectDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
CComboBox* pmyComboBox = (CComboBox*)GetDlgItem(IDC_COMBO1);
pmyComboBox->AddString(“ALL“);
pmyComboBox->AddString(“TCP“);
pmyComboBox->AddString(“UDP“);
pmyComboBox->SetCurSel(0);
GetDlgItem(IDC_EDIT1)->SetWindowText(“扫描结果\r\n“);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CDetectDlg::OnOK()
{
// TODO: Add extra validation here
if(((CIPAddressCtrl*)GetDlgItem(IDC_IPADDRESS1))->IsBlank()){
MessageBox(“请设置起始IP!“ “设置“ MB_ICONINFORMATION | MB_OK);
GetDlgItem(IDC_IPADDRESS1)->SetFocus();
return;
}
if(((CIPAddressCtrl*)GetDlgItem(IDC_IPADDRESS2))->IsBlank()){
MessageBox(“请设置结束IP!“ “设置“ MB_ICONINFORMATION | MB_OK);
GetDlgItem(IDC_IPADDRESS2)->SetFocus();
return;
}
((CIPAddressCtrl*)GetDlgItem(IDC_IPADDRESS1))->GetAddress(hoststart);
((CIPAddressCtrl*)GetDlgItem(IDC_IPADDRESS2))->GetAddress(hoststop);
if(hoststart > hoststop){
DWORD host = hoststart;
hoststart = hoststop;
hoststop = host;
}
if( 0 == GetDlgItem(IDC_EDIT2)->GetWindowTextLength() ){
MessageBox(“请设置起始端口!“ “设置“ MB_ICONINFORMATION | MB_OK);
GetDlgItem(IDC_EDIT2)->SetFocus();
return;
}
if( 0 == GetDlgItem(IDC_EDIT3)->GetWindowTextLength() ){
MessageBox(“请设置结束端口!“ “设置“ MB_ICONINFORMATION | MB_OK);
GetDlgItem(IDC_EDIT3)->SetFocus();
return;
}
CString str2;
CString str3;
GetDlgItem(IDC_EDIT2)->GetWindowText(str2);
GetDlgItem(IDC_EDIT3)->GetWindowText(str3);
startport = atoi(str2.LockBuffer());
endport = atoi(str3.LockBuffer());
if( 0 > startport || startport > 65535 ){
MessageBox(“计算机端口范围0~65535请重新设置起始端口!“ “设置“ MB_ICONINFORMATION | MB_OK);
GetDlgItem(IDC_EDIT2)->SetFocus();
return;
}
if( 0 > endport || endport > 65535 ){
MessageBox(“计算机端口范围0~65535请重新设置结束端口!“ “设置“ MB_ICONINFORM
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 553 2011-09-09 14:21 NetTest\Debug\config.xm
文件 7290 2011-09-13 16:18 NetTest\DetectDlg.cpp
文件 1463 2011-09-13 15:34 NetTest\DetectDlg.h
文件 87782 2008-09-11 18:10 NetTest\markup.cpp
文件 19252 2008-09-11 18:10 NetTest\markup.h
文件 36760 2011-09-13 14:17 NetTest\NetTest.aps
文件 2197 2011-09-13 16:22 NetTest\NetTest.clw
文件 1505 2011-09-08 11:38 NetTest\NetTest.cpp
文件 4381 2011-09-09 15:56 NetTest\NetTest.dsp
文件 1193 2011-09-06 10:57 NetTest\NetTest.h
文件 1860 2011-09-13 16:23 NetTest\NetTest.plg
文件 7269 2011-09-13 14:17 NetTest\NetTest.rc
文件 8241 2011-09-13 16:23 NetTest\NetTestDlg.cpp
文件 1625 2011-09-13 14:56 NetTest\NetTestDlg.h
文件 11843 2011-09-13 16:08 NetTest\ping.cpp
文件 8112 2011-09-13 16:03 NetTest\ping.h
文件 15086 2002-07-31 08:47 NetTest\res\NetTest.ico
文件 399 2011-09-06 10:57 NetTest\res\NetTest.rc2
..A.SH. 4096 2011-09-06 11:11 NetTest\res\Thumbs.db
文件 1144 2011-09-09 16:32 NetTest\resource.h
文件 209 2011-09-06 10:57 NetTest\StdAfx.cpp
文件 999 2011-09-06 10:57 NetTest\StdAfx.h
目录 0 2011-09-13 16:24 NetTest\Debug
目录 0 2011-09-13 16:24 NetTest\Release
目录 0 2011-09-06 11:11 NetTest\res
目录 0 2011-09-13 16:23 NetTest
----------- --------- ---------- ----- ----
223259 26
- 上一篇:基于C++的绘图软件
- 下一篇:VC++操作WPS表格的类(VC6.0编译通过)
相关资源
- 国际象棋的qt源代码
- C++中头文件与源文件的作用详解
- C++多线程网络编程Socket
- VC++ 多线程文件读写操作
- 利用C++哈希表的方法实现电话号码查
- 移木块游戏,可以自编自玩,vc6.0编写
- C++纯文字DOS超小RPG游戏
- VC++MFC小游戏实例教程(实例)+MFC类库
- 连铸温度场计算程序(C++)
- 6自由度机器人运动学正反解C++程序
- Em算法(使用C++编写)
- libstdc++-4.4.7-4.el6.i686.rpm
- VC++实现CMD命令执行与获得返回信息
- 白话C++(全)
- C++标准库第1、2
- 大数类c++大数类
- C++语言编写串口调试助手
- c++素数筛选法
- C++ mqtt 用法
- 商品库存管理系统 C++ MFC
- c++ 多功能计算器
- C++17 In Detail
- 嵌入式QtC++编程课件
- 颜色识别形状识别STM103嵌入式代码
- c++ 邮件多附件群发
- c++ 透明代理(hookproxy)
- mfc 调用redis
- FTP客户端源码(c++)
- c++ 画图(14Qt-XPS)
- c++多边形交并差运算
评论
共有 条评论