amv1991

Port Scanner com Tkinter

Jan 22nd, 2021
1,198
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from tkinter import *
  2. from socket import *
  3.  
  4. fonte = font=("Arial","11")
  5. c = "gray15"
  6. co = "green2"
  7. scanner = Tk()
  8.  
  9. lb = Label(scanner, text="Port Scanner", font=("Gang of Three", "20"), bg=c, fg=co)
  10. lb.place(x=1, y=1)
  11.  
  12. lb1 = Label(scanner, text="URL ou IP", font=fonte, bg=c, fg=co)
  13. lb1.place(x=5, y=50)
  14.  
  15. inf = Entry(scanner, font=fonte, bg="gray10", fg="white")
  16. inf.place(x=80, y=50)
  17.  
  18. ed12 = Text(scanner, font=("Arial","12", "bold"), bg="gray10", fg="white", width=43, height=18, selectbackground="green2", selectforeground="gray10")
  19. ed12.place(x=5, y=140)
  20.  
  21. lb2 = Label(scanner, text="Início", font=fonte, bg=c, fg=co)
  22. lb2.place(x=5, y=80)
  23.  
  24. ini = Entry(scanner, font=fonte, bg="gray10", fg="white")
  25. ini.place(x=80, y=80)
  26.  
  27. lb3 = Label(scanner, text="Fim", font=fonte, bg=c, fg=co)
  28. lb3.place(x=5, y=110)
  29.  
  30. fim = Entry(scanner, font=fonte, bg="gray10", fg="white")
  31. fim.place(x=80, y=110)
  32.  
  33. def scan():
  34.     ed12.delete(0.0)
  35.     a = int(ini.get())
  36.     b = int(fim.get())
  37.     aa = a-1
  38.     url = inf.get()
  39.     lista = range(b, aa, -1)
  40.     for i in lista:
  41.         a = socket(AF_INET, SOCK_STREAM)
  42.         a.settimeout(0.5)
  43.         b = a.connect_ex((url, i))
  44.         if b!= 0:
  45.             ed12.insert(0.0, "A porta {} está fechada\n".format(i))
  46.         else:
  47.             ed12.insert(0.0, "A porta {} está aberta\n".format(i))
  48. bt = Button(scanner, text="Iniciar", width=15, font=fonte, bg="gray10", fg=co, activebackground=c, activeforeground=co, command=scan)
  49. bt.place(x=243, y=500)
  50.  
  51. scanner["bg"] = "gray15"
  52. scanner.resizable(height=False, width=False)
  53. scanner.title("Port Scanner")
  54. scanner.geometry("400x540+450+20")
  55. scanner.mainloop()
  56.  
  57.  
  58.  
  59.  
RAW Paste Data