资源简介
PortFinder.rar
代码片段和文件信息
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.Net.Sockets;
using System.Threading;
namespace PortFinder
{
public partial class PortFinder : Form
{
//已扫描端口数目
internal static List openedPorts = new List();
//已扫描端口数目
internal static int scannedCount = 0;
internal static int runningThreadCount = 0;
static int startPort = 1;
static int endPort = 1500;
public string host = “Sunny“;
public int Oport = 0;
static int maxThread = 100;
public PortFinder()
{
InitializeComponent();
txtHost.Text = “Sunny“;
}
public void scan()
{
TcpClient tc = new TcpClient();
tc.SendTimeout = tc.ReceiveTimeout = 100;
try
{
tc.Connect(host Oport);
if (tc.Connected)
{
openedPorts.Add(Oport);
}
}
catch
{
}
finally
{
tc.Close();
tc = null;
PortFinder.scannedCount++;
PortFinder.runningThreadCount--;
}
}
private void btnSearch_Click(object sender EventArgs e)
{
lbResult.Items.Clear();
openedPorts.Clear();
if (txtHost.Text == ““)
{
MessageBox.Show(“请输入主机名或者主机IP!“);
return;
}
if(txtStart.Text != ““ && txtEnd.Text != ““)
{
startPort = Convert.ToInt16(txtStart.Text.Trim());
endPort = Convert.ToInt16(txtEnd.Text.Trim());
}
host = txtHost.Text;
for (int port = startPort; port < endPort; port++)
{
Oport = port;
runningThreadCount++;
Thread thread = new Thread(new ThreadStart(scan));
thread.Name = port.ToString();
thread.IsBackground = true;
thread.Start();
Thread.Sleep(10);
// while (runningThreadCount >= maxThread) ;
}
while (scannedCount + 1 < (endPort - startPort)) ;
foreach (int port in openedPorts)
{
string RP = string.Format(“port: {0} is open“ port.ToString().PadLeft(6));
lbResult.Items.Add(RP);
}
}
}
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 10240 2010-09-17 18:12 PortFinder\PortFinder\bin\Debug\PortFinder.exe
文件 26112 2010-09-17 18:12 PortFinder\PortFinder\bin\Debug\PortFinder.pdb
文件 14328 2010-09-19 09:00 PortFinder\PortFinder\bin\Debug\PortFinder.vshost.exe
文件 490 2007-07-21 01:33 PortFinder\PortFinder\bin\Debug\PortFinder.vshost.exe.manifest
文件 582 2010-09-19 09:00 PortFinder\PortFinder\obj\Debug\PortFinder.csproj.FileListAbsolute.txt
文件 852 2010-09-16 18:04 PortFinder\PortFinder\obj\Debug\PortFinder.csproj.GenerateResource.Cache
文件 10240 2010-09-17 18:12 PortFinder\PortFinder\obj\Debug\PortFinder.exe
文件 26112 2010-09-17 18:12 PortFinder\PortFinder\obj\Debug\PortFinder.pdb
文件 180 2010-09-16 18:04 PortFinder\PortFinder\obj\Debug\PortFinder.PortFinder.resources
文件 180 2010-09-16 18:04 PortFinder\PortFinder\obj\Debug\PortFinder.Properties.Resources.resources
文件 2812 2010-09-17 18:12 PortFinder\PortFinder\PortFinder.cs
文件 3377 2010-09-16 18:04 PortFinder\PortFinder\PortFinder.csproj
文件 4060 2010-09-16 18:04 PortFinder\PortFinder\PortFinder.Designer.cs
文件 5814 2010-09-16 18:04 PortFinder\PortFinder\PortFinder.resx
文件 476 2010-09-16 17:42 PortFinder\PortFinder\Program.cs
文件 1376 2010-09-16 17:41 PortFinder\PortFinder\Properties\AssemblyInfo.cs
文件 2870 2010-09-16 17:41 PortFinder\PortFinder\Properties\Resources.Designer.cs
文件 5612 2010-09-16 17:41 PortFinder\PortFinder\Properties\Resources.resx
文件 1095 2010-09-16 17:41 PortFinder\PortFinder\Properties\Settings.Designer.cs
文件 249 2010-09-16 17:41 PortFinder\PortFinder\Properties\Settings.settings
文件 920 2010-09-16 17:41 PortFinder\PortFinder.sln
..A..H. 12288 2010-09-19 18:03 PortFinder\PortFinder.suo
目录 0 2010-09-16 17:42 PortFinder\PortFinder\obj\Debug\Refactor
目录 0 2010-09-16 17:41 PortFinder\PortFinder\obj\Debug\TempPE
目录 0 2010-09-17 08:47 PortFinder\PortFinder\bin\Debug
目录 0 2010-09-17 18:12 PortFinder\PortFinder\obj\Debug
目录 0 2010-09-16 17:44 PortFinder\PortFinder\bin
目录 0 2010-09-16 17:41 PortFinder\PortFinder\obj
目录 0 2010-09-16 17:41 PortFinder\PortFinder\Properties
目录 0 2010-09-17 18:12 PortFinder\PortFinder
............此处省略4个文件信息
相关资源
- jdk.txt
- 7x8x统一规则发布模块.rar
- test.htm
- c9cf03eff7255712a6ed328fe1408ae5.h
- hopchen_7959641.zip
- C趣味编程100题.txt
- mm018.rar
- 闪光灯屏幕背光SOS三种模式的手电筒
- 20181026232608chromecj.com.crx
- 前后端分离1111.txt
- orCADPspice9.1仿真软件汉化补丁包.rar
- Popgen32.rar
- down_189.rar
- UniPatcher_v1.1.zip
- 微机第三版教材布置的习题参考答案
- 股权转让协议.doc
- labview2014中文破解版地址.txt
- m(1)
- wangyong_28.rar
- 试题.rar
- 合算法与计算理论-作业答案.pptx
- SystemView仿真资料CDMA码分多址资料大全
- WordExcel密码.rar
- bd9069c129ad2985bc6790f3cafabc8d.txt
- Paper_HeartSound.doc
- b91be5b23e4c62f28115f604018f7d9d.pdf
- 584c308befd011d7720037e150f3c32b.txt
- 1bdd1dcafa658ade9dc1bfb9fea58a58.7z
- 数据连接地址.txt
- 3bb65b4e23058e05b4aae103e67bf68f.DsnWrk
评论
共有 条评论