A port scanner/sweeper is a software application designed to probe a server or host for open ports. This is often used by administrators to verify security policies of their networks and by attackers to identify running services on a host with the view to compromise it. A portscan can be defined as an attack that sends client requests to a range of server port addresses on a host, with the goal of finding an active port and exploiting a known vulnerability of that service, although the majority of uses of a port scan are not attacks and are simple probes to determine services available on a remote machine.
So, Here’s a python code nugget that does the port sweep on any give host.
How to run:
Simple, copy the above code (Say porter.py), just run the command ’python porter.py’. Here’s how the output looks like: