• 大小: 0.04M
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-06-12
  • 语言: 其他
  • 标签: 其他  

资源简介

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个文件信息

评论

共有 条评论