Advertisement
anhlocpr

vng

Apr 10th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. import socket
  2. import time
  3. import logging
  4. import threading
  5.  
  6.  
  7. logging.basicConfig(filename='data.log', level=logging.DEBUG)
  8.  
  9.  
  10. def is_open_port(ip, port):
  11. sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  12. sock.settimeout(4)
  13. try:
  14. result = sock.connect_ex((ip, port))
  15. sock.close()
  16. return not result
  17. except Exception, b:
  18. logging.debug(str(b) + ip)
  19. return False
  20.  
  21.  
  22. def check(domain, c, ip):
  23. logging.info(domain + "," + c + "," + ip + "," + " 80: " + str(is_open_port(domain, 80)) + "," + " 443: " + str(is_open_port(domain, 443)) )
  24.  
  25. threads = []
  26.  
  27.  
  28. with open('vng-records.txt') as f:
  29. lines = f.readlines()
  30. for line in lines:
  31. while threading.activeCount() > 500:
  32. time.sleep(1)
  33. domain = line.split(",")[0].replace("\"", "")
  34. c = line.split(",")[1].replace("\"", "")
  35. ip = line.split(",")[2].replace("\"", "").strip()
  36. p = threading.Thread(target=check, args=[domain, c, ip])
  37. p.daemon = True
  38. threads.append(p)
  39. p.start()
  40.  
  41. for _ in threads:
  42. _.join()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement