问题
Does anyone knows of any .Net library or resources that will assist me to implement a TCP port scanner?
回答1:
For simple one, that will just try to connect to each port and report success / failure, without any "tricks", like sending only ACK packets etc. - you won't need anything else than System.Net
and System.Net.Sockets
, create socket, try connecting to a host, check if you have succeeded. For better performance, you can create more sockets, and use asynchronous approach (BeginConnect/EndConnect).
回答2:
I found some example codes.
http://www.geekpedia.com/tutorial142_Creating-a-Port-Scanner-with-Csharp.html
http://www.dijksterhuis.org/building-a-simple-portscanner-in-c/
WinPcap is a network monitoring and packet capturing tool but it might be also useful because it is another way to get an idea about network transmissions. But it may not suit to your requirement.
回答3:
You can try my open source program here ;)
http://dercousin.xhost.ro/index.php?option=com_content&view=category&layout=blog&id=35&Itemid=53
回答4:
You can use Pcap.Net to create and send raw packets.
You can also capture packets using this framework.
It includes a packet interpretation and creation framework so it should be pretty easy to create the packets you need to scan the ports and to parse the packets returned.
来源:https://stackoverflow.com/questions/1331902/c-sharp-tcp-port-scanner-resources