Ready to Start Your Career?

Python Port Scanner

Moose 's profile image

By: Moose

April 4, 2018

The following python code will allow you to scan a local or remote host for open ports. The program scans for select ports on a certain IP address and reflects the open ports back to the user. #import socket libraryfrom socket import * #User prompts for IP and Portsprint "This tool should be used to verify open ports on the machine n"print "Please follow the steps provided to check ports. n"ip=raw_input("Enter the IP of the machine that you would like to scan: ")#prompts user to enter in the pema ipprint "n"print "-" * 60print "Please enter the range of ports you would like to scan on the machine"print "-" * 60sport=input("Enter first port number to scan: ")print "n"endport=input("Enter last port number to scan:")print "n" # Bannerprint "-" * 60print "Please wait, scanning remote host", ipprint "-" * 60print "All connected ports between ", sport, " and ", endport, " will display"print "-" * 60print "Press Ctrl + C to stop scan"print "-" * 60 #Informs user of successful connectionsfor port in range(sport,endport,):s=socket(AF_INET, SOCK_STREAM)if(s.connect_ex((ip, port))==0):print "Port" , port, "is open on PEMA " + pema_ips.close() Thanks for looking!
Schedule Demo