hardsploit_gui 2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +22 -0
- data/Rakefile +1 -0
- data/bin/hardsploit_gui +3 -0
- data/lib/Firmware/FPGA/I2C/I2C_INTERACT/HARDSPLOIT_FIRMWARE_FPGA_I2C_INTERACT.rpd +0 -0
- data/lib/Firmware/FPGA/PARALLEL/NO_MUX_PARALLEL_MEMORY/HARDSPLOIT_FIRMWARE_FPGA_NO_MUX_PARALLEL_MEMORY.rpd +0 -0
- data/lib/Firmware/FPGA/SPI/SPI_INTERACT/HARDSPLOIT_FIRMWARE_FPGA_SPI_INTERACT.rpd +0 -0
- data/lib/Firmware/FPGA/SWD/SWD_INTERACT/HARDSPLOIT_FIRMWARE_FPGA_SWD_INTERACT.rpd +0 -0
- data/lib/Firmware/FPGA/TEST/TEST_INTERACT/HARDSPLOIT_FIRMWARE_FPGA_TEST_INTERACT.rpd +0 -0
- data/lib/Firmware/FPGA/VersionFPGA.rb +5 -0
- data/lib/Firmware/UC/HARDSPLOIT_FIRMWARE_UC.bin +0 -0
- data/lib/Firmware/UC/VersionUC.rb +12 -0
- data/lib/HardsploitAPI/HardsploitAPI.rb +134 -0
- data/lib/HardsploitAPI/HardsploitAPI_CONSTANT.rb +145 -0
- data/lib/HardsploitAPI/HardsploitAPI_FIRMWARE.rb +311 -0
- data/lib/HardsploitAPI/HardsploitAPI_I2C.rb +218 -0
- data/lib/HardsploitAPI/HardsploitAPI_NO_MUX_PARALLELE_MEMORY.rb +229 -0
- data/lib/HardsploitAPI/HardsploitAPI_SPI.rb +179 -0
- data/lib/HardsploitAPI/HardsploitAPI_TEST_INTERACT.rb +98 -0
- data/lib/HardsploitAPI/HardsploitAPI_USB_COMMUNICATION.rb +149 -0
- data/lib/HardsploitAPI/LICENSE.txt +674 -0
- data/lib/HardsploitAPI/README.md +22 -0
- data/lib/HardsploitAPI/SWD/HardsploitAPI_SWD.rb +249 -0
- data/lib/HardsploitAPI/SWD/HardsploitAPI_SWD_DEBUG.rb +102 -0
- data/lib/HardsploitAPI/SWD/HardsploitAPI_SWD_MEM_AP.rb +78 -0
- data/lib/HardsploitAPI/SWD/HardsploitAPI_SWD_STM32.rb +104 -0
- data/lib/HardsploitAPI/TRADEMARK +3 -0
- data/lib/LICENSE.txt +674 -0
- data/lib/README.md +22 -0
- data/lib/TRADEMARK +3 -0
- data/lib/class/Chip_editor.rb +448 -0
- data/lib/class/Command_editor.rb +268 -0
- data/lib/class/Command_table.rb +239 -0
- data/lib/class/Console.rb +28 -0
- data/lib/class/Export_manager.rb +124 -0
- data/lib/class/Firmware.rb +29 -0
- data/lib/class/Generic_commands.rb +275 -0
- data/lib/class/HardsploitGUI.rb +462 -0
- data/lib/class/I2C/I2c_command.rb +48 -0
- data/lib/class/I2C/I2c_export.rb +121 -0
- data/lib/class/I2C/I2c_import.rb +92 -0
- data/lib/class/I2C/I2c_settings.rb +117 -0
- data/lib/class/PARALLEL/Parallel_export.rb +146 -0
- data/lib/class/PARALLEL/Parallel_import.rb +88 -0
- data/lib/class/PARALLEL/Parallel_settings.rb +102 -0
- data/lib/class/SPI/Spi_export.rb +141 -0
- data/lib/class/SPI/Spi_import.rb +112 -0
- data/lib/class/SPI/Spi_settings.rb +90 -0
- data/lib/class/Wire_helper.rb +246 -0
- data/lib/db/associations.rb +125 -0
- data/lib/db/hs.db +0 -0
- data/lib/gui/gui_chip_editor.rb +355 -0
- data/lib/gui/gui_chip_management.rb +372 -0
- data/lib/gui/gui_command_editor.rb +218 -0
- data/lib/gui/gui_export_manager.rb +93 -0
- data/lib/gui/gui_generic_commands.rb +164 -0
- data/lib/gui/gui_generic_export.rb +148 -0
- data/lib/gui/gui_generic_import.rb +126 -0
- data/lib/gui/gui_i2c_command.rb +115 -0
- data/lib/gui/gui_i2c_settings.rb +201 -0
- data/lib/gui/gui_parallel_settings.rb +194 -0
- data/lib/gui/gui_spi_import.rb +126 -0
- data/lib/gui/gui_spi_settings.rb +187 -0
- data/lib/gui/gui_wire_helper.rb +99 -0
- data/lib/gui_designer/gui_chip_editor.ui +553 -0
- data/lib/gui_designer/gui_chip_management.ui +842 -0
- data/lib/gui_designer/gui_command_editor.ui +347 -0
- data/lib/gui_designer/gui_export_manager.ui +115 -0
- data/lib/gui_designer/gui_generic_commands.ui +258 -0
- data/lib/gui_designer/gui_generic_export.ui +179 -0
- data/lib/gui_designer/gui_generic_import.ui +142 -0
- data/lib/gui_designer/gui_i2c_command.ui +145 -0
- data/lib/gui_designer/gui_i2c_settings.ui +261 -0
- data/lib/gui_designer/gui_parallel_settings.ui +244 -0
- data/lib/gui_designer/gui_processing.ui +81 -0
- data/lib/gui_designer/gui_spi_settings.ui +321 -0
- data/lib/gui_designer/gui_wire_helper.ui +117 -0
- data/lib/hardsploit.rb +122 -0
- data/lib/images/search.png +0 -0
- data/lib/logs/error.log +0 -0
- metadata +236 -0
@@ -0,0 +1,462 @@
|
|
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 '../HardsploitAPI/HardsploitAPI'
|
9
|
+
class HardsploitGUI < Qt::MainWindow
|
10
|
+
VERSION = "2.0"
|
11
|
+
slots 'load_tree(int, int)'
|
12
|
+
slots 'load_chip_action(QTreeWidgetItem*, int)'
|
13
|
+
slots 'feed_chip_array()'
|
14
|
+
slots 'update_uc_firmware()'
|
15
|
+
slots 'get_hardsploit_versions()'
|
16
|
+
slots 'get_log_path()'
|
17
|
+
slots 'get_db_path()'
|
18
|
+
slots 'get_hardsploit_website()'
|
19
|
+
slots 'set_firmware()'
|
20
|
+
slots 'display_current_firmware()'
|
21
|
+
slots 'console_view()'
|
22
|
+
slots 'add_chip()'
|
23
|
+
slots 'edit_chip()'
|
24
|
+
slots 'wire_chip()'
|
25
|
+
slots 'delete_chip()'
|
26
|
+
slots 'swd_detect()'
|
27
|
+
slots 'swd_import()'
|
28
|
+
slots 'swd_export()'
|
29
|
+
slots 'swd_erase()'
|
30
|
+
|
31
|
+
def initialize(api)
|
32
|
+
super()
|
33
|
+
@cm = Ui_Chip_management.new
|
34
|
+
@cm.setupUi(self)
|
35
|
+
@api = api
|
36
|
+
@cm.img_search.setPixmap(Qt::Pixmap.new(File.expand_path(File.dirname(__FILE__)) + "/../images/search.png"))
|
37
|
+
inputRestrict(@cm.lie_search, 2)
|
38
|
+
feed_chip_array
|
39
|
+
feed_manufacturer_cbx
|
40
|
+
feed_type_cbx
|
41
|
+
@cm.tbl_chip.resizeColumnsToContents
|
42
|
+
@cm.tbl_chip.resizeRowsToContents
|
43
|
+
@cm.tbl_chip.horizontalHeader.stretchLastSection = true
|
44
|
+
@cm.tbl_console.horizontalHeader.stretchLastSection = true
|
45
|
+
@console = Console.new(@cm.tbl_console)
|
46
|
+
check_hardsploit_connection(api)
|
47
|
+
rescue Exception => msg
|
48
|
+
logger = Logger.new($logFilePath)
|
49
|
+
logger.error msg
|
50
|
+
Qt::MessageBox.new(Qt::MessageBox::Critical, "GUI Error", "Error while loading Hardsploit GUI").exec
|
51
|
+
end
|
52
|
+
|
53
|
+
def feed_type_cbx
|
54
|
+
manufacturer = Manufacturer.all
|
55
|
+
manufacturer.each do |m|
|
56
|
+
@cm.cbx_manufacturer.addItem(m.manufacturer_name)
|
57
|
+
end
|
58
|
+
rescue Exception => msg
|
59
|
+
logger = Logger.new($logFilePath)
|
60
|
+
logger.error msg
|
61
|
+
Qt::MessageBox.new(Qt::MessageBox::Critical, "Error", "Error while loading the manufacturer list from the database").exec
|
62
|
+
end
|
63
|
+
|
64
|
+
def feed_manufacturer_cbx
|
65
|
+
cType = CType.all
|
66
|
+
cType.each do |c|
|
67
|
+
@cm.cbx_type.addItem(c.cType_name)
|
68
|
+
end
|
69
|
+
rescue Exception => msg
|
70
|
+
logger = Logger.new($logFilePath)
|
71
|
+
logger.error msg
|
72
|
+
Qt::MessageBox.new(Qt::MessageBox::Critical, "Error", "Error while loading the type list from the database").exec
|
73
|
+
end
|
74
|
+
|
75
|
+
def console_view
|
76
|
+
if @cm.check_console.isChecked
|
77
|
+
@cm.tbl_console.show
|
78
|
+
else
|
79
|
+
@cm.tbl_console.hide
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def get_chip_buses(chip)
|
84
|
+
chip_bus_name = []
|
85
|
+
chip_bus_id = []
|
86
|
+
chipSignalId = chip.pin.pluck(:pin_signal)
|
87
|
+
chipSignalId.delete(62) # NA
|
88
|
+
chipSignalId.each do |s|
|
89
|
+
chip_bus_id.push(Use.find_by(signal_id: s).bus_id)
|
90
|
+
end
|
91
|
+
chip_bus_id.uniq.each do |b|
|
92
|
+
chip_bus_name.push(Bus.find_by(bus_id: b).bus_name)
|
93
|
+
end
|
94
|
+
return chip_bus_name
|
95
|
+
rescue Exception => msg
|
96
|
+
logger = Logger.new($logFilePath)
|
97
|
+
logger.error msg
|
98
|
+
Qt::MessageBox.new(Qt::MessageBox::Critical, "Error", "Error while getting the bus list").exec
|
99
|
+
end
|
100
|
+
|
101
|
+
def load_tree(line, column)
|
102
|
+
return 0 unless column.zero?
|
103
|
+
@cm.tw_chip.clear
|
104
|
+
@chip_clicked = Chip.find_by(chip_reference: @cm.tbl_chip.item(line, column).text)
|
105
|
+
# CHIP LEVEL
|
106
|
+
chip_lvl = Qt::TreeWidgetItem.new
|
107
|
+
chip_lvl.setText(0, @cm.tbl_chip.item(line, column).text)
|
108
|
+
# ACTION LEVEL
|
109
|
+
action_lvl = Qt::TreeWidgetItem.new
|
110
|
+
action_lvl.setText(0, 'Manage')
|
111
|
+
chip_lvl.addChild(create_action_nodes(action_lvl))
|
112
|
+
# BUS LEVEL(S)
|
113
|
+
chip_bus = get_chip_buses(@chip_clicked)
|
114
|
+
chip_bus.each do |b|
|
115
|
+
bus_lvl = Qt::TreeWidgetItem.new
|
116
|
+
bus_lvl.setText(0, b)
|
117
|
+
chip_lvl.addChild(create_bus_nodes(b, bus_lvl))
|
118
|
+
end
|
119
|
+
# ADD THE PARENT NODE
|
120
|
+
@cm.tw_chip.addTopLevelItem(chip_lvl)
|
121
|
+
end
|
122
|
+
|
123
|
+
def create_action_nodes(parent_node)
|
124
|
+
wiring_lvl = Qt::TreeWidgetItem.new
|
125
|
+
wiring_lvl.setText(0, "Wiring")
|
126
|
+
parent_node.addChild(wiring_lvl)
|
127
|
+
edit_lvl = Qt::TreeWidgetItem.new
|
128
|
+
edit_lvl.setText(0, "Edit")
|
129
|
+
parent_node.addChild(edit_lvl)
|
130
|
+
template_lvl = Qt::TreeWidgetItem.new
|
131
|
+
template_lvl.setText(0, "Template")
|
132
|
+
parent_node.addChild(template_lvl)
|
133
|
+
delete_lvl = Qt::TreeWidgetItem.new
|
134
|
+
delete_lvl.setText(0, "Delete")
|
135
|
+
parent_node.addChild(delete_lvl)
|
136
|
+
return parent_node
|
137
|
+
end
|
138
|
+
|
139
|
+
def create_bus_nodes(bus, parent_node)
|
140
|
+
case bus
|
141
|
+
when 'SPI', 'I2C'
|
142
|
+
settings_lvl = Qt::TreeWidgetItem.new
|
143
|
+
settings_lvl.setText(0, "Settings")
|
144
|
+
parent_node.addChild(settings_lvl)
|
145
|
+
cmd_lvl = Qt::TreeWidgetItem.new
|
146
|
+
cmd_lvl.setText(0, "Commands")
|
147
|
+
parent_node.addChild(cmd_lvl)
|
148
|
+
import_lvl = Qt::TreeWidgetItem.new
|
149
|
+
import_lvl.setText(0, "Import")
|
150
|
+
parent_node.addChild(import_lvl)
|
151
|
+
export_lvl = Qt::TreeWidgetItem.new
|
152
|
+
export_lvl.setText(0, "Export")
|
153
|
+
parent_node.addChild(export_lvl)
|
154
|
+
when 'PARALLEL'
|
155
|
+
settings_lvl = Qt::TreeWidgetItem.new
|
156
|
+
settings_lvl.setText(0, "Settings")
|
157
|
+
parent_node.addChild(settings_lvl)
|
158
|
+
import_lvl = Qt::TreeWidgetItem.new
|
159
|
+
import_lvl.setText(0, "Import")
|
160
|
+
parent_node.addChild(import_lvl)
|
161
|
+
export_lvl = Qt::TreeWidgetItem.new
|
162
|
+
export_lvl.setText(0, "Export")
|
163
|
+
parent_node.addChild(export_lvl)
|
164
|
+
end
|
165
|
+
return parent_node
|
166
|
+
end
|
167
|
+
|
168
|
+
def feed_chip_array
|
169
|
+
@cm.tbl_chip.clearContents
|
170
|
+
ref = @cm.lie_search.text
|
171
|
+
if @cm.cbx_manufacturer.currentIndex != 0
|
172
|
+
manufacturer = Manufacturer.find_by(manufacturer_name: @cm.cbx_manufacturer.currentText).manufacturer_id
|
173
|
+
end
|
174
|
+
if @cm.cbx_type.currentIndex != 0
|
175
|
+
type = CType.find_by(cType_name: @cm.cbx_type.currentText).cType_id
|
176
|
+
end
|
177
|
+
if ref.empty?
|
178
|
+
chip = Chip.all
|
179
|
+
else
|
180
|
+
chip = Chip.where("chip_reference LIKE ?", "%#{ref}%")
|
181
|
+
end
|
182
|
+
chip = chip.where("chip_manufacturer = ?", manufacturer) unless manufacturer.nil?
|
183
|
+
chip = chip.where("chip_type = ?", type) unless type.nil?
|
184
|
+
@cm.tbl_chip.setRowCount(chip.count);
|
185
|
+
# Insert elements
|
186
|
+
chip.to_enum.with_index(0).each do |c, i|
|
187
|
+
item = Qt::TableWidgetItem.new(c.chip_reference)
|
188
|
+
item.setFlags(Qt::ItemIsSelectable|Qt::ItemIsEnabled)
|
189
|
+
@cm.tbl_chip.setItem(i, 0, item)
|
190
|
+
|
191
|
+
item2 = Qt::TableWidgetItem.new(CType.find(c.chip_type).cType_name)
|
192
|
+
item2.setFlags(Qt::ItemIsEnabled)
|
193
|
+
@cm.tbl_chip.setItem(i, 1, item2)
|
194
|
+
|
195
|
+
item3 = Qt::TableWidgetItem.new(Manufacturer.find(c.chip_manufacturer).manufacturer_name)
|
196
|
+
item3.setFlags(Qt::ItemIsEnabled)
|
197
|
+
@cm.tbl_chip.setItem(i, 2, item3)
|
198
|
+
bus_list = get_chip_buses(c)
|
199
|
+
bus_list_str = ''
|
200
|
+
bus_list.each do |b|
|
201
|
+
bus_list_str = bus_list_str + "#{b} "
|
202
|
+
end
|
203
|
+
|
204
|
+
item4 = Qt::TableWidgetItem.new(bus_list_str)
|
205
|
+
item4.setFlags(Qt::ItemIsEnabled)
|
206
|
+
@cm.tbl_chip.setItem(i, 3, item4)
|
207
|
+
end
|
208
|
+
rescue Exception => msg
|
209
|
+
logger = Logger.new($logFilePath)
|
210
|
+
logger.error msg
|
211
|
+
Qt::MessageBox.new(Qt::MessageBox::Critical, "Critical error", "Error occured while loading the chip array").exec
|
212
|
+
end
|
213
|
+
|
214
|
+
def load_chip_action(item, column)
|
215
|
+
return 0 unless item.childCount.zero?
|
216
|
+
if item.parent.text(0) == 'Manage'
|
217
|
+
case item.text(0)
|
218
|
+
when 'Wiring'
|
219
|
+
wire_chip
|
220
|
+
when 'Edit'
|
221
|
+
edit_chip
|
222
|
+
when 'Template'
|
223
|
+
add_chip
|
224
|
+
when 'Delete'
|
225
|
+
delete_chip
|
226
|
+
end
|
227
|
+
else
|
228
|
+
case item.parent.text(0)
|
229
|
+
when 'SPI'
|
230
|
+
load_spi_module(item.text(0))
|
231
|
+
when 'I2C'
|
232
|
+
load_i2c_module(item.text(0))
|
233
|
+
when 'PARALLEL'
|
234
|
+
load_parallel_module(item.text(0))
|
235
|
+
when 'SWD'
|
236
|
+
load_swd_module(item.text(0))
|
237
|
+
end
|
238
|
+
end
|
239
|
+
end
|
240
|
+
|
241
|
+
def load_spi_module(spi_module)
|
242
|
+
case spi_module
|
243
|
+
when 'Settings'
|
244
|
+
spi_settings_window = Spi_settings.new(@chip_clicked)
|
245
|
+
spi_settings_window.show
|
246
|
+
when 'Commands'
|
247
|
+
generic_command_window = Generic_commands.new(@api, @chip_clicked, 'SPI')
|
248
|
+
generic_command_window.show
|
249
|
+
when 'Import'
|
250
|
+
spi_import_window = Spi_import.new(@api, @chip_clicked)
|
251
|
+
spi_import_window.show
|
252
|
+
when 'Export'
|
253
|
+
spi_export_window = Spi_export.new(@api, @chip_clicked)
|
254
|
+
spi_export_window.show
|
255
|
+
end
|
256
|
+
end
|
257
|
+
|
258
|
+
def load_i2c_module(i2c_module)
|
259
|
+
case i2c_module
|
260
|
+
when 'Settings'
|
261
|
+
bus_settings_window = I2c_settings.new(@api, @chip_clicked)
|
262
|
+
bus_settings_window.show
|
263
|
+
when 'Commands'
|
264
|
+
bus_command_window = Generic_commands.new(@api, @chip_clicked, 'I2C')
|
265
|
+
bus_command_window.show
|
266
|
+
when 'Import'
|
267
|
+
bus_import_window = I2c_import.new(@api, @chip_clicked)
|
268
|
+
bus_import_window.show
|
269
|
+
when 'Export'
|
270
|
+
bus_export_window = I2c_export.new(@api, @chip_clicked)
|
271
|
+
bus_export_window.show
|
272
|
+
end
|
273
|
+
end
|
274
|
+
|
275
|
+
def load_parallel_module(parallel_module)
|
276
|
+
case parallel_module
|
277
|
+
when 'Settings'
|
278
|
+
bus_settings_window = Parallel_settings.new(@chip_clicked)
|
279
|
+
bus_settings_window.show
|
280
|
+
when 'Import'
|
281
|
+
bus_import_window = Parallel_import.new(@api, @chip_clicked)
|
282
|
+
bus_import_window.show
|
283
|
+
when 'Export'
|
284
|
+
bus_export_window = Parallel_export.new(@api, @chip_clicked)
|
285
|
+
bus_export_window.show
|
286
|
+
end
|
287
|
+
end
|
288
|
+
|
289
|
+
def add_chip
|
290
|
+
if sender.objectName == 'tw_chip'
|
291
|
+
unless @chip_clicked.nil?
|
292
|
+
add_chip = Chip_editor.new(self, @chip_clicked, 'temp')
|
293
|
+
else
|
294
|
+
Qt::MessageBox.new(Qt::MessageBox::Information, "Chip template", "No chip loaded").exec
|
295
|
+
return 0
|
296
|
+
end
|
297
|
+
else
|
298
|
+
add_chip = Chip_editor.new(self, 'none', 'new')
|
299
|
+
end
|
300
|
+
add_chip.setWindowModality(Qt::ApplicationModal)
|
301
|
+
add_chip.show
|
302
|
+
end
|
303
|
+
|
304
|
+
def edit_chip
|
305
|
+
unless @chip_clicked.nil?
|
306
|
+
edit_chip = Chip_editor.new(self, @chip_clicked, 'edit')
|
307
|
+
edit_chip.setWindowModality(Qt::ApplicationModal)
|
308
|
+
edit_chip.show
|
309
|
+
else
|
310
|
+
Qt::MessageBox.new(Qt::MessageBox::Information, "Edit chip", "No chip loaded").exec
|
311
|
+
end
|
312
|
+
end
|
313
|
+
|
314
|
+
def delete_chip
|
315
|
+
unless @chip_clicked.nil?
|
316
|
+
msg = Qt::MessageBox.new
|
317
|
+
msg.setWindowTitle("Delete this chip")
|
318
|
+
msg.setText("By deleting this chip, all the commands linked to it will be deleted too. Continue ?")
|
319
|
+
msg.setIcon(Qt::MessageBox::Question)
|
320
|
+
msg.setStandardButtons(Qt::MessageBox::Cancel | Qt::MessageBox::Ok)
|
321
|
+
msg.setDefaultButton(Qt::MessageBox::Cancel)
|
322
|
+
if msg.exec == Qt::MessageBox::Ok
|
323
|
+
@chip_clicked.destroy
|
324
|
+
feed_chip_array
|
325
|
+
@cm.tw_chip.clear
|
326
|
+
end
|
327
|
+
else
|
328
|
+
Qt::MessageBox.new(Qt::MessageBox::Information, "Delete chip", "No chip loaded").exec
|
329
|
+
end
|
330
|
+
end
|
331
|
+
|
332
|
+
def wire_chip
|
333
|
+
unless @chip_clicked.nil?
|
334
|
+
wire_helper = Wire_helper.new(@chip_clicked, @api)
|
335
|
+
wire_helper.setWindowModality(Qt::ApplicationModal)
|
336
|
+
wire_helper.show
|
337
|
+
else
|
338
|
+
Qt::MessageBox.new(Qt::MessageBox::Information, "Wire chip", "No chip loaded").exec
|
339
|
+
end
|
340
|
+
end
|
341
|
+
|
342
|
+
def swd_detect
|
343
|
+
Firmware.new(@api, 'SWD')
|
344
|
+
@api.runSWD
|
345
|
+
code = @api.obtainCodes
|
346
|
+
@console.print('New action: SWD Detect')
|
347
|
+
Qt::MessageBox.new(Qt::MessageBox::Information, "SWD detection", "Detected:\nDP.IDCODE: #{code[:DebugPortId].to_s(16)}\nAP.IDCODE: #{code[:AccessPortId].to_s(16)}\nCPU ID : #{code[:CpuId].to_s(16)}\nDEVICE ID : #{code[:DeviceId].to_s(16)}").exec
|
348
|
+
rescue Exception => msg
|
349
|
+
logger = Logger.new($logFilePath)
|
350
|
+
logger.error msg
|
351
|
+
Qt::MessageBox.new(Qt::MessageBox::Critical, "Critical error", "No device found, check the wiring").exec
|
352
|
+
end
|
353
|
+
|
354
|
+
def swd_export
|
355
|
+
Firmware.new(@api, 'SWD')
|
356
|
+
@api.runSWD
|
357
|
+
filepath = Qt::FileDialog.getSaveFileName(self, tr('Select a file'), '/', tr('Bin file (*.bin)'))
|
358
|
+
unless filepath.nil?
|
359
|
+
@api.dumpFlash(filepath)
|
360
|
+
Qt::MessageBox.new(Qt::MessageBox::Information, "Export status", "Dump finished").exec
|
361
|
+
end
|
362
|
+
rescue Exception => msg
|
363
|
+
logger = Logger.new($logFilePath)
|
364
|
+
logger.error msg
|
365
|
+
Qt::MessageBox.new(Qt::MessageBox::Critical, "Critical error", "No device found, check the wiring").exec
|
366
|
+
end
|
367
|
+
|
368
|
+
def swd_import
|
369
|
+
Firmware.new(@api, 'SWD')
|
370
|
+
@api.runSWD
|
371
|
+
filepath = Qt::FileDialog.getOpenFileName(self, tr('Select a file'), '/')
|
372
|
+
unless filepath.nil?
|
373
|
+
@api.writeFlash(filepath)
|
374
|
+
Qt::MessageBox.new(Qt::MessageBox::Information, "Import status", "Import finished").exec
|
375
|
+
end
|
376
|
+
rescue Exception => msg
|
377
|
+
logger = Logger.new($logFilePath)
|
378
|
+
logger.error msg
|
379
|
+
Qt::MessageBox.new(Qt::MessageBox::Critical, "Critical error", "No device found, check the wiring").exec
|
380
|
+
end
|
381
|
+
|
382
|
+
def swd_erase
|
383
|
+
msg = Qt::MessageBox.new
|
384
|
+
msg.setWindowTitle("Delete the data")
|
385
|
+
msg.setText("You are going to delete all the data. Continue?")
|
386
|
+
msg.setIcon(Qt::MessageBox::Critical)
|
387
|
+
msg.setStandardButtons(Qt::MessageBox::Cancel | Qt::MessageBox::Ok)
|
388
|
+
msg.setDefaultButton(Qt::MessageBox::Cancel)
|
389
|
+
if msg.exec == Qt::MessageBox::Ok
|
390
|
+
Firmware.new(@api, 'SWD')
|
391
|
+
@api.runSWD
|
392
|
+
@api.eraseFlash
|
393
|
+
Qt::MessageBox.new(Qt::MessageBox::Information, "Erase status", "Erase finished").exec
|
394
|
+
end
|
395
|
+
rescue Exception => msg
|
396
|
+
logger = Logger.new($logFilePath)
|
397
|
+
logger.error msg
|
398
|
+
Qt::MessageBox.new(Qt::MessageBox::Critical, "Critical error", "No device found, check the wiring").exec
|
399
|
+
end
|
400
|
+
|
401
|
+
def display_current_firmware
|
402
|
+
if $currentFirmware.nil?
|
403
|
+
Qt::MessageBox.new(Qt::MessageBox::Information, "Firmware", "No firmware loaded").exec
|
404
|
+
else
|
405
|
+
Qt::MessageBox.new(Qt::MessageBox::Information, "Firmware", "Actual firmware: #{$currentFirmware}").exec
|
406
|
+
end
|
407
|
+
end
|
408
|
+
|
409
|
+
def set_firmware
|
410
|
+
Firmware.new(@api,sender.objectName[6, sender.objectName.length])
|
411
|
+
Qt::MessageBox.new(Qt::MessageBox::Information, "Firmware", "#{sender.objectName[6, sender.objectName.length]} firmware loaded").exec
|
412
|
+
end
|
413
|
+
|
414
|
+
def update_uc_firmware
|
415
|
+
msg = Qt::MessageBox.new
|
416
|
+
msg.setWindowTitle("Microcontroler update")
|
417
|
+
msg.setText("Hardsploit must be launch in bootloader mod and dfu-util package must be installed in order to continue. Proceed ?")
|
418
|
+
msg.setIcon(Qt::MessageBox::Question)
|
419
|
+
msg.setStandardButtons(Qt::MessageBox::Cancel | Qt::MessageBox::Ok)
|
420
|
+
msg.setDefaultButton(Qt::MessageBox::Cancel)
|
421
|
+
if msg.exec == Qt::MessageBox::Ok
|
422
|
+
system("dfu-util -D 0483:df11 -a 0 -s 0x08000000 -R --download #{File.expand_path(File.dirname(__FILE__))}'/../Firmware/UC/HARDSPLOIT_FIRMWARE_UC.bin'")
|
423
|
+
end
|
424
|
+
end
|
425
|
+
|
426
|
+
def get_hardsploit_versions
|
427
|
+
if $usbConnected == true
|
428
|
+
Qt::MessageBox.new(Qt::MessageBox::Information, "Hardsploit versions", "GUI VERSION : #{VERSION}\nAPI VERSION : #{HardsploitAPI::VERSION::API}\nBOARD : #{@api.getVersionNumber}").exec
|
429
|
+
else
|
430
|
+
Qt::MessageBox.new(Qt::MessageBox::Information, "Hardsploit versions", "GUI VERSION : #{VERSION}\nAPI VERSION : #{HardsploitAPI::VERSION::API}").exec
|
431
|
+
end
|
432
|
+
end
|
433
|
+
|
434
|
+
def get_log_path
|
435
|
+
Qt::MessageBox.new(Qt::MessageBox::Information, 'Log path', "#{$logFilePath}").exec
|
436
|
+
end
|
437
|
+
|
438
|
+
def get_db_path
|
439
|
+
Qt::MessageBox.new(Qt::MessageBox::Information, 'Database path', "#{$dbFilePath}").exec
|
440
|
+
end
|
441
|
+
|
442
|
+
def get_hardsploit_website
|
443
|
+
Qt::MessageBox.new(Qt::MessageBox::Information, 'Hardsploit website', 'Find all the new about Hardsploit on our website: http://hardsploit.io').exec
|
444
|
+
end
|
445
|
+
|
446
|
+
def check_hardsploit_connection(api)
|
447
|
+
case api.connect
|
448
|
+
when HardsploitAPI::USB_STATE::NOT_CONNECTED
|
449
|
+
$usbConnected = false
|
450
|
+
@console.print('Hardsploit board unconnected, wiring and command execution disabled')
|
451
|
+
when HardsploitAPI::USB_STATE::UNKNOWN_CONNECTED
|
452
|
+
@console.print('The device may be BUSY or a another device with the same IdVendor and IdProduct was found')
|
453
|
+
when HardsploitAPI::USB_STATE::CONNECTED
|
454
|
+
$usbConnected = true
|
455
|
+
api.startFPGA
|
456
|
+
@console.print("Hardsploit board detected GUI V#{VERSION} API V#{HardsploitAPI::VERSION::API} BOARD : #{api.getVersionNumber}")
|
457
|
+
@console.print('Hardsploit ready to suck chip souls !')
|
458
|
+
else
|
459
|
+
@console.print('You are in the else part of a case that should normally never be triggered. Good luck.')
|
460
|
+
end
|
461
|
+
end
|
462
|
+
end
|