-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathmain.py
189 lines (168 loc) · 7.43 KB
/
main.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
#!/usr/bin/python
############################
## Attify Zigbee Framework #
############################
from PyQt4 import QtCore,QtGui
from PyQt4.QtGui import QAction,QIcon
from PyQt4.QtCore import SIGNAL
from UI.Base import Ui_MainWindow
from src.kbi import RavenRefresh,ZBDumpThread,ZBReplayThread,ZBWireShark
from src.ztmThread import ZBStumblerThread
import sys,subprocess,os,fnmatch
try:
_fromUtf8 = QtCore.QString.fromUtf8
except AttributeError:
def _fromUtf8(s):
return s
class AZFMain(Ui_MainWindow):
def __init__(self,dialog,parent=None):
Ui_MainWindow.__init__(self)
self.setupUi(dialog)
self.ToolIcon.setPixmap(QtGui.QPixmap(_fromUtf8('UI/icon.png')))
self.zbstumblerThread=None
self.zbdumpThread=None
self.zbreplayThread=None
self.zbwiresharkThread=None
self.ravenRefresh()
self.pcapRefresh()
self.pushButton_Refresh.clicked.connect(self.ravenRefresh)
self.pushButton_zbstumbler.clicked.connect(self.zbstumblerRun)
self.pushButton_Zbdump.clicked.connect(self.zdump)
self.pushButton_Zbreplay.clicked.connect(self.zbreplay)
self.wiresharkStart.clicked.connect(self.zbwireshark)
self.attifyWebLink.setOpenExternalLinks(True)
self.AttifyStoreLink.setOpenExternalLinks(True)
self.killerbeeLink.setOpenExternalLinks(True)
def pcapRefresh(self):
#Function to add pcap files to the file slectors
print("[*] pcapRefresh invoked ")
self.statusbar.showMessage(" AZF | Refreshing Pcap Files ",2000)
path="pcap/"
pattern="*.pcap"
result=[]
for root, dirs, files in os.walk(path):
for name in files:
if fnmatch.fnmatch(name, pattern):
result.append(os.path.join(name))
self.zbreplayFile.clear()
self.zbreplayFile.addItems(result)
def ravenRefresh(self):
print "[*] Executing Raven Refresh "
self.statusbar.showMessage(" AZF | Refreshing devices",2000)
self.ravenRefreshThread=RavenRefresh()
self.ravenRefreshThread.start()
QtCore.QObject.connect(self.ravenRefreshThread,QtCore.SIGNAL("ravenrefresh_update(QString)"), self.update_refresh_status)
def update_refresh_status(self,QString):
if len(str(QString)) > 50:
self.labelDeviceStatus.setText("Connected")
string=str(QString).split("\n")
output=[]
for i in string:
output.append(i.strip())
QString=output[0]+"\n"+output[1]
self.labelDeviceDetails.setText(QString)
else:
self.labelDeviceStatus.setText("Disconnected")
self.ravenRefreshThread.close()
def zbstumblerRun(self):
if self.zbstumblerThread==None:
self.statusbar.showMessage(" AZF | Starting zbstumbler",2000)
print "[*] Starting zbstumbler"
self.pushButton_zbstumbler.setText("Stop")
channel=self.zbstumbler_Channel.currentText()
if channel=="Select Channel":
channel=11
self.zbstumblerConsole.append("\n[ * ] Scanning channel : "+channel+"\n")
self.zbstumblerThread=ZBStumblerThread(int(channel))
self.zbstumblerThread.start()
QtCore.QObject.connect(self.zbstumblerThread,QtCore.SIGNAL("stumbler_update(QString)"), self.update_zbstumbler)
else:
print "[*] Stopping zbstumbler"
self.statusbar.showMessage(" AZF | Stopping zbstumbler",2000)
self.pushButton_zbstumbler.setText("Start")
self.zbstumblerThread.close()
self.zbstumblerThread=None
def update_zbstumbler(self,QString):
if(str(QString)=="Complete"):
print "[*] Stopping zbstumbler"
self.statusbar.showMessage(" AZF | Stopping zbstumbler",2000)
self.pushButton_zbstumbler.setText("Start")
self.zbstumblerThread.close()
self.zbstumblerThread=None
self.zbstumblerConsole.append("\n[ * ] Scanning complete")
else:
self.zbstumblerConsole.append(QString)
def zdump(self):
channel=self.zbdumpChannel.currentText()
file=self.zbdumpFile.text()
count=self.zbdumpCount.text()
if self.zbdumpThread==None:
print "[*] Starting ZBdump"
self.statusbar.showMessage(" AZF | Starting zbdump",1500)
self.pushButton_Zbdump.setText("Stop Capture")
self.zbdumpThread=ZBDumpThread(channel,file,count)
self.zbdumpThread.start()
QtCore.QObject.connect(self.zbdumpThread,QtCore.SIGNAL("zbdump_update(QString)"), self.zbdump_complete)
else:
print "[*] Stopping ZBdump"
self.statusbar.showMessage(" AZF | Stopping zbdump",1500)
self.pushButton_Zbdump.setText("Start Capture")
self.zbdumpThread.close()
self.zbdumpThread=None
def zbdump_complete(self):
self.zbdumpThread.close()
print "[*] Stopping ZBdump"
self.statusbar.showMessage(" AZF | Stopping zbdump",1500)
self.pushButton_Zbdump.setText("Start Capture")
self.zbdumpThread=None
self.pcapRefresh()
def zbreplay(self):
channel=self.zbreplayChannel.currentText()
file=self.zbreplayFile.text()
count=self.zbreplayCount.text()
delay=self.zbreplayDelay.text()
if self.zbreplayThread==None:
print "[*] Starting ZBreplay"
self.statusbar.showMessage(" AZF | Starting zbreplay",1500)
self.pushButton_Zbreplay.setText("Stop Replay")
self.zbreplayThread=ZBReplayThread(channel,file,count,delay)
self.zbreplayThread.start()
QtCore.QObject.connect(self.zbreplayThread,QtCore.SIGNAL("zreplay_update(QString)"), self.replay_complete)
else:
print "[*] Stopping ZBreplay"
self.statusbar.showMessage(" AZF | Stopping zbreplay",1500)
self.pushButton_Zbreplay.setText("Start Replay")
self.zbreplayThread.close()
self.zbreplayThread=None
def replay_complete(self):
self.zbreplayThread.close()
print "[*] Stopping ZBreplay"
self.statusbar.showMessage(" AZF | Stopping zbreplay",1500)
self.pushButton_Zbreplay.setText("Start Replay")
self.zbreplayThread=None
def zbwireshark(self):
count=None
channel=self.wiresharkChannel.text()
try:
count=self.wiresharkCount.text()
except Exception as e:
print "[*] Zbwireshark count error : "+str(e)
if self.zbwiresharkThread==None:
print "[*] Starting ZBWireshark"
self.statusbar.showMessage(" AZF | Starting ZBWireshark ",2000)
self.wiresharkStart.setText(" Stop Wireshark ")
self.zbwiresharkThread=ZBWireShark(channel,count)
self.zbwiresharkThread.start()
else:
print "[*] Stopping ZBWireshark"
self.statusbar.showMessage(" AZF | Stopping ZBWireshark ",2000)
self.wiresharkStart.setText(" Launch Wireshark ")
self.zbwiresharkThread.close()
self.zbwiresharkThread=None
if __name__=="__main__":
app=QtGui.QApplication(sys.argv)
dialog=QtGui.QMainWindow()
app.setWindowIcon(QIcon("UI/icon.png"))
prog=AZFMain(dialog)
dialog.show()
sys.exit(app.exec_())