Created
October 10, 2018 16:44
-
-
Save aj07mm/9183136e38f4f863edd167bc5d58c675 to your computer and use it in GitHub Desktop.
Python script to test open outgoing ports from local network
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
#!/usr/bin/env python | |
"""Port test | |
Python script to test open outgoing ports from local network | |
""" | |
import socket | |
for port in range(1,65000): | |
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
# A lower timeout can miss responses | |
sock.settimeout(0.05) | |
# Ping portquiz.net which has all of its ports open | |
result = sock.connect_ex(('portquiz.net', port)) | |
# List all the open ports | |
if result == 0: | |
print "Open: %d" % port |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment