Last active
October 1, 2019 19:22
-
-
Save MayankFawkes/d029dc111278bc4621f2858c62a8a0f9 to your computer and use it in GitHub Desktop.
simple port scanning script
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
import socket,sys,os | |
host=input("host :") | |
pfrom=input("Port from :") | |
pto=input("Port to :") | |
def TCP_connect(ip, port_number): | |
TCPsock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
TCPsock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) | |
TCPsock.settimeout(0.5) | |
try: | |
TCPsock.connect((ip, port_number)) | |
print("[scan] -> port open! {} | {}".format(ip,port_number)) | |
except: | |
print("",end="") | |
for n in range(int(pfrom),int(pto)+1): | |
sys.stdout.flush() | |
sys.stdout.write("[scan] -> trying! {} | {}\r".format(host,n)) | |
TCP_connect(host,n) | |
print(" ") | |
input("Press any key to exit") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment