-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAircrackIntervals.py
52 lines (37 loc) · 1.3 KB
/
AircrackIntervals.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import subprocess, os, sys, time
from datetime import datetime
script_name = sys.argv[0]
# each experiment will be Nhours in duration
Nhours = 2
# each CSV file will be Nseconds in duration
Nseconds = 15
# figure out how many files there will be
Nfiles = int((Nhours*3600)/Nseconds)
# create a unique file prefix for this experiment
date_prefix = datetime.now().strftime('%Y-%m-%d_%H-%m')
# create a dir for this experiment
wifi = "/wifi/"+date_prefix
import socket
hostname = socket.gethostname()
file_prefix = hostname+'_'+date_prefix
print wifi
print ["mkdir","-p",wifi]
subprocess.call(["mkdir","-p",wifi])
print("[%s] About to put card in monitor mode."%(script_name) )
subprocess.call(['ifconfig','wlan0','down'])
subprocess.call(['iwconfig','wlan0','mode','monitor'])
subprocess.call(['ifconfig','wlan0','up'])
print "Done."
for i in range(Nfiles):
# construct the airodump command and pipe all its output to /dev/null so it doesn't blow up the syslog
FNULL = open(os.devnull,'w')
the_cmd = ['airodump-ng','wlan0','-w',file_prefix,'--output-format','csv']
# call it
p = subprocess.Popen(the_cmd,
stdout=FNULL, stderr=subprocess.STDOUT,
cwd=wifi)
# wait for it
time.sleep(Nseconds)
# aaaaand bail
p.kill()
print("[%s] Success!"%(script_name) )