-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscanner2.py
executable file
·47 lines (37 loc) · 1.39 KB
/
scanner2.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
#!/usr/bin/env python
import os
from time import sleep
import globalVars as gv
import subprocess as sp
from splib import changeIfaceMode, mqttLog, mqttCmd
# Variables
clientID = 'scanner'
scriptScanner = 'tshark.py'
scriptWriter = 'writer.py'
channels= [1,6,11]
#channels= [40,44,48,52,56]
# System preparation
changeIfaceMode(gv.iface)
# Start Scanner
procScanner = sp.Popen(['python', scriptScanner])
mqttLog(clientID, 'Starting scanner subprocess with PID: %s' %procScanner.pid)
try:
procWriter = sp.Popen(['python', scriptWriter])
mqttLog(clientID, 'Starting writer subprocess with PID: %s' %procWriter.pid)
for channel in channels:
os.system("sudo iwconfig " + gv.iface + " channel " + str(channel))
mqttLog(clientID, 'Changing interface channel to: %s' %channel)
sleep(int(gv.scanTime))
mqttCmd(clientID, 'TShark', 'stop')
sleep(2)
mqttLog(clientID, 'Stopping scanner subprocess with PID: %s' %procScanner.pid)
procScanner.terminate()
mqttLog(clientID, 'Stopping writer subprocess with PID: %s' %procWriter.pid)
procWriter.terminate()
except KeyboardInterrupt:
mqttLog(clientID, 'Interrupt received, exiting')
finally:
mqttLog(clientID, 'Stopping scanner subprocess with PID: %s' %procScanner.pid)
procScanner.terminate()
mqttLog(clientID, 'Stopping writer subprocess with PID: %s' %procWriter.pid)
procWriter.terminate()