資源簡(jiǎn)介
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
????{
????????//已掃描端口數(shù)目
????????internal?static?List?openedPorts?=?new?List();
????????//已掃描端口數(shù)目
????????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(“請(qǐng)輸入主機(jī)名或者主機(jī)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?????????????{
????????????????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);
????????????}
????????}
????}
}
?屬性????????????大小?????日期????時(shí)間???名稱(chēng)
-----------?---------??----------?-----??----
?????文件??????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個(gè)文件信息
評(píng)論
共有 條評(píng)論