Advertisement
Guest User

Untitled

a guest
Aug 1st, 2016
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. import threading
  2. import wmi
  3. import json
  4. import subprocess
  5. import time
  6.  
  7. from ldap3 import Server,
  8. Connection,
  9. AUTO_BIND_NO_TLS,
  10. SUBTREE,
  11. ALL_ATTRIBUTES
  12.  
  13.  
  14.  
  15.  
  16. class Ping(threading.Thread):
  17. def run (self):
  18. i = 40
  19. done = False
  20. while i < 250:
  21. scan_ip = threading.currentThread().getName() + str(i)
  22. response = subprocess.Popen(["ping", "-n", "1", "-w", "200", scan_ip]).wait()
  23. time.sleep(5)
  24. if(response == 0):
  25. try:
  26. wql = 'SELECT * FROM Win32_computerSystem'
  27. c = wmi.WMI(scan_ip, user='admin', password='pass')
  28. for item in c.query(wql):
  29. time.sleep(5)
  30. if(str(item.UserName) == "pestova"):
  31. print(scan_ip)
  32. done = True
  33. except:
  34. print("-")
  35. if done:
  36. break
  37. i += 1
  38.  
  39.  
  40. x = Ping(name = "192.168.4.")
  41. y = Ping(name = "192.168.5.")
  42.  
  43. x.start()
  44. y.start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement