hardsploit_gui 2.3 → 2.4.0
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/README.md +22 -22
- data/Rakefile +1 -1
- data/bin/hardsploit_gui +3 -3
- data/lib/Firmwares/FPGA/I2C/I2C_INTERACT/HARDSPLOIT_FIRMWARE_FPGA_I2C_INTERACT.rpd +0 -0
- data/lib/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/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/Firmwares/FPGA/UART/UART_INTERACT/HARDSPLOIT_FIRMWARE_FPGA_UART_INTERACT.rpd +0 -0
- data/lib/Firmwares/FPGA/VersionFPGA.rb +5 -5
- data/lib/Firmwares/UC/VersionUC.rb +12 -12
- data/lib/HardsploitAPI/Core/HardsploitAPI.rb +210 -210
- data/lib/HardsploitAPI/Core/HardsploitAPI_CONSTANT.rb +150 -150
- data/lib/HardsploitAPI/Core/HardsploitAPI_ERROR.rb +109 -109
- data/lib/HardsploitAPI/Core/HardsploitAPI_FIRMWARE.rb +305 -305
- data/lib/HardsploitAPI/Core/HardsploitAPI_PROGRESS.rb +28 -28
- data/lib/HardsploitAPI/Core/HardsploitAPI_USB_COMMUNICATION.rb +166 -166
- data/lib/HardsploitAPI/Modules/I2C/HardsploitAPI_I2C.rb +356 -356
- data/lib/HardsploitAPI/Modules/NO_MUX_PARALLEL_MEMORY/HardsploitAPI_NO_MUX_PARALLEL_MEMORY.rb +206 -206
- data/lib/HardsploitAPI/Modules/NRF24L01/HardsploitAPI_NRF24L01.rb +306 -306
- data/lib/HardsploitAPI/Modules/SPI/HardsploitAPI_SPI.rb +340 -340
- data/lib/HardsploitAPI/Modules/SPI_SNIFFER/HardsploitAPI_SPI_SNIFFER.rb +83 -83
- data/lib/HardsploitAPI/Modules/SWD/HardsploitAPI_SWD.rb +367 -367
- data/lib/HardsploitAPI/Modules/SWD/HardsploitAPI_SWD_DEBUG.rb +89 -89
- data/lib/HardsploitAPI/Modules/SWD/HardsploitAPI_SWD_MEM_AP.rb +61 -61
- data/lib/HardsploitAPI/Modules/SWD/HardsploitAPI_SWD_STM32.rb +121 -121
- data/lib/HardsploitAPI/Modules/TEST/HardsploitAPI_TEST_INTERACT.rb +98 -98
- data/lib/HardsploitAPI/Modules/UART/HardsploitAPI_UART.rb +196 -196
- data/lib/Hardsploit_gui.rb +96 -96
- data/lib/LICENSE.txt +674 -674
- data/lib/README.md +22 -22
- data/lib/TRADEMARK +2 -2
- data/lib/class/Chip_editor.rb +304 -304
- data/lib/class/Chip_management.rb +496 -496
- data/lib/class/Command_editor.rb +216 -216
- data/lib/class/Command_table.rb +233 -233
- data/lib/class/Console.rb +26 -26
- data/lib/class/ErrorMsg.rb +312 -312
- data/lib/class/Export.rb +140 -140
- data/lib/class/Export_manager.rb +124 -124
- data/lib/class/Firmware.rb +70 -70
- data/lib/class/Generic_commands.rb +260 -260
- data/lib/class/{i2c → I2C}/I2c_command.rb +51 -51
- data/lib/class/{i2c → I2C}/I2c_export.rb +95 -95
- data/lib/class/{i2c → I2C}/I2c_import.rb +117 -117
- data/lib/class/{i2c → I2C}/I2c_scanner.rb +114 -114
- data/lib/class/{i2c → I2C}/I2c_settings.rb +148 -148
- data/lib/class/Import.rb +193 -193
- data/lib/class/{parallel → PARALLEL}/Parallel_export.rb +118 -118
- data/lib/class/{parallel → PARALLEL}/Parallel_import.rb +113 -113
- data/lib/class/{parallel → PARALLEL}/Parallel_settings.rb +81 -81
- data/lib/class/Progress_bar.rb +32 -32
- data/lib/class/{spi → SPI}/Spi_export.rb +108 -108
- data/lib/class/{spi → SPI}/Spi_import.rb +159 -159
- data/lib/class/{spi → SPI}/Spi_settings.rb +108 -108
- data/lib/class/{spi → SPI}/Spi_sniffer.rb +101 -101
- data/lib/class/Signal_mapper.rb +120 -120
- data/lib/class/Wire_helper.rb +230 -230
- data/lib/class/swd/Swd.rb +125 -125
- data/lib/class/swd/Swd_scanner.rb +121 -121
- data/lib/class/swd/Swd_settings.rb +76 -76
- data/lib/class/uart/Uart_baudrate.rb +62 -62
- data/lib/class/uart/Uart_console.rb +115 -115
- data/lib/class/uart/Uart_settings.rb +102 -102
- data/lib/db/associations.rb +138 -138
- data/lib/db/database.rb +4 -4
- data/lib/db/development.sqlite3 +0 -0
- data/lib/db/migrate/004_create_manufacturers.rb +13 -13
- data/lib/db/migrate/005_create_packages.rb +13 -13
- data/lib/db/migrate/006_create_chip_types.rb +11 -11
- data/lib/db/migrate/007_create_buses.rb +11 -11
- data/lib/db/migrate/008_create_signals.rb +14 -14
- data/lib/db/migrate/009_create_chips.rb +25 -25
- data/lib/db/migrate/010_create_commands.rb +21 -21
- data/lib/db/migrate/011_create_bytes.rb +19 -19
- data/lib/db/migrate/012_create_i2c_settings.rb +21 -21
- data/lib/db/migrate/013_create_spi_settings.rb +26 -26
- data/lib/db/migrate/014_create_parallel_settings.rb +21 -21
- data/lib/db/migrate/015_create_pins.rb +19 -19
- data/lib/db/migrate/016_create_uses.rb +17 -17
- data/lib/db/migrate/017_create_swd_settings.rb +19 -19
- data/lib/db/migrate/018_create_uart_settings.rb +22 -22
- data/lib/db/schema.rb +157 -157
- data/lib/db/seeds.rb +161 -161
- data/lib/gui/gui_chip_editor.rb +349 -349
- data/lib/gui/gui_chip_management.rb +377 -377
- data/lib/gui/gui_command_editor.rb +219 -219
- data/lib/gui/gui_export.rb +132 -132
- data/lib/gui/gui_export_manager.rb +93 -93
- data/lib/gui/gui_generic_commands.rb +202 -202
- data/lib/gui/gui_generic_export.rb +164 -164
- data/lib/gui/gui_generic_import.rb +142 -142
- data/lib/gui/gui_i2c_command.rb +116 -116
- data/lib/gui/gui_i2c_settings.rb +230 -230
- data/lib/gui/gui_import.rb +131 -131
- data/lib/gui/gui_parallel_settings.rb +195 -195
- data/lib/gui/gui_progress_bar.rb +85 -85
- data/lib/gui/gui_signal_mapper.rb +121 -121
- data/lib/gui/gui_signal_scanner.rb +146 -146
- data/lib/gui/gui_spi_import.rb +126 -126
- data/lib/gui/gui_spi_settings.rb +313 -313
- data/lib/gui/gui_spi_sniffer.rb +112 -112
- data/lib/gui/gui_swd_settings.rb +166 -166
- data/lib/gui/gui_uart_baudrate.rb +114 -114
- data/lib/gui/gui_uart_console.rb +164 -164
- data/lib/gui/gui_uart_settings.rb +243 -243
- data/lib/gui/gui_wire_helper.rb +99 -99
- data/lib/gui_designer/gui_chip_editor.ui +549 -549
- data/lib/gui_designer/gui_chip_management.ui +886 -886
- data/lib/gui_designer/gui_command_editor.ui +350 -350
- data/lib/gui_designer/gui_export.ui +171 -171
- data/lib/gui_designer/gui_export_manager.ui +115 -115
- data/lib/gui_designer/gui_generic_commands.ui +342 -342
- data/lib/gui_designer/gui_generic_export.ui +202 -202
- data/lib/gui_designer/gui_generic_import.ui +165 -165
- data/lib/gui_designer/gui_i2c_command.ui +148 -148
- data/lib/gui_designer/gui_i2c_settings.ui +292 -292
- data/lib/gui_designer/gui_import.ui +168 -168
- data/lib/gui_designer/gui_parallel_settings.ui +247 -247
- data/lib/gui_designer/gui_progress_bar.ui +86 -86
- data/lib/gui_designer/gui_signal_mapper.ui +179 -179
- data/lib/gui_designer/gui_signal_scanner.ui +261 -261
- data/lib/gui_designer/gui_spi_settings.ui +446 -446
- data/lib/gui_designer/gui_spi_sniffer.ui +156 -156
- data/lib/gui_designer/gui_swd_settings.ui +189 -189
- data/lib/gui_designer/gui_uart_baudrate.ui +161 -161
- data/lib/gui_designer/gui_uart_console.ui +284 -284
- data/lib/gui_designer/gui_uart_settings.ui +280 -280
- data/lib/gui_designer/gui_wire_helper.ui +117 -117
- data/lib/images/search.png +0 -0
- data/lib/logs/error.log +0 -63
- data/lib/models/bus.rb +19 -19
- data/lib/models/byte.rb +29 -29
- data/lib/models/chip.rb +41 -41
- data/lib/models/chip_type.rb +14 -14
- data/lib/models/command.rb +20 -20
- data/lib/models/i2c_setting.rb +41 -41
- data/lib/models/manufacturer.rb +14 -14
- data/lib/models/package.rb +26 -26
- data/lib/models/parallel_setting.rb +37 -37
- data/lib/models/pin.rb +14 -14
- data/lib/models/signall.rb +20 -20
- data/lib/models/spi_setting.rb +67 -67
- data/lib/models/swd_setting.rb +25 -25
- data/lib/models/uart_setting.rb +52 -52
- data/lib/models/use.rb +6 -6
- data/lib/startHardsploit.rb +10 -10
- metadata +14 -14
data/lib/class/Import.rb
CHANGED
@@ -1,193 +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
|
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
|
@@ -1,118 +1,118 @@
|
|
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_generic_export'
|
9
|
-
require_relative '../../HardsploitAPI/Modules/NO_MUX_PARALLEL_MEMORY/HardsploitAPI_NO_MUX_PARALLEL_MEMORY'
|
10
|
-
|
11
|
-
class Parallel_export < Qt::Widget
|
12
|
-
slots 'export()'
|
13
|
-
slots 'select_export_file()'
|
14
|
-
|
15
|
-
def initialize(chip)
|
16
|
-
super()
|
17
|
-
@view = Ui_Generic_export.new
|
18
|
-
centerWindow(self)
|
19
|
-
@view.setupUi(self)
|
20
|
-
@view.lbl_chip.setText(chip.reference)
|
21
|
-
inputRestrict(@view.lie_start, 0)
|
22
|
-
inputRestrict(@view.lie_stop, 0)
|
23
|
-
@chip = chip
|
24
|
-
end
|
25
|
-
|
26
|
-
def select_export_file
|
27
|
-
@filepath = Qt::FileDialog.getSaveFileName(self, tr('Select a file'), '/', tr('Bin file (*.bin)'))
|
28
|
-
unless @filepath.nil?
|
29
|
-
@view.btn_export.setEnabled(true)
|
30
|
-
@view.btn_full_export.setEnabled(true)
|
31
|
-
end
|
32
|
-
rescue Exception => msg
|
33
|
-
ErrorMsg.new.unknown(msg)
|
34
|
-
end
|
35
|
-
|
36
|
-
def export
|
37
|
-
if sender.objectName == 'btn_full_export'
|
38
|
-
return false unless control_export_settings('full')
|
39
|
-
start = 0
|
40
|
-
stop = @chip.parallel_setting.total_size - 1
|
41
|
-
else
|
42
|
-
return false unless control_export_settings('partial')
|
43
|
-
start = @view.lie_start.text.to_i
|
44
|
-
stop = @view.lie_stop.text.to_i
|
45
|
-
end
|
46
|
-
@chip.parallel_setting.word_size == 0 ? word_size = true : word_size = false
|
47
|
-
Firmware.new('PARALLEL')
|
48
|
-
parallel = HardsploitAPI_PARALLEL.new
|
49
|
-
time = Time.new
|
50
|
-
|
51
|
-
parallel.read_Memory_WithoutMultiplexing(
|
52
|
-
path: @filepath,
|
53
|
-
addressStart: start,
|
54
|
-
addressStop: stop,
|
55
|
-
bits8_or_bits16_DataSize: word_size,
|
56
|
-
latency: @chip.parallel_setting.read_latency
|
57
|
-
)
|
58
|
-
|
59
|
-
control_export_result(stop, time)
|
60
|
-
@view.btn_export.setEnabled(false)
|
61
|
-
@view.btn_full_export.setEnabled(false)
|
62
|
-
@filepath = nil
|
63
|
-
rescue HardsploitAPI::ERROR::HARDSPLOIT_NOT_FOUND
|
64
|
-
ErrorMsg.new.hardsploit_not_found
|
65
|
-
rescue HardsploitAPI::ERROR::USB_ERROR
|
66
|
-
ErrorMsg.new.usb_error
|
67
|
-
rescue Exception => msg
|
68
|
-
ErrorMsg.new.unknown(msg)
|
69
|
-
end
|
70
|
-
|
71
|
-
def control_export_result(stop, time)
|
72
|
-
time = Time.new - time
|
73
|
-
file_size = File.size("#{@filepath}")
|
74
|
-
# 8 bits test
|
75
|
-
if @chip.parallel_setting.word_size.zero?
|
76
|
-
if (stop - @view.lie_start.text.to_i + 1) == file_size
|
77
|
-
Qt::MessageBox.new(
|
78
|
-
Qt::MessageBox::Information,
|
79
|
-
"Information",
|
80
|
-
"Dump finished at #{((file_size / time)).round(2)}Bytes/s (#{(file_size)} Bytes in #{time.round(4)} s)"
|
81
|
-
).exec
|
82
|
-
else
|
83
|
-
ErrorMsg.new.filesize_error
|
84
|
-
end
|
85
|
-
else
|
86
|
-
if (stop - @view.lie_start.text.to_i + 1) == (file_size / 2)
|
87
|
-
Qt::MessageBox.new(
|
88
|
-
Qt::MessageBox::Information,
|
89
|
-
"Information",
|
90
|
-
"Dump finished at #{((file_size / time)).round(2)}Bytes/s (#{(file_size)} Bytes in #{time.round(4)} s)"
|
91
|
-
).exec
|
92
|
-
else
|
93
|
-
ErrorMsg.new.filesize_error
|
94
|
-
end
|
95
|
-
end
|
96
|
-
p "DUMP #{((file_size/time)).round(2)}Bytes/s (#{(file_size)}Bytes in #{time.round(4)} s)"
|
97
|
-
end
|
98
|
-
|
99
|
-
def control_export_settings(type)
|
100
|
-
return ErrorMsg.new.settings_missing if @chip.parallel_setting.nil?
|
101
|
-
return ErrorMsg.new.para_read_latency if @chip.parallel_setting.read_latency.nil?
|
102
|
-
return ErrorMsg.new.para_word_size if @chip.parallel_setting.word_size.nil?
|
103
|
-
return ErrorMsg.new.full_size_error if @chip.parallel_setting.total_size.nil?
|
104
|
-
return ErrorMsg.new.full_size_error if @chip.parallel_setting.total_size.zero?
|
105
|
-
if type == 'partial'
|
106
|
-
return ErrorMsg.new.start_stop_missing if @view.lie_start.text.empty?
|
107
|
-
return ErrorMsg.new.start_stop_missing if @view.lie_stop.text.empty?
|
108
|
-
start = @view.lie_start.text.to_i
|
109
|
-
stop = @view.lie_stop.text.to_i
|
110
|
-
total_size = @chip.parallel_setting.total_size
|
111
|
-
return ErrorMsg.new.start_neq_stop if start == stop
|
112
|
-
return ErrorMsg.new.start_inf_to_stop if start > stop
|
113
|
-
return ErrorMsg.new.inf_to_total_size if start > (total_size - 1)
|
114
|
-
return ErrorMsg.new.inf_to_total_size if stop > (total_size - 1)
|
115
|
-
end
|
116
|
-
return true
|
117
|
-
end
|
118
|
-
end
|
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_generic_export'
|
9
|
+
require_relative '../../HardsploitAPI/Modules/NO_MUX_PARALLEL_MEMORY/HardsploitAPI_NO_MUX_PARALLEL_MEMORY'
|
10
|
+
|
11
|
+
class Parallel_export < Qt::Widget
|
12
|
+
slots 'export()'
|
13
|
+
slots 'select_export_file()'
|
14
|
+
|
15
|
+
def initialize(chip)
|
16
|
+
super()
|
17
|
+
@view = Ui_Generic_export.new
|
18
|
+
centerWindow(self)
|
19
|
+
@view.setupUi(self)
|
20
|
+
@view.lbl_chip.setText(chip.reference)
|
21
|
+
inputRestrict(@view.lie_start, 0)
|
22
|
+
inputRestrict(@view.lie_stop, 0)
|
23
|
+
@chip = chip
|
24
|
+
end
|
25
|
+
|
26
|
+
def select_export_file
|
27
|
+
@filepath = Qt::FileDialog.getSaveFileName(self, tr('Select a file'), '/', tr('Bin file (*.bin)'))
|
28
|
+
unless @filepath.nil?
|
29
|
+
@view.btn_export.setEnabled(true)
|
30
|
+
@view.btn_full_export.setEnabled(true)
|
31
|
+
end
|
32
|
+
rescue Exception => msg
|
33
|
+
ErrorMsg.new.unknown(msg)
|
34
|
+
end
|
35
|
+
|
36
|
+
def export
|
37
|
+
if sender.objectName == 'btn_full_export'
|
38
|
+
return false unless control_export_settings('full')
|
39
|
+
start = 0
|
40
|
+
stop = @chip.parallel_setting.total_size - 1
|
41
|
+
else
|
42
|
+
return false unless control_export_settings('partial')
|
43
|
+
start = @view.lie_start.text.to_i
|
44
|
+
stop = @view.lie_stop.text.to_i
|
45
|
+
end
|
46
|
+
@chip.parallel_setting.word_size == 0 ? word_size = true : word_size = false
|
47
|
+
Firmware.new('PARALLEL')
|
48
|
+
parallel = HardsploitAPI_PARALLEL.new
|
49
|
+
time = Time.new
|
50
|
+
|
51
|
+
parallel.read_Memory_WithoutMultiplexing(
|
52
|
+
path: @filepath,
|
53
|
+
addressStart: start,
|
54
|
+
addressStop: stop,
|
55
|
+
bits8_or_bits16_DataSize: word_size,
|
56
|
+
latency: @chip.parallel_setting.read_latency
|
57
|
+
)
|
58
|
+
|
59
|
+
control_export_result(stop, time)
|
60
|
+
@view.btn_export.setEnabled(false)
|
61
|
+
@view.btn_full_export.setEnabled(false)
|
62
|
+
@filepath = nil
|
63
|
+
rescue HardsploitAPI::ERROR::HARDSPLOIT_NOT_FOUND
|
64
|
+
ErrorMsg.new.hardsploit_not_found
|
65
|
+
rescue HardsploitAPI::ERROR::USB_ERROR
|
66
|
+
ErrorMsg.new.usb_error
|
67
|
+
rescue Exception => msg
|
68
|
+
ErrorMsg.new.unknown(msg)
|
69
|
+
end
|
70
|
+
|
71
|
+
def control_export_result(stop, time)
|
72
|
+
time = Time.new - time
|
73
|
+
file_size = File.size("#{@filepath}")
|
74
|
+
# 8 bits test
|
75
|
+
if @chip.parallel_setting.word_size.zero?
|
76
|
+
if (stop - @view.lie_start.text.to_i + 1) == file_size
|
77
|
+
Qt::MessageBox.new(
|
78
|
+
Qt::MessageBox::Information,
|
79
|
+
"Information",
|
80
|
+
"Dump finished at #{((file_size / time)).round(2)}Bytes/s (#{(file_size)} Bytes in #{time.round(4)} s)"
|
81
|
+
).exec
|
82
|
+
else
|
83
|
+
ErrorMsg.new.filesize_error
|
84
|
+
end
|
85
|
+
else
|
86
|
+
if (stop - @view.lie_start.text.to_i + 1) == (file_size / 2)
|
87
|
+
Qt::MessageBox.new(
|
88
|
+
Qt::MessageBox::Information,
|
89
|
+
"Information",
|
90
|
+
"Dump finished at #{((file_size / time)).round(2)}Bytes/s (#{(file_size)} Bytes in #{time.round(4)} s)"
|
91
|
+
).exec
|
92
|
+
else
|
93
|
+
ErrorMsg.new.filesize_error
|
94
|
+
end
|
95
|
+
end
|
96
|
+
p "DUMP #{((file_size/time)).round(2)}Bytes/s (#{(file_size)}Bytes in #{time.round(4)} s)"
|
97
|
+
end
|
98
|
+
|
99
|
+
def control_export_settings(type)
|
100
|
+
return ErrorMsg.new.settings_missing if @chip.parallel_setting.nil?
|
101
|
+
return ErrorMsg.new.para_read_latency if @chip.parallel_setting.read_latency.nil?
|
102
|
+
return ErrorMsg.new.para_word_size if @chip.parallel_setting.word_size.nil?
|
103
|
+
return ErrorMsg.new.full_size_error if @chip.parallel_setting.total_size.nil?
|
104
|
+
return ErrorMsg.new.full_size_error if @chip.parallel_setting.total_size.zero?
|
105
|
+
if type == 'partial'
|
106
|
+
return ErrorMsg.new.start_stop_missing if @view.lie_start.text.empty?
|
107
|
+
return ErrorMsg.new.start_stop_missing if @view.lie_stop.text.empty?
|
108
|
+
start = @view.lie_start.text.to_i
|
109
|
+
stop = @view.lie_stop.text.to_i
|
110
|
+
total_size = @chip.parallel_setting.total_size
|
111
|
+
return ErrorMsg.new.start_neq_stop if start == stop
|
112
|
+
return ErrorMsg.new.start_inf_to_stop if start > stop
|
113
|
+
return ErrorMsg.new.inf_to_total_size if start > (total_size - 1)
|
114
|
+
return ErrorMsg.new.inf_to_total_size if stop > (total_size - 1)
|
115
|
+
end
|
116
|
+
return true
|
117
|
+
end
|
118
|
+
end
|