A Software Technologist's Blog (Wanna Email Me?)

Archive for June, 2012

I have noticed that there are quite a few requests for a network scanning application to search for Windows shared folders.
I thought this will be an interesting implementation for pysmb (a pure Python implementation of the SMB1 and SMB2 protocol that supports the Windows file sharing functionality) as well as for developers who are learning to use pysmb for their applications.

You will need Python 2.4 and above, and have installed pyasn1 and pysmb. Next, download the ScanNetworkForSMB.py script. Then, run the script with 1 IP address to scan for a single machine, or a start/end IP address pair to scan a range of IP addresses. If the scanned machine has its Windows sharing port (port 137) active, the script will print out its IP address together with the names associated with this machine.

Sample output

$bash> python ScanNetworkForSMB.py
Beginning scanning 255 IP addresses... --> CETUS WORKGROUP --> I7PC WORKGROUP

Query timeout. No replies from 253 IP addresses