Scanning Network for Windows Shared Folders
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 192.168.1.2 192.168.1.256 Beginning scanning 255 IP addresses... 192.168.1.2 --> CETUS WORKGROUP 192.168.1.109 --> I7PC WORKGROUP Query timeout. No replies from 253 IP addresses