posts - 112, comments - 215, trackbacks - 0, articles - 34
  IT博客 :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理

C#简易端口扫描器实例

Posted on 2007-12-21 19:52 济公 阅读(1152) 评论(1)  编辑 收藏 引用 所属分类: NetWorks
扫描器界面:
 
   //扫描端口
   int iStart=(int)this.numericUpDown1.Value;
   int iEnd=(int)this.numericUpDown2.Value;
   try
   {
    this.progressBar1.Minimum=iStart;
    this.progressBar1.Maximum=iEnd;
    this.richTextBox1.Text="程序开始扫描端口:\n"; 
    this.richTextBox1.Update();
    for(int i=iStart;i<iEnd;i++)
    {
     this.progressBar1.Value=i;
     TcpClient MyTCP=null;      
     try
     {
      MyTCP = new TcpClient(this.textBox1.Text,i);
      this.richTextBox1.Text+="端口 " + i.ToString() + " 开放!\n";
      this.richTextBox1.Update();
     }   
     catch
     {
     }   
    }
    this.richTextBox1.Text+="扫描端口结束!\n";   
   }
   catch(Exception Err)
   {
    MessageBox.Show("扫描端口操作发生错误,错误信息是:"+Err.Message,"信息提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
   }

Feedback

# re: C#简易端口扫描器实例[未登录]  回复  更多评论   

2008-11-10 16:37 by 无名
效率很低啊。。。
只有注册用户登录后才能发表评论。