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