端口扫描工具下载_在线端口扫描源码

hacker|
464

求IP端口扫描器的VB源码

'4个TEXTBOX控件,2个COMMANDBUTTON控件,一个WINSOCK控件

Dim portnum As Long

Dim start As String

Sub scanningports()

Dim porttwo As Long

portnum = Text1.Text

porttwo = Text2.Text

Command2.Enabled = True

On Error GoTo viriio

Do

portnum = portnum + 1

DoEvents

If start = True Then

'关闭当前WINSOCK

Winsock1.Close

'防止系统冻结

DoEvents

Winsock1.LocalPort = portnum

DoEvents

Text3.Text = portnum

Winsock1.Listen

DoEvents

Else

portnum = 0

Command1.Enabled = True

Text1.Locked = False

Text2.Locked = False

Exit Sub

End If

Winsock1.Close

DoEvents

Loop Until portnum = porttwo

portnum = 0

Command1.Enabled = True

logport.Text = logport.Text vbCrLf "Scanning Ports Done!" vbCrLf

Text1.Locked = False

Text2.Locked = False

viriio:

If Err.Number = 10048 Then

logport.Text = logport.Text vbCrLf "端口" Winsock1.LocalPort " 开启中"

Resume Next

End If

End Sub

Private Sub Command1_Click()

Command2.Enabled = True

If Text1.Text = "" Then

MsgBox "你必须指定开始端口号!"

Exit Sub

End If

If Text2.Text = "" Then

MsgBox "你必须指定一个结束端口号"

Exit Sub

End If

Text1.Locked = True

Text2.Locked = True

Command1.Enabled = False

Winsock1.Close

start = True

Call scanningports

logport.Text = logport.Text vbCrLf "端口" Text1.Text "- " Text3.Text " 已经成功扫描!"

End Sub

Private Sub Command2_Click()

Command2.Enabled = False

start = False

End Sub

那里有端口扫描器的源代码程序

#include string.h

#include winsock.h

#include windows.h

#include iostream.h

#pragma comment (lib,"ws2_32.lib")

int main (int argc, char *argv[])

{

int iportFrom,iportTo;

int testsocket;

int iopenedport = 0;

struct sockaddr_in target_addr;

WSADATA wsaData;

WORD wVersionRequested=MAKEWORD(1,1);

if (argc = 3)

{

cout "使用格式 : " argv[0] " 主机IP地址 开始端口号 结束端口号\n" endl;

exit(1);

}

if (atoi (argv[2]) atoi (argv[3]))

{

cout "错误!开始端口号必须小于结束端口号" endl;

exit(1);

}

else

{

if (WSAStartup (wVersionRequested , wsaData) )

{

cout "连接socket库失败,请检查版本号是否为1.1\n" endl;

exit(1);

}

iportFrom=atoi (argv[2]);

iportTo=atoi (argv[3]);

for (int i=iportFrom; i = iportTo; i++)

{

cout "正在建立socket................................" endl;

if ((testsocket=socket (AF_INET,SOCK_STREAM,0) ) == INVALID_SOCKET)

{

cout "Socket建立失败!" endl;

exit(0);

}

target_addr.sin_family = AF_INET;

target_addr.sin_port = htons(i);

target_addr.sin_addr.s_addr = inet_addr (argv[1]);

cout "正在扫描端口:" i endl;

if (connect (testsocket, (struct sockaddr *) target_addr, sizeof(struct sockaddr)) == SOCKET_ERROR)

cout "端口" i "关闭!" endl;

else

{

iopenedport++;

cout "端口" i "开放\n" endl;

}

}

cout "目标主机" argv[1] "从" iportFrom "--" iportTo "共有" iopenedport "个端口开放" endl;

closesocket (testsocket);

WSACleanup();

}

return 0;

}

vc6.0 下 编译

求 网络计算机端口扫描程序

%易%可 Baidu Hi / 私信/追问/求助联系,有偿处理此类问题,

%软%额外的联系方式看个人简介,

%科%此回复针对所有访问者和需求者有效

%技%全面匹配学习版/专业版/企业版应用,功能可定制,

设计一个判断端口是否开启的扫描器程序的源代码怎么写?

for(int i=0;i6;i++)

{

for(int j=0;j10;j++)

{

theport[j].rmt_host=rmt_host;

theport[j].p=port[i*10+j];

theport[j].n=j;

Thread[j]=AfxBeginThread(pScan,(LPVOID)theport[j]);

//启动端口扫描线程

hThread[j]=Thread[j]-m_hThread;

Sleep(1);

}

WaitForMultipleObjects(10,hThread,TRUE,120000);

}

//扫描模块代码

SOCKET sockfd;

SOCKADDR_IN addr;

sockfd = socket(AF_INET, SOCK_STREAM, 0);

if (sockfd 0)

{

exit(0);

}

addr.sin_family = AF_INET;

addr.sin_port = htons(port);

addr.sin_addr.s_addr = inet_addr(rmt_host);

int r = connect(sockfd,(struct sockaddr *) addr, sizeof(addr));

//尝试连接端口进行检测

closesocket(sockfd);

//连接返回值处理

if (r!=-1)

{

::PostMessage(hWnd,WM_DISPLAY,port,0);

}

//显示端口扫描结果

LONG CScanDlg::OnDisplay(LONG lParam, UINT wParam)

{

LPSERVENT bar;

CString open;

int p=lParam;

bar = getservbyport(htons(p),"tcp");

open.Format("\t%d号端口(%s)开放!\r\n",p,(bar == NULL) ? "未知" :

bar-s_name);

m_HistoryEdit.AppendString (open);

return 0;

}

0条大神的评论

发表评论