Created
November 30, 2021 08:47
-
-
Save marcusschiesser/bdb9e90948d267a0a10798e78de10d27 to your computer and use it in GitHub Desktop.
Test ports for different machines
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
import socket | |
machines = ['mickey','mouse'] | |
ports = [8000, 8089, 8088] | |
# scans ports on the given machines and ports | |
def scan_ports(machines, ports): | |
for machine in machines: | |
for port in ports: | |
print("Scanning port " + str(port) + " on " + machine) | |
try: | |
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
s.settimeout(1) | |
s.connect((machine, port)) | |
s.close() | |
print("Port " + str(port) + " is open on " + machine) | |
except: | |
print("Port " + str(port) + " is closed on " + machine) | |
scan_ports(machines, ports) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment