C#版的端口扫描器(PortScanner
上网很久的朋友一定对端口扫描器不会陌生吧。XScanner,SuperScanner大家一定都使用过。
今天我们就用最新的.Net技术来制作一个自己的端口扫描器,无垠出品!
今天主要使用到的是System.Net和System.Threading名称空间.
1
2using System;
3using System.Collections.Generic;
4using System.Text;
5
6using System.Net;
7using System.Net.Sockets;
8
9using System.Threading;
10
11namespace PortScanner
12{
13 class Program
14 {
15 //已扫描端口数目
16 internal static int scannedCount = 0;
17 //正在运行的线程数目
18 internal static int runningThreadCount = 0;
19 //打开的端口数目
20 internal static List<int> openedPorts = new List<int>();
21 //起始扫描端口
22 static int startPort = 1;
23 //结束端口号
24 static int endPort = 500;
25 //最大Php?ads_id=698&site_id=6235007045035685&click=1&url=http%3A//www.zhaopin.com/&v=0&k=%u5DE5%u4F5C&s=http%3A//www.cnblogs.com/skyover/archive/2006/09/24/513563.html&rn=571879" target=_blank>工作线程数
26 static int maxThread = 100;
27 static void Main(string[] args)
28 {
29 //接收传入参数一作为要扫描的Php?ads_id=1277&site_id=6235007045035685&click=1&url=http%3A//hasee2005.allyes.com/hasee/&v=0&k=%u4E3B%u673A&s=http%3A//www.cnblogs.com/skyover/archive/2006/09/24/513563.html&rn=442545" target=_blank>主机
30 string host = args[0];
31 //接收传入参数二作为端口扫描范围,如1-4000
32 string portRange = args[1];
33 startPort = int.Parse(portRange.Split('-')[0].Trim());
34 endPort = int.Parse(portRange.Split('-')[1].Trim());
35
36 for (int port = startPort; port < endPort; port++)
37 {
38 //创建扫描类
39 Scanner scanner = new Scanner(host, port);
40 Thread thread = new Thread(new ThreadStart(scanner.Scan));
41 thread.Name = port.ToString();
42 thread.IsBackground = true;
43 //启动扫描线程
44 thread.Start();
45
46 &n
相关新闻>>
- 发表评论
-
- 最新评论 更多>>