Gorcupt

gerg

Apr 4th, 2022
30
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. import socket
  2. from pythonping import ping
  3. import threading
  4. import socket
  5. import time
  6.  
  7. def getMyIp():
  8. s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
  9. s.connect(("8.8.8.8", 80))
  10. ip = s.getsockname()[0]
  11. s.close()
  12. return ip
  13.  
  14.  
  15. def scan_Ip(ip):
  16. address = str(net) + str(ip)
  17. p = ping(address).rtt_avg_ms
  18. if p != 2000:
  19. print("address: " + address + " ping: " + str(p))
  20.  
  21. net = getMyIp()
  22. print('You IP :',net)
  23. net_split = net.split('.')
  24. a = '.'
  25. net = net_split[0] + a + net_split[1] + a + net_split[2] + a
  26. start_point = 1
  27. end_point = 255
  28.  
  29. startTime = time.time()
  30. print("Scanning in Progress:")
  31.  
  32. for ip in range(start_point, end_point):
  33. if ip == int(net_split[3]):
  34. continue
  35. potoc = threading.Thread(target=scan_Ip, args=[ip])
  36. potoc.start()
  37.  
  38. potoc.join()
  39.  
  40. print("Total time: " + str(time.time() - startTime))
Advertisement
Add Comment
Please, Sign In to add comment