hardsploit_gui 2.2 → 2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/bin/hardsploit_gui +2 -2
- data/lib/{Firmware → Firmwares}/FPGA/I2C/I2C_INTERACT/HARDSPLOIT_FIRMWARE_FPGA_I2C_INTERACT.rpd +0 -0
- data/lib/{Firmware/FPGA/SWD/SWD_INTERACT/HARDSPLOIT_FIRMWARE_FPGA_SWD_INTERACT.rpd → Firmwares/FPGA/PARALLEL/NO_MUX_PARALLEL_MEMORY/HARDSPLOIT_FIRMWARE_FPGA_NO_MUX_PARALLEL_MEMORY.rpd} +0 -0
- data/lib/Firmwares/FPGA/SPI/SPI_INTERACT/HARDSPLOIT_FIRMWARE_FPGA_SPI_INTERACT.rpd +0 -0
- data/lib/{Firmware/FPGA/SPI/SPI_INTERACT/HARDSPLOIT_FIRMWARE_FPGA_SPI_INTERACT.rpd → Firmwares/FPGA/SPI/SPI_SNIFFER/HARDSPLOIT_FIRMWARE_FPGA_SPI_SNIFFER.rpd} +0 -0
- data/lib/Firmwares/FPGA/SWD/SWD_INTERACT/HARDSPLOIT_FIRMWARE_FPGA_SWD_INTERACT.rpd +0 -0
- data/lib/{Firmware → Firmwares}/FPGA/TEST/TEST_INTERACT/HARDSPLOIT_FIRMWARE_FPGA_TEST_INTERACT.rpd +0 -0
- data/lib/Firmwares/FPGA/UART/UART_INTERACT/HARDSPLOIT_FIRMWARE_FPGA_UART_INTERACT.rpd +0 -0
- data/lib/{Firmware → Firmwares}/FPGA/VersionFPGA.rb +1 -1
- data/lib/{Firmware → Firmwares}/UC/HARDSPLOIT_FIRMWARE_UC.bin +0 -0
- data/lib/{Firmware → Firmwares}/UC/VersionUC.rb +1 -1
- data/lib/HardsploitAPI/Core/HardsploitAPI.rb +210 -0
- data/lib/HardsploitAPI/Core/HardsploitAPI_CONSTANT.rb +150 -0
- data/lib/HardsploitAPI/Core/HardsploitAPI_ERROR.rb +109 -0
- data/lib/HardsploitAPI/Core/HardsploitAPI_FIRMWARE.rb +305 -0
- data/lib/HardsploitAPI/{HardsploitAPI_PROGRESS.rb → Core/HardsploitAPI_PROGRESS.rb} +0 -0
- data/lib/HardsploitAPI/Core/HardsploitAPI_USB_COMMUNICATION.rb +166 -0
- data/lib/HardsploitAPI/Modules/I2C/HardsploitAPI_I2C.rb +356 -0
- data/lib/HardsploitAPI/{HardsploitAPI_NO_MUX_PARALLELE_MEMORY.rb → Modules/NO_MUX_PARALLEL_MEMORY/HardsploitAPI_NO_MUX_PARALLEL_MEMORY.rb} +26 -49
- data/lib/HardsploitAPI/Modules/NRF24L01/HardsploitAPI_NRF24L01.rb +306 -0
- data/lib/HardsploitAPI/Modules/SPI/HardsploitAPI_SPI.rb +340 -0
- data/lib/HardsploitAPI/Modules/SPI_SNIFFER/HardsploitAPI_SPI_SNIFFER.rb +83 -0
- data/lib/HardsploitAPI/Modules/SWD/HardsploitAPI_SWD.rb +367 -0
- data/lib/HardsploitAPI/Modules/SWD/HardsploitAPI_SWD_DEBUG.rb +89 -0
- data/lib/HardsploitAPI/Modules/SWD/HardsploitAPI_SWD_MEM_AP.rb +61 -0
- data/lib/HardsploitAPI/{SWD → Modules/SWD}/HardsploitAPI_SWD_STM32.rb +32 -15
- data/lib/HardsploitAPI/{HardsploitAPI_TEST_INTERACT.rb → Modules/TEST/HardsploitAPI_TEST_INTERACT.rb} +1 -1
- data/lib/HardsploitAPI/Modules/UART/HardsploitAPI_UART.rb +196 -0
- data/lib/Hardsploit_gui.rb +96 -0
- data/lib/class/Chip_editor.rb +186 -330
- data/lib/class/Chip_management.rb +496 -0
- data/lib/class/Command_editor.rb +130 -182
- data/lib/class/Command_table.rb +16 -22
- data/lib/class/Console.rb +0 -2
- data/lib/class/ErrorMsg.rb +312 -0
- data/lib/class/Export.rb +140 -0
- data/lib/class/Export_manager.rb +43 -43
- data/lib/class/Firmware.rb +52 -11
- data/lib/class/Generic_commands.rb +180 -190
- data/lib/class/Import.rb +193 -0
- data/lib/class/Progress_bar.rb +1 -0
- data/lib/class/Signal_mapper.rb +120 -0
- data/lib/class/Wire_helper.rb +132 -148
- data/lib/class/{I2C → i2c}/I2c_command.rb +16 -13
- data/lib/class/i2c/I2c_export.rb +95 -0
- data/lib/class/i2c/I2c_import.rb +117 -0
- data/lib/class/i2c/I2c_scanner.rb +114 -0
- data/lib/class/i2c/I2c_settings.rb +148 -0
- data/lib/class/parallel/Parallel_export.rb +118 -0
- data/lib/class/parallel/Parallel_import.rb +113 -0
- data/lib/class/parallel/Parallel_settings.rb +81 -0
- data/lib/class/spi/Spi_export.rb +108 -0
- data/lib/class/spi/Spi_import.rb +159 -0
- data/lib/class/spi/Spi_settings.rb +108 -0
- data/lib/class/spi/Spi_sniffer.rb +101 -0
- data/lib/class/swd/Swd.rb +125 -0
- data/lib/class/swd/Swd_scanner.rb +121 -0
- data/lib/class/swd/Swd_settings.rb +76 -0
- data/lib/class/uart/Uart_baudrate.rb +62 -0
- data/lib/class/uart/Uart_console.rb +115 -0
- data/lib/class/uart/Uart_settings.rb +102 -0
- data/lib/db/associations.rb +42 -29
- data/lib/db/database.rb +4 -0
- data/lib/db/development.sqlite3 +0 -0
- data/lib/db/migrate/004_create_manufacturers.rb +13 -0
- data/lib/db/migrate/005_create_packages.rb +13 -0
- data/lib/db/migrate/006_create_chip_types.rb +11 -0
- data/lib/db/migrate/007_create_buses.rb +11 -0
- data/lib/db/migrate/008_create_signals.rb +14 -0
- data/lib/db/migrate/009_create_chips.rb +25 -0
- data/lib/db/migrate/010_create_commands.rb +21 -0
- data/lib/db/migrate/011_create_bytes.rb +19 -0
- data/lib/db/migrate/012_create_i2c_settings.rb +21 -0
- data/lib/db/migrate/013_create_spi_settings.rb +26 -0
- data/lib/db/migrate/014_create_parallel_settings.rb +21 -0
- data/lib/db/migrate/015_create_pins.rb +19 -0
- data/lib/db/migrate/016_create_uses.rb +17 -0
- data/lib/db/migrate/017_create_swd_settings.rb +19 -0
- data/lib/db/migrate/018_create_uart_settings.rb +22 -0
- data/lib/db/schema.rb +157 -0
- data/lib/db/seeds.rb +161 -0
- data/lib/gui/gui_chip_editor.rb +23 -22
- data/lib/gui/gui_chip_management.rb +43 -38
- data/lib/gui/gui_command_editor.rb +2 -1
- data/lib/gui/gui_export.rb +132 -0
- data/lib/gui/gui_generic_commands.rb +69 -31
- data/lib/gui/gui_generic_export.rb +18 -2
- data/lib/gui/gui_generic_import.rb +18 -2
- data/lib/gui/gui_i2c_command.rb +2 -1
- data/lib/gui/gui_i2c_settings.rb +2 -2
- data/lib/gui/gui_import.rb +131 -0
- data/lib/gui/gui_parallel_settings.rb +2 -1
- data/lib/gui/gui_progress_bar.rb +2 -1
- data/lib/gui/gui_signal_mapper.rb +121 -0
- data/lib/gui/gui_signal_scanner.rb +146 -0
- data/lib/gui/gui_spi_settings.rb +6 -2
- data/lib/gui/gui_spi_sniffer.rb +112 -0
- data/lib/gui/gui_swd_settings.rb +166 -0
- data/lib/gui/gui_uart_baudrate.rb +114 -0
- data/lib/gui/gui_uart_console.rb +164 -0
- data/lib/gui/gui_uart_settings.rb +243 -0
- data/lib/gui_designer/gui_chip_editor.ui +9 -6
- data/lib/gui_designer/gui_chip_management.ui +79 -35
- data/lib/gui_designer/gui_command_editor.ui +3 -0
- data/lib/gui_designer/gui_export.ui +171 -0
- data/lib/gui_designer/gui_generic_commands.ui +274 -190
- data/lib/gui_designer/gui_generic_export.ui +24 -1
- data/lib/gui_designer/gui_generic_import.ui +25 -2
- data/lib/gui_designer/gui_i2c_command.ui +3 -0
- data/lib/gui_designer/gui_i2c_settings.ui +2 -2
- data/lib/gui_designer/gui_import.ui +168 -0
- data/lib/gui_designer/gui_parallel_settings.ui +4 -1
- data/lib/gui_designer/gui_progress_bar.ui +3 -0
- data/lib/gui_designer/gui_signal_mapper.ui +179 -0
- data/lib/gui_designer/gui_signal_scanner.ui +261 -0
- data/lib/gui_designer/gui_spi_settings.ui +15 -2
- data/lib/gui_designer/gui_spi_sniffer.ui +156 -0
- data/lib/gui_designer/gui_swd_settings.ui +189 -0
- data/lib/gui_designer/gui_uart_baudrate.ui +161 -0
- data/lib/gui_designer/gui_uart_console.ui +284 -0
- data/lib/gui_designer/gui_uart_settings.ui +280 -0
- data/lib/logs/error.log +63 -0
- data/lib/models/bus.rb +19 -0
- data/lib/models/byte.rb +29 -0
- data/lib/models/chip.rb +41 -0
- data/lib/models/chip_type.rb +14 -0
- data/lib/models/command.rb +20 -0
- data/lib/models/i2c_setting.rb +41 -0
- data/lib/models/manufacturer.rb +14 -0
- data/lib/models/package.rb +26 -0
- data/lib/models/parallel_setting.rb +37 -0
- data/lib/models/pin.rb +14 -0
- data/lib/models/signall.rb +20 -0
- data/lib/models/spi_setting.rb +67 -0
- data/lib/models/swd_setting.rb +25 -0
- data/lib/models/uart_setting.rb +52 -0
- data/lib/models/use.rb +6 -0
- data/lib/startHardsploit.rb +2 -2
- metadata +106 -41
- data/lib/Firmware/FPGA/PARALLEL/NO_MUX_PARALLEL_MEMORY/HARDSPLOIT_FIRMWARE_FPGA_NO_MUX_PARALLEL_MEMORY.rpd +0 -0
- data/lib/HardsploitAPI/HardsploitAPI.rb +0 -133
- data/lib/HardsploitAPI/HardsploitAPI_CONSTANT.rb +0 -145
- data/lib/HardsploitAPI/HardsploitAPI_ERROR.rb +0 -38
- data/lib/HardsploitAPI/HardsploitAPI_FIRMWARE.rb +0 -311
- data/lib/HardsploitAPI/HardsploitAPI_I2C.rb +0 -360
- data/lib/HardsploitAPI/HardsploitAPI_SPI.rb +0 -369
- data/lib/HardsploitAPI/HardsploitAPI_USB_COMMUNICATION.rb +0 -148
- data/lib/HardsploitAPI/LICENSE.txt +0 -674
- data/lib/HardsploitAPI/README.md +0 -22
- data/lib/HardsploitAPI/SWD/HardsploitAPI_SWD.rb +0 -249
- data/lib/HardsploitAPI/SWD/HardsploitAPI_SWD_DEBUG.rb +0 -102
- data/lib/HardsploitAPI/SWD/HardsploitAPI_SWD_MEM_AP.rb +0 -78
- data/lib/HardsploitAPI/TRADEMARK +0 -3
- data/lib/class/HardsploitGUI.rb +0 -463
- data/lib/class/I2C/I2c_export.rb +0 -118
- data/lib/class/I2C/I2c_import.rb +0 -79
- data/lib/class/I2C/I2c_settings.rb +0 -129
- data/lib/class/PARALLEL/Parallel_export.rb +0 -146
- data/lib/class/PARALLEL/Parallel_import.rb +0 -88
- data/lib/class/PARALLEL/Parallel_settings.rb +0 -102
- data/lib/class/SPI/Spi_export.rb +0 -138
- data/lib/class/SPI/Spi_import.rb +0 -113
- data/lib/class/SPI/Spi_settings.rb +0 -134
- data/lib/db/hs.db +0 -0
- data/lib/hardsploit.rb +0 -131
data/lib/class/Console.rb
CHANGED
@@ -5,8 +5,6 @@
|
|
5
5
|
# License URI: http://www.gnu.org/licenses/gpl.txt
|
6
6
|
#===================================================
|
7
7
|
require 'date'
|
8
|
-
require_relative '../HardsploitAPI/HardsploitAPI'
|
9
|
-
require_relative '../class/Command_table'
|
10
8
|
require_relative '../gui/gui_command_editor'
|
11
9
|
class Console < Qt::TableWidget
|
12
10
|
|
@@ -0,0 +1,312 @@
|
|
1
|
+
class ErrorMsg
|
2
|
+
|
3
|
+
def hardsploit_not_found
|
4
|
+
Qt::MessageBox.new(
|
5
|
+
Qt::MessageBox::Critical,
|
6
|
+
'Hardsploit Connectivity',
|
7
|
+
'Hardsploit not detected. Please check the USB connection'
|
8
|
+
).exec
|
9
|
+
return true
|
10
|
+
end
|
11
|
+
|
12
|
+
def usb_error
|
13
|
+
Qt::MessageBox.new(
|
14
|
+
Qt::MessageBox::Critical,
|
15
|
+
'Hardsploit USB error',
|
16
|
+
'USB error occured'
|
17
|
+
).exec
|
18
|
+
end
|
19
|
+
|
20
|
+
def no_chip_loaded
|
21
|
+
Qt::MessageBox.new(
|
22
|
+
Qt::MessageBox::Information,
|
23
|
+
"Wire chip",
|
24
|
+
"You need to load a chip first"
|
25
|
+
).exec
|
26
|
+
return true
|
27
|
+
end
|
28
|
+
|
29
|
+
def invalid_pin_nbr
|
30
|
+
Qt::MessageBox.new(
|
31
|
+
Qt::MessageBox::Warning,
|
32
|
+
'Invalid pin number value',
|
33
|
+
'Pin number needs to be between 4 and 144'
|
34
|
+
).exec
|
35
|
+
end
|
36
|
+
|
37
|
+
def filesize_error
|
38
|
+
Qt::MessageBox.new(
|
39
|
+
Qt::MessageBox::Critical,
|
40
|
+
'Error',
|
41
|
+
'Dump error: The file size does not match with the given parameters'
|
42
|
+
).exec
|
43
|
+
end
|
44
|
+
|
45
|
+
def swd_not_found
|
46
|
+
Qt::MessageBox.new(
|
47
|
+
Qt::MessageBox::Information,
|
48
|
+
'SWD Action',
|
49
|
+
'No return from the SWD'
|
50
|
+
).exec
|
51
|
+
end
|
52
|
+
|
53
|
+
def swd_error
|
54
|
+
Qt::MessageBox.new(
|
55
|
+
Qt::MessageBox::Critical,
|
56
|
+
'SWD Action',
|
57
|
+
'An error occured while processing the SWD scan'
|
58
|
+
).exec
|
59
|
+
return false
|
60
|
+
end
|
61
|
+
|
62
|
+
def spi_error
|
63
|
+
Qt::MessageBox.new(
|
64
|
+
Qt::MessageBox::Critical,
|
65
|
+
'SPI Action',
|
66
|
+
'An error occured while processing the SPI command'
|
67
|
+
).exec
|
68
|
+
end
|
69
|
+
|
70
|
+
def spi_mode_missing
|
71
|
+
Qt::MessageBox.new(
|
72
|
+
Qt::MessageBox::Warning,
|
73
|
+
'SPI mode missing',
|
74
|
+
'Mode setting is missing for this chip'
|
75
|
+
).exec
|
76
|
+
return false
|
77
|
+
end
|
78
|
+
|
79
|
+
def spi_cmd_too_long
|
80
|
+
Qt::MessageBox.new(
|
81
|
+
Qt::MessageBox::Warning,
|
82
|
+
'SPI command invalid',
|
83
|
+
'SPI command size is to big (> 4000)'
|
84
|
+
).exec
|
85
|
+
return false
|
86
|
+
end
|
87
|
+
|
88
|
+
def i2c_error
|
89
|
+
Qt::MessageBox.new(
|
90
|
+
Qt::MessageBox::Critical,
|
91
|
+
'I²C Action',
|
92
|
+
'An error occured while processing the I²C command (I²C wrong speed)'
|
93
|
+
).exec
|
94
|
+
return false
|
95
|
+
end
|
96
|
+
|
97
|
+
def parallel_error
|
98
|
+
Qt::MessageBox.new(
|
99
|
+
Qt::MessageBox::Critical,
|
100
|
+
'Parallel Action',
|
101
|
+
'An error occured while processing the parallel command'
|
102
|
+
).exec
|
103
|
+
end
|
104
|
+
# Commands
|
105
|
+
|
106
|
+
def no_cmd_selected
|
107
|
+
Qt::MessageBox.new(
|
108
|
+
Qt::MessageBox::Warning,
|
109
|
+
'Missing command',
|
110
|
+
'Select a command in the array first'
|
111
|
+
).exec
|
112
|
+
return true
|
113
|
+
end
|
114
|
+
|
115
|
+
def concat_nbr
|
116
|
+
Qt::MessageBox.new(
|
117
|
+
Qt::MessageBox::Warning,
|
118
|
+
'Wrong selection',
|
119
|
+
'Select two commands in the table to concatenate them'
|
120
|
+
).exec
|
121
|
+
return true
|
122
|
+
end
|
123
|
+
|
124
|
+
def concat_disallow
|
125
|
+
Qt::MessageBox.new(
|
126
|
+
Qt::MessageBox::Warning,
|
127
|
+
'Concatenation option',
|
128
|
+
'This option can be used only with I2C bus commands'
|
129
|
+
).exec
|
130
|
+
return false
|
131
|
+
end
|
132
|
+
|
133
|
+
def lowbyte_missing
|
134
|
+
Qt::MessageBox.new(
|
135
|
+
Qt::MessageBox::Critical,
|
136
|
+
'Command error',
|
137
|
+
'Payload size invalid or payload size (low) missing'
|
138
|
+
).exec
|
139
|
+
return false
|
140
|
+
end
|
141
|
+
|
142
|
+
def highbyte_missing
|
143
|
+
Qt::MessageBox.new(
|
144
|
+
Qt::MessageBox::Critical,
|
145
|
+
'Command error',
|
146
|
+
'Payload size invalid or payload size (high) missing'
|
147
|
+
).exec
|
148
|
+
return false
|
149
|
+
end
|
150
|
+
|
151
|
+
def mode_missing
|
152
|
+
Qt::MessageBox.new(
|
153
|
+
Qt::MessageBox::Critical,
|
154
|
+
'Command error',
|
155
|
+
'Payload size invalid or Read / Write address missing'
|
156
|
+
).exec
|
157
|
+
return false
|
158
|
+
end
|
159
|
+
|
160
|
+
def size_neq_row_number
|
161
|
+
Qt::MessageBox.new(
|
162
|
+
Qt::MessageBox::Critical,
|
163
|
+
'Command error',
|
164
|
+
'The payload size does not match with the row number'
|
165
|
+
).exec
|
166
|
+
return false
|
167
|
+
end
|
168
|
+
|
169
|
+
def i2c_cmd_too_long
|
170
|
+
Qt::MessageBox.new(
|
171
|
+
Qt::MessageBox::Critical,
|
172
|
+
'I2C command invalid',
|
173
|
+
'Your payload is too big (> 2000)'
|
174
|
+
).exec
|
175
|
+
return false
|
176
|
+
end
|
177
|
+
|
178
|
+
def positive_cell_value
|
179
|
+
Qt::MessageBox.new(
|
180
|
+
Qt::MessageBox::Warning,
|
181
|
+
'Wrong data',
|
182
|
+
'Only positive values are accepted in this cell'
|
183
|
+
).exec
|
184
|
+
end
|
185
|
+
|
186
|
+
def hexa_cell_value
|
187
|
+
Qt::MessageBox.new(
|
188
|
+
Qt::MessageBox::Warning,
|
189
|
+
'Wrong data',
|
190
|
+
'Only hexadecimal values are accepted in this cell'
|
191
|
+
).exec
|
192
|
+
end
|
193
|
+
|
194
|
+
def char_cell_value
|
195
|
+
Qt::MessageBox.new(
|
196
|
+
Qt::MessageBox::Warning,
|
197
|
+
'Wrong data',
|
198
|
+
'Wrong characters in this cell'
|
199
|
+
).exec
|
200
|
+
end
|
201
|
+
|
202
|
+
def ascii_only
|
203
|
+
Qt::MessageBox.new(
|
204
|
+
Qt::MessageBox::Warning,
|
205
|
+
'String error',
|
206
|
+
'Only ASCII characters can be specified'
|
207
|
+
).exec
|
208
|
+
return false
|
209
|
+
end
|
210
|
+
|
211
|
+
# Global Settings
|
212
|
+
|
213
|
+
def settings_missing
|
214
|
+
Qt::MessageBox.new(
|
215
|
+
Qt::MessageBox::Warning,
|
216
|
+
'Missing settings',
|
217
|
+
'No settings saved for this chip'
|
218
|
+
).exec
|
219
|
+
return false
|
220
|
+
end
|
221
|
+
|
222
|
+
def frequency_missing
|
223
|
+
Qt::MessageBox.new(
|
224
|
+
Qt::MessageBox::Warning,
|
225
|
+
'Missing settings',
|
226
|
+
'Frequency setting missing'
|
227
|
+
).exec
|
228
|
+
return false
|
229
|
+
end
|
230
|
+
|
231
|
+
def mode_missing
|
232
|
+
Qt::MessageBox.new(
|
233
|
+
Qt::MessageBox::Warning,
|
234
|
+
'Missing settings',
|
235
|
+
'Missing write base address (I²C) or read command (SPI)'
|
236
|
+
).exec
|
237
|
+
return false
|
238
|
+
end
|
239
|
+
|
240
|
+
def full_size_error
|
241
|
+
Qt::MessageBox.new(
|
242
|
+
Qt::MessageBox::Warning,
|
243
|
+
'Empty field',
|
244
|
+
'Full size setting missing or equal 0'
|
245
|
+
).exec
|
246
|
+
return false
|
247
|
+
end
|
248
|
+
|
249
|
+
def start_stop_missing
|
250
|
+
Qt::MessageBox.new(
|
251
|
+
Qt::MessageBox::Warning,
|
252
|
+
'Empty field',
|
253
|
+
'Start and stop address must be filled'
|
254
|
+
).exec
|
255
|
+
return false
|
256
|
+
end
|
257
|
+
|
258
|
+
def start_neq_stop
|
259
|
+
Qt::MessageBox.new(
|
260
|
+
Qt::MessageBox::Warning,
|
261
|
+
'Wrong value',
|
262
|
+
'Start address must not be equal to the stop address'
|
263
|
+
).exec
|
264
|
+
return false
|
265
|
+
end
|
266
|
+
|
267
|
+
def start_inf_to_stop
|
268
|
+
Qt::MessageBox.new(
|
269
|
+
Qt::MessageBox::Warning,
|
270
|
+
'Wrong value',
|
271
|
+
'Start address must be inforior to the stop address'
|
272
|
+
).exec
|
273
|
+
return false
|
274
|
+
end
|
275
|
+
|
276
|
+
def inf_to_total_size
|
277
|
+
Qt::MessageBox.new(
|
278
|
+
Qt::MessageBox::Warning,
|
279
|
+
'Wrong value',
|
280
|
+
'Start and stop address must be inforior to the chip total size'
|
281
|
+
).exec
|
282
|
+
return false
|
283
|
+
end
|
284
|
+
|
285
|
+
def para_read_latency
|
286
|
+
Qt::MessageBox.new(
|
287
|
+
Qt::MessageBox::Warning,
|
288
|
+
'Missing parallel settings',
|
289
|
+
'Read latency setting missing'
|
290
|
+
).exec
|
291
|
+
return false
|
292
|
+
end
|
293
|
+
|
294
|
+
def para_word_size
|
295
|
+
Qt::MessageBox.new(
|
296
|
+
Qt::MessageBox::Warning,
|
297
|
+
'Missing parallel settings',
|
298
|
+
'Word size setting missing'
|
299
|
+
).exec
|
300
|
+
return false
|
301
|
+
end
|
302
|
+
|
303
|
+
# Unknown
|
304
|
+
def unknown(msg)
|
305
|
+
Logger.new($logFilePath).error(msg)
|
306
|
+
Qt::MessageBox.new(
|
307
|
+
Qt::MessageBox::Critical,
|
308
|
+
'Hardsploit unknown error',
|
309
|
+
'An unknown error has been detected. Check the log for more details.'
|
310
|
+
).exec
|
311
|
+
end
|
312
|
+
end
|
data/lib/class/Export.rb
ADDED
@@ -0,0 +1,140 @@
|
|
1
|
+
#===================================================
|
2
|
+
# Hardsploit GUI - By Opale Security
|
3
|
+
# www.opale-security.com || www.hardsploit.io
|
4
|
+
# License: GNU General Public License v3
|
5
|
+
# License URI: http://www.gnu.org/licenses/gpl.txt
|
6
|
+
#===================================================
|
7
|
+
|
8
|
+
require_relative '../gui/gui_export'
|
9
|
+
class Export < Qt::Widget
|
10
|
+
slots 'export()'
|
11
|
+
slots 'export_file()'
|
12
|
+
|
13
|
+
def initialize(chip_list)
|
14
|
+
super()
|
15
|
+
@export_ui = Ui_Export.new
|
16
|
+
centerWindow(self)
|
17
|
+
@export_ui.setupUi(self)
|
18
|
+
@chip_list = chip_list
|
19
|
+
@export_ui.rbn_cmds.setEnabled(false) unless @chip_list.count == 1
|
20
|
+
end
|
21
|
+
|
22
|
+
def export_file
|
23
|
+
@filepath = Qt::FileDialog.getSaveFileName(self, tr('Select a file'), '/')
|
24
|
+
end
|
25
|
+
|
26
|
+
def export
|
27
|
+
unless @filepath.nil?
|
28
|
+
@file = File.open("#{@filepath}.json", 'w')
|
29
|
+
unless @file.nil?
|
30
|
+
@file.write("{\n")
|
31
|
+
@chip_list.each_with_index do |current_chip, index|
|
32
|
+
@file.write("\t\"#{index}\": {\n")
|
33
|
+
@chip = Chip.find_by(reference: current_chip.text)
|
34
|
+
if @export_ui.rbn_both.isChecked
|
35
|
+
export_chip
|
36
|
+
export_commands
|
37
|
+
elsif @export_ui.rbn_comp.isChecked
|
38
|
+
export_chip
|
39
|
+
else
|
40
|
+
export_commands
|
41
|
+
end
|
42
|
+
if index.next < @chip_list.count
|
43
|
+
@file.write("\t},\n")
|
44
|
+
else
|
45
|
+
@file.write("\t}\n")
|
46
|
+
end
|
47
|
+
end
|
48
|
+
@file.write("}")
|
49
|
+
@file.close
|
50
|
+
end
|
51
|
+
Qt::MessageBox.new(Qt::MessageBox::Information, 'Export status', 'Export finished').exec
|
52
|
+
else
|
53
|
+
Qt::MessageBox.new(Qt::MessageBox::Warning, 'File missing', 'Choose a file before exporting').exec
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def export_chip
|
58
|
+
@file.write("\t\t\"chip\":{\n")
|
59
|
+
write_commons
|
60
|
+
write_settings
|
61
|
+
write_pins
|
62
|
+
if @export_ui.rbn_both.isChecked
|
63
|
+
@file.write("\t\t},\n")
|
64
|
+
else
|
65
|
+
@file.write("\t\t}\n")
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def write_commons
|
70
|
+
@file.write("\t\t\t\t\"package\": #{@chip.package.to_json},\n")
|
71
|
+
@file.write("\t\t\t\t\"chip_type\": #{@chip.chip_type.to_json},\n")
|
72
|
+
@file.write("\t\t\t\t\"manufacturer\": #{@chip.manufacturer.to_json},\n")
|
73
|
+
@file.write("\t\t\t\t\"characteristics\": #{@chip.to_json},\n")
|
74
|
+
end
|
75
|
+
|
76
|
+
def write_settings
|
77
|
+
@file.write("\t\t\t\t\"settings\":{\n")
|
78
|
+
if @chip.parallel_setting.nil?
|
79
|
+
@file.write("\t\t\t\t\t\t\"parralel\": {},\n")
|
80
|
+
else
|
81
|
+
@file.write("\t\t\t\t\t\t\"parralel\": #{@chip.parallel_setting.to_json},\n")
|
82
|
+
end
|
83
|
+
if @chip.spi_setting.nil?
|
84
|
+
@file.write("\t\t\t\t\t\t\"spi\": {},\n")
|
85
|
+
else
|
86
|
+
@file.write("\t\t\t\t\t\t\"spi\":#{@chip.spi_setting.to_json},\n")
|
87
|
+
end
|
88
|
+
if @chip.i2c_setting.nil?
|
89
|
+
@file.write("\t\t\t\t\t\t\"i2c\": {},\n")
|
90
|
+
else
|
91
|
+
@file.write("\t\t\t\t\t\t\"i2c\": #{@chip.i2c_setting.to_json},\n")
|
92
|
+
end
|
93
|
+
if @chip.swd_setting.nil?
|
94
|
+
@file.write("\t\t\t\t\t\t\"swd\": {},\n")
|
95
|
+
else
|
96
|
+
@file.write("\t\t\t\t\t\t\"swd\": #{@chip.swd_setting.to_json},\n")
|
97
|
+
end
|
98
|
+
if @chip.uart_setting.nil?
|
99
|
+
@file.write("\t\t\t\t\t\t\"uart\": {}\n")
|
100
|
+
else
|
101
|
+
@file.write("\t\t\t\t\t\t\"uart\": #{@chip.uart_setting.to_json}\n")
|
102
|
+
end
|
103
|
+
@file.write("\t\t\t\t},\n")
|
104
|
+
end
|
105
|
+
|
106
|
+
def write_pins
|
107
|
+
@file.write("\t\t\t\t\"pins\":[\n")
|
108
|
+
@chip.pins.each_with_index do |pin, index|
|
109
|
+
if index + 1 < @chip.pins.count
|
110
|
+
@file.write("\t\t\t\t\t\t#{pin.to_json},\n")
|
111
|
+
else
|
112
|
+
@file.write("\t\t\t\t\t\t#{pin.to_json}\n")
|
113
|
+
end
|
114
|
+
end
|
115
|
+
@file.write("\t\t\t\t]\n")
|
116
|
+
end
|
117
|
+
|
118
|
+
def export_commands
|
119
|
+
@file.write("\t\t\"commands\":{\n")
|
120
|
+
@chip.commands.each_with_index do |cmd, index|
|
121
|
+
@file.write("\t\t\t\t\"#{index}\":{\n")
|
122
|
+
@file.write("\t\t\t\t\t\t\"characteristics\": #{cmd.to_json},\n")
|
123
|
+
@file.write("\t\t\t\t\t\t\"bytes\":[\n")
|
124
|
+
cmd.bytes.each_with_index do |bytes, index|
|
125
|
+
if index + 1 < cmd.bytes.count
|
126
|
+
@file.write("\t\t\t\t\t\t\t\t#{bytes.to_json},\n")
|
127
|
+
else
|
128
|
+
@file.write("\t\t\t\t\t\t\t\t#{bytes.to_json}\n")
|
129
|
+
end
|
130
|
+
end
|
131
|
+
@file.write("\t\t\t\t\t\t]\n")
|
132
|
+
if index.next < @chip.commands.count
|
133
|
+
@file.write("\t\t\t\t},\n")
|
134
|
+
else
|
135
|
+
@file.write("\t\t\t\t}\n")
|
136
|
+
end
|
137
|
+
end
|
138
|
+
@file.write("\t\t}\n")
|
139
|
+
end
|
140
|
+
end
|