I need to build port scanner.
Could somebody help me?
How should I start?


What have you written so far?

try writing some pseudo code first :)

you will want an IP

and a specific range of ports to check.

you will need a method for sending a ping to them and a method for listening for a response (three part handshake for networking peeps)

you should start by writing something that can ping a local address, or even just something that can connect to a local machine to get the feel for how networking works.

Could You give me a little example(C#), so i`ll try to continue

Could You give me a little example(C#), so i`ll try to continue

you should really try to gain an understanding of what you are trying to do.

in about 30 seconds of google searching i was able to find examples of what you need to do.

hint an IP with a PORT is called a socket

so look up C# and sockets.

I`ll try to ask accurate question:
I need to implement few type of scanning:

  • TCP connect()
  • TCP SYN scan
  • TCP FIN scan
  • TCP XMAS scan
  • TCP NULL scan

I already did something:

public static void connect1(string host, int startPort, int finishPort)    

        IPAddress[] IPs = Dns.GetHostAddresses(host);
        Socket s = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
        Console.WriteLine("Establishing Connection to {0}", host);

        for (int curPort = startPort; curPort <= finishPort; curPort++)

                s.Connect(IPs[0], curPort);
                Console.WriteLine("Port {0}     : opened", curPort);
                Console.WriteLine("Port {0}     : blocked", curPort);

It's working, but I don't know which type is it, and how to continue
with other types

Edited 3 Years Ago by mike_2000_17: Fixed formatting

This article has been dead for over six months. Start a new discussion instead.