Guest User

pygel

a guest
Jun 13th, 2018
288
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. import subprocess
  2. import datetime
  3.  
  4.  
  5. #Run until stopped
  6. x="1"
  7. x=input("Enter to continue. Enter 0 to skip capture")
  8. while x != "0":
  9. blah = subprocess.check_output(["tshark -i mon0 -f \"subtype probe-req\" -T fields -e wlan_mgt.ssid -c 50"], shell=True)
  10. with open("results.txt", 'ab+') as f:
  11. f.write(blah)
  12. x=input("To get out enter 0")
  13. print("Capturing Cancelled")
  14.  
  15. try:
  16. #Does blah exist?
  17. print(blah)
  18. except:
  19. #Clean text files, removes duplicated and empty lines
  20. print("Cleaning files")
  21. subprocess.call(['./stripUnique.sh'])
  22. exit()
  23. else:
  24. print("Exiting")
  25.  
  26. #split the blah variable by line
  27. splitblah = blah.split(b"\n")
  28.  
  29. #repeat for each line, -1 ignores first line since it contains headers
  30. for value in splitblah[:-1]:
  31.  
  32. #split each line by tab delimiter
  33. splitvalue = value.split(b"\t")
  34.  
  35. #check if SSID value exists
  36. try:
  37. MAC = str(splitvalue[1])
  38. SSID = str(splitvalue[2])
  39. TIME = str(datetime.datetime.now())
  40. print("Found SSID's", MAC + SSID + TIME)
  41. with open("results2.txt", "a+") as f:
  42. f.write(MAC+" "+SSID+" "+time+"\r\n")
  43. except:
  44. MAC = str(splitvalue[1])
  45. TIME = str(datetime.datetime.now())
  46. print("No SSID's", MAC +" " + TIME)
  47. with open("results2.txt", "a+") as f:
  48. f.write(MAC + TIME + "\r\n")
  49. exit()
Advertisement
Add Comment
Please, Sign In to add comment