資源簡介
基于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編譯通過)
評論
共有 條評論