Skip to content

Instantly share code, notes, and snippets.

@aj07mm
Created October 10, 2018 16:44
Show Gist options
  • Save aj07mm/9183136e38f4f863edd167bc5d58c675 to your computer and use it in GitHub Desktop.
Save aj07mm/9183136e38f4f863edd167bc5d58c675 to your computer and use it in GitHub Desktop.
Python script to test open outgoing ports from local network
#!/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