Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import subprocess
- import datetime
- #Run until stopped
- x="1"
- x=input("Enter to continue. Enter 0 to skip capture")
- while x != "0":
- blah = subprocess.check_output(["tshark -i mon0 -f \"subtype probe-req\" -T fields -e wlan_mgt.ssid -c 50"], shell=True)
- with open("results.txt", 'ab+') as f:
- f.write(blah)
- x=input("To get out enter 0")
- print("Capturing Cancelled")
- try:
- #Does blah exist?
- print(blah)
- except:
- #Clean text files, removes duplicated and empty lines
- print("Cleaning files")
- subprocess.call(['./stripUnique.sh'])
- exit()
- else:
- print("Exiting")
- #split the blah variable by line
- splitblah = blah.split(b"\n")
- #repeat for each line, -1 ignores first line since it contains headers
- for value in splitblah[:-1]:
- #split each line by tab delimiter
- splitvalue = value.split(b"\t")
- #check if SSID value exists
- try:
- MAC = str(splitvalue[1])
- SSID = str(splitvalue[2])
- TIME = str(datetime.datetime.now())
- print("Found SSID's", MAC + SSID + TIME)
- with open("results2.txt", "a+") as f:
- f.write(MAC+" "+SSID+" "+time+"\r\n")
- except:
- MAC = str(splitvalue[1])
- TIME = str(datetime.datetime.now())
- print("No SSID's", MAC +" " + TIME)
- with open("results2.txt", "a+") as f:
- f.write(MAC + TIME + "\r\n")
- exit()
Advertisement
Add Comment
Please, Sign In to add comment