[ Curiosity,Experimentation ]

Random stuff from the parallel universe of Ones and Zeroes

A Minimal Cross-platform Port Scanner in Python

Posted by appusajeev on July 6, 2009


A  Port Scanner is one of the most basic tools in the arsenal of an attacker/administrator. Basically a port scanner is a tool which can identify the open ports on a remote system. Given an ip address and an optional port range,a port scanner tries to connect to the ports on the machine sequentially and a successful connection means an open port. Open ports can sometimes prove to be a juicy entry point for an attacker,when there is a vulnerable application/service on the other side with an open port.

With that basic idea,presented here is a minimal port scanner i developed Python.

No rocket science,pretty straight forward code. The source can be altered to make it a portsweeper even

You can download the source here

The source is displayed below. And remember,this is a simple portscanner .So no advanced features

Port Scanner Source

Port Scanner Source

First,the program checks for the right number of command line arguments which includes the remote IP address,starting port and ending port. After extracting these parameters , a TCP socket is created each time to connect to the different ports sequentially on the same machine. A successful connection means that that port is open and some application/service is listening to it.

Currently what bothers me is the time taken to complete the scan. It takes quite some time :d

Suggestions and bug reports are welcome…….

4 Responses to “A Minimal Cross-platform Port Scanner in Python”

  1. neo2904 said

    hey…thats simple yet powerful..good work

  2. smogger said

    thats sme serious stuff out ther…
    hey people..it may sound simple but u cant imagine hw powerfull this is..
    i hope u learnt is so that u may be spared 😉

  3. Nikhil said

    great

    simple one and working very well

  4. saintah said

    well its wonderful!!!!
    saint

Leave a comment