├── ATG-python Specification V1.docx
├── LICENSE
├── README.md
├── __init__.pyc
├── attack_config.xml
├── canInterface.py
├── canMatrixTest.py
├── frame.py
├── frame.pyc
├── tools.py
├── tools.pyc
├── trash.bmp
└── usb2can.dll
/ATG-python Specification V1.docx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TianTianlove/ATG-python/67024e24381de4a6c89e50ac2e774345a408961a/ATG-python Specification V1.docx
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2018 天祥
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # ATG-python
2 | Attack Traffic Generation(ATG) tool enables users to explore automotive CAN bus cyber-security rapidly.
3 | ## 1 Getting Started
4 | ATG is a vehicle CAN bus packet analyzer and attack packets generator. ATG enables researchers to begin to explore automotive cyber-physical system rapidly. To a certain extent, it can verify the cyber security solution of in-vehicle CAN bus and ECUs with different attack modes. For some novel IDS countermeasures, it is also a good tool to generate a dataset, and test it in python environment.
5 | ### 1.1 Current Version
6 | This specification is based on the beta version, running on Windows XP, Vista, 7, 8, 10 (64 and 32).
7 | ### 1.2 CAN Interface
8 | USB2CAN is the default CAN bus interface of ATG. It provides drivers for Windows and Linux system. Meanwhile, for the developer, it provides DLL (Dynamic Link Library) for windows application and Socket CAN drivers for Linux application.
9 | You can buy this device from 8device website: http://www.8devices.com/products/usb2can The price is only $65.
10 | ### 1.3 Installing Drivers
11 | Firstly, you should install the drivers on windows. You can download the drivers from 8device website:
12 | * 64bit:http://www.8devices.com/media/products/usb2can/downloads/usb2can_win64_v1.0.2.1.zip
13 | * 32bit:http://www.8devices.com/media/products/usb2can/downloads/usb2can_win32_v1.0.2.1.zip
14 |
15 | You can see the device information in Device Manager when you success to install the drivers.
16 |
17 | ## 2 Using ATG
18 | ### 2.1 Activate Interface
19 | After connecting the CAN device to the computer and running ATG, you should check the device id at the back of the device and input it in ID input box. And then, select the suitable baud rate (range from 10 to 1000 Kbps). At last, you can click the Open button to activate interface. If the text changes to Shutdown, it means there is no problem. When the device is at activated state, the LED color on the USB2CAN become green. Otherwise it is still red.
20 | ### 2.2 Packets Sniffer
21 | This is the basic function of ATG. It can collect the packets in real time and display in a different way.
22 | #### 2.2.1 Starting tracing
23 | When you click the Start Tracing button, the trace window shows the packets including Time(ms), ECU_ID, Data, and Dir (RX denote Receiving, TX denote Transmitting) information.
24 | #### 2.2.2 Changing display style
25 | You can click the checked box △t to switch the time type between interval and timestamp. You can select the message refresh mode in the choice box, Chronological mode record and show all packets, Fixed mode classify packets by ID and fix the position with each kind of packet. Following figures show the difference between two modes:Chronological mode and Fixed mode.
26 | #### 2.2.3 Packets Logging
27 | To make it possible and easy to analyze the entire packets after you get these from a real vehicle, ATG supports two kinds of logging file formats, database file(.db) and log file(.log). You can check Save as DB or Save as log checkbox and select the storage path. This can show and store packets at the same time after you click Start Tracking button. When you complete logging, you can open log file in Notepad and database file in database view software, such as SQLite Expert Personal 3. Another difference between these two formats is that only the log format file can label the attack packets when you launch attacks and playback.
28 | Comparing to other software logging feature the advantages of ATG are:
29 |
(1) Candump module of [can-utils](https://github.com/linux-can/can-utils) just can logging data, it cannot generate attack packets and label them.
30 |
(2) CANoe store packets as *.blf/*.asc/*.mf4 binary format file. You cannot analysis directly, and the Adaptive CAN interface is expensive.
31 | ATG not only guarantee the performance to store a huge number of packets but also make it easy to modify and analyze the dataset.
32 | ### 2.2 Playback
33 | Playback function can help you to replay the log file. After you select the log file, you can click Play button to launch the data into CAN bus. You can also pause or stop it.
34 | ### 2.3 Attack Tool
35 | #### 2.3.1 DoS attack
36 | In the DoS attack mode, ATG can inject the highest priority packet of 0x0 CAN ID every 1 millisecond.
37 | #### 2.3.2 Fuzzing attack
38 | In the Fuzzing attack mode, ATG can inject the random ID and random data.
39 | #### 2.3.3 Spoofing attack
40 | After sniffing and marking the control field in a control frame, it is easy to use a reverse engineering. ATG can inject the malicious message in a shorter interval than the normal nodes, which causes the receiving node to execute a dangerous operation.
41 | The step to launch fuzzing attack is as follows.
42 |
(1) Analyzing the packets
43 | In the Attack Tab, you can click Analyze button to get and classify the packets. For example, in the following figure, you can see there are two kinds of packets 386(0x182) ID and 291(0x123) ID, TS is the interval, IF is a flag to judge whether this packet is cyclic, 5 means it is.
44 |
(2) Selecting target packet and Configuring parameters
45 | You can select the target message in the analysis result box. And then you can configure the appointed byte of attack packet. Shown as following, you can input 30, 31 and 21 in the first, second and fourth input box, and check the checkbox under them. The default mode is Fixed Data, under this mode, it just replaces the selected byte of original data to a preset value. Under the Data Offset mode, it adds the value to the original data. You can also change the frequency of attack by the slider to make the injected messages difficult to find.
46 |
(3)Launching attack
47 | You can check the Spoofing Attack Radio button and click Start button to launch such attack. In the following picture, I use another software to check the attack messages.
48 | #### 2.3.4 Automatic attack
49 | Usually, it is not convenient to manually launch an attack event by previous way. So ATG provides attack config function. You can define the attack events in an XML file. ATG can load it and trigger them one by one.
50 |
The config format is similar to the attack config above:
51 |
(1) DoS attack
52 |
Sample:
53 | ```XML
54 |
55 | 2
56 | 4
57 |
58 | ```
59 | In the attack node, define the type attribute as “DoS”, then set the start time and end time (s).
60 |
(2)Fuzzing attack
61 |
Sample:
62 | ```XML
63 |
64 | 60
65 | 70
66 |
67 | 19C0EFF1
68 | AA
69 | 21
70 |
71 |
72 | ```
73 | In the attack node, Define the type attribute as “Fuzzing”, then set the start time and end time. In the message node, the type attribute can be configured as “random” or “fixed”. Random mode denotes the ID and Data are randomly generated; fixed mode means the relevant bytes would be randomly generated then define the target_id. active_byte and frequency.
74 |
(3)Spoofing attack
75 |
Sample:
76 | ```XML
77 |
78 | 80
79 | 110
80 |
81 | 125
82 | 00 00 00 00 21 23 21 11
83 | 0F
84 | 21
85 |
86 |
87 | ```
88 | In the attack node, Define the type attribute as “Spoofing”, then set the start time and end time. In the message node, you can define the type attribute as “fixed” or “offset”, then define the target_id, data, active_byte and frequency. Fixed mode denotes the target bytes can be modified to fixed value; Offset indicates adding offset value on the original value of target bytes (offset value can be minus).
89 |
90 | When you launch an automatic attack, there is a progress bar shows the attack progress.
91 |
92 | ### 2.4 CAN Matrix Convert
93 | CAN Matrix can convert can matrix file among different format.
94 | It is an open source project on GitHub. You can get more information on the website: https://github.com/ebroecker/canmatrix.
95 | ATG only call it and make it easy to use in window interface. With this tool, you can convert a can matrix file to an XML file which can be easy to load in an embedded IDS (Intrusion Detection System) as the detection rules.
96 | ### 2.5 Dataset Format Convert
97 | A Database file is not a general format of the dataset, so you can use this tool to convert the database file to a .CSV (Comma-Separated Values) file. You can share this file with other researchers in more general ways.
98 | ## 3 Note
99 |
(1) ATG is developed using python which is the popular language in analysis and AI research field. If you want to develop an IDS system by machine learning method, ATG is the best way to achieve your goal.
100 |
(2) For the CAN bus interface, USB2CAN is the only available interface in the beta version. To improve the performance, in the later version we will support more interfaces such as Kvaser, PCAN and so on.
101 |
(3)This open project will be published in [AReS’18](https://www.ares-conference.eu/accepted-papers/).
102 |
103 |
104 |
--------------------------------------------------------------------------------
/__init__.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TianTianlove/ATG-python/67024e24381de4a6c89e50ac2e774345a408961a/__init__.pyc
--------------------------------------------------------------------------------
/attack_config.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 2
5 | 4
6 |
7 |
8 |
9 | 5
10 | 6
11 |
12 | 20-53
13 |
14 |
15 |
16 |
17 | 7
18 | 8
19 |
20 | 20
21 | 01 12 21 31 00 12 33 12
22 | 20
23 |
24 |
25 |
26 |
27 | 8
28 | 40
29 |
30 | 318
31 | 01 12 21 31 00 12 33 12
32 | F0
33 | 89
34 |
35 |
36 |
37 |
38 | 60
39 | 70
40 |
41 | 318
42 | 13 14 02 01 21 23 21 11
43 | AA
44 | 21
45 |
46 |
47 |
48 |
49 | 80
50 | 110
51 |
52 | 150
53 | 00 00 00 00 21 23 21 11
54 | 0F
55 | 21
56 |
57 |
58 |
59 |
60 | 130
61 | 150
62 |
63 | 20-53
64 |
65 |
66 |
67 |
--------------------------------------------------------------------------------
/canInterface.py:
--------------------------------------------------------------------------------
1 | import wx
2 | import can
3 | from can.interfaces.usb2can.usb2canInterface import Usb2canBus
4 | import frame
5 | import time
6 | import threading
7 | from wx.lib.pubsub import pub
8 | import canmatrix.convert
9 | import sqlite3
10 | from tools import Tool
11 | import math
12 | import random
13 | import csv
14 | import matplotlib.pyplot as plt
15 | import string
16 | import re
17 | import xlrd
18 | import xml.dom.minidom as Dom
19 | # import xml.etree.ElementTree as ET
20 | import sched
21 | from threading import Timer
22 |
23 | # Manage the open status
24 | openFlag = False
25 | # Manage the tracing status
26 | isStarted = False
27 | isPlayerStarted = False
28 |
29 | # Check the Spoofing analysis
30 | isSpoofingAttackAnalysis = False
31 | isSpoofingAttacked = False
32 |
33 | isDoSAttacked = False
34 | isFuzzAttacked = False
35 |
36 | FuzzingAttackIDRangeStart = 0
37 | FuzzingAttackIDRangeEnd = 0
38 | FuzzingAttackData = [0, 0, 0, 0, 0, 0, 0, 0]
39 | FuzzingAttackID = 0
40 | Fuzzing_attack_mode = 1
41 | FuzzingAttackFre = 0.1
42 |
43 | Spoofing_attack_mode = 1
44 | SpoofingAttackID = 0
45 | SpoofingAttackFre = 100
46 | SpoofingAttackDOSelect = [0, 0, 0, 0, 0, 0, 0, 0]
47 | SpoofingAttackDOValue = [0, 0, 0, 0, 0, 0, 0, 0]
48 | SpoofingAttackActiveBit = 0x00
49 |
50 | AttackConfigCounter = 0
51 | AttackConfigTimer = None
52 | AttackConfigList = None
53 | AttackConfigNowMode = 1
54 | attack_gauge_run = None
55 |
56 | # 0 is normal mode message are Chronological, 1 the messages are fixed
57 | traceListMode = 0
58 | # interval time mode
59 | intervalTimeMode = False
60 |
61 | global_time = 0
62 | refresh_time = 0
63 |
64 | # Open the port
65 | def open_port(id, rate):
66 | global bus
67 | global openFlag
68 | bus = Usb2canBus(id, flags=0x00000008, serial=id, bitrate=rate)
69 | # identify the connect state by the return value
70 |
71 | if bus.handle == 0:
72 | print ("Open fail")
73 | openFlag = False
74 | wx.MessageBox("Failed to open device.", "Message", wx.OK | wx.ICON_INFORMATION)
75 | return
76 |
77 | else:
78 | openFlag = True
79 | print ("Open success")
80 | frame.m_buttonTest.Enable(enable=True)
81 | frame.m_button_attack_start.Enable(enable=True)
82 | frame.m_button_analysis1.Enable(enable=True)
83 | # frame.m_button_analysis2.Enable(enable=True)
84 | frame.m_buttonOpen.SetLabelText("Shutdown")
85 | frame.m_btn_start_tracing.Enable(enable=True)
86 | frame.m_btn_stop_tracing.Enable(enable=False)
87 | frame.m_btn_pause_tracing.Enable(enable=False)
88 | frame.m_btn_start_player.Enable(enable=True)
89 | frame.m_btn_stop_player.Enable(enable=False)
90 | frame.m_btn_pause_player.Enable(enable=False)
91 |
92 |
93 | # Send a htx message
94 | def send_msg(msg):
95 |
96 | if msg is None:
97 | msg = can.Message(arbitration_id=0x123,
98 | data=[1, 2, 3, 4, 5, 6, 7, 8]
99 | , extended_id=False
100 | , timestamp=refresh_time + int(time.clock()*1000)-global_time)
101 | else:
102 | msg.timestamp = refresh_time + int(time.clock()*1000)-global_time
103 |
104 | try:
105 | bus.send(msg)
106 | # print("Message sent on {}".format(bus.channel_info))
107 | except can.CanError:
108 | # print("Message NOT sent")
109 | pass
110 |
111 | if isStarted is True:
112 | wx.CallAfter(pub.sendMessage, "ut", msg=msg, type=2)
113 |
114 | # flexible increase sure that the submit event will be lunched period
115 |
116 | global logfile
117 | if logfile is not None:
118 | canid = msg.arbitration_id
119 | timestamp = msg.timestamp
120 | data = ' '.join(hex(x) for x in msg.data)
121 | attack_info = ""
122 |
123 | if isDoSAttacked is True:
124 | attack_info = "1"
125 | elif isFuzzAttacked is True:
126 | attack_info = "2"
127 | elif isSpoofingAttacked is True:
128 | attack_info = "3-" + hex(SpoofingAttackActiveBit)
129 |
130 | logfile.writemsg(timestamp, canid, data, "2," + "A_Info:" + attack_info)
131 |
132 |
133 | # Define shutdown the bus safe
134 | def shutdown():
135 | global openFlag
136 | global timer1, timer2, AttackConfigTimer, isDoSAttacked, isFuzzAttacked
137 | global isStarted, isPlayerStarted
138 | global canReader
139 | if isStarted:
140 | canReader.stop()
141 | isStarted = False
142 | if isPlayerStarted:
143 | canReader.stop()
144 | isPlayerStarted = False
145 |
146 | Usb2canBus.shutdown(bus)
147 | # close the timer
148 | if timer1:
149 | timer1.cancel()
150 | isDoSAttacked = False
151 | if timer2:
152 | timer2.cancel()
153 | isFuzzAttacked = False
154 | if AttackConfigTimer:
155 | AttackConfigTimer.cancel()
156 |
157 | frame.m_buttonTest.Enable(enable=False)
158 | frame.m_button_attack_start.Enable(enable=False)
159 | frame.m_button_analysis1.Enable(enable=False)
160 | # frame.m_button_analysis2.Enable(enable=False)
161 | frame.m_btn_start_tracing.Enable(enable=False)
162 | frame.m_btn_stop_tracing.Enable(enable=False)
163 | frame.m_btn_pause_tracing.Enable(enable=False)
164 | frame.m_btn_start_player.Enable(enable=False)
165 | frame.m_btn_stop_player.Enable(enable=False)
166 | frame.m_btn_pause_player.Enable(enable=False)
167 | frame.m_buttonOpen.SetLabelText("Open")
168 | openFlag = False
169 | print ("Close success")
170 |
171 |
172 | # Define Frame Class
173 | class CalcFrame(frame.MyFrame1):
174 | def __init__(self, parent):
175 | frame.MyFrame1.__init__(self, parent)
176 | self.count = 0
177 | self.display_list()
178 | pub.subscribe(self.update_trace_display, "ut")
179 | pub.subscribe(self.get_Spoofing_attack_analysis, "ufa")
180 |
181 | self.IDCountMap = {}
182 | self.ID2Packets = {}
183 | self.PeriodFlag = {}
184 | self.TimeIntervalMap = {}
185 | self.TimeLastIntervalMap = {}
186 | self.TimeStampMap = {}
187 | self.last_time_stamp = 0
188 | self.time_show_count = 0
189 |
190 | def OnExit(self, event):
191 | # event.Skip()
192 | if openFlag:
193 | shutdown()
194 | global canReader
195 | if canReader is not None:
196 | canReader.stop()
197 | self.Destroy()
198 |
199 | # Device control
200 | def clickOpen(self, event):
201 | if openFlag:
202 | shutdown()
203 | else:
204 | open_port(str(self.m_textID.Value), int(self.m_choice_BR.GetStringSelection()))
205 |
206 | def clickTest(self, event):
207 | send_msg(None)
208 |
209 | # DoS Attack control
210 | def onclick_attack_start(self, event):
211 |
212 | global Spoofing_attack_mode
213 | global SpoofingAttackID, SpoofingAttackFre
214 | global SpoofingAttackDOSelect, SpoofingAttackDOValue, SpoofingAttackActiveBit
215 | global isSpoofingAttacked
216 | global canReader
217 |
218 | if self.m_radioBtnDos.GetValue():
219 | self.m_radioBtnDos.Enable(enable=False)
220 | global timer1, timer2, isDoSAttacked
221 | timer1 = threading.Timer(0.05, send_attack)
222 | timer1.start()
223 | isDoSAttacked = True
224 |
225 | elif self.m_radioBtnFuzz.GetValue():
226 | self.m_radioBtnFuzz.Enable(enable=False)
227 | global timer2, isFuzzAttacked, FuzzingAttackIDRangeEnd, FuzzingAttackIDRangeStart
228 | timer2 = threading.Timer(1, fuzz_attack)
229 | timer2.start()
230 | time_range_text = self.m_textCtrl_FuzzID.GetValue()
231 | time_list = time_range_text.split(",")
232 | time_range_list = time_list[0].split("-")
233 | FuzzingAttackIDRangeStart = int(time_range_list[0], 16)
234 | FuzzingAttackIDRangeEnd = int(time_range_list[1], 16)
235 |
236 | isFuzzAttacked = True
237 |
238 | elif self.m_radioBtnSpoof.GetValue():
239 | SpoofingAttackID = long(self.m_listBox_spoof_attack.GetStringSelection().split(';')[0].replace("ECU_ID:", ""))
240 | temp = []
241 | temp.append(int(self.m_textCtrl_fixdata1.GetValue(), 16))
242 | temp.append(int(self.m_textCtrl_fixdata2.GetValue(), 16))
243 | temp.append(int(self.m_textCtrl_fixdata3.GetValue(), 16))
244 | temp.append(int(self.m_textCtrl_fixdata4.GetValue(), 16))
245 | temp.append(int(self.m_textCtrl_fixdata5.GetValue(), 16))
246 | temp.append(int(self.m_textCtrl_fixdata6.GetValue(), 16))
247 | temp.append(int(self.m_textCtrl_fixdata7.GetValue(), 16))
248 | temp.append(int(self.m_textCtrl_fixdata8.GetValue(), 16))
249 |
250 | if self.m_checkBox_a_fd.GetValue() is True:
251 | # self.SpoofingAttackMsg = can.Message(arbitration_id=self.SpoofingAttackID, data=[temp[0], temp[1]
252 | # , temp[2], temp[3], temp[4], temp[5], temp[6], temp[7]] , extended_id=False)
253 | Spoofing_attack_mode = 1
254 |
255 | elif self.m_checkBox_a_do.GetValue() is True:
256 | Spoofing_attack_mode = 2
257 |
258 | SpoofingAttackDOSelect[0] = int(self.m_checkBox_offset1.GetValue())
259 | SpoofingAttackDOSelect[1] = int(self.m_checkBox_offset2.GetValue())
260 | SpoofingAttackDOSelect[2] = int(self.m_checkBox_offset3.GetValue())
261 | SpoofingAttackDOSelect[3] = int(self.m_checkBox_offset4.GetValue())
262 | SpoofingAttackDOSelect[4] = int(self.m_checkBox_offset5.GetValue())
263 | SpoofingAttackDOSelect[5] = int(self.m_checkBox_offset6.GetValue())
264 | SpoofingAttackDOSelect[6] = int(self.m_checkBox_offset7.GetValue())
265 | SpoofingAttackDOSelect[7] = int(self.m_checkBox_offset8.GetValue())
266 |
267 | SpoofingAttackActiveBit = 0x00
268 | for i in range(0, 8):
269 | if SpoofingAttackDOSelect[i] is 1:
270 | SpoofingAttackDOValue[i] = temp[i]
271 | SpoofingAttackActiveBit = SpoofingAttackActiveBit | (0x01 << (7 - i))
272 | else:
273 | SpoofingAttackDOValue[i] = 0
274 |
275 | SpoofingAttackFre = 100 - self.m_slider_Spoofing_f.GetValue()
276 |
277 | canReader = CANPacketReader(None, None)
278 | canReader.start()
279 | isSpoofingAttacked = True
280 |
281 | self.m_radioBtnSpoof.Enable(enable=False)
282 |
283 | # print (str(self.SpoofingAttackFre))
284 | # print (SpoofingAttackID, self.SpoofingAttackMsg)
285 |
286 | elif self.m_radioBtnConfig.GetValue():
287 | self.m_radioBtnConfig.Enable(enable=False)
288 | do_attack_config(self.m_filePicker_config.GetPath())
289 |
290 | else:
291 | wx.MessageBox("Please select attack method!", "Message", wx.OK | wx.ICON_INFORMATION)
292 | return
293 |
294 | event.GetEventObject().Disable()
295 | self.m_button_attack_stop.Enable(enable=True)
296 | self.m_button_analysis1.Enable(enable=False)
297 |
298 | def onclick_attack_stop(self, event):
299 | self.m_button_attack_start.Enable(enable=True)
300 | self.m_button_attack_stop.Enable(enable=False)
301 | global timer1, timer2, isDoSAttacked, isSpoofingAttacked, isFuzzAttacked
302 |
303 | if self.m_radioBtnDos.GetValue():
304 | self.m_radioBtnDos.Enable(enable=True)
305 | timer1.cancel()
306 | isDoSAttacked = False
307 | elif self.m_radioBtnFuzz.GetValue():
308 | self.m_radioBtnFuzz.Enable(enable=True)
309 | timer2.cancel()
310 | isFuzzAttacked = False
311 | elif self.m_radioBtnSpoof.GetValue():
312 | self.m_radioBtnSpoof.Enable(enable=True)
313 | if isStarted:
314 | isSpoofingAttacked = False
315 | else:
316 | global canReader
317 | canReader.stop()
318 |
319 | elif self.m_radioBtnConfig.GetValue():
320 | self.m_radioBtnConfig.Enable(enable=True)
321 | global AttackConfigTimer, AttackConfigCounter
322 | AttackConfigTimer.cancel()
323 | AttackConfigCounter = 0
324 | if AttackConfigNowMode == 1:
325 | timer1.cancel()
326 | isDoSAttacked = False
327 | elif AttackConfigNowMode == 3:
328 | timer2.cancel()
329 | isFuzzAttacked = False
330 | elif AttackConfigNowMode == 2:
331 | if isStarted:
332 | isSpoofingAttacked = False
333 | else:
334 | global canReader
335 | canReader.stop()
336 | if attack_gauge_run:
337 | attack_gauge_run.stop()
338 | frame.set_gauge_value(0)
339 |
340 | self.m_button_analysis1.Enable(enable=True)
341 | # global canReader
342 | # canReader.stop()
343 | # self.m_button_analysis2.Enable(enable=True)
344 |
345 | def onclick_start_tracing(self, event):
346 | global canReader
347 | global isStarted
348 | # check if the threading is started
349 | if isStarted:
350 | canReader.resume()
351 | else:
352 | isStarted = True
353 | if self.m_cb_savedb.GetValue():
354 | canReader = CANPacketReader(1, self.m_dP_db.GetPath())
355 | elif self.m_cb_savelog.GetValue():
356 | canReader = CANPacketReader(2, self.m_dP_db.GetPath())
357 | else:
358 | canReader = CANPacketReader(0, self.m_dP_db.GetPath())
359 | canReader.start()
360 | self.m_btn_start_tracing.Enable(enable=False)
361 | self.m_btn_pause_tracing.Enable(enable=True)
362 | self.m_btn_stop_tracing.Enable(enable=True)
363 |
364 | def onclick_pause_tracing(self, event):
365 | global canReader
366 | canReader.pause()
367 | self.m_btn_start_tracing.Enable(enable=True)
368 | self.m_btn_pause_tracing.Enable(enable=False)
369 | self.m_btn_stop_tracing.Enable(enable=True)
370 |
371 | def onclick_stop_tracing(self, event):
372 | global canReader
373 | canReader.stop()
374 | global isStarted
375 | isStarted = False
376 | self.m_btn_start_tracing.Enable(enable=True)
377 | self.m_btn_pause_tracing.Enable(enable=False)
378 | self.m_btn_stop_tracing.Enable(enable=False)
379 |
380 | def onclick_start_play(self, event):
381 | if self.m_filePicker_player.GetPath() == "":
382 | wx.MessageBox("Please select an available file!", "Message", wx.OK | wx.ICON_INFORMATION)
383 | return
384 | global canPlayer
385 | global isPlayerStarted
386 | # check if the threading is started
387 | if isPlayerStarted:
388 | canPlayer.resume()
389 | else:
390 | if self.m_textCtrl_player_loop.GetValue() is None:
391 | canPlayer = CanPlayer(0, self.m_filePicker_player.GetPath())
392 | else:
393 | canPlayer = CanPlayer(int(self.m_textCtrl_player_loop.GetValue()), self.m_filePicker_player.GetPath())
394 | canPlayer.start()
395 | self.m_btn_start_player.Enable(enable=False)
396 | self.m_btn_pause_player.Enable(enable=True)
397 | self.m_btn_stop_player.Enable(enable=True)
398 |
399 | def onclick_pause_play(self, event):
400 | global canPlayer
401 | canPlayer.pause()
402 | self.m_btn_start_player.Enable(enable=True)
403 | self.m_btn_pause_player.Enable(enable=False)
404 | self.m_btn_stop_player.Enable(enable=True)
405 |
406 | def onclick_stop_play(self, event):
407 | global canPlayer
408 | canPlayer.stop()
409 | global isPlayerStarted
410 | isPlayerStarted = False
411 | self.m_btn_start_player.Enable(enable=True)
412 | self.m_btn_pause_player.Enable(enable=False)
413 | self.m_btn_stop_player.Enable(enable=False)
414 |
415 | def on_text_enter_player(self, event):
416 | s = self.m_textCtrl_player_loop.GetValue()
417 | if len(s) > 0 and len(s) <= 5 and re.match("\A[0-9]+\Z", s) is not None:
418 | return
419 | elif len(s) > 0 or len(s) > 5:
420 | self.m_textCtrl_player_loop.SetValue("")
421 | wx.MessageBox("Please enter a valid value!", "Message", wx.OK | wx.ICON_INFORMATION)
422 | else:
423 | return
424 |
425 | def onclick_convert(self, event):
426 | can_matrix_convert(self.m_cb_for_IDS.GetValue(), self.m_filePicker_matrix_imput.GetPath()
427 | , str(self.m_textCtrl_matrix_output_name.GetValue())
428 | , self.m_choice_matrix_output_format.GetStringSelection()
429 | , self.m_dirPicker_matrix_output_path.GetPath())
430 |
431 | def onclick_data_convert(self, event):
432 | can_data_convert(self.m_filePicker_data_imput.GetPath(), str(self.m_textCtrl_data_output_name.GetValue())
433 | , self.m_choice_data_output_format.GetStringSelection()
434 | , self.m_dirPicker_data_output_path.GetPath())
435 |
436 | def onclick_trace_clean_up(self, event):
437 | self.m_listCtrl1.DeleteAllItems()
438 |
439 | def onclick_choice_tracelist_mode(self, event):
440 | global traceListMode
441 | traceListMode = int(self.m_choice_tracelist_mode.GetSelection())
442 | # self.m_listCtrl1.SetItemText([1, 2, 3])
443 |
444 | def onclick_cb_trace_time_mode(self, event):
445 | global intervalTimeMode
446 | if self.m_cb_time_mode.Value:
447 | intervalTimeMode = True
448 | print "is interval mode"
449 | else:
450 | intervalTimeMode = False
451 | print "is not interval mode"
452 |
453 | def onclick_btn_Spoofing_attack(self, event):
454 | global canReader
455 | global isSpoofingAttackAnalysis
456 | if isSpoofingAttackAnalysis is False:
457 | self.m_button_analysis1.SetLabelText(" Stop ")
458 | isSpoofingAttackAnalysis = True
459 | if isStarted:
460 | canReader.resume()
461 | else:
462 | canReader = CANPacketReader(None, None)
463 | canReader.start()
464 | else:
465 | self.m_button_analysis1.SetLabelText("Analyze")
466 | isSpoofingAttackAnalysis = False
467 | canReader.stop()
468 | i = 0
469 | for key in self.PeriodFlag:
470 | if self.PeriodFlag[key] >= 5:
471 | i += 1
472 | # if there is at least one period message , we can lunch Spoofing attack
473 | if i >= 1:
474 | self.m_radioBtnSpoof.Enable(enable=True)
475 |
476 | def onclick_da_analye(self, event):
477 | dataset_analysis(self.m_filePicker_da_imput.GetPath())
478 |
479 | def onclick_da_generate(self, event):
480 | id_list = []
481 | select_item_num = self.m_listBox2.GetSelections()
482 | # get the select items ID
483 | for item in select_item_num:
484 | print select_item_num[0]
485 | select_item = self.m_listBox2.GetString(item)
486 | id_list.append(select_item.split(';')[0].replace("ID:", ""))
487 |
488 | dataset_analysis_generate_plot(1 ,self.m_filePicker_da_imput.GetPath(), id_list)
489 |
490 | def on_check_box_fd(self, event):
491 | self.m_checkBox_a_do.SetValue(False)
492 |
493 | def on_check_box_do(self, event):
494 | self.m_checkBox_a_fd.SetValue(False)
495 |
496 | # Scroll changed
497 | def on_Spoofing_fre_change(self, event):
498 | self.m_text_Spoofing_fv.SetLabelText(str(self.m_slider_Spoofing_f.GetValue()))
499 |
500 | def on_text_enter_at_fixd1(self, event):
501 | s = self.m_textCtrl_fixdata1.GetValue()
502 | if len(s) > 0 and len(s) <= 2 and re.match("\A[0-9a-fA-F]+\Z", s) is not None:
503 | return
504 | elif len(s) > 0 or len(s) > 2:
505 | self.m_textCtrl_fixdata1.SetValue("")
506 | wx.MessageBox("Please enter a valid hex value!", "Message", wx.OK | wx.ICON_INFORMATION)
507 | else:
508 | return
509 |
510 | def on_text_enter_at_fixd2(self, event):
511 | s = self.m_textCtrl_fixdata2.GetValue()
512 | if len(s) > 0 and len(s) <= 2 and re.match("\A[0-9a-fA-F]+\Z", s) is not None:
513 | return
514 | elif len(s) > 0 or len(s) > 2:
515 | self.m_textCtrl_fixdata2.SetValue("")
516 | wx.MessageBox("Please enter a valid hex value!", "Message", wx.OK | wx.ICON_INFORMATION)
517 | else:
518 | return
519 |
520 | def on_text_enter_at_fixd3(self, event):
521 | s = self.m_textCtrl_fixdata3.GetValue()
522 | if len(s) > 0 and len(s) <= 2 and re.match("\A[0-9a-fA-F]+\Z", s) is not None:
523 | return
524 | elif len(s) > 0 or len(s) > 2:
525 | self.m_textCtrl_fixdata3.SetValue("")
526 | wx.MessageBox("Please enter a valid hex value!", "Message", wx.OK | wx.ICON_INFORMATION)
527 | else:
528 | return
529 |
530 | def on_text_enter_at_fixd4(self, event):
531 | s = self.m_textCtrl_fixdata4.GetValue()
532 | if len(s) > 0 and len(s) <= 2 and re.match("\A[0-9a-fA-F]+\Z", s) is not None:
533 | return
534 | elif len(s) > 0 or len(s) > 2:
535 | self.m_textCtrl_fixdata4.SetValue("")
536 | wx.MessageBox("Please enter a valid hex value!", "Message", wx.OK | wx.ICON_INFORMATION)
537 | else:
538 | return
539 |
540 | def on_text_enter_at_fixd5(self, event):
541 | s = self.m_textCtrl_fixdata5.GetValue()
542 | if len(s) > 0 and len(s) <= 2 and re.match("\A[0-9a-fA-F]+\Z", s) is not None:
543 | return
544 | elif len(s) > 0 or len(s) > 2:
545 | self.m_textCtrl_fixdata5.SetValue("")
546 | wx.MessageBox("Please enter a valid hex value!", "Message", wx.OK | wx.ICON_INFORMATION)
547 | else:
548 | return
549 |
550 | def on_text_enter_at_fixd6(self, event):
551 | s = self.m_textCtrl_fixdata6.GetValue()
552 | if len(s) > 0 and len(s) <= 2 and re.match("\A[0-9a-fA-F]+\Z", s) is not None:
553 | return
554 | elif len(s) > 0 or len(s) > 2:
555 | self.m_textCtrl_fixdata6.SetValue("")
556 | wx.MessageBox("Please enter a valid hex value!", "Message", wx.OK | wx.ICON_INFORMATION)
557 | else:
558 | return
559 |
560 | def on_text_enter_at_fixd7(self, event):
561 | s = self.m_textCtrl_fixdata7.GetValue()
562 | if len(s) > 0 and len(s) <= 2 and re.match("\A[0-9a-fA-F]+\Z", s) is not None:
563 | return
564 | elif len(s) > 0 or len(s) > 2:
565 | self.m_textCtrl_fixdata7.SetValue("")
566 | wx.MessageBox("Please enter a valid hex value!", "Message", wx.OK | wx.ICON_INFORMATION)
567 | else:
568 | return
569 |
570 | def on_text_enter_at_fixd8(self, event):
571 | s = self.m_textCtrl_fixdata8.GetValue()
572 | if len(s) > 0 and len(s) <= 2 and re.match("\A[0-9a-fA-F]+\Z", s) is not None:
573 | return
574 | elif len(s) > 0 or len(s) > 2:
575 | self.m_textCtrl_fixdata8.SetValue("")
576 | wx.MessageBox("Please enter a valid hex value!", "Message", wx.OK | wx.ICON_INFORMATION)
577 | else:
578 | return
579 |
580 | def set_gauge_range(self, range1):
581 | self.m_gauge1.SetRange(range1)
582 |
583 | def set_gauge_value(self, value):
584 | self.m_gauge1.SetValue(value)
585 |
586 | # Display
587 | def display_list(self):
588 | self.m_listCtrl1.InsertColumn(1, 'Time', format=wx.LIST_FORMAT_CENTRE)
589 | self.m_listCtrl1.InsertColumn(2, 'ECU_ID', format=wx.LIST_FORMAT_CENTRE)
590 | self.m_listCtrl1.InsertColumn(3, 'Data', format=wx.LIST_FORMAT_CENTRE)
591 | self.m_listCtrl1.InsertColumn(4, 'Count', format=wx.LIST_FORMAT_CENTRE)
592 | self.m_listCtrl1.InsertColumn(5, 'Dir', format=wx.LIST_FORMAT_CENTRE)
593 |
594 | self.m_listCtrl1.SetColumnWidth(0, 80)
595 | self.m_listCtrl1.SetColumnWidth(1, 80)
596 | self.m_listCtrl1.SetColumnWidth(2, 300)
597 | self.m_listCtrl1.SetColumnWidth(3, 80)
598 | self.m_listCtrl1.SetColumnWidth(4, 80)
599 |
600 | def update_trace_display(self, msg, type):
601 | global intervalTimeMode
602 | my_msg = msg
603 | # set the count in Dic
604 | # t = time.clock()
605 | timestamp = my_msg.timestamp
606 |
607 | idtemp = msg.arbitration_id
608 | idStr = hex(idtemp).replace('L', '')
609 | payload = ' '.join(hex(x) for x in msg.data)
610 | # print time.clock()-t
611 |
612 | if type == 2:
613 | # self.m_listCtrl1.Append([timestamp, idStr, payload, "", "TX"])
614 | return
615 |
616 | # Change the count
617 | if not self.IDCountMap.has_key(idStr):
618 | self.IDCountMap[idStr] = 1
619 | else:
620 | self.IDCountMap[idStr] += 1
621 |
622 | # check the show mode
623 | if intervalTimeMode is False and traceListMode == 0:
624 | # insert the message into the listview
625 |
626 | self.m_listCtrl1.Append([timestamp, idStr, payload,"","RX"])
627 | self.m_listCtrl1.EnsureVisible(self.m_listCtrl1.GetItemCount() - 1 if self.m_listCtrl1.GetItemCount() > 0 else 0)
628 |
629 | # check the show mode
630 | if intervalTimeMode is True and traceListMode == 0:
631 | # insert the message into the listview
632 | self.m_listCtrl1.Append([-1 if self.last_time_stamp == 0 else timestamp-self.last_time_stamp, idStr, payload,"","RX"])
633 | self.m_listCtrl1.EnsureVisible(
634 | self.m_listCtrl1.GetItemCount() - 1 if self.m_listCtrl1.GetItemCount() > 0 else 0)
635 | self.last_time_stamp = timestamp
636 |
637 | elif intervalTimeMode is True and traceListMode == 1:
638 | if not self.TimeIntervalMap.has_key(idStr):
639 | self.TimeStampMap[idStr] = timestamp
640 | self.TimeIntervalMap[idStr] = -1
641 | else:
642 | self.TimeIntervalMap[idStr] = timestamp - self.TimeStampMap[idStr]
643 | self.TimeStampMap[idStr] = timestamp
644 |
645 | self.ID2Packets[idStr] = payload
646 |
647 | self.time_show_count += int(timestamp - self.last_time_stamp) / 10 + 1
648 | self.last_time_stamp = timestamp
649 |
650 | if self.time_show_count >= 250:
651 | self.time_show_count = 0
652 | self.m_listCtrl1.DeleteAllItems()
653 | for key in self.TimeIntervalMap:
654 | self.m_listCtrl1.Append([self.TimeIntervalMap[key], key, self.ID2Packets[key], self.IDCountMap[key], "RX"])
655 |
656 | elif intervalTimeMode is False and traceListMode == 1:
657 | if not self.TimeIntervalMap.has_key(idStr):
658 | self.TimeStampMap[idStr] = timestamp
659 | self.TimeIntervalMap[idStr] = -1
660 | else:
661 | self.TimeIntervalMap[idStr] = timestamp - self.TimeStampMap[idStr]
662 | self.TimeStampMap[idStr] = timestamp
663 |
664 | self.ID2Packets[idStr] = payload
665 |
666 | self.time_show_count += int(timestamp - self.last_time_stamp) / 10 + 1
667 | self.last_time_stamp = timestamp
668 |
669 | if self.time_show_count >= 500:
670 | self.time_show_count = 0
671 | self.m_listCtrl1.DeleteAllItems()
672 | for key in self.TimeIntervalMap:
673 | self.m_listCtrl1.Append([self.TimeStampMap[key], key, self.ID2Packets[key], self.IDCountMap[key], "RX"])
674 |
675 | else:
676 | pass
677 |
678 | def get_Spoofing_attack_analysis(self, msg):
679 | global intervalTimeMode
680 | # my_msg = msg
681 | # set the count in Dic
682 |
683 | timestamp = msg.timestamp
684 | idtemp = msg.arbitration_id
685 |
686 | idStr = str(idtemp)
687 | # payload = ' '.join(hex(x) for x in msg.data)
688 | # if get target messages, then send the attack messages
689 | if isSpoofingAttacked:
690 | if idtemp == SpoofingAttackID and random.randint(0, 100) > SpoofingAttackFre:
691 | if Spoofing_attack_mode is 1:
692 | for i in range(0, len(msg.data)):
693 | if SpoofingAttackDOSelect[i] is 1:
694 | msg.data[i] = SpoofingAttackDOValue[i]
695 | if msg.data[i] > 0xff:
696 | msg.data[i] = 0xff
697 | elif Spoofing_attack_mode is 2:
698 | for i in range(0, len(msg.data)):
699 | msg.data[i] += SpoofingAttackDOValue[i]
700 | if msg.data[i] > 0xff:
701 | msg.data[i] = 0xff
702 | send_msg(msg)
703 | # print ("log2")
704 | return
705 |
706 | # Change the count
707 | if not self.IDCountMap.has_key(idStr):
708 | self.IDCountMap[idStr] = 1
709 | self.PeriodFlag[idStr] = 0
710 | else:
711 | self.IDCountMap[idStr] += 1
712 |
713 | if not self.TimeIntervalMap.has_key(idStr):
714 | self.TimeStampMap[idStr] = timestamp
715 | self.TimeIntervalMap[idStr] = -1
716 | self.TimeLastIntervalMap[idStr] = -1
717 | else:
718 | self.TimeIntervalMap[idStr] = timestamp - self.TimeStampMap[idStr]
719 | self.TimeStampMap[idStr] = timestamp
720 | # if the contiguous messages interval is in a very min range
721 | if self.TimeLastIntervalMap is not -1 and math.fabs(self.TimeIntervalMap[idStr] - self.TimeLastIntervalMap[idStr]) < 10:
722 | self.PeriodFlag[idStr] += 1
723 | if self.PeriodFlag[idStr] >= 5:
724 | self.PeriodFlag[idStr] = 5
725 | else:
726 | self.PeriodFlag[idStr] -= 1
727 | if self.PeriodFlag[idStr] <= 0:
728 | self.PeriodFlag[idStr] = 0
729 |
730 | self.TimeLastIntervalMap[idStr] = self.TimeIntervalMap[idStr]
731 |
732 | self.time_show_count += int(timestamp - self.last_time_stamp) / 10 + 1
733 | self.last_time_stamp = timestamp
734 |
735 | if self.time_show_count >= 250:
736 | self.time_show_count = 0
737 | self.m_listBox_spoof_attack.Clear()
738 | for key in self.TimeIntervalMap:
739 | self.m_listBox_spoof_attack.Append("ECU_ID:"+key+";Time:"+str(self.TimeIntervalMap[key])+";IF:"
740 | + str(self.PeriodFlag[key]))
741 |
742 |
743 | # DoS Attack send message
744 | def send_attack():
745 | # t=msg
746 | global timer1, isDoSAttacked
747 | msg = can.Message(arbitration_id=0x0,
748 | data=[0x0, 0x0],
749 | extended_id=False)
750 | send_msg(msg)
751 | if isDoSAttacked is True:
752 | timer1 = threading.Timer(0.0005, send_attack)
753 | timer1.start()
754 |
755 |
756 | # DoS Attack send message
757 | def fuzz_attack():
758 | # t=msg
759 | global timer2, isFuzzAttacked, FuzzingAttackIDRangeStart, FuzzingAttackIDRangeEnd,\
760 | FuzzingAttackData, FuzzingAttackFre, Fuzzing_attack_mode, FuzzingAttackID
761 |
762 | data = []
763 | if Fuzzing_attack_mode == 1:
764 | r_id = random.randint(FuzzingAttackIDRangeStart, FuzzingAttackIDRangeEnd)
765 | for i in range(0, 8):
766 | data.append(random.randint(0, 255))
767 |
768 | msg = can.Message(arbitration_id=r_id,
769 | data=data,
770 | extended_id=False)
771 | t = random.randint(20, 100) / 1000
772 | send_msg(msg)
773 |
774 | elif Fuzzing_attack_mode == 2:
775 | msg = can.Message(arbitration_id=FuzzingAttackID,
776 | data=FuzzingAttackData,
777 | extended_id=False)
778 | t = FuzzingAttackFre
779 | send_msg(msg)
780 |
781 | if isFuzzAttacked is True:
782 | timer2 = threading.Timer(t, fuzz_attack)
783 | timer2.start()
784 |
785 |
786 | def do_attack_config(path):
787 | global AttackConfigTimer, AttackConfigCounter, AttackConfigList, attack_gauge_run
788 | AttackConfigList = Tool.getlist(path)
789 | AttackConfigCounter = 0
790 | AttackConfigTimer = Timer(AttackConfigList[AttackConfigCounter].start_t, set_and_start
791 | , (AttackConfigList[AttackConfigCounter],))
792 | AttackConfigTimer.start()
793 | #set A gauge
794 | gauge_total_time = AttackConfigList[len(AttackConfigList)-1].end_t - AttackConfigList[AttackConfigCounter].start_t
795 | frame.set_gauge_range(gauge_total_time)
796 | attack_gauge_run = GaugeRun(gauge_total_time)
797 | attack_gauge_run.start()
798 |
799 |
800 | def set_and_start(attack_info):
801 |
802 | global AttackConfigTimer, AttackConfigNowMode
803 | global SpoofingAttackID, SpoofingAttackFre, SpoofingAttackActiveBit
804 | global SpoofingAttackDOSelect, SpoofingAttackDOValue
805 | global AttackConfigList
806 | global isSpoofingAttacked
807 | global Spoofing_attack_mode
808 | global canReader
809 |
810 | # DoS attack
811 | if attack_info.attack_type == 1:
812 | global timer1, isDoSAttacked
813 | timer1 = threading.Timer(0.05, send_attack)
814 | timer1.start()
815 | isDoSAttacked = True
816 | AttackConfigNowMode = 1
817 | print "set and start DoS"
818 |
819 | # Fuzz attack
820 | elif attack_info.attack_type == 3:
821 | global timer2, isFuzzAttacked, FuzzingAttackIDRangeStart, \
822 | FuzzingAttackIDRangeEnd, Fuzzing_attack_mode, FuzzingAttackID, FuzzingAttackFre, FuzzingAttackData
823 |
824 | Fuzzing_attack_mode = attack_info.msg_type
825 | if Fuzzing_attack_mode == 1:
826 | time_list = attack_info.msg_range.split(",")
827 | time_range_list = time_list[0].split("-")
828 | FuzzingAttackIDRangeStart = int(time_range_list[0], 16)
829 | FuzzingAttackIDRangeEnd = int(time_range_list[1], 16)
830 |
831 | elif Fuzzing_attack_mode == 2:
832 | FuzzingAttackID = attack_info.msg_id
833 | FuzzingAttackFre = attack_info.msg_fre * 0.001
834 | for i in range(0, 8):
835 | FuzzingAttackData[i] = int(attack_info.msg_data[i], 16)
836 |
837 | timer2 = threading.Timer(0.05, fuzz_attack)
838 | timer2.start()
839 | isFuzzAttacked = True
840 | AttackConfigNowMode = 3
841 | print "set and start Fuzz"
842 |
843 | # Spoofing attack
844 | elif attack_info.attack_type == 2:
845 | SpoofingAttackID = long(attack_info.msg_id)
846 | temp = []
847 | for i in range(0, 8):
848 | temp.append(int(attack_info.msg_data[i], 16))
849 |
850 | Spoofing_attack_mode = attack_info.msg_type
851 |
852 | for i in range(0, 8):
853 | SpoofingAttackDOSelect[i] = attack_info.msg_active_bit >> (7-i) & 0x01
854 |
855 | SpoofingAttackActiveBit = attack_info.msg_active_bit
856 |
857 | for i in range(0, 8):
858 | if SpoofingAttackDOSelect[i] == 1:
859 | SpoofingAttackDOValue[i] = temp[i]
860 | else:
861 | SpoofingAttackDOValue[i] = 0
862 |
863 | SpoofingAttackFre = 100 - attack_info.msg_fre
864 |
865 | if canReader is None:
866 | canReader = CANPacketReader(None, None)
867 | canReader.start()
868 | elif canReader.runstate == 0 or canReader.runstate == 2:
869 | canReader.resume()
870 | elif canReader.runstate == 1:
871 | pass
872 |
873 | isSpoofingAttacked = True
874 | AttackConfigNowMode = 2
875 |
876 | print "set and start Spoofing"
877 |
878 | AttackConfigTimer = Timer(AttackConfigList[AttackConfigCounter].end_t
879 | - AttackConfigList[AttackConfigCounter].start_t, end_and_wait
880 | , ())
881 | AttackConfigTimer.start()
882 |
883 |
884 | def end_and_wait():
885 | global timer1, timer2, AttackConfigTimer, AttackConfigNowMode, AttackConfigCounter
886 | global AttackConfigList
887 | global isDoSAttacked, isFuzzAttacked
888 |
889 | if AttackConfigNowMode == 1:
890 | timer1.cancel()
891 | isDoSAttacked = False
892 | print "Stop DoS"
893 | elif AttackConfigNowMode == 3:
894 | timer2.cancel()
895 | isFuzzAttacked = False
896 | print "Stop Fuzz"
897 | elif AttackConfigNowMode == 2:
898 | global isSpoofingAttacked
899 | isSpoofingAttacked = False
900 | print "Stop Spoofing"
901 |
902 | AttackConfigCounter += 1
903 | if AttackConfigCounter < len(AttackConfigList):
904 | AttackConfigTimer = Timer(AttackConfigList[AttackConfigCounter].start_t
905 | - AttackConfigList[AttackConfigCounter-1].end_t, set_and_start
906 | , (AttackConfigList[AttackConfigCounter],))
907 | AttackConfigTimer.start()
908 | else:
909 | frame.onclick_attack_stop(None)
910 | AttackConfigTimer.cancel()
911 |
912 |
913 | # CAN packetReader
914 | class GaugeRun(threading.Thread):
915 | Debug = 1
916 |
917 | def __init__(self, total_time):
918 | # threading.Thread.__init__(self)
919 | super(GaugeRun, self).__init__()
920 | self.__flag = threading.Event() # To add flag to a stop
921 | self.__flag.set() # set True
922 | self.__running = threading.Event() # set stop
923 | self.__running.set()
924 | self.count = 0
925 | self.end_t = total_time
926 |
927 | def run(self):
928 | while self.__running.isSet():
929 | time.sleep(1)
930 | self.count += 1
931 | frame.set_gauge_value(self.count)
932 | if self.count == self.end_t:
933 | self.stop()
934 |
935 | def pause(self):
936 | self.__flag.clear()
937 |
938 | def resume(self):
939 | self.__flag.set()
940 |
941 | def stop(self):
942 | self.__flag.set()
943 | self.__running.clear()
944 |
945 |
946 | # CAN packetReader
947 | class CANPacketReader(threading.Thread):
948 | Debug = 1
949 |
950 | runstate = 0
951 |
952 | def __init__(self, is_save, log_db):
953 | # threading.Thread.__init__(self)
954 | super(CANPacketReader, self).__init__()
955 | self.__flag = threading.Event() # To add flag to a stop
956 | self.__flag.set() # set True
957 | self.__running = threading.Event() # set stop
958 | self.__running.set() # runset true
959 | self.LogDB = log_db
960 | self.IsSave = is_save
961 | global logfile
962 | logfile = None
963 |
964 | def run(self):
965 | global global_time, refresh_time
966 | self.runstate = 1
967 | i = 0
968 | j = 0
969 | data1 = []
970 | sql = 'INSERT INTO Packets(Timestamp, ECU_ID, Data) VALUES(?,?,?);'
971 | last_time_stamp = 0
972 |
973 | if self.IsSave == 1 and self.LogDB:
974 | conn = sqlite3.connect(self.LogDB+"\\mydata.db")
975 | cursor = conn.cursor()
976 | try:
977 | # create table
978 | cursor.execute(
979 | "CREATE TABLE Packets(id INTEGER PRIMARY KEY AUTOINCREMENT, Timestamp INTEGER, ECU_ID INTEGER, Data VARCHAR(15))")
980 | except:
981 | pass
982 |
983 | if self.IsSave == 2 and self.LogDB:
984 | # os.mknod(self.LogDB+"\\mydata.txt")
985 | # self.logf = open(self.LogDB+"\\mydata.log", 'w')
986 | global logfile
987 | logfile = File(self.LogDB)
988 |
989 | if self.Debug > 0:
990 | fd = None
991 | try:
992 | fd = open("raw_packets.log", "wb")
993 | except:
994 | import traceback
995 | traceback.print_exc()
996 |
997 | while openFlag is True and self.__running.isSet():
998 | self.__flag.wait()
999 | global bus
1000 | msg = Usb2canBus.recv(bus, timeout=None)
1001 | if msg is not None:
1002 | # if Spoofing attack is started
1003 | if isSpoofingAttackAnalysis or isSpoofingAttacked:
1004 | wx.CallAfter(pub.sendMessage, "ufa", msg=msg)
1005 |
1006 | if isStarted is True and self.IsSave == 0:
1007 | wx.CallAfter(pub.sendMessage, "ut", msg=msg, type=1)
1008 |
1009 | # current_time = time.time()
1010 | # save msg to sqlite
1011 | if self.IsSave == 1:
1012 | canid = msg.arbitration_id
1013 | timestamp = msg.timestamp
1014 | data = ' '.join(hex(x) for x in msg.data)
1015 | # flexible increase sure that the submit event will be lunched period
1016 | i += int(timestamp-last_time_stamp)/10 + 1
1017 | last_time_stamp = timestamp
1018 | data1.append((timestamp, canid, data))
1019 | if i >= 500:
1020 | i = 0
1021 | try:
1022 | sql = sql[:-1] + ';'
1023 | cursor.executemany(sql, data1)
1024 | conn.commit()
1025 | except:
1026 | import traceback
1027 | if self.Debug > 0:
1028 | if fd is not None:
1029 | fd.write("Exception:" + traceback.format_exc())
1030 | else:
1031 | traceback.print_exc()
1032 | data1 = []
1033 |
1034 | if self.IsSave == 2:
1035 | # start_time = time.clock()
1036 | canid = msg.arbitration_id
1037 | timestamp = msg.timestamp
1038 | data = ' '.join(hex(x) for x in msg.data)
1039 | # flexible increase sure that the submit event will be lunched period
1040 | global logfile
1041 | logfile.writemsg(timestamp, canid, data, "1")
1042 |
1043 | timestamp = msg.timestamp
1044 | j += int(timestamp - last_time_stamp) / 10 + 1
1045 | last_time_stamp = timestamp
1046 | if j >= 500:
1047 | j = 0
1048 | global_time = int(time.clock()*1000)
1049 | refresh_time = timestamp
1050 |
1051 | def pause(self):
1052 | self.runstate = 2
1053 | self.__flag.clear()
1054 |
1055 | def resume(self):
1056 | self.runstate = 1
1057 | self.__flag.set()
1058 |
1059 | def stop(self):
1060 | self.runstate = 0
1061 | self.__flag.set()
1062 | self.__running.clear()
1063 | global logfile
1064 | if logfile is not None:
1065 | logfile.close_file()
1066 |
1067 |
1068 | class CanPlayer(threading.Thread):
1069 | Debug = 1
1070 |
1071 | def __init__(self, loop, file):
1072 | # threading.Thread.__init__(self)
1073 | super(CanPlayer, self).__init__()
1074 | self.__flag = threading.Event() # To add flag to a stop
1075 | self.__flag.set() # set True
1076 | self.__running = threading.Event() # set stop
1077 | self.__running.set() # runset true
1078 | self.LogDB = file
1079 | self.loop = loop
1080 | self.logf = None
1081 |
1082 | def run(self):
1083 | global isPlayerStarted
1084 | isPlayerStarted = True
1085 |
1086 | if self.LogDB:
1087 | self.logf = open(self.LogDB, 'r')
1088 |
1089 | count = 0
1090 |
1091 | while openFlag is True and self.__running.isSet():
1092 | self.__flag.wait()
1093 | global bus
1094 | time_stamp = 0
1095 |
1096 | for i in range(0, self.loop):
1097 | self.logf = open(self.LogDB, 'r')
1098 | for line in self.logf:
1099 |
1100 | data = line.split(",")
1101 | time_st = long(data[0].replace("Time:", ""))
1102 | id_my = int(data[1].replace("ID:", ""))
1103 | datastr = data[2].replace("Data:", "")
1104 |
1105 | if time_stamp > 0:
1106 | slp = time_st - time_stamp
1107 | if slp < 0:
1108 | slp = 0
1109 | else:
1110 | slp = 0
1111 |
1112 | time_stamp = time_st
1113 |
1114 | data_temp = []
1115 | i = 0
1116 | for s in datastr.split(" "):
1117 | data_temp.append(int(s, 16))
1118 | i += 1
1119 | msg = can.Message(arbitration_id=id_my,
1120 | data=data_temp,
1121 | extended_id=False)
1122 | try:
1123 | bus.send(msg)
1124 | except can.CanError:
1125 | pass
1126 |
1127 | if slp == 0:
1128 | pass
1129 | elif slp == 1:
1130 | temp = time.clock()
1131 | wx.MilliSleep(1)
1132 | print time.clock() - temp
1133 | elif slp > 1:
1134 | time.sleep(slp * 0.001)
1135 |
1136 | self.logf.close()
1137 |
1138 | self.stop()
1139 | global isPlayerStarted
1140 | isPlayerStarted = False
1141 | frame.m_btn_start_player.Enable(enable=True)
1142 | frame.m_btn_pause_player.Enable(enable=False)
1143 | frame.m_btn_stop_player.Enable(enable=False)
1144 |
1145 | def pause(self):
1146 | self.__flag.clear()
1147 |
1148 | def resume(self):
1149 | self.__flag.set()
1150 |
1151 | def stop(self):
1152 | self.__flag.set()
1153 | self.__running.clear()
1154 | self.logf.close()
1155 |
1156 |
1157 | # CanMatrix Convert
1158 | def can_matrix_convert(mode, input_file, output_file_name, out_file_format, output_file_path):
1159 | if mode is False:
1160 | extent = Tool.GetFileNameAndExt(input_file)
1161 | if input_file == '':
1162 | wx.MessageBox("Please select file!", "Message", wx.OK | wx.ICON_INFORMATION)
1163 | return
1164 | if out_file_format == '':
1165 | wx.MessageBox("Please select file!", "Message", wx.OK | wx.ICON_INFORMATION)
1166 | return
1167 | if output_file_path == '':
1168 | wx.MessageBox("Please input the path!", "Message", wx.OK | wx.ICON_INFORMATION)
1169 | return
1170 | if extent == out_file_format:
1171 | wx.MessageBox("Convert format must be different!", "Message", wx.OK | wx.ICON_INFORMATION)
1172 | return
1173 | output = "%s\\%s%s" % (output_file_path, output_file_name, out_file_format)
1174 | canmatrix.convert.convert(input_file, output)
1175 | else:
1176 | if input_file == '':
1177 | wx.MessageBox("Please select file!", "Message", wx.OK | wx.ICON_INFORMATION)
1178 | return
1179 | # if out_file_format is not ".xml":
1180 | # wx.MessageBox("Please select file!", "Message", wx.OK | wx.ICON_INFORMATION)
1181 | # return
1182 | # if output_file_path == '':
1183 | # wx.MessageBox("Please input the path!", "Message", wx.OK | wx.ICON_INFORMATION)
1184 | # return
1185 | output = "%s\\%s%s" % (output_file_path, output_file_name, ".xml")
1186 | data = open_excel(input_file)
1187 | table = data.sheets()[0]
1188 | nrows = table.nrows
1189 | ncols = table.ncols
1190 | colnames = table.row_values(0)
1191 | list = []
1192 | for rownum in range(1, nrows):
1193 | row = table.row_values(rownum)
1194 | if row:
1195 | app = {}
1196 | for i in range(0, 3):
1197 | app[colnames[i]] = row[i]
1198 | if len(list) > 1:
1199 | if app != list[len(list)-1]:
1200 | list.append(app)
1201 | else:
1202 | list.append(app)
1203 |
1204 | generate_xml(list, output)
1205 |
1206 | return list
1207 |
1208 |
1209 | def generate_xml(list, outfile):
1210 | doc = Dom.Document()
1211 | root_node = doc.createElement("elements")
1212 | root_node.setAttribute("name", "pdus")
1213 | doc.appendChild(root_node)
1214 |
1215 | for item in list:
1216 | book_node = doc.createElement("pdu")
1217 |
1218 | book_name_node = doc.createElement("id")
1219 | book_name_value = doc.createTextNode(item["ID"])
1220 | book_name_node.appendChild(book_name_value)
1221 | book_node.appendChild(book_name_node)
1222 |
1223 | book_author_node = doc.createElement("period")
1224 | book_author_value = doc.createTextNode(str(item["Cycle Time [ms]"]))
1225 | book_author_node.appendChild(book_author_value)
1226 | book_node.appendChild(book_author_node)
1227 |
1228 | book_author_node = doc.createElement("frame_name")
1229 | book_author_value = doc.createTextNode(item["Frame Name"])
1230 | book_author_node.appendChild(book_author_value)
1231 | book_node.appendChild(book_author_node)
1232 |
1233 | root_node.appendChild(book_node)
1234 |
1235 | f = open(outfile, "w")
1236 | f.write(doc.toprettyxml(indent="\t", newl="\n", encoding="utf-8"))
1237 | f.close()
1238 |
1239 |
1240 | def open_excel(file):
1241 | try:
1242 | data = xlrd.open_workbook(file)
1243 | return data
1244 | except Exception, e:
1245 | print str(e)
1246 |
1247 |
1248 | def dataset_analysis_generate_plot(mode,input_file, id_set):
1249 | if mode is 1:
1250 | for j in range(0, len(id_set)):
1251 | print (j,len(id_set))
1252 | time_step = []
1253 | time_stamp = []
1254 | with open(input_file, 'rb') as csvfile:
1255 | spamreader = csv.reader(csvfile)
1256 | i = 0
1257 | while True:
1258 | try:
1259 | list_temp = spamreader.next()
1260 | if list_temp is not None:
1261 | if list_temp[1] == id_set[j]:
1262 | if i is 0:
1263 | time_stamp.append(string.atof(list_temp[0]))
1264 | else:
1265 | k = string.atof(list_temp[0])
1266 | l = string.atof(time_stamp[len(time_step) - 1])
1267 | time_stamp.append(string.atof(list_temp[0]))
1268 | m = k - l
1269 | time_step.append(m)
1270 | i += 1
1271 |
1272 | except StopIteration:
1273 | break
1274 | if j == 0:
1275 | plt.plot(range(0, len(time_step), 1), time_step , 'go')
1276 | elif j == 1:
1277 | plt.plot(range(0, len(time_step), 1), time_step, 'ro')
1278 |
1279 | plt.ylabel("Interval (ms)")
1280 | plt.xlabel("count")
1281 |
1282 | # plt.axis([0, 6, 0, 20])
1283 | plt.show()
1284 | else:
1285 | return
1286 |
1287 |
1288 | def dataset_analysis(input_file):
1289 | analysis_result = {}
1290 | sum = 0
1291 | if input_file == '':
1292 | wx.MessageBox("Please select file!", "Message", wx.OK | wx.ICON_INFORMATION)
1293 | return
1294 |
1295 | with open(input_file, 'rb') as csvfile:
1296 | spamreader = csv.reader(csvfile)
1297 | while True:
1298 | try:
1299 | list_temp = spamreader.next()
1300 | if list_temp is not None:
1301 | id = list_temp[1]
1302 | if not analysis_result.has_key(id):
1303 | analysis_result[id] = 1
1304 | else:
1305 | analysis_result[id] += 1
1306 | except StopIteration:
1307 | break
1308 |
1309 | if analysis_result is not None:
1310 | frame.m_listBox2.Clear()
1311 | for key in analysis_result:
1312 | frame.m_listBox2.Append("ID:"+key+"; Count:"+str(analysis_result[key]))
1313 | sum += analysis_result[key]
1314 | print sum
1315 |
1316 |
1317 | # Data Convert
1318 | def can_data_convert(input_file, output_file_name, out_file_format, output_file_path):
1319 | extent = Tool.GetFileNameAndExt(input_file)
1320 | if input_file == '':
1321 | wx.MessageBox("Please select file!", "Message", wx.OK | wx.ICON_INFORMATION)
1322 | return
1323 | if out_file_format == '':
1324 | wx.MessageBox("Please select file!", "Message", wx.OK | wx.ICON_INFORMATION)
1325 | return
1326 | if output_file_path == '':
1327 | wx.MessageBox("Please input the path!", "Message", wx.OK | wx.ICON_INFORMATION)
1328 | return
1329 | if extent == out_file_format:
1330 | wx.MessageBox("Convert format must be different!", "Message", wx.OK | wx.ICON_INFORMATION)
1331 | return
1332 | output = "%s\\%s%s" % (output_file_path, output_file_name, out_file_format)
1333 |
1334 | with sqlite3.connect(input_file) as connection:
1335 | csvWriter = csv.writer(open(output, "w"))
1336 | c = connection.cursor()
1337 | rows = c.execute("SELECT * FROM Packets")
1338 | t = time.time()
1339 | for x in rows:
1340 | csvWriter.writerow(x)
1341 | print time.time()-t
1342 |
1343 |
1344 | class File():
1345 | def __init__(self, path):
1346 | # self.path = path
1347 | self.logfile = open(path+"\\mydata5.log", 'w')
1348 |
1349 | def writemsg(self, timestamp, canid, data, dir):
1350 | self.logfile.write("Time:" + str(timestamp) + ",ID:" + str(canid) + ",Data:" + data + ",Dir:"+ dir + '\n')
1351 |
1352 | def close_file(self):
1353 | self.logfile.close()
1354 |
1355 | app = wx.App()
1356 | frame = CalcFrame(None)
1357 | # Define the bus instance
1358 | bus = None
1359 | canReader = None
1360 | canPlayer = None
1361 | logfile = None
1362 | timer1 = None
1363 | timer2 = None
1364 | timerSpoofing = None
1365 | frame.Show(True)
1366 | # start the applications
1367 | app.MainLoop()
1368 |
--------------------------------------------------------------------------------
/canMatrixTest.py:
--------------------------------------------------------------------------------
1 | import sys
2 | import canmatrix.convert
3 |
4 | print("hello world!")
5 |
6 | sys.path.append("E:\dbcfile")
7 | f = open("E:\dbcfile\kest.txt", "r")
8 | while True:
9 | line = f.readline()
10 | print(line)
11 | if line:
12 | pass # do something here
13 | else:
14 | break
15 | f.close()
16 |
17 | canmatrix.convert.convert('E:\dbcfile\\BC.dbc', 'E:\dbcfile\\target2.xls')
18 |
19 |
--------------------------------------------------------------------------------
/frame.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | ###########################################################################
4 | ## Python code generated with wxFormBuilder (version Dec 21 2016)
5 | ## http://www.wxformbuilder.org/
6 | ##
7 | ## PLEASE DO "NOT" EDIT THIS FILE!
8 | ###########################################################################
9 |
10 | import wx
11 | import wx.xrc
12 |
13 |
14 | ###########################################################################
15 | ## Class MyFrame1
16 | ###########################################################################
17 |
18 | class MyFrame1(wx.Frame):
19 | def __init__(self, parent):
20 | wx.Frame.__init__(self, parent, id=wx.ID_ANY, title=u"ATG", pos=wx.DefaultPosition, size=wx.Size(903, 667),
21 | style=wx.DEFAULT_FRAME_STYLE | wx.TAB_TRAVERSAL)
22 |
23 | self.SetSizeHintsSz(wx.DefaultSize, wx.DefaultSize)
24 |
25 | self.m_menubar1 = wx.MenuBar(0)
26 | self.m_menu1 = wx.Menu()
27 | self.m_menubar1.Append(self.m_menu1, u"File")
28 |
29 | self.m_menu2 = wx.Menu()
30 | self.m_menu11 = wx.Menu()
31 | self.m_menu2.AppendSubMenu(self.m_menu11, u"About")
32 |
33 | self.m_menubar1.Append(self.m_menu2, u"Help")
34 |
35 | self.SetMenuBar(self.m_menubar1)
36 |
37 | bSizer2 = wx.BoxSizer(wx.VERTICAL)
38 |
39 | self.m_splitter2 = wx.SplitterWindow(self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.SP_3D)
40 | self.m_splitter2.Bind(wx.EVT_IDLE, self.m_splitter2OnIdle)
41 |
42 | self.m_splitter2.SetBackgroundColour(wx.SystemSettings.GetColour(wx.SYS_COLOUR_INFOTEXT))
43 |
44 | self.m_panel1 = wx.Panel(self.m_splitter2, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize,
45 | wx.DOUBLE_BORDER | wx.TAB_TRAVERSAL)
46 | self.m_panel1.SetBackgroundColour(wx.SystemSettings.GetColour(wx.SYS_COLOUR_BTNFACE))
47 |
48 | bSizer3 = wx.BoxSizer(wx.VERTICAL)
49 |
50 | self.m_splitter7 = wx.SplitterWindow(self.m_panel1, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.SP_3D)
51 | self.m_splitter7.Bind(wx.EVT_IDLE, self.m_splitter7OnIdle)
52 |
53 | self.m_panel3 = wx.Panel(self.m_splitter7, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize,
54 | wx.DOUBLE_BORDER | wx.TAB_TRAVERSAL)
55 | self.m_panel3.SetBackgroundColour(wx.SystemSettings.GetColour(wx.SYS_COLOUR_MENU))
56 |
57 | bSizer4 = wx.BoxSizer(wx.VERTICAL)
58 |
59 | self.m_staticText1 = wx.StaticText(self.m_panel3, wx.ID_ANY, u"Device Control", wx.DefaultPosition,
60 | wx.DefaultSize, 0)
61 | self.m_staticText1.Wrap(-1)
62 | bSizer4.Add(self.m_staticText1, 0, wx.ALL, 5)
63 |
64 | bSizer6 = wx.BoxSizer(wx.HORIZONTAL)
65 |
66 | self.m_staticText2 = wx.StaticText(self.m_panel3, wx.ID_ANY, u"ID:", wx.DefaultPosition, wx.DefaultSize, 0)
67 | self.m_staticText2.Wrap(-1)
68 | bSizer6.Add(self.m_staticText2, 0, wx.ALL, 5)
69 |
70 | self.m_textID = wx.TextCtrl(self.m_panel3, wx.ID_ANY, u"ED000200", wx.DefaultPosition, wx.DefaultSize, 0)
71 | bSizer6.Add(self.m_textID, 1, wx.ALL | wx.EXPAND, 5)
72 |
73 | bSizer4.Add(bSizer6, 0, wx.EXPAND, 5)
74 |
75 | bSizer7 = wx.BoxSizer(wx.HORIZONTAL)
76 |
77 | self.m_staticText4 = wx.StaticText(self.m_panel3, wx.ID_ANY, u"BR:", wx.DefaultPosition, wx.DefaultSize, 0)
78 | self.m_staticText4.Wrap(-1)
79 | bSizer7.Add(self.m_staticText4, 0, wx.ALL, 5)
80 |
81 | m_choice_BRChoices = [u"10", u"20", u"50", u"100", u"125", u"250", u"500", u"800", u"1000"]
82 | self.m_choice_BR = wx.Choice(self.m_panel3, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, m_choice_BRChoices,
83 | 0)
84 | self.m_choice_BR.SetSelection(5)
85 | bSizer7.Add(self.m_choice_BR, 0, wx.ALL, 5)
86 |
87 | self.m_staticText5 = wx.StaticText(self.m_panel3, wx.ID_ANY, u"Kbps", wx.DefaultPosition, wx.DefaultSize, 0)
88 | self.m_staticText5.Wrap(-1)
89 | bSizer7.Add(self.m_staticText5, 0, wx.ALL, 5)
90 |
91 | bSizer4.Add(bSizer7, 0, wx.EXPAND, 5)
92 |
93 | self.m_buttonOpen = wx.Button(self.m_panel3, wx.ID_ANY, u"Open", wx.DefaultPosition, wx.DefaultSize, 0)
94 | bSizer4.Add(self.m_buttonOpen, 0, wx.ALL | wx.ALIGN_CENTER_HORIZONTAL, 5)
95 |
96 | self.m_buttonTest = wx.Button(self.m_panel3, wx.ID_ANY, u"Send Test", wx.DefaultPosition, wx.DefaultSize, 0)
97 | self.m_buttonTest.Enable(False)
98 |
99 | bSizer4.Add(self.m_buttonTest, 0, wx.ALL | wx.ALIGN_CENTER_HORIZONTAL, 5)
100 |
101 | self.m_panel3.SetSizer(bSizer4)
102 | self.m_panel3.Layout()
103 | bSizer4.Fit(self.m_panel3)
104 | self.m_panel4 = wx.Panel(self.m_splitter7, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize,
105 | wx.DOUBLE_BORDER | wx.TAB_TRAVERSAL)
106 | bSizer14 = wx.BoxSizer(wx.VERTICAL)
107 |
108 | self.m_panel4.SetSizer(bSizer14)
109 | self.m_panel4.Layout()
110 | bSizer14.Fit(self.m_panel4)
111 | self.m_splitter7.SplitHorizontally(self.m_panel3, self.m_panel4, 237)
112 | bSizer3.Add(self.m_splitter7, 1, wx.EXPAND, 5)
113 |
114 | self.m_panel1.SetSizer(bSizer3)
115 | self.m_panel1.Layout()
116 | bSizer3.Fit(self.m_panel1)
117 | self.m_panel2 = wx.Panel(self.m_splitter2, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.TAB_TRAVERSAL)
118 | self.m_panel2.SetBackgroundColour(wx.SystemSettings.GetColour(wx.SYS_COLOUR_INACTIVEBORDER))
119 |
120 | bSizer61 = wx.BoxSizer(wx.VERTICAL)
121 |
122 | self.m_notebook1 = wx.Notebook(self.m_panel2, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, 0)
123 | self.m_panel7 = wx.Panel(self.m_notebook1, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize,
124 | wx.DOUBLE_BORDER | wx.TAB_TRAVERSAL)
125 | bSizer10 = wx.BoxSizer(wx.VERTICAL)
126 |
127 | bSizer18 = wx.BoxSizer(wx.HORIZONTAL)
128 |
129 | self.m_btn_start_tracing = wx.Button(self.m_panel7, wx.ID_ANY, u"Start Tracing", wx.DefaultPosition,
130 | wx.DefaultSize, 0)
131 | self.m_btn_start_tracing.Enable(False)
132 |
133 | bSizer18.Add(self.m_btn_start_tracing, 0, wx.ALL, 5)
134 |
135 | self.m_btn_pause_tracing = wx.Button(self.m_panel7, wx.ID_ANY, u"Pause Tracing", wx.DefaultPosition,
136 | wx.DefaultSize, 0)
137 | self.m_btn_pause_tracing.Enable(False)
138 |
139 | bSizer18.Add(self.m_btn_pause_tracing, 0, wx.ALL, 5)
140 |
141 | self.m_btn_stop_tracing = wx.Button(self.m_panel7, wx.ID_ANY, u"Stop Tracing", wx.DefaultPosition,
142 | wx.DefaultSize, 0)
143 | self.m_btn_stop_tracing.Enable(False)
144 |
145 | bSizer18.Add(self.m_btn_stop_tracing, 0, wx.ALL, 5)
146 |
147 | bSizer10.Add(bSizer18, 0, wx.EXPAND, 5)
148 |
149 | bSizer20 = wx.BoxSizer(wx.HORIZONTAL)
150 |
151 | self.m_cb_savedb = wx.CheckBox(self.m_panel7, wx.ID_ANY, u"Save as DB", wx.DefaultPosition, wx.DefaultSize, 0)
152 | bSizer20.Add(self.m_cb_savedb, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5)
153 |
154 | self.m_cb_savelog = wx.CheckBox(self.m_panel7, wx.ID_ANY, u"Save as Log", wx.DefaultPosition, wx.DefaultSize, 0)
155 | bSizer20.Add(self.m_cb_savelog, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5)
156 |
157 | self.m_dP_db = wx.DirPickerCtrl(self.m_panel7, wx.ID_ANY, wx.EmptyString, u"Select a folder",
158 | wx.DefaultPosition, wx.DefaultSize, wx.DIRP_DEFAULT_STYLE)
159 | bSizer20.Add(self.m_dP_db, 1, wx.ALL, 5)
160 |
161 | bSizer10.Add(bSizer20, 0, wx.EXPAND, 5)
162 |
163 | bSizer19 = wx.BoxSizer(wx.HORIZONTAL)
164 |
165 | self.m_cb_time_mode = wx.CheckBox(self.m_panel7, wx.ID_ANY, u"△t", wx.DefaultPosition, wx.DefaultSize, 0)
166 | bSizer19.Add(self.m_cb_time_mode, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5)
167 |
168 | m_choice_tracelist_modeChoices = [u"Chronological", u"Fixed"]
169 | self.m_choice_tracelist_mode = wx.Choice(self.m_panel7, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize,
170 | m_choice_tracelist_modeChoices, 0)
171 | self.m_choice_tracelist_mode.SetSelection(0)
172 | bSizer19.Add(self.m_choice_tracelist_mode, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5)
173 |
174 | self.m_btn_clean_up = wx.Button(self.m_panel7, wx.ID_ANY, u"Clean up", wx.DefaultPosition, wx.DefaultSize, 0)
175 | bSizer19.Add(self.m_btn_clean_up, 0, wx.ALL, 5)
176 |
177 | bSizer10.Add(bSizer19, 0, wx.EXPAND, 5)
178 |
179 | self.m_listCtrl1 = wx.ListCtrl(self.m_panel7, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LC_REPORT)
180 | bSizer10.Add(self.m_listCtrl1, 1, wx.TOP | wx.RIGHT | wx.LEFT | wx.EXPAND, 5)
181 |
182 | self.m_panel7.SetSizer(bSizer10)
183 | self.m_panel7.Layout()
184 | bSizer10.Fit(self.m_panel7)
185 | self.m_notebook1.AddPage(self.m_panel7, u"Trace", False)
186 | self.m_panel12 = wx.Panel(self.m_notebook1, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize,
187 | wx.DOUBLE_BORDER | wx.TAB_TRAVERSAL)
188 | bSizer101 = wx.BoxSizer(wx.VERTICAL)
189 |
190 | bSizer181 = wx.BoxSizer(wx.HORIZONTAL)
191 |
192 | self.m_btn_start_player = wx.Button(self.m_panel12, wx.ID_ANY, u"Play", wx.DefaultPosition, wx.DefaultSize, 0)
193 | self.m_btn_start_player.Enable(False)
194 |
195 | bSizer181.Add(self.m_btn_start_player, 0, wx.ALL, 5)
196 |
197 | self.m_btn_pause_player = wx.Button(self.m_panel12, wx.ID_ANY, u"Pause", wx.DefaultPosition, wx.DefaultSize, 0)
198 | self.m_btn_pause_player.Enable(False)
199 |
200 | bSizer181.Add(self.m_btn_pause_player, 0, wx.ALL, 5)
201 |
202 | self.m_btn_stop_player = wx.Button(self.m_panel12, wx.ID_ANY, u"Stop", wx.DefaultPosition, wx.DefaultSize, 0)
203 | self.m_btn_stop_player.Enable(False)
204 |
205 | bSizer181.Add(self.m_btn_stop_player, 0, wx.ALL, 5)
206 |
207 | bSizer101.Add(bSizer181, 0, wx.EXPAND, 5)
208 |
209 | bSizer201 = wx.BoxSizer(wx.HORIZONTAL)
210 |
211 | self.m_filePicker_player = wx.FilePickerCtrl(self.m_panel12, wx.ID_ANY, wx.EmptyString, u"Select a file",
212 | u"*.*", wx.DefaultPosition, wx.DefaultSize, wx.FLP_DEFAULT_STYLE)
213 | bSizer201.Add(self.m_filePicker_player, 1, wx.ALL, 5)
214 |
215 | bSizer101.Add(bSizer201, 0, wx.EXPAND, 5)
216 |
217 | bSizer44 = wx.BoxSizer(wx.VERTICAL)
218 |
219 | bSizer45 = wx.BoxSizer(wx.HORIZONTAL)
220 |
221 | self.m_staticText24 = wx.StaticText(self.m_panel12, wx.ID_ANY, u"Loop:", wx.DefaultPosition, wx.DefaultSize, 0)
222 | self.m_staticText24.Wrap(-1)
223 | bSizer45.Add(self.m_staticText24, 0, wx.ALL, 5)
224 |
225 | self.m_textCtrl_player_loop = wx.TextCtrl(self.m_panel12, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition,
226 | wx.DefaultSize, 0)
227 | bSizer45.Add(self.m_textCtrl_player_loop, 0, wx.ALL, 5)
228 |
229 | bSizer44.Add(bSizer45, 0, wx.EXPAND, 5)
230 |
231 | self.m_staticText23 = wx.StaticText(self.m_panel12, wx.ID_ANY, u"State:", wx.DefaultPosition, wx.DefaultSize, 0)
232 | self.m_staticText23.Wrap(-1)
233 | bSizer44.Add(self.m_staticText23, 0, wx.ALL, 5)
234 |
235 | self.m_staticText_count = wx.StaticText(self.m_panel12, wx.ID_ANY, u"0", wx.DefaultPosition, wx.DefaultSize, 0)
236 | self.m_staticText_count.Wrap(-1)
237 | bSizer44.Add(self.m_staticText_count, 0, wx.ALL, 5)
238 |
239 | bSizer101.Add(bSizer44, 1, wx.EXPAND, 5)
240 |
241 | self.m_panel12.SetSizer(bSizer101)
242 | self.m_panel12.Layout()
243 | bSizer101.Fit(self.m_panel12)
244 | self.m_notebook1.AddPage(self.m_panel12, u"Playback", False)
245 | self.m_panel9 = wx.Panel(self.m_notebook1, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize,
246 | wx.DOUBLE_BORDER | wx.TAB_TRAVERSAL)
247 | bSizer12 = wx.BoxSizer(wx.VERTICAL)
248 |
249 | bSizer37 = wx.BoxSizer(wx.VERTICAL)
250 |
251 | self.m_radioBtnConfig = wx.RadioButton(self.m_panel9, wx.ID_ANY, u"Config File", wx.DefaultPosition,
252 | wx.DefaultSize, 0)
253 | bSizer37.Add(self.m_radioBtnConfig, 0, wx.ALL, 5)
254 |
255 | self.m_filePicker_config = wx.FilePickerCtrl(self.m_panel9, wx.ID_ANY, wx.EmptyString, u"Select a file", u"*.*",
256 | wx.DefaultPosition, wx.DefaultSize, wx.FLP_DEFAULT_STYLE)
257 | bSizer37.Add(self.m_filePicker_config, 1, wx.ALL | wx.EXPAND, 5)
258 |
259 | self.m_gauge1 = wx.Gauge(self.m_panel9, wx.ID_ANY, 100, wx.DefaultPosition, wx.DefaultSize, wx.GA_HORIZONTAL)
260 | self.m_gauge1.SetValue(0)
261 | bSizer37.Add(self.m_gauge1, 0, wx.ALL | wx.EXPAND, 5)
262 |
263 | bSizer12.Add(bSizer37, 0, wx.EXPAND, 5)
264 |
265 | self.m_staticline22 = wx.StaticLine(self.m_panel9, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize,
266 | wx.LI_HORIZONTAL)
267 | bSizer12.Add(self.m_staticline22, 0, wx.EXPAND | wx.ALL, 5)
268 |
269 | bSizer15 = wx.BoxSizer(wx.HORIZONTAL)
270 |
271 | bSizer15.SetMinSize(wx.Size(-1, 80))
272 | self.m_radioBtnDos = wx.RadioButton(self.m_panel9, wx.ID_ANY, u"DoS Attack", wx.Point(30, -1), wx.Size(200, -1),
273 | 0)
274 | bSizer15.Add(self.m_radioBtnDos, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5)
275 |
276 | self.m_radioBtnFuzz = wx.RadioButton(self.m_panel9, wx.ID_ANY, u"Fuzzing Attack", wx.Point(30, -1),
277 | wx.DefaultSize, 0)
278 | bSizer15.Add(self.m_radioBtnFuzz, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5)
279 |
280 | self.m_staticText351 = wx.StaticText(self.m_panel9, wx.ID_ANY, u"ID:", wx.DefaultPosition, wx.DefaultSize, 0)
281 | self.m_staticText351.Wrap(-1)
282 | bSizer15.Add(self.m_staticText351, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5)
283 |
284 | self.m_textCtrl_FuzzID = wx.TextCtrl(self.m_panel9, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition,
285 | wx.DefaultSize, 0)
286 | bSizer15.Add(self.m_textCtrl_FuzzID, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5)
287 |
288 | bSizer12.Add(bSizer15, 0, wx.EXPAND, 5)
289 |
290 | self.m_staticline2 = wx.StaticLine(self.m_panel9, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize,
291 | wx.LI_HORIZONTAL)
292 | bSizer12.Add(self.m_staticline2, 0, wx.EXPAND | wx.ALL, 5)
293 |
294 | bSizer16 = wx.BoxSizer(wx.VERTICAL)
295 |
296 | bSizer16.SetMinSize(wx.Size(-1, 80))
297 | bSizer22 = wx.BoxSizer(wx.HORIZONTAL)
298 |
299 | self.m_radioBtnSpoof = wx.RadioButton(self.m_panel9, wx.ID_ANY, u"Spoofing Attack", wx.DefaultPosition,
300 | wx.DefaultSize, 0)
301 | self.m_radioBtnSpoof.Enable(False)
302 |
303 | bSizer22.Add(self.m_radioBtnSpoof, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5)
304 |
305 | self.m_button_analysis1 = wx.Button(self.m_panel9, wx.ID_ANY, u"Analyze", wx.DefaultPosition, wx.DefaultSize, 0)
306 | self.m_button_analysis1.Enable(False)
307 |
308 | bSizer22.Add(self.m_button_analysis1, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5)
309 |
310 | bSizer211 = wx.BoxSizer(wx.VERTICAL)
311 |
312 | self.m_staticText111 = wx.StaticText(self.m_panel9, wx.ID_ANY, u"Analysis result:", wx.DefaultPosition,
313 | wx.DefaultSize, 0)
314 | self.m_staticText111.Wrap(-1)
315 | bSizer211.Add(self.m_staticText111, 0, wx.ALL, 5)
316 |
317 | m_listBox_spoof_attackChoices = []
318 | self.m_listBox_spoof_attack = wx.ListBox(self.m_panel9, wx.ID_ANY, wx.DefaultPosition, wx.Size(-1, 150),
319 | m_listBox_spoof_attackChoices, 0 | wx.VSCROLL)
320 | bSizer211.Add(self.m_listBox_spoof_attack, 1, wx.ALL | wx.EXPAND, 5)
321 |
322 | bSizer22.Add(bSizer211, 1, wx.EXPAND, 5)
323 |
324 | bSizer16.Add(bSizer22, 1, wx.EXPAND, 5)
325 |
326 | bSizer23 = wx.BoxSizer(wx.HORIZONTAL)
327 |
328 | self.m_checkBox_a_fd = wx.CheckBox(self.m_panel9, wx.ID_ANY, u"Fixed Data", wx.DefaultPosition, wx.DefaultSize,
329 | 0)
330 | self.m_checkBox_a_fd.SetValue(True)
331 | bSizer23.Add(self.m_checkBox_a_fd, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5)
332 |
333 | gSizer2 = wx.GridSizer(1, 8, 0, 0)
334 |
335 | self.m_textCtrl_fixdata1 = wx.TextCtrl(self.m_panel9, wx.ID_ANY, u"0", wx.DefaultPosition, wx.Size(35, -1), 0)
336 | gSizer2.Add(self.m_textCtrl_fixdata1, 0, wx.ALL, 5)
337 |
338 | self.m_textCtrl_fixdata2 = wx.TextCtrl(self.m_panel9, wx.ID_ANY, u"0", wx.DefaultPosition, wx.Size(35, -1), 0)
339 | gSizer2.Add(self.m_textCtrl_fixdata2, 0, wx.ALL, 5)
340 |
341 | self.m_textCtrl_fixdata3 = wx.TextCtrl(self.m_panel9, wx.ID_ANY, u"0", wx.DefaultPosition, wx.Size(35, -1), 0)
342 | gSizer2.Add(self.m_textCtrl_fixdata3, 0, wx.ALL, 5)
343 |
344 | self.m_textCtrl_fixdata4 = wx.TextCtrl(self.m_panel9, wx.ID_ANY, u"0", wx.DefaultPosition, wx.Size(35, -1), 0)
345 | gSizer2.Add(self.m_textCtrl_fixdata4, 0, wx.ALL, 5)
346 |
347 | self.m_textCtrl_fixdata5 = wx.TextCtrl(self.m_panel9, wx.ID_ANY, u"0", wx.DefaultPosition, wx.Size(35, -1), 0)
348 | gSizer2.Add(self.m_textCtrl_fixdata5, 0, wx.ALL, 5)
349 |
350 | self.m_textCtrl_fixdata6 = wx.TextCtrl(self.m_panel9, wx.ID_ANY, u"0", wx.DefaultPosition, wx.Size(35, -1), 0)
351 | gSizer2.Add(self.m_textCtrl_fixdata6, 0, wx.ALL, 5)
352 |
353 | self.m_textCtrl_fixdata7 = wx.TextCtrl(self.m_panel9, wx.ID_ANY, u"0", wx.DefaultPosition, wx.Size(35, -1), 0)
354 | gSizer2.Add(self.m_textCtrl_fixdata7, 0, wx.ALL, 5)
355 |
356 | self.m_textCtrl_fixdata8 = wx.TextCtrl(self.m_panel9, wx.ID_ANY, u"0", wx.DefaultPosition, wx.Size(35, -1), 0)
357 | gSizer2.Add(self.m_textCtrl_fixdata8, 0, wx.ALL, 5)
358 |
359 | bSizer23.Add(gSizer2, 1, wx.EXPAND, 5)
360 |
361 | bSizer16.Add(bSizer23, 0, wx.EXPAND, 5)
362 |
363 | bSizer25 = wx.BoxSizer(wx.HORIZONTAL)
364 |
365 | self.m_checkBox_a_do = wx.CheckBox(self.m_panel9, wx.ID_ANY, u"Data Offset", wx.DefaultPosition, wx.DefaultSize,
366 | 0)
367 | bSizer25.Add(self.m_checkBox_a_do, 0, wx.ALL, 5)
368 |
369 | gSizer1 = wx.GridSizer(1, 8, 0, 0)
370 |
371 | self.m_checkBox_offset1 = wx.CheckBox(self.m_panel9, wx.ID_ANY, u"1", wx.DefaultPosition, wx.DefaultSize, 0)
372 | gSizer1.Add(self.m_checkBox_offset1, 0, wx.ALL, 5)
373 |
374 | self.m_checkBox_offset2 = wx.CheckBox(self.m_panel9, wx.ID_ANY, u"2", wx.DefaultPosition, wx.DefaultSize, 0)
375 | gSizer1.Add(self.m_checkBox_offset2, 0, wx.ALL, 5)
376 |
377 | self.m_checkBox_offset3 = wx.CheckBox(self.m_panel9, wx.ID_ANY, u"3", wx.DefaultPosition, wx.DefaultSize, 0)
378 | gSizer1.Add(self.m_checkBox_offset3, 0, wx.ALL, 5)
379 |
380 | self.m_checkBox_offset4 = wx.CheckBox(self.m_panel9, wx.ID_ANY, u"4", wx.DefaultPosition, wx.DefaultSize, 0)
381 | gSizer1.Add(self.m_checkBox_offset4, 0, wx.ALL, 5)
382 |
383 | self.m_checkBox_offset5 = wx.CheckBox(self.m_panel9, wx.ID_ANY, u"5", wx.DefaultPosition, wx.DefaultSize, 0)
384 | gSizer1.Add(self.m_checkBox_offset5, 0, wx.ALL, 5)
385 |
386 | self.m_checkBox_offset6 = wx.CheckBox(self.m_panel9, wx.ID_ANY, u"6", wx.DefaultPosition, wx.DefaultSize, 0)
387 | gSizer1.Add(self.m_checkBox_offset6, 0, wx.ALL, 5)
388 |
389 | self.m_checkBox_offset7 = wx.CheckBox(self.m_panel9, wx.ID_ANY, u"7", wx.DefaultPosition, wx.DefaultSize, 0)
390 | gSizer1.Add(self.m_checkBox_offset7, 0, wx.ALL, 5)
391 |
392 | self.m_checkBox_offset8 = wx.CheckBox(self.m_panel9, wx.ID_ANY, u"8", wx.DefaultPosition, wx.DefaultSize, 0)
393 | gSizer1.Add(self.m_checkBox_offset8, 0, wx.ALL, 5)
394 |
395 | bSizer25.Add(gSizer1, 1, wx.EXPAND, 5)
396 |
397 | bSizer16.Add(bSizer25, 0, wx.EXPAND, 5)
398 |
399 | bSizer26 = wx.BoxSizer(wx.HORIZONTAL)
400 |
401 | self.m_staticText141 = wx.StaticText(self.m_panel9, wx.ID_ANY, u"Frequency", wx.DefaultPosition, wx.DefaultSize,
402 | 0)
403 | self.m_staticText141.Wrap(-1)
404 | bSizer26.Add(self.m_staticText141, 0, wx.ALL, 5)
405 |
406 | self.m_slider_fuzzing_f = wx.Slider(self.m_panel9, wx.ID_ANY, 100, 0, 100, wx.DefaultPosition, wx.Size(300, -1),
407 | wx.SL_HORIZONTAL)
408 | bSizer26.Add(self.m_slider_fuzzing_f, 0, wx.ALL, 5)
409 |
410 | self.m_staticText142 = wx.StaticText(self.m_panel9, wx.ID_ANY, u"Every 100 insert", wx.DefaultPosition,
411 | wx.DefaultSize, 0)
412 | self.m_staticText142.Wrap(-1)
413 | bSizer26.Add(self.m_staticText142, 0, wx.ALL, 5)
414 |
415 | self.m_text_fuzzing_fv = wx.StaticText(self.m_panel9, wx.ID_ANY, u"100", wx.DefaultPosition, wx.DefaultSize, 0)
416 | self.m_text_fuzzing_fv.Wrap(-1)
417 | bSizer26.Add(self.m_text_fuzzing_fv, 0, wx.ALL, 5)
418 |
419 | bSizer16.Add(bSizer26, 0, 0, 5)
420 |
421 | bSizer12.Add(bSizer16, 0, wx.EXPAND, 5)
422 |
423 | self.m_staticline3 = wx.StaticLine(self.m_panel9, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize,
424 | wx.LI_HORIZONTAL)
425 | bSizer12.Add(self.m_staticline3, 0, wx.EXPAND | wx.ALL, 5)
426 |
427 | bSizer21 = wx.BoxSizer(wx.HORIZONTAL)
428 |
429 | self.m_button_attack_start = wx.Button(self.m_panel9, wx.ID_ANY, u"Start", wx.DefaultPosition, wx.DefaultSize,
430 | 0)
431 | self.m_button_attack_start.Enable(False)
432 |
433 | bSizer21.Add(self.m_button_attack_start, 0, wx.ALL, 5)
434 |
435 | self.m_button_attack_stop = wx.Button(self.m_panel9, wx.ID_ANY, u"Stop", wx.DefaultPosition, wx.DefaultSize, 0)
436 | self.m_button_attack_stop.Enable(False)
437 |
438 | bSizer21.Add(self.m_button_attack_stop, 0, wx.ALL, 5)
439 |
440 | bSizer12.Add(bSizer21, 0, wx.ALIGN_RIGHT, 5)
441 |
442 | self.m_panel9.SetSizer(bSizer12)
443 | self.m_panel9.Layout()
444 | bSizer12.Fit(self.m_panel9)
445 | self.m_notebook1.AddPage(self.m_panel9, u"Attack", True)
446 | self.m_panel8 = wx.Panel(self.m_notebook1, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize,
447 | wx.DOUBLE_BORDER | wx.TAB_TRAVERSAL)
448 | bSizer11 = wx.BoxSizer(wx.VERTICAL)
449 |
450 | self.m_staticText6 = wx.StaticText(self.m_panel8, wx.ID_ANY, u"Select File:", wx.DefaultPosition,
451 | wx.DefaultSize, 0)
452 | self.m_staticText6.Wrap(-1)
453 | self.m_staticText6.SetFont(
454 | wx.Font(wx.NORMAL_FONT.GetPointSize(), wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD,
455 | False, wx.EmptyString))
456 |
457 | bSizer11.Add(self.m_staticText6, 0, wx.ALL, 5)
458 |
459 | self.m_filePicker_matrix_imput = wx.FilePickerCtrl(self.m_panel8, wx.ID_ANY, wx.EmptyString, u"Select a file",
460 | u"*.*", wx.DefaultPosition, wx.DefaultSize,
461 | wx.FLP_DEFAULT_STYLE)
462 | bSizer11.Add(self.m_filePicker_matrix_imput, 0, wx.ALL | wx.EXPAND, 5)
463 |
464 | self.m_staticline6 = wx.StaticLine(self.m_panel8, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize,
465 | wx.LI_HORIZONTAL)
466 | bSizer11.Add(self.m_staticline6, 0, wx.EXPAND | wx.ALL, 5)
467 |
468 | self.m_staticText12 = wx.StaticText(self.m_panel8, wx.ID_ANY, u"OutPut File:", wx.DefaultPosition,
469 | wx.DefaultSize, 0)
470 | self.m_staticText12.Wrap(-1)
471 | self.m_staticText12.SetFont(
472 | wx.Font(wx.NORMAL_FONT.GetPointSize(), wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD,
473 | False, wx.EmptyString))
474 |
475 | bSizer11.Add(self.m_staticText12, 0, wx.ALL, 5)
476 |
477 | bSizer162 = wx.BoxSizer(wx.HORIZONTAL)
478 |
479 | self.m_staticText13 = wx.StaticText(self.m_panel8, wx.ID_ANY, u"Name:", wx.DefaultPosition, wx.DefaultSize, 0)
480 | self.m_staticText13.Wrap(-1)
481 | bSizer162.Add(self.m_staticText13, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5)
482 |
483 | self.m_textCtrl_matrix_output_name = wx.TextCtrl(self.m_panel8, wx.ID_ANY, u"target", wx.DefaultPosition,
484 | wx.Size(200, -1), 0)
485 | bSizer162.Add(self.m_textCtrl_matrix_output_name, 0, wx.ALL, 5)
486 |
487 | m_choice_matrix_output_formatChoices = [u".dbc", u".dbf", u".kcd", u".xls", u".xlsx", u".json", u".arxml",
488 | u".yaml", u".sym", u".xml"]
489 | self.m_choice_matrix_output_format = wx.Choice(self.m_panel8, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize,
490 | m_choice_matrix_output_formatChoices, 0)
491 | self.m_choice_matrix_output_format.SetSelection(0)
492 | bSizer162.Add(self.m_choice_matrix_output_format, 0, wx.ALL, 5)
493 |
494 | bSizer11.Add(bSizer162, 0, wx.EXPAND, 5)
495 |
496 | bSizer17 = wx.BoxSizer(wx.HORIZONTAL)
497 |
498 | self.m_staticText14 = wx.StaticText(self.m_panel8, wx.ID_ANY, u"Path: ", wx.DefaultPosition, wx.DefaultSize, 0)
499 | self.m_staticText14.Wrap(-1)
500 | bSizer17.Add(self.m_staticText14, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5)
501 |
502 | self.m_dirPicker_matrix_output_path = wx.DirPickerCtrl(self.m_panel8, wx.ID_ANY, wx.EmptyString,
503 | u"Select a folder", wx.DefaultPosition, wx.DefaultSize,
504 | wx.DIRP_DEFAULT_STYLE)
505 | bSizer17.Add(self.m_dirPicker_matrix_output_path, 1, wx.ALL, 5)
506 |
507 | bSizer11.Add(bSizer17, 0, wx.EXPAND, 5)
508 |
509 | self.m_staticline8 = wx.StaticLine(self.m_panel8, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize,
510 | wx.LI_HORIZONTAL)
511 | bSizer11.Add(self.m_staticline8, 0, wx.EXPAND | wx.ALL, 5)
512 |
513 | bSizer31 = wx.BoxSizer(wx.HORIZONTAL)
514 |
515 | self.m_cb_for_IDS = wx.CheckBox(self.m_panel8, wx.ID_ANY, u"For IDS", wx.DefaultPosition, wx.DefaultSize, 0)
516 | bSizer31.Add(self.m_cb_for_IDS, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5)
517 |
518 | self.m_btn_convert = wx.Button(self.m_panel8, wx.ID_ANY, u"Convert", wx.DefaultPosition, wx.DefaultSize, 0)
519 | bSizer31.Add(self.m_btn_convert, 0, wx.ALL, 5)
520 |
521 | bSizer11.Add(bSizer31, 0, wx.EXPAND, 5)
522 |
523 | self.m_staticline10 = wx.StaticLine(self.m_panel8, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize,
524 | wx.LI_HORIZONTAL)
525 | bSizer11.Add(self.m_staticline10, 0, wx.EXPAND | wx.ALL, 5)
526 |
527 | bSizer151 = wx.BoxSizer(wx.HORIZONTAL)
528 |
529 | self.m_staticText71 = wx.StaticText(self.m_panel8, wx.ID_ANY,
530 | u"supported file formats for import:\n .dbc candb / Vector\n .dbf Busmaster (open source!)\n .kcd kayak (open source!)\n .arxml autosar system description\n .yaml dump of the python object\n .xls(x) \n .sym peak pcan can description",
531 | wx.DefaultPosition, wx.DefaultSize, 0)
532 | self.m_staticText71.Wrap(-1)
533 | bSizer151.Add(self.m_staticText71, 0, wx.ALL, 5)
534 |
535 | self.m_staticline5 = wx.StaticLine(self.m_panel8, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_VERTICAL)
536 | self.m_staticline5.SetForegroundColour(wx.SystemSettings.GetColour(wx.SYS_COLOUR_INACTIVECAPTIONTEXT))
537 | self.m_staticline5.SetBackgroundColour(wx.SystemSettings.GetColour(wx.SYS_COLOUR_INACTIVECAPTIONTEXT))
538 |
539 | bSizer151.Add(self.m_staticline5, 0, wx.ALL | wx.EXPAND, 5)
540 |
541 | self.m_staticText11 = wx.StaticText(self.m_panel8, wx.ID_ANY,
542 | u"supported file formats for export:\n .dbc\n .dbf\n .kcd\n .xls(x)\n .json Canard (open source!)\n .arxml (very basic implementation)\n .yaml (dump of the python object)\n .sym\n .xml fibex",
543 | wx.DefaultPosition, wx.DefaultSize, 0)
544 | self.m_staticText11.Wrap(-1)
545 | bSizer151.Add(self.m_staticText11, 0, wx.ALL, 5)
546 |
547 | bSizer11.Add(bSizer151, 0, wx.EXPAND, 5)
548 |
549 | self.m_panel8.SetSizer(bSizer11)
550 | self.m_panel8.Layout()
551 | bSizer11.Fit(self.m_panel8)
552 | self.m_notebook1.AddPage(self.m_panel8, u"CAN Matrix", False)
553 | self.m_panel10 = wx.Panel(self.m_notebook1, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize,
554 | wx.DOUBLE_BORDER | wx.TAB_TRAVERSAL)
555 | bSizer111 = wx.BoxSizer(wx.VERTICAL)
556 |
557 | self.m_staticText61 = wx.StaticText(self.m_panel10, wx.ID_ANY, u"Select File:", wx.DefaultPosition,
558 | wx.DefaultSize, 0)
559 | self.m_staticText61.Wrap(-1)
560 | self.m_staticText61.SetFont(
561 | wx.Font(wx.NORMAL_FONT.GetPointSize(), wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD,
562 | False, wx.EmptyString))
563 |
564 | bSizer111.Add(self.m_staticText61, 0, wx.ALL, 5)
565 |
566 | self.m_filePicker_data_imput = wx.FilePickerCtrl(self.m_panel10, wx.ID_ANY, wx.EmptyString, u"Select a file",
567 | u"*.*", wx.DefaultPosition, wx.DefaultSize,
568 | wx.FLP_DEFAULT_STYLE)
569 | bSizer111.Add(self.m_filePicker_data_imput, 0, wx.ALL | wx.EXPAND, 5)
570 |
571 | self.m_staticline61 = wx.StaticLine(self.m_panel10, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize,
572 | wx.LI_HORIZONTAL)
573 | bSizer111.Add(self.m_staticline61, 0, wx.EXPAND | wx.ALL, 5)
574 |
575 | self.m_staticText121 = wx.StaticText(self.m_panel10, wx.ID_ANY, u"OutPut File:", wx.DefaultPosition,
576 | wx.DefaultSize, 0)
577 | self.m_staticText121.Wrap(-1)
578 | self.m_staticText121.SetFont(
579 | wx.Font(wx.NORMAL_FONT.GetPointSize(), wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD,
580 | False, wx.EmptyString))
581 |
582 | bSizer111.Add(self.m_staticText121, 0, wx.ALL, 5)
583 |
584 | bSizer1621 = wx.BoxSizer(wx.HORIZONTAL)
585 |
586 | self.m_staticText131 = wx.StaticText(self.m_panel10, wx.ID_ANY, u"Name:", wx.DefaultPosition, wx.DefaultSize, 0)
587 | self.m_staticText131.Wrap(-1)
588 | bSizer1621.Add(self.m_staticText131, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5)
589 |
590 | self.m_textCtrl_data_output_name = wx.TextCtrl(self.m_panel10, wx.ID_ANY, u"target", wx.DefaultPosition,
591 | wx.Size(200, -1), 0)
592 | bSizer1621.Add(self.m_textCtrl_data_output_name, 0, wx.ALL, 5)
593 |
594 | m_choice_data_output_formatChoices = [u".csv", u".log"]
595 | self.m_choice_data_output_format = wx.Choice(self.m_panel10, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize,
596 | m_choice_data_output_formatChoices, 0)
597 | self.m_choice_data_output_format.SetSelection(0)
598 | bSizer1621.Add(self.m_choice_data_output_format, 0, wx.ALL, 5)
599 |
600 | bSizer111.Add(bSizer1621, 0, wx.EXPAND, 5)
601 |
602 | bSizer171 = wx.BoxSizer(wx.HORIZONTAL)
603 |
604 | self.m_staticText143 = wx.StaticText(self.m_panel10, wx.ID_ANY, u"Path: ", wx.DefaultPosition, wx.DefaultSize,
605 | 0)
606 | self.m_staticText143.Wrap(-1)
607 | bSizer171.Add(self.m_staticText143, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5)
608 |
609 | self.m_dirPicker_data_output_path = wx.DirPickerCtrl(self.m_panel10, wx.ID_ANY, wx.EmptyString,
610 | u"Select a folder", wx.DefaultPosition, wx.DefaultSize,
611 | wx.DIRP_DEFAULT_STYLE)
612 | bSizer171.Add(self.m_dirPicker_data_output_path, 1, wx.ALL, 5)
613 |
614 | bSizer111.Add(bSizer171, 0, wx.EXPAND, 5)
615 |
616 | self.m_staticline81 = wx.StaticLine(self.m_panel10, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize,
617 | wx.LI_HORIZONTAL)
618 | bSizer111.Add(self.m_staticline81, 0, wx.EXPAND | wx.ALL, 5)
619 |
620 | self.m_btn_convert_data = wx.Button(self.m_panel10, wx.ID_ANY, u"Convert", wx.DefaultPosition, wx.DefaultSize,
621 | 0)
622 | bSizer111.Add(self.m_btn_convert_data, 0, wx.ALL, 5)
623 |
624 | self.m_staticline101 = wx.StaticLine(self.m_panel10, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize,
625 | wx.LI_HORIZONTAL)
626 | bSizer111.Add(self.m_staticline101, 0, wx.EXPAND | wx.ALL, 5)
627 |
628 | bSizer1511 = wx.BoxSizer(wx.HORIZONTAL)
629 |
630 | self.m_staticText711 = wx.StaticText(self.m_panel10, wx.ID_ANY,
631 | u"supported file formats for import:\n .db\n .log\n .csv",
632 | wx.DefaultPosition, wx.DefaultSize, 0)
633 | self.m_staticText711.Wrap(-1)
634 | bSizer1511.Add(self.m_staticText711, 0, wx.ALL, 5)
635 |
636 | self.m_staticline51 = wx.StaticLine(self.m_panel10, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize,
637 | wx.LI_VERTICAL)
638 | self.m_staticline51.SetForegroundColour(wx.SystemSettings.GetColour(wx.SYS_COLOUR_INACTIVECAPTIONTEXT))
639 | self.m_staticline51.SetBackgroundColour(wx.SystemSettings.GetColour(wx.SYS_COLOUR_INACTIVECAPTIONTEXT))
640 |
641 | bSizer1511.Add(self.m_staticline51, 0, wx.ALL | wx.EXPAND, 5)
642 |
643 | self.m_staticText112 = wx.StaticText(self.m_panel10, wx.ID_ANY,
644 | u"supported file formats for export:\n .csv\n .log", wx.DefaultPosition,
645 | wx.DefaultSize, 0)
646 | self.m_staticText112.Wrap(-1)
647 | bSizer1511.Add(self.m_staticText112, 0, wx.ALL, 5)
648 |
649 | bSizer111.Add(bSizer1511, 0, wx.EXPAND, 5)
650 |
651 | self.m_panel10.SetSizer(bSizer111)
652 | self.m_panel10.Layout()
653 | bSizer111.Fit(self.m_panel10)
654 | self.m_notebook1.AddPage(self.m_panel10, u"Dataset conversion", False)
655 | self.m_panel11 = wx.Panel(self.m_notebook1, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize,
656 | wx.DOUBLE_BORDER | wx.TAB_TRAVERSAL)
657 | bSizer1111 = wx.BoxSizer(wx.VERTICAL)
658 |
659 | self.m_staticText611 = wx.StaticText(self.m_panel11, wx.ID_ANY, u"Select File:", wx.DefaultPosition,
660 | wx.DefaultSize, 0)
661 | self.m_staticText611.Wrap(-1)
662 | self.m_staticText611.SetFont(
663 | wx.Font(wx.NORMAL_FONT.GetPointSize(), wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD,
664 | False, wx.EmptyString))
665 |
666 | bSizer1111.Add(self.m_staticText611, 0, wx.ALL, 5)
667 |
668 | self.m_filePicker_da_imput = wx.FilePickerCtrl(self.m_panel11, wx.ID_ANY, wx.EmptyString, u"Select a file",
669 | u"*.*", wx.DefaultPosition, wx.DefaultSize, wx.FLP_DEFAULT_STYLE)
670 | bSizer1111.Add(self.m_filePicker_da_imput, 0, wx.ALL | wx.EXPAND, 5)
671 |
672 | self.m_staticline611 = wx.StaticLine(self.m_panel11, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize,
673 | wx.LI_HORIZONTAL)
674 | bSizer1111.Add(self.m_staticline611, 0, wx.EXPAND | wx.ALL, 5)
675 |
676 | self.m_btn_da_analyze = wx.Button(self.m_panel11, wx.ID_ANY, u"Analyze", wx.DefaultPosition, wx.DefaultSize, 0)
677 | bSizer1111.Add(self.m_btn_da_analyze, 0, wx.ALL, 5)
678 |
679 | self.m_staticText1211 = wx.StaticText(self.m_panel11, wx.ID_ANY, u"Messages:", wx.DefaultPosition,
680 | wx.DefaultSize, 0)
681 | self.m_staticText1211.Wrap(-1)
682 | self.m_staticText1211.SetFont(
683 | wx.Font(wx.NORMAL_FONT.GetPointSize(), wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD,
684 | False, wx.EmptyString))
685 |
686 | bSizer1111.Add(self.m_staticText1211, 0, wx.ALL, 5)
687 |
688 | m_listBox2Choices = []
689 | self.m_listBox2 = wx.ListBox(self.m_panel11, wx.ID_ANY, wx.DefaultPosition, wx.Size(-1, 120), m_listBox2Choices,
690 | wx.LB_MULTIPLE)
691 | bSizer1111.Add(self.m_listBox2, 0, wx.ALL | wx.EXPAND, 5)
692 |
693 | bSizer46 = wx.BoxSizer(wx.HORIZONTAL)
694 |
695 | self.m_radioBtn4 = wx.RadioButton(self.m_panel11, wx.ID_ANY, u"Interval", wx.DefaultPosition, wx.DefaultSize, 0)
696 | bSizer46.Add(self.m_radioBtn4, 0, wx.ALL, 5)
697 |
698 | self.m_radioBtn5 = wx.RadioButton(self.m_panel11, wx.ID_ANY, u"Clock skew", wx.DefaultPosition, wx.DefaultSize,
699 | 0)
700 | bSizer46.Add(self.m_radioBtn5, 0, wx.ALL, 5)
701 |
702 | bSizer1111.Add(bSizer46, 0, 0, 5)
703 |
704 | self.m_staticline1011 = wx.StaticLine(self.m_panel11, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize,
705 | wx.LI_HORIZONTAL)
706 | bSizer1111.Add(self.m_staticline1011, 0, wx.EXPAND | wx.ALL, 5)
707 |
708 | self.m_btn_figure = wx.Button(self.m_panel11, wx.ID_ANY, u"Generate Figure", wx.DefaultPosition, wx.DefaultSize,
709 | 0)
710 | bSizer1111.Add(self.m_btn_figure, 0, wx.ALL, 5)
711 |
712 | self.m_panel11.SetSizer(bSizer1111)
713 | self.m_panel11.Layout()
714 | bSizer1111.Fit(self.m_panel11)
715 | self.m_notebook1.AddPage(self.m_panel11, u"DA", False)
716 | self.m_panel111 = wx.Panel(self.m_notebook1, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize,
717 | wx.DOUBLE_BORDER | wx.TAB_TRAVERSAL)
718 | bSizer11111 = wx.BoxSizer(wx.VERTICAL)
719 |
720 | bSizer42 = wx.BoxSizer(wx.VERTICAL)
721 |
722 | gSizer3 = wx.GridSizer(2, 6, 0, 0)
723 |
724 | self.m_staticText33 = wx.StaticText(self.m_panel111, wx.ID_ANY, u"ID:", wx.DefaultPosition, wx.DefaultSize, 0)
725 | self.m_staticText33.Wrap(-1)
726 | gSizer3.Add(self.m_staticText33, 0, wx.ALL, 5)
727 |
728 | self.m_staticText34 = wx.StaticText(self.m_panel111, wx.ID_ANY, u"Value:", wx.DefaultPosition, wx.DefaultSize,
729 | 0)
730 | self.m_staticText34.Wrap(-1)
731 | gSizer3.Add(self.m_staticText34, 0, wx.ALL, 5)
732 |
733 | self.m_staticText35 = wx.StaticText(self.m_panel111, wx.ID_ANY, u"Startbit:", wx.DefaultPosition,
734 | wx.DefaultSize, 0)
735 | self.m_staticText35.Wrap(-1)
736 | gSizer3.Add(self.m_staticText35, 0, wx.ALL, 5)
737 |
738 | self.m_staticText38 = wx.StaticText(self.m_panel111, wx.ID_ANY, u"Length:", wx.DefaultPosition, wx.DefaultSize,
739 | 0)
740 | self.m_staticText38.Wrap(-1)
741 | gSizer3.Add(self.m_staticText38, 0, wx.ALL, 5)
742 |
743 | self.m_staticText36 = wx.StaticText(self.m_panel111, wx.ID_ANY, u"Factor:", wx.DefaultPosition, wx.DefaultSize,
744 | 0)
745 | self.m_staticText36.Wrap(-1)
746 | gSizer3.Add(self.m_staticText36, 0, wx.ALL, 5)
747 |
748 | self.m_staticText39 = wx.StaticText(self.m_panel111, wx.ID_ANY, u"Offset:", wx.DefaultPosition, wx.DefaultSize,
749 | 0)
750 | self.m_staticText39.Wrap(-1)
751 | gSizer3.Add(self.m_staticText39, 0, wx.ALL, 5)
752 |
753 | self.m_textCtrl13 = wx.TextCtrl(self.m_panel111, wx.ID_ANY, u"0x302", wx.DefaultPosition, wx.Size(70, -1), 0)
754 | gSizer3.Add(self.m_textCtrl13, 0, wx.ALL, 5)
755 |
756 | self.m_textCtrl14 = wx.TextCtrl(self.m_panel111, wx.ID_ANY, u"980", wx.DefaultPosition, wx.Size(70, -1), 0)
757 | gSizer3.Add(self.m_textCtrl14, 0, wx.ALL, 5)
758 |
759 | self.m_textCtrl15 = wx.TextCtrl(self.m_panel111, wx.ID_ANY, u"8", wx.DefaultPosition, wx.Size(70, -1), 0)
760 | gSizer3.Add(self.m_textCtrl15, 0, wx.ALL, 5)
761 |
762 | self.m_textCtrl16 = wx.TextCtrl(self.m_panel111, wx.ID_ANY, u"16", wx.DefaultPosition, wx.Size(70, -1), 0)
763 | gSizer3.Add(self.m_textCtrl16, 0, wx.ALL, 5)
764 |
765 | self.m_textCtrl17 = wx.TextCtrl(self.m_panel111, wx.ID_ANY, u"0.25", wx.DefaultPosition, wx.Size(70, -1), 0)
766 | gSizer3.Add(self.m_textCtrl17, 0, wx.ALL, 5)
767 |
768 | self.m_textCtrl18 = wx.TextCtrl(self.m_panel111, wx.ID_ANY, u"0", wx.DefaultPosition, wx.Size(70, -1), 0)
769 | gSizer3.Add(self.m_textCtrl18, 0, wx.ALL, 5)
770 |
771 | bSizer42.Add(gSizer3, 1, wx.EXPAND, 5)
772 |
773 | bSizer43 = wx.BoxSizer(wx.HORIZONTAL)
774 |
775 | self.m_staticText40 = wx.StaticText(self.m_panel111, wx.ID_ANY, u"Name:", wx.DefaultPosition, wx.DefaultSize, 0)
776 | self.m_staticText40.Wrap(-1)
777 | bSizer43.Add(self.m_staticText40, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5)
778 |
779 | self.m_textCtrl19 = wx.TextCtrl(self.m_panel111, wx.ID_ANY, u"EngineSpeed", wx.DefaultPosition,
780 | wx.Size(150, -1), 0)
781 | bSizer43.Add(self.m_textCtrl19, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5)
782 |
783 | self.m_radioBtn10 = wx.RadioButton(self.m_panel111, wx.ID_ANY, u"Motorola", wx.DefaultPosition, wx.DefaultSize,
784 | 0)
785 | bSizer43.Add(self.m_radioBtn10, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5)
786 |
787 | self.m_radioBtn101 = wx.RadioButton(self.m_panel111, wx.ID_ANY, u"Intel", wx.DefaultPosition, wx.DefaultSize, 0)
788 | bSizer43.Add(self.m_radioBtn101, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5)
789 |
790 | self.m_button21 = wx.Button(self.m_panel111, wx.ID_ANY, u"Add", wx.DefaultPosition, wx.DefaultSize, 0)
791 | bSizer43.Add(self.m_button21, 0, wx.ALL | wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL, 5)
792 |
793 | bSizer42.Add(bSizer43, 1, wx.EXPAND, 5)
794 |
795 | bSizer11111.Add(bSizer42, 1, wx.EXPAND, 5)
796 |
797 | self.m_staticline6111 = wx.StaticLine(self.m_panel111, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize,
798 | wx.LI_HORIZONTAL)
799 | bSizer11111.Add(self.m_staticline6111, 0, wx.EXPAND | wx.ALL, 5)
800 |
801 | self.m_staticText12111 = wx.StaticText(self.m_panel111, wx.ID_ANY, u"Signals:", wx.DefaultPosition,
802 | wx.DefaultSize, 0)
803 | self.m_staticText12111.Wrap(-1)
804 | self.m_staticText12111.SetFont(
805 | wx.Font(wx.NORMAL_FONT.GetPointSize(), wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD,
806 | False, wx.EmptyString))
807 |
808 | bSizer11111.Add(self.m_staticText12111, 0, wx.ALL, 5)
809 |
810 | m_listBox21Choices = [u"BrakePadelStatus, ID:0x302, Value:1, Startbit:37, Length:2, Factor:1, Offset:0",
811 | u"EngineSpeed, ID:0x302, Value:980, Startbit:8, Length:16, Factor:0.25, Offset:0",
812 | wx.EmptyString]
813 | self.m_listBox21 = wx.ListBox(self.m_panel111, wx.ID_ANY, wx.DefaultPosition, wx.Size(-1, 110),
814 | m_listBox21Choices, wx.LB_MULTIPLE)
815 | bSizer11111.Add(self.m_listBox21, 0, wx.ALL | wx.EXPAND, 5)
816 |
817 | self.m_btn_figure1 = wx.Button(self.m_panel111, wx.ID_ANY, u"Generate frames", wx.DefaultPosition,
818 | wx.DefaultSize, 0)
819 | bSizer11111.Add(self.m_btn_figure1, 0, wx.ALL | wx.ALIGN_RIGHT, 5)
820 |
821 | self.m_staticline101111 = wx.StaticLine(self.m_panel111, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize,
822 | wx.LI_HORIZONTAL)
823 | bSizer11111.Add(self.m_staticline101111, 0, wx.EXPAND | wx.ALL, 5)
824 |
825 | self.m_staticText121111 = wx.StaticText(self.m_panel111, wx.ID_ANY, u"Result:", wx.DefaultPosition,
826 | wx.DefaultSize, 0)
827 | self.m_staticText121111.Wrap(-1)
828 | self.m_staticText121111.SetFont(
829 | wx.Font(wx.NORMAL_FONT.GetPointSize(), wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD,
830 | False, wx.EmptyString))
831 |
832 | bSizer11111.Add(self.m_staticText121111, 0, wx.ALL, 5)
833 |
834 | m_listBox211Choices = [u"ID:0x302, 00 0F 50 00 04 00 00 00"]
835 | self.m_listBox211 = wx.ListBox(self.m_panel111, wx.ID_ANY, wx.DefaultPosition, wx.Size(-1, 110),
836 | m_listBox211Choices, wx.LB_MULTIPLE)
837 | bSizer11111.Add(self.m_listBox211, 0, wx.ALL | wx.EXPAND, 5)
838 |
839 | self.m_panel111.SetSizer(bSizer11111)
840 | self.m_panel111.Layout()
841 | bSizer11111.Fit(self.m_panel111)
842 | self.m_notebook1.AddPage(self.m_panel111, u"Package frame", False)
843 |
844 | bSizer61.Add(self.m_notebook1, 1, wx.EXPAND | wx.ALL, 5)
845 |
846 | self.m_staticline21 = wx.StaticLine(self.m_panel2, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize,
847 | wx.LI_HORIZONTAL)
848 | bSizer61.Add(self.m_staticline21, 0, wx.EXPAND | wx.ALL, 5)
849 |
850 | self.m_panel2.SetSizer(bSizer61)
851 | self.m_panel2.Layout()
852 | bSizer61.Fit(self.m_panel2)
853 | self.m_splitter2.SplitVertically(self.m_panel1, self.m_panel2, 224)
854 | bSizer2.Add(self.m_splitter2, 1, wx.EXPAND, 5)
855 |
856 | self.SetSizer(bSizer2)
857 | self.Layout()
858 | self.m_statusBar1 = self.CreateStatusBar(1, 0 | wx.NO_BORDER, wx.ID_ANY)
859 |
860 | self.Centre(wx.BOTH)
861 |
862 | # Connect Events
863 | self.Bind(wx.EVT_CLOSE, self.OnExit)
864 | self.m_buttonOpen.Bind(wx.EVT_BUTTON, self.clickOpen)
865 | self.m_buttonTest.Bind(wx.EVT_BUTTON, self.clickTest)
866 | self.m_btn_start_tracing.Bind(wx.EVT_BUTTON, self.onclick_start_tracing)
867 | self.m_btn_pause_tracing.Bind(wx.EVT_BUTTON, self.onclick_pause_tracing)
868 | self.m_btn_stop_tracing.Bind(wx.EVT_BUTTON, self.onclick_stop_tracing)
869 | self.m_cb_time_mode.Bind(wx.EVT_CHECKBOX, self.onclick_cb_trace_time_mode)
870 | self.m_choice_tracelist_mode.Bind(wx.EVT_CHOICE, self.onclick_choice_tracelist_mode)
871 | self.m_btn_clean_up.Bind(wx.EVT_BUTTON, self.onclick_trace_clean_up)
872 | self.m_btn_start_player.Bind(wx.EVT_BUTTON, self.onclick_start_play)
873 | self.m_btn_pause_player.Bind(wx.EVT_BUTTON, self.onclick_pause_play)
874 | self.m_btn_stop_player.Bind(wx.EVT_BUTTON, self.onclick_stop_play)
875 | self.m_textCtrl_player_loop.Bind(wx.EVT_TEXT, self.on_text_enter_player)
876 | self.m_button_analysis1.Bind(wx.EVT_BUTTON, self.onclick_btn_fuzzing_attack)
877 | self.m_checkBox_a_fd.Bind(wx.EVT_CHECKBOX, self.on_check_box_fd)
878 | self.m_textCtrl_fixdata1.Bind(wx.EVT_TEXT, self.on_text_enter_at_fixd1)
879 | self.m_textCtrl_fixdata2.Bind(wx.EVT_TEXT, self.on_text_enter_at_fixd2)
880 | self.m_textCtrl_fixdata3.Bind(wx.EVT_TEXT, self.on_text_enter_at_fixd3)
881 | self.m_textCtrl_fixdata4.Bind(wx.EVT_TEXT, self.on_text_enter_at_fixd4)
882 | self.m_textCtrl_fixdata5.Bind(wx.EVT_TEXT, self.on_text_enter_at_fixd5)
883 | self.m_textCtrl_fixdata6.Bind(wx.EVT_TEXT, self.on_text_enter_at_fixd6)
884 | self.m_textCtrl_fixdata7.Bind(wx.EVT_TEXT, self.on_text_enter_at_fixd7)
885 | self.m_textCtrl_fixdata8.Bind(wx.EVT_TEXT, self.on_text_enter_at_fixd8)
886 | self.m_checkBox_a_do.Bind(wx.EVT_CHECKBOX, self.on_check_box_do)
887 | self.m_slider_fuzzing_f.Bind(wx.EVT_SCROLL, self.on_fuzzing_fre_change)
888 | self.m_button_attack_start.Bind(wx.EVT_BUTTON, self.onclick_attack_start)
889 | self.m_button_attack_stop.Bind(wx.EVT_BUTTON, self.onclick_attack_stop)
890 | self.m_btn_convert.Bind(wx.EVT_BUTTON, self.onclick_convert)
891 | self.m_btn_convert_data.Bind(wx.EVT_BUTTON, self.onclick_data_convert)
892 | self.m_btn_da_analyze.Bind(wx.EVT_BUTTON, self.onclick_da_analye)
893 | self.m_btn_figure.Bind(wx.EVT_BUTTON, self.onclick_da_generate)
894 | self.m_btn_figure1.Bind(wx.EVT_BUTTON, self.onclick_da_generate)
895 |
896 | def __del__(self):
897 | pass
898 |
899 | # Virtual event handlers, overide them in your derived class
900 | def OnExit(self, event):
901 | event.Skip()
902 |
903 | def clickOpen(self, event):
904 | event.Skip()
905 |
906 | def clickTest(self, event):
907 | event.Skip()
908 |
909 | def onclick_start_tracing(self, event):
910 | event.Skip()
911 |
912 | def onclick_pause_tracing(self, event):
913 | event.Skip()
914 |
915 | def onclick_stop_tracing(self, event):
916 | event.Skip()
917 |
918 | def onclick_cb_trace_time_mode(self, event):
919 | event.Skip()
920 |
921 | def onclick_choice_tracelist_mode(self, event):
922 | event.Skip()
923 |
924 | def onclick_trace_clean_up(self, event):
925 | event.Skip()
926 |
927 | def onclick_start_play(self, event):
928 | event.Skip()
929 |
930 | def onclick_pause_play(self, event):
931 | event.Skip()
932 |
933 | def onclick_stop_play(self, event):
934 | event.Skip()
935 |
936 | def on_text_enter_player(self, event):
937 | event.Skip()
938 |
939 | def onclick_btn_fuzzing_attack(self, event):
940 | event.Skip()
941 |
942 | def on_check_box_fd(self, event):
943 | event.Skip()
944 |
945 | def on_text_enter_at_fixd1(self, event):
946 | event.Skip()
947 |
948 | def on_text_enter_at_fixd2(self, event):
949 | event.Skip()
950 |
951 | def on_text_enter_at_fixd3(self, event):
952 | event.Skip()
953 |
954 | def on_text_enter_at_fixd4(self, event):
955 | event.Skip()
956 |
957 | def on_text_enter_at_fixd5(self, event):
958 | event.Skip()
959 |
960 | def on_text_enter_at_fixd6(self, event):
961 | event.Skip()
962 |
963 | def on_text_enter_at_fixd7(self, event):
964 | event.Skip()
965 |
966 | def on_text_enter_at_fixd8(self, event):
967 | event.Skip()
968 |
969 | def on_check_box_do(self, event):
970 | event.Skip()
971 |
972 | def on_fuzzing_fre_change(self, event):
973 | event.Skip()
974 |
975 | def onclick_attack_start(self, event):
976 | event.Skip()
977 |
978 | def onclick_attack_stop(self, event):
979 | event.Skip()
980 |
981 | def onclick_convert(self, event):
982 | event.Skip()
983 |
984 | def onclick_data_convert(self, event):
985 | event.Skip()
986 |
987 | def onclick_da_analye(self, event):
988 | event.Skip()
989 |
990 | def onclick_da_generate(self, event):
991 | event.Skip()
992 |
993 | def m_splitter2OnIdle(self, event):
994 | self.m_splitter2.SetSashPosition(224)
995 | self.m_splitter2.Unbind(wx.EVT_IDLE)
996 |
997 | def m_splitter7OnIdle(self, event):
998 | self.m_splitter7.SetSashPosition(237)
999 | self.m_splitter7.Unbind(wx.EVT_IDLE)
1000 |
1001 |
1002 |
--------------------------------------------------------------------------------
/frame.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TianTianlove/ATG-python/67024e24381de4a6c89e50ac2e774345a408961a/frame.pyc
--------------------------------------------------------------------------------
/tools.py:
--------------------------------------------------------------------------------
1 | import os
2 | import xml.etree.ElementTree as ET
3 |
4 |
5 | class Tool():
6 |
7 | @staticmethod
8 | def GetFileNameAndExt(filename):
9 | (filepath, tempfilename) = os.path.split(filename)
10 | (shotname, extension) = os.path.splitext(tempfilename)
11 | return extension
12 |
13 | @staticmethod
14 | def getlist(path):
15 | attack_list = []
16 | tree = ET.parse(path)
17 | root = tree.getroot()
18 | for attack in root:
19 | # print('child-tag is:',child.tag,',child.attrib:',child.attrib,',child.text:',child.text)
20 | if attack.attrib["type"] == "DoS":
21 | # print "1"
22 | i = 0
23 | atk = AttackMessage()
24 | atk.attack_type = 1
25 | for attack_info in attack:
26 | if i == 0:
27 | atk.start_t = int(attack_info.text)
28 | # print attack_info.text
29 | elif i == 1:
30 | atk.end_t = int(attack_info.text)
31 | i += 1
32 | # print atk.display_attack()
33 | attack_list.append(atk)
34 |
35 | if attack.attrib["type"] == "Fuzzing":
36 | # print "1"
37 | i = 0
38 | atk = AttackMessage()
39 | atk.attack_type = 3
40 | for attack_info in attack:
41 | if i == 0:
42 | atk.start_t = int(attack_info.text)
43 | elif i == 1:
44 | atk.end_t = int(attack_info.text)
45 | if i == 2:
46 | # print attack_info.attrib["type"]
47 | if attack_info.attrib["type"] == "random":
48 | atk.msg_type = 1
49 | # print "1"
50 | j = 0
51 | for msg_info in attack_info:
52 | if j == 0:
53 | atk.msg_range = msg_info.text
54 | j += 1
55 | elif attack_info.attrib["type"] == "fixed":
56 | atk.msg_type = 2
57 | # print "1"
58 | j = 0
59 | for msg_info in attack_info:
60 | if j == 0:
61 | atk.msg_id = int(msg_info.text, 16)
62 | elif j == 1:
63 | atk.msg_data = msg_info.text.split(" ")
64 | elif j == 2:
65 | atk.msg_fre = int(msg_info.text)
66 | j += 1
67 | i += 1
68 |
69 | # print atk.display_attack()
70 | attack_list.append(atk)
71 |
72 | elif attack.attrib["type"] == "Spoofing":
73 | print "Spoofing"
74 | i = 0
75 | atk = AttackMessage()
76 | atk.attack_type = 2
77 | for attack_info in attack:
78 | if i == 0:
79 | atk.start_t = int(attack_info.text)
80 | # print attack_info.text
81 | elif i == 1:
82 | atk.end_t = int(attack_info.text)
83 | # print attack_info.text
84 | if i == 2:
85 | # print attack_info.attrib["type"]
86 | if attack_info.attrib["type"] == "fixed":
87 | atk.msg_type = 1
88 | # print "1"
89 | j = 0
90 | for msg_info in attack_info:
91 | if j == 0:
92 | atk.msg_id = int(msg_info.text, 16)
93 | elif j == 1:
94 | atk.msg_data = msg_info.text.split(" ")
95 | pass
96 | elif j == 2:
97 | atk.msg_active_bit = int(msg_info.text, 16)
98 | elif j == 3:
99 | atk.msg_fre = int(msg_info.text)
100 | j += 1
101 |
102 | elif attack_info.attrib["type"] == "offset":
103 | atk.msg_type = 2
104 | # print "2"
105 | j = 0
106 | for msg_info in attack_info:
107 | if j == 0:
108 | atk.msg_id = int(msg_info.text, 16)
109 | elif j == 1:
110 | atk.msg_data = msg_info.text.split(" ")
111 | elif j == 2:
112 | atk.msg_active_bit = int(msg_info.text, 16)
113 | elif j == 3:
114 | atk.msg_fre = int(msg_info.text)
115 | j += 1
116 |
117 | elif attack_info.attrib["type"] == "random":
118 | atk.msg_type = 3
119 | # print "3"
120 | for msg_info in attack_info:
121 | atk.msg_fre = int(msg_info.text)
122 |
123 | i += 1
124 | attack_list.append(atk)
125 |
126 | return attack_list
127 |
128 |
129 | class AttackMessage:
130 | start_t = 0
131 | end_t = 0
132 | attack_type = 0
133 | # type 1 = DoS,type 2 = Spoofing, type 3 = Fuzzing
134 | msg_type = 0
135 | # msg_type 1 = fixed, msg_type 2 = offset, msg_type 3 = random
136 | msg_id = 0
137 | msg_data = [0, 0, 0, 0, 0, 0, 0, 0]
138 | msg_active_bit = 0xff
139 | msg_fre = 100
140 |
141 | msg_range = ""
142 |
143 | # def __init__(self, start_t, end_t, attack_type, msg_typ, msg_id, msg_data, msg_active_bit, msg_fre):
144 | # self.start_t = start_t
145 | # self.end_t = end_t
146 | # self.attack_type = attack_type
147 | # self.msg_type = msg_typ
148 | # self.msg_id = msg_id
149 | # self.msg_data = msg_data
150 | # self.msg_active_bit = msg_active_bit
151 | # self.msg_fre = msg_fre
152 |
153 | def __init__(self):
154 | self.start_t = 0
155 | self.end_t = 0
156 | self.attack_type = 0
157 | self.msg_type = 0
158 | self.msg_id = 0
159 | self.msg_data = [0, 0, 0, 0, 0, 0, 0, 0]
160 | self.msg_active_bit = 0xff
161 | self.msg_fre = 100
162 | self.msg_range = 100
163 |
164 | def display_attack(self):
165 | print (str(self.attack_type) + " Attack from " + str(self.start_t) + "-" + str(self.end_t))
166 |
167 |
168 |
169 |
170 |
171 |
--------------------------------------------------------------------------------
/tools.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TianTianlove/ATG-python/67024e24381de4a6c89e50ac2e774345a408961a/tools.pyc
--------------------------------------------------------------------------------
/trash.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TianTianlove/ATG-python/67024e24381de4a6c89e50ac2e774345a408961a/trash.bmp
--------------------------------------------------------------------------------
/usb2can.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TianTianlove/ATG-python/67024e24381de4a6c89e50ac2e774345a408961a/usb2can.dll
--------------------------------------------------------------------------------