[ Curiosity,Experimentation ]

Random stuff from the parallel universe of Ones and Zeroes

Posts Tagged ‘Port Scanner’

Optimized Port Scanner [With Threading]

Posted by appusajeev on August 13, 2009

I had earlier presented here a Port Scanner program written in Python (In fact,it was my maiden post !). I had stated that the major bottleneck associated with its performance was the amount of time taken to complete the scan for even a small range of ports. The connections were made sequentially,one after the other and took mammoth time to verify the entire ports in the list.

Well,that problem is solved now by using threaded execution,the use of separate threads for processing each port. The entire ports are processed simultaneously by separate  threads and this has brought down the execution time to a great extent.Hence i am presenting here, an optimized version of the port scanner which i had earlier presented.

A thread is a sequence  of instructions that are executed concurrently with other instructions/threads. Python provides two modules to implement threading-Thread module and Threading module. I have used the latter module and has overridden the run() method in the Thread class(by subclassing it)present in the module Threading.

Download Source code

Or see the source below:

Port Scanner-Optimized Source

Port Scanner-Optimized Source

Here the scanner in action:

”]Port Scanning [Screenshot]

I have used microsoft.com as the example. Notice from the scan that port 443 is open. Its the port for HTTPS.

Suggestions are welcome

Port Scanner -Scanning

Posted in Port Scanner, Python | Tagged: , , | 9 Comments »