How to create an efficient port scanner

I have stated some points that should be taken into account for a good port scanner:

  • Multithreading should be used for high performance
  • The socket.setdefaulttimeout(1) method should be set according to the situation
  • The port scanner should have the ability to take host names as well as domain names
  • The port should provide the service name with the port number
  • The total time should be taken into account for port scanning
  • To scan ports 0 to 65535, the time taken should be around 3 minutes

So now I have written my port scanner, which I usually use for port scanning:

from threading import Threadimport timeimport socketfrom datetime import datetimeimport cPickle'''Section1'''pickle_file = open("port_description.dat",'r') ...

Get Python Penetration Testing Essentials now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.