Created
May 21, 2010 12:54
-
-
Save vanne02135/408791 to your computer and use it in GitHub Desktop.
Test for open ports
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import socket | |
import sys | |
host = sys.argv[1] | |
maxport = int(sys.argv[2]) | |
for k in range(1, maxport): | |
try: | |
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
s.settimeout(0.5) | |
s.connect((host, k)) | |
#c = socket.connect((host, k), 1) | |
print "%s : %d responds" % (host, k) | |
s.close() | |
except: | |
pass | |
#print "no response in %s : %d" % (host, k) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment