Created
July 5, 2019 06:03
-
-
Save Kajvdh/9ab95a5159dee025225d04f2161dd85b to your computer and use it in GitHub Desktop.
Python script to test open outgoing ports from local network
This file contains hidden or 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