amv1991

Port Scanner

Jan 22nd, 2021 (edited)
315
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from socket import *
  2.  
  3. def scan():
  4.     a = int(input("Porta inicial: "))
  5.     b = int(input("Porta final: "))
  6.     url = input("URL: ")
  7.     lista = range(a, b+1)       #Lista de 75 a 85
  8.     for i in lista:
  9.         a = socket(AF_INET, SOCK_STREAM)
  10.         a.settimeout(0.5)
  11.         b = a.connect_ex((url, i))
  12.         if b != 0:
  13.             print("A porta {} está fechada".format(i))
  14.         else:
  15.             print("\nA porta {} está ABERTA\n".format(i))
  16.  
  17. scan()      #Chama a função scan
  18.  
  19. input("\nAperte ENTER para sair...")
RAW Paste Data