hardsploit_gui 2.2 → 2.3
Sign up to get free protection for your applications and to get access to all the features.
- 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/Import.rb
ADDED
@@ -0,0 +1,193 @@
|
|
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 'json'
|
9
|
+
require_relative '../gui/gui_import'
|
10
|
+
class Import < Qt::Widget
|
11
|
+
slots 'import()'
|
12
|
+
slots 'import_file()'
|
13
|
+
|
14
|
+
def initialize(cm, chip = 'none')
|
15
|
+
super()
|
16
|
+
@import_ui = Ui_Import.new
|
17
|
+
centerWindow(self)
|
18
|
+
@import_ui.setupUi(self)
|
19
|
+
@chip = chip
|
20
|
+
@cm = cm
|
21
|
+
@import_ui.lbl_import.setText("Import:")
|
22
|
+
end
|
23
|
+
|
24
|
+
def import_file
|
25
|
+
@filepath = Qt::FileDialog.getOpenFileName(
|
26
|
+
self,
|
27
|
+
tr('Select a file'),
|
28
|
+
'/',
|
29
|
+
tr('JSON file (*.json)')
|
30
|
+
)
|
31
|
+
end
|
32
|
+
|
33
|
+
def import
|
34
|
+
unless @filepath.nil?
|
35
|
+
@file = File.read("#{@filepath}")
|
36
|
+
data_hash = JSON.parse(@file)
|
37
|
+
data_hash.each_with_index do |element, index|
|
38
|
+
@data_chip = element[1]['chip']
|
39
|
+
@data_commands = element[1]['commands']
|
40
|
+
if @import_ui.rbn_both.isChecked
|
41
|
+
import_chip
|
42
|
+
import_commands
|
43
|
+
elsif @import_ui.rbn_comp.isChecked
|
44
|
+
import_chip
|
45
|
+
else
|
46
|
+
import_commands
|
47
|
+
end
|
48
|
+
end
|
49
|
+
@cm.feed_chip_array
|
50
|
+
Qt::MessageBox.new(
|
51
|
+
Qt::MessageBox::Information,
|
52
|
+
'Import status',
|
53
|
+
'Import complete'
|
54
|
+
).exec
|
55
|
+
self.close
|
56
|
+
else
|
57
|
+
Qt::MessageBox.new(
|
58
|
+
Qt::MessageBox::Warning,
|
59
|
+
'File missing',
|
60
|
+
'Choose a file before importing'
|
61
|
+
).exec
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def import_package
|
66
|
+
package = Package.new
|
67
|
+
package.from_json(@data_chip['package'].to_json)
|
68
|
+
if Package.exists?(name: package.name)
|
69
|
+
return Package.find_by(name: package.name).id
|
70
|
+
else
|
71
|
+
Package.last.nil? ? package.id = 1 : package.id = Package.last.id.next
|
72
|
+
package.save
|
73
|
+
return package.id
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def import_type
|
78
|
+
chip_type = ChipType.new
|
79
|
+
chip_type.from_json(@data_chip['chip_type'].to_json)
|
80
|
+
if ChipType.exists?(name: chip_type.name)
|
81
|
+
return ChipType.find_by(name: chip_type.name).id
|
82
|
+
else
|
83
|
+
ChipType.last.nil? ? chip_type.id = 1 : chip_type.id = ChipType.last.id.next
|
84
|
+
chip_type.save
|
85
|
+
return chip_type.id
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
def import_manufacturer
|
90
|
+
manufacturer = Manufacturer.new
|
91
|
+
manufacturer.from_json(@data_chip['manufacturer'].to_json)
|
92
|
+
if Manufacturer.exists?(name: manufacturer.name)
|
93
|
+
return Manufacturer.find_by(name: manufacturer.name).id
|
94
|
+
else
|
95
|
+
Manufacturer.last.nil? ? manufacturer.id = 1 : manufacturer.id = Manufacturer.last.id.next
|
96
|
+
manufacturer.save
|
97
|
+
return manufacturer.id
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
def import_chip
|
102
|
+
@chip = Chip.new
|
103
|
+
@chip.from_json(@data_chip['characteristics'].to_json)
|
104
|
+
if Chip.exists?(reference: @chip.reference)
|
105
|
+
Qt::MessageBox.new(
|
106
|
+
Qt::MessageBox::Warning,
|
107
|
+
'Import aborted',
|
108
|
+
'This component already exists'
|
109
|
+
).exec
|
110
|
+
return 0
|
111
|
+
else
|
112
|
+
Chip.last.nil? ? @chip.id = 1 : @chip.id = Chip.last.id.next
|
113
|
+
@chip.package_id = import_package
|
114
|
+
@chip.chip_type_id = import_type
|
115
|
+
@chip.manufacturer_id = import_manufacturer
|
116
|
+
@chip.save
|
117
|
+
import_parallel_settings unless @data_chip['settings']['parallel'].nil?
|
118
|
+
import_spi_settings unless @data_chip['settings']['spi'].empty?
|
119
|
+
import_i2c_settings unless @data_chip['settings']['i2c'].empty?
|
120
|
+
import_swd_settings unless @data_chip['settings']['swd'].empty?
|
121
|
+
import_uart_settings unless @data_chip['settings']['uart'].empty?
|
122
|
+
import_pins
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
def import_pins
|
127
|
+
@data_chip['pins'].each do |data_pin|
|
128
|
+
pin = Pin.new
|
129
|
+
pin.from_json(data_pin.to_json)
|
130
|
+
pin.chip_id = @chip.id
|
131
|
+
Pin.last.nil? ? pin.id = 1 : pin.id = Pin.last.id.next
|
132
|
+
pin.save
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
def import_parallel_settings
|
137
|
+
parallel_settings = ParallelSetting.new
|
138
|
+
parallel_settings.from_json(@data_chip['settings']['parallel'].to_json)
|
139
|
+
parallel_settings.chip_id = @chip.id
|
140
|
+
ParallelSetting.last.nil? ? parallel_settings.id = 1 : parallel_settings.id = ParallelSetting.last.id.next
|
141
|
+
parallel_settings.save
|
142
|
+
end
|
143
|
+
|
144
|
+
def import_spi_settings
|
145
|
+
spi_settings = SpiSetting.new
|
146
|
+
spi_settings.from_json(@data_chip['settings']['spi'].to_json)
|
147
|
+
spi_settings.chip_id = @chip.id
|
148
|
+
SpiSetting.last.nil? ? spi_settings.id = 1 : spi_settings.id = SpiSetting.last.id.next
|
149
|
+
spi_settings.save
|
150
|
+
end
|
151
|
+
|
152
|
+
def import_i2c_settings
|
153
|
+
i2c_settings = I2cSetting.new
|
154
|
+
i2c_settings.from_json(@data_chip['settings']['i2c'].to_json)
|
155
|
+
i2c_settings.chip_id = @chip.id
|
156
|
+
I2cSetting.last.nil? ? i2c_settings.id = 1 : i2c_settings.id = I2cSetting.last.id.next
|
157
|
+
i2c_settings.save
|
158
|
+
end
|
159
|
+
|
160
|
+
def import_swd_settings
|
161
|
+
swd_settings = SwdSetting.new
|
162
|
+
swd_settings.from_json(@data_chip['settings']['swd'].to_json)
|
163
|
+
swd_settings.chip_id = @chip.id
|
164
|
+
SwdSetting.last.nil? ? swd_settings.id = 1 : swd_settings.id = SwdSetting.last.id.next
|
165
|
+
swd_settings.save
|
166
|
+
end
|
167
|
+
|
168
|
+
def import_uart_settings
|
169
|
+
uart_settings = UartSetting.new
|
170
|
+
uart_settings.from_json(@data_chip['settings']['uart'].to_json)
|
171
|
+
uart_settings.chip_id = @chip.id
|
172
|
+
UartSetting.last.nil? ? uart_settings.id = 1 : uart_settings.id = UartSetting.last.id.next
|
173
|
+
uart_settings.save
|
174
|
+
end
|
175
|
+
|
176
|
+
def import_commands
|
177
|
+
return 0 if @data_commands.empty?
|
178
|
+
@data_commands.each do |cmd_element|
|
179
|
+
cmd = Command.new
|
180
|
+
cmd.from_json(cmd_element[1]['characteristics'].to_json)
|
181
|
+
Command.last.nil? ? cmd.id = 1 : cmd.id = Command.last.id.next
|
182
|
+
cmd.chip_id = @chip.id
|
183
|
+
cmd.save
|
184
|
+
cmd_element[1]['bytes'].each do |byte_element|
|
185
|
+
byte = Byte.new
|
186
|
+
byte.from_json(byte_element.to_json)
|
187
|
+
Byte.last.nil? ? byte.id = 1 : byte.id = Byte.last.id.next
|
188
|
+
byte.command_id = cmd.id
|
189
|
+
byte.save
|
190
|
+
end
|
191
|
+
end
|
192
|
+
end
|
193
|
+
end
|
data/lib/class/Progress_bar.rb
CHANGED
@@ -0,0 +1,120 @@
|
|
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_signal_mapper'
|
9
|
+
class Signal_mapper < Qt::Widget
|
10
|
+
slots 'check_mapping_value(QTableWidgetItem*)'
|
11
|
+
slots 'update_map_table(QString)'
|
12
|
+
slots 'save_signal_mapping()'
|
13
|
+
|
14
|
+
def initialize
|
15
|
+
super()
|
16
|
+
@view = Ui_Signal_mapper.new
|
17
|
+
centerWindow(self)
|
18
|
+
@view.setupUi(self)
|
19
|
+
init_bus_list
|
20
|
+
rescue Exception => msg
|
21
|
+
ErrorMsg.new.unknown(msg)
|
22
|
+
end
|
23
|
+
|
24
|
+
def init_bus_list
|
25
|
+
Bus.all.each do |b|
|
26
|
+
@view.cbx_bus.addItem(b.name) unless b.name == "NA"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def check_mapping_value(item)
|
31
|
+
if item.column == 1
|
32
|
+
item.setText(item.text.upcase)
|
33
|
+
reg = Qt::RegExp.new("^[A-H]{1}[0-7]${1}")
|
34
|
+
reg_val = Qt::RegExpValidator.new(reg, self)
|
35
|
+
if reg_val.validate(item.text, item.text.length) == Qt::Validator::Invalid || item.text.nil?
|
36
|
+
item.setText('')
|
37
|
+
Qt::MessageBox.new(
|
38
|
+
Qt::MessageBox::Warning,
|
39
|
+
'Wrong data',
|
40
|
+
'Only values from A0 to H7 are accepted in this cell'
|
41
|
+
).exec
|
42
|
+
end
|
43
|
+
end
|
44
|
+
rescue Exception => msg
|
45
|
+
ErrorMsg.new.unknown(msg)
|
46
|
+
end
|
47
|
+
|
48
|
+
def update_map_table(bus_name)
|
49
|
+
unless bus_name == 'Bus...'
|
50
|
+
@view.map_table.clearContents
|
51
|
+
@view.map_table.setRowCount(0)
|
52
|
+
Bus.find_by(name: bus_name).signalls.each do |s|
|
53
|
+
@view.map_table.insertRow(@view.map_table.rowCount)
|
54
|
+
signal_cell = Qt::TableWidgetItem.new(s.name)
|
55
|
+
signal_cell.setFlags(Qt::ItemIsEnabled)
|
56
|
+
@view.map_table.setItem(@view.map_table.rowCount - 1, 0, signal_cell)
|
57
|
+
pin_cell = Qt::TableWidgetItem.new(s.pin)
|
58
|
+
@view.map_table.setItem(@view.map_table.rowCount - 1, 1, pin_cell)
|
59
|
+
end
|
60
|
+
resize_to_content
|
61
|
+
end
|
62
|
+
rescue Exception => msg
|
63
|
+
ErrorMsg.new.unknown(msg)
|
64
|
+
end
|
65
|
+
|
66
|
+
def save_signal_mapping
|
67
|
+
return 0 unless are_values_ok?
|
68
|
+
@view.map_table.rowCount.times do |i|
|
69
|
+
current_signal = Signall.find_by(name: @view.map_table.item(i, 0).text)
|
70
|
+
if current_signal.name != @view.map_table.item(i, 1).text
|
71
|
+
current_signal.update(pin: @view.map_table.item(i, 1).text)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
Qt::MessageBox.new(
|
75
|
+
Qt::MessageBox::Information,
|
76
|
+
'Save mapping',
|
77
|
+
'Pin mapping saved successfuly'
|
78
|
+
).exec
|
79
|
+
close
|
80
|
+
end
|
81
|
+
|
82
|
+
def are_values_ok?
|
83
|
+
pins = []
|
84
|
+
@view.map_table.rowCount.times do |i|
|
85
|
+
pins.push(@view.map_table.item(i, 1).text)
|
86
|
+
end
|
87
|
+
return true if check_empty(pins) && check_duplicate(pins)
|
88
|
+
end
|
89
|
+
|
90
|
+
def check_empty(pins)
|
91
|
+
return true unless pins.include?('')
|
92
|
+
@view.map_table.setCurrentItem(@view.map_table.item(pins.index(''), 1))
|
93
|
+
Qt::MessageBox.new(
|
94
|
+
Qt::MessageBox::Warning,
|
95
|
+
'Empty pin',
|
96
|
+
'Empty pin value detected'
|
97
|
+
).exec
|
98
|
+
return false
|
99
|
+
end
|
100
|
+
|
101
|
+
def check_duplicate(pins)
|
102
|
+
duplicate = pins.inject(Hash.new(0)) {|ha, e| ha[e] += 1 ; ha}.delete_if {|k, v| v == 1}.keys
|
103
|
+
unless duplicate.empty?
|
104
|
+
@view.map_table.setCurrentItem(@view.map_table.item(pins.index(duplicate[0]), 1))
|
105
|
+
Qt::MessageBox.new(
|
106
|
+
Qt::MessageBox::Warning,
|
107
|
+
'Wrong value',
|
108
|
+
"Duplicate values detected: #{duplicate[0]}"
|
109
|
+
).exec
|
110
|
+
return false
|
111
|
+
end
|
112
|
+
return true
|
113
|
+
end
|
114
|
+
|
115
|
+
def resize_to_content
|
116
|
+
@view.map_table.resizeColumnsToContents
|
117
|
+
@view.map_table.resizeRowsToContents
|
118
|
+
@view.map_table.horizontalHeader.stretchLastSection = true
|
119
|
+
end
|
120
|
+
end
|
data/lib/class/Wire_helper.rb
CHANGED
@@ -5,126 +5,39 @@
|
|
5
5
|
# License URI: http://www.gnu.org/licenses/gpl.txt
|
6
6
|
#===================================================
|
7
7
|
|
8
|
-
require_relative '../HardsploitAPI/HardsploitAPI'
|
9
8
|
require_relative '../gui/gui_wire_helper'
|
9
|
+
require_relative '../HardsploitAPI/Core/HardsploitAPI'
|
10
10
|
|
11
11
|
class Wire_helper < Qt::Widget
|
12
12
|
slots 'rotate_scene()'
|
13
13
|
|
14
|
-
def initialize(chip
|
14
|
+
def initialize(chip)
|
15
15
|
super()
|
16
16
|
@wire_helper_gui = Ui_Wire_helper.new
|
17
17
|
centerWindow(self)
|
18
18
|
@wire_helper_gui.setupUi(self)
|
19
19
|
@chip = chip
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
# Get the pin total number
|
30
|
-
# UniqPin parameters: (scene, pinNum, pinChip, xSig, ySig, xNum, yNum, xRect, yRect, wRect, hRect, rotation)
|
31
|
-
total_pin_nbr = Pin.where(pin_chip: @chip.chip_id).count
|
32
|
-
# If it's a square
|
33
|
-
if Package.find_by(package_id: chip.chip_package).package_shape == 0
|
34
|
-
pin_by_side = total_pin_nbr / 4
|
35
|
-
cHeight = 14*(pin_by_side + 4) # Chip's height (+4 because we add a space equal to one pin for each corner)
|
36
|
-
scene.addRect(Qt::RectF.new(0, 0, cHeight, cHeight))
|
37
|
-
y = 32
|
38
|
-
y2 = cHeight - 38
|
39
|
-
x = 32
|
40
|
-
x2 = cHeight - 38
|
41
|
-
(1..total_pin_nbr).each do |i|
|
42
|
-
# Face 1
|
43
|
-
if i <= pin_by_side
|
44
|
-
ySig = y
|
45
|
-
yNum = y
|
46
|
-
UniqPin.new(scene, i, @chip.chip_id, -70, ySig - 12, 0, yNum - 12, 0, y, -20, 6, false, api)
|
47
|
-
y = y + 14 # Space between each pin
|
48
|
-
elsif i > pin_by_side && i <= total_pin_nbr / 2
|
49
|
-
# Face 2
|
50
|
-
xSig2 = x
|
51
|
-
xNum2 = x
|
52
|
-
UniqPin.new(scene, i, @chip.chip_id, xSig2 - 12, cHeight + 55, xNum2 - 12, cHeight, x, cHeight, 6, 20, true, api)
|
53
|
-
x = x + 14
|
54
|
-
elsif i > total_pin_nbr / 2 && i <= (total_pin_nbr - (pin_by_side))
|
55
|
-
# Face 3
|
56
|
-
xSig = cHeight + 24
|
57
|
-
ySig = y2
|
58
|
-
yNum = y2
|
59
|
-
|
60
|
-
if i < 10
|
61
|
-
xNum = cHeight - 20
|
62
|
-
elsif i >= 10 && i < 100
|
63
|
-
xNum = cHeight - 25
|
64
|
-
else
|
65
|
-
xNum = cHeight - 35
|
66
|
-
end
|
67
|
-
UniqPin.new(scene, i, @chip.chip_id, xSig, ySig - 12, xNum, yNum - 12, cHeight, y2, 20, 6, false, api)
|
68
|
-
y2 = y2 - 14
|
69
|
-
else
|
70
|
-
# Face 4
|
71
|
-
xSig2 = x2
|
72
|
-
xNum2 = x2
|
73
|
-
|
74
|
-
if i < 10
|
75
|
-
yNum2 = 20
|
76
|
-
elsif i >= 10 && i < 100
|
77
|
-
yNum2 = 30
|
78
|
-
else
|
79
|
-
yNum2 = 40
|
80
|
-
end
|
81
|
-
UniqPin.new(scene, i, @chip.chip_id, xSig2 - 12, -20, xNum2 - 12, yNum2, x2, 0, 6, -20, true, api)
|
82
|
-
x2 = x2 - 14
|
83
|
-
end
|
84
|
-
end
|
85
|
-
# If it's a rectangle
|
86
|
-
else
|
87
|
-
pin_by_side = total_pin_nbr / 2
|
88
|
-
cHeight = 14 * (pin_by_side + 2) # +2 because we add a space equal to one pin for each corner
|
89
|
-
scene.addRect(Qt::RectF.new(0, 0, cHeight, cHeight))
|
90
|
-
# Add the pins + text
|
91
|
-
y = 18
|
92
|
-
y2 = cHeight - 24
|
93
|
-
(1..total_pin_nbr).each do |i|
|
94
|
-
# Face 1
|
95
|
-
if i <= total_pin_nbr / 2
|
96
|
-
ySig = y
|
97
|
-
yNum = y
|
98
|
-
UniqPin.new(scene, i, @chip.chip_id, -70, ySig - 12, 0, yNum - 12, 0, y, -20, 6, false, api)
|
99
|
-
y = y + 14
|
100
|
-
# Face 2
|
101
|
-
else
|
102
|
-
xSig = cHeight + 24
|
103
|
-
ySig = y2
|
104
|
-
yNum = y2
|
105
|
-
|
106
|
-
if i < 10
|
107
|
-
xNum = cHeight - 20
|
108
|
-
elsif i >= 10 && i < 100
|
109
|
-
xNum = cHeight - 25
|
110
|
-
else
|
111
|
-
xNum = cHeight - 35
|
112
|
-
end
|
113
|
-
UniqPin.new(scene, i, @chip.chip_id, xSig, ySig - 12, xNum, yNum - 12, cHeight, y2, 20, 6, false, api)
|
114
|
-
y2 = y2 - 14
|
115
|
-
end
|
116
|
-
end
|
117
|
-
end
|
118
|
-
# Draw!
|
119
|
-
@wire_helper_gui.gView.setScene(scene)
|
20
|
+
HardsploitAPI.instance.setWiringLeds(value: 0x0000000000000000)
|
21
|
+
@scene = Qt::GraphicsScene.new
|
22
|
+
@wire_helper_gui.lbl_chip.setText("Your chip (#{chip.reference}):")
|
23
|
+
Package.find_by(id: chip.package_id).shape.zero? ? draw_square : draw_rect
|
24
|
+
@wire_helper_gui.gView.setScene(@scene)
|
25
|
+
rescue HardsploitAPI::ERROR::HARDSPLOIT_NOT_FOUND
|
26
|
+
ErrorMsg.new.hardsploit_not_found
|
27
|
+
rescue HardsploitAPI::ERROR::USB_ERROR
|
28
|
+
ErrorMsg.new.usb_error
|
120
29
|
rescue Exception => msg
|
121
|
-
|
122
|
-
logger = Logger.new($logFilePath)
|
123
|
-
logger.error msg
|
30
|
+
ErrorMsg.new.unknown(msg)
|
124
31
|
end
|
125
32
|
|
126
33
|
def closeEvent(event)
|
127
|
-
|
34
|
+
HardsploitAPI.instance.setWiringLeds(value: 0xFF00FF00FF00FF00)
|
35
|
+
rescue HardsploitAPI::ERROR::HARDSPLOIT_NOT_FOUND
|
36
|
+
ErrorMsg.new.hardsploit_not_found
|
37
|
+
rescue HardsploitAPI::ERROR::USB_ERROR
|
38
|
+
ErrorMsg.new.usb_error
|
39
|
+
rescue Exception => msg
|
40
|
+
ErrorMsg.new.unknown(msg)
|
128
41
|
end
|
129
42
|
|
130
43
|
def rotate_scene
|
@@ -132,13 +45,104 @@ class Wire_helper < Qt::Widget
|
|
132
45
|
end
|
133
46
|
end
|
134
47
|
|
48
|
+
def draw_square
|
49
|
+
total_pin_nbr = Pin.where(chip_id: @chip.id).count
|
50
|
+
pin_by_side = total_pin_nbr / 4
|
51
|
+
cHeight = 14*(pin_by_side + 4) # Chip's height (+4 because we add a space equal to one pin for each corner)
|
52
|
+
@scene.addRect(Qt::RectF.new(0, 0, cHeight, cHeight))
|
53
|
+
y = 32
|
54
|
+
y2 = cHeight - 38
|
55
|
+
x = 32
|
56
|
+
x2 = cHeight - 38
|
57
|
+
(1..total_pin_nbr).each do |i|
|
58
|
+
# Face 1
|
59
|
+
if i <= pin_by_side
|
60
|
+
ySig = y
|
61
|
+
yNum = y
|
62
|
+
UniqPin.new(@scene, i, @chip.id, -70, ySig - 12, 0, yNum - 12, 0, y, -20, 6, false)
|
63
|
+
y = y + 14 # Space between each pin
|
64
|
+
elsif i > pin_by_side && i <= total_pin_nbr / 2
|
65
|
+
# Face 2
|
66
|
+
xSig2 = x
|
67
|
+
xNum2 = x
|
68
|
+
UniqPin.new(@scene, i, @chip.id, xSig2 - 12, cHeight + 55, xNum2 - 12, cHeight, x, cHeight, 6, 20, true)
|
69
|
+
x = x + 14
|
70
|
+
elsif i > total_pin_nbr / 2 && i <= (total_pin_nbr - (pin_by_side))
|
71
|
+
# Face 3
|
72
|
+
xSig = cHeight + 24
|
73
|
+
ySig = y2
|
74
|
+
yNum = y2
|
75
|
+
|
76
|
+
if i < 10
|
77
|
+
xNum = cHeight - 20
|
78
|
+
elsif i >= 10 && i < 100
|
79
|
+
xNum = cHeight - 25
|
80
|
+
else
|
81
|
+
xNum = cHeight - 35
|
82
|
+
end
|
83
|
+
UniqPin.new(@scene, i, @chip.id, xSig, ySig - 12, xNum, yNum - 12, cHeight, y2, 20, 6, false)
|
84
|
+
y2 = y2 - 14
|
85
|
+
else
|
86
|
+
# Face 4
|
87
|
+
xSig2 = x2
|
88
|
+
xNum2 = x2
|
89
|
+
|
90
|
+
if i < 10
|
91
|
+
yNum2 = 20
|
92
|
+
elsif i >= 10 && i < 100
|
93
|
+
yNum2 = 30
|
94
|
+
else
|
95
|
+
yNum2 = 40
|
96
|
+
end
|
97
|
+
UniqPin.new(@scene, i, @chip.id, xSig2 - 12, -20, xNum2 - 12, yNum2, x2, 0, 6, -20, true)
|
98
|
+
x2 = x2 - 14
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
def draw_rect
|
104
|
+
total_pin_nbr = Pin.where(chip_id: @chip.id).count
|
105
|
+
pin_by_side = total_pin_nbr / 2
|
106
|
+
cHeight = 14 * (pin_by_side + 2) # +2 because we add a space equal to one pin for each corner
|
107
|
+
@scene.addRect(Qt::RectF.new(0, 0, cHeight, cHeight))
|
108
|
+
# Add the pins + text
|
109
|
+
y = 18
|
110
|
+
y2 = cHeight - 24
|
111
|
+
(1..total_pin_nbr).each do |i|
|
112
|
+
# Face 1
|
113
|
+
if i <= total_pin_nbr / 2
|
114
|
+
ySig = y
|
115
|
+
yNum = y
|
116
|
+
UniqPin.new(@scene, i, @chip.id, -70, ySig - 12, 0, yNum - 12, 0, y, -20, 6, false)
|
117
|
+
y = y + 14
|
118
|
+
# Face 2
|
119
|
+
else
|
120
|
+
xSig = cHeight + 24
|
121
|
+
ySig = y2
|
122
|
+
yNum = y2
|
123
|
+
|
124
|
+
if i < 10
|
125
|
+
xNum = cHeight - 20
|
126
|
+
elsif i >= 10 && i < 100
|
127
|
+
xNum = cHeight - 25
|
128
|
+
else
|
129
|
+
xNum = cHeight - 35
|
130
|
+
end
|
131
|
+
UniqPin.new(@scene, i, @chip.id, xSig, ySig - 12, xNum, yNum - 12, cHeight, y2, 20, 6, false)
|
132
|
+
y2 = y2 - 14
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
|
135
138
|
#
|
136
139
|
# Custom Item - To trigger events on the graphics text items
|
137
140
|
#
|
138
141
|
class CustomItem < Qt::GraphicsTextItem
|
139
142
|
|
140
|
-
def setPin(upin)
|
143
|
+
def setPin(upin, api_value)
|
141
144
|
@UPin = upin
|
145
|
+
@api_value = api_value
|
142
146
|
end
|
143
147
|
|
144
148
|
def boundingRect
|
@@ -149,73 +153,55 @@ class CustomItem < Qt::GraphicsTextItem
|
|
149
153
|
return rect
|
150
154
|
end
|
151
155
|
|
152
|
-
def
|
153
|
-
begin
|
156
|
+
def mousePressEvent(event)
|
154
157
|
pin = self.instance_variable_get('@UPin')
|
155
158
|
pin.setColor
|
156
|
-
pin.instance_variable_get('@api').signalHelpingWiring(pin.instance_variable_get('@signalId'))
|
157
159
|
pin.instance_variable_get('@signalTxt').clearFocus
|
158
160
|
pin.instance_variable_get('@nbrTxt').clearFocus
|
159
|
-
|
160
|
-
|
161
|
+
return false if @api_value == 'NA'
|
162
|
+
pin_group = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H']
|
163
|
+
hardsploit_pin_number = pin_group.index(@api_value.pin[0]) * 8 + @api_value.pin[1].to_i
|
164
|
+
HardsploitAPI.instance.setWiringLeds(value: 2**hardsploit_pin_number)
|
165
|
+
rescue HardsploitAPI::ERROR::HARDSPLOIT_NOT_FOUND
|
166
|
+
ErrorMsg.new.hardsploit_not_found
|
167
|
+
rescue HardsploitAPI::ERROR::USB_ERROR
|
168
|
+
ErrorMsg.new.usb_error
|
169
|
+
rescue Exception => msg
|
170
|
+
HardsploitAPI.instance.setWiringLeds(value: 0x0000000000000000)
|
161
171
|
pin.instance_variable_get('@signalTxt').clearFocus
|
162
172
|
pin.instance_variable_get('@nbrTxt').clearFocus
|
163
|
-
Qt::MessageBox.new(Qt::MessageBox::Critical, 'Signal not found', 'This signal is not handled by the board').exec
|
164
173
|
end
|
165
|
-
end
|
166
174
|
|
167
|
-
|
168
|
-
begin
|
175
|
+
def mouseDoubleClickEvent(event)
|
169
176
|
pin = self.instance_variable_get('@UPin')
|
170
|
-
pin.setColor
|
171
|
-
pin.instance_variable_get('@api').signalHelpingWiring(pin.instance_variable_get('@signalId'))
|
172
177
|
pin.instance_variable_get('@signalTxt').clearFocus
|
173
178
|
pin.instance_variable_get('@nbrTxt').clearFocus
|
174
|
-
rescue
|
175
|
-
pin.instance_variable_get('@api').setWiringLeds(0x0000000000000000)
|
176
|
-
pin.instance_variable_get('@signalTxt').clearFocus
|
177
|
-
pin.instance_variable_get('@nbrTxt').clearFocus
|
178
|
-
Qt::MessageBox.new(Qt::MessageBox::Critical, 'Signal not found', 'This signal is not handled by the board').exec
|
179
179
|
end
|
180
|
-
end
|
181
180
|
end
|
182
181
|
|
183
182
|
#
|
184
183
|
# UniqPin - Contain all data linked to one pin on the graphic
|
185
184
|
#
|
186
185
|
class UniqPin
|
187
|
-
def initialize(scene, pinNum, pinChip, xSig, ySig, xNum, yNum, xRect, yRect, wRect, hRect, rotation
|
188
|
-
|
189
|
-
|
190
|
-
# Set the signal id
|
191
|
-
@signalId = currentSignal
|
192
|
-
|
193
|
-
@api = api
|
194
|
-
# Signal text
|
195
|
-
@signalTxt = CustomItem.new(currentSignal)
|
186
|
+
def initialize(scene, pinNum, pinChip, xSig, ySig, xNum, yNum, xRect, yRect, wRect, hRect, rotation)
|
187
|
+
signal_name = Pin.find_by(number: pinNum, chip_id: pinChip).signall
|
188
|
+
@signalTxt = CustomItem.new(signal_name.name)
|
196
189
|
@signalTxt.cursor = Qt::Cursor.new(Qt::PointingHandCursor)
|
197
|
-
@signalTxt.setPin(self)
|
190
|
+
@signalTxt.setPin(self, signal_name)
|
198
191
|
@signalTxt.setTextInteractionFlags(Qt::TextSelectableByMouse)
|
199
192
|
@signalTxt.setX(xSig)
|
200
193
|
@signalTxt.setY(ySig)
|
201
|
-
if rotation
|
202
|
-
@signalTxt.rotation = 270.00
|
203
|
-
end
|
194
|
+
@signalTxt.rotation = 270.00 if rotation
|
204
195
|
scene.addItem(@signalTxt)
|
205
196
|
|
206
|
-
# Number text
|
207
197
|
@nbrTxt = CustomItem.new(pinNum.to_s)
|
208
198
|
@nbrTxt.cursor = Qt::Cursor.new(Qt::PointingHandCursor)
|
209
|
-
@nbrTxt.setPin(self)
|
199
|
+
@nbrTxt.setPin(self, pinNum.to_s)
|
210
200
|
@nbrTxt.setTextInteractionFlags(Qt::TextSelectableByMouse)
|
211
201
|
@nbrTxt.setX(xNum)
|
212
202
|
@nbrTxt.setY(yNum)
|
213
|
-
if rotation
|
214
|
-
@nbrTxt.rotation = 270.00
|
215
|
-
end
|
203
|
+
@nbrTxt.rotation = 270.00 if rotation
|
216
204
|
scene.addItem(@nbrTxt)
|
217
|
-
|
218
|
-
# Pin graphic
|
219
205
|
@pinGraphItem = scene.addRect(xRect, yRect, wRect, hRect)
|
220
206
|
end
|
221
207
|
|
@@ -223,10 +209,8 @@ class UniqPin
|
|
223
209
|
# Colors
|
224
210
|
@on = Qt::Color.new(0, 0, 255)
|
225
211
|
@off = Qt::Color.new(0, 0, 0)
|
226
|
-
# Disable the pin if
|
227
|
-
unless $pinEnabled.nil?
|
228
|
-
$pinEnabled.unsetColor
|
229
|
-
end
|
212
|
+
# Disable the pin if another pin is already enabled
|
213
|
+
$pinEnabled.unsetColor unless $pinEnabled.nil?
|
230
214
|
# Light the new pin
|
231
215
|
@nbrTxt.setDefaultTextColor(@on)
|
232
216
|
@signalTxt.setDefaultTextColor(@on)
|