基于C#端口扫描器的实现
摘 要
由于网络技术的飞速发展,网络规模迅猛增长和计算机系统日益复杂,导致新的系统漏洞层出不穷。黑客或者计算机病毒要想顺利渗透入目标计算机中,不管使用何种技术手段,必然要寻找目标计算机的漏洞为自己打开入侵的大门。为了保证网络中计算机的安全性,必须采取主动策略,快速、及时、准确、安全的检测出网络中计算机及防火墙开放的和未开放的端口。计算机端口扫描技术就是这种主动防御策略实现的重要技术手段。
本课题通过端口扫描器的研究来提高对计算机安全的认识。该端口扫描器采用C#语言开发,在VC 2005.net编译环境下通过测试。利用TCP connect扫描原理,扫描主机通过TCP/IP协议的三次握手与目标主机的指定端口建立一次完整的连接,如果目标主机该端口有回复,则说明该端口开放。利用多线程技术实现了对一目标IP进行设定数目的端口扫描,对多IP段的特定端口进行扫描。此外,还利用委托技术实现对界面元素的刷新。
关键字:端口扫描器;IP段扫描;C#的多线程编程
The Implement of Port Scanner Based on C#
Abstract
Along with the rapid development of network technology, the more complication of computer and the more enlarged size of Internet, the more leaks may existed in new system. When computer virus or hacker wants to invade to a system or host, no matter what means their take, it is obvious that they have to scan the system leaks at first. So as far as system security is concerned, no matter in Internet or Intranet, you should actively adopt a strategy to detect the state of the ports on your host computer or firewall. Computer port-scanning technology is one of important means to realize positive defense.
This topic focuses on the study of port scanner to improve understanding of computer security. The port scanner is developed and tested by C# in VC 2005.net environment. By using TCP connect scaning technique, the scanning host use TCP / IP three-shook hands protocol to establish a complete link with the target through the specified host ports. If the port of the specified host replies, it shows that the port is opened. The scanner utilizes multi-thread to implement port scanning for multiple target IP addresses at a given time or scanning a specified port in multiple different IP segments.
Keywords: Port Scanner; IP Scanner; C # Multithreaded Programming