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
@@ -1,51 +1,51 @@
|
|
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_i2c_command'
|
9
|
-
class I2c_command < Qt::Widget
|
10
|
-
slots 'open_generic_cmd()'
|
11
|
-
|
12
|
-
def initialize(chip, bus_id, parent)
|
13
|
-
super()
|
14
|
-
@view = Ui_I2c_command.new
|
15
|
-
centerWindow(self)
|
16
|
-
@view.setupUi(self)
|
17
|
-
@view.rbn_read.setChecked(true)
|
18
|
-
inputRestrict(@view.lie_size, 0)
|
19
|
-
@chip = chip
|
20
|
-
@chip_settings = chip.i2c_setting
|
21
|
-
@bus_id = bus_id
|
22
|
-
@parent = parent
|
23
|
-
end
|
24
|
-
|
25
|
-
def open_generic_cmd
|
26
|
-
return 0 if check_form_param.zero?
|
27
|
-
if @view.rbn_read.isChecked
|
28
|
-
mode = "r"
|
29
|
-
addr = @chip_settings.address_r
|
30
|
-
else
|
31
|
-
mode = "w"
|
32
|
-
addr = @chip_settings.address_w
|
33
|
-
end
|
34
|
-
i2c_cmd_form = Command_editor.new(0, nil, @chip, @bus_id, @parent, :mode => mode, :size => @view.lie_size.text, :addr => addr)
|
35
|
-
i2c_cmd_form.setWindowModality(Qt::ApplicationModal)
|
36
|
-
i2c_cmd_form.show
|
37
|
-
close
|
38
|
-
end
|
39
|
-
|
40
|
-
def check_form_param
|
41
|
-
if @view.lie_size.text.empty? || @view.lie_size.text.to_i.zero?
|
42
|
-
Qt::MessageBox.new(
|
43
|
-
Qt::MessageBox::Information,
|
44
|
-
"Form invalid",
|
45
|
-
"Payload size must be filled and superior to 0"
|
46
|
-
).exec
|
47
|
-
return 0
|
48
|
-
end
|
49
|
-
return 1
|
50
|
-
end
|
51
|
-
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_i2c_command'
|
9
|
+
class I2c_command < Qt::Widget
|
10
|
+
slots 'open_generic_cmd()'
|
11
|
+
|
12
|
+
def initialize(chip, bus_id, parent)
|
13
|
+
super()
|
14
|
+
@view = Ui_I2c_command.new
|
15
|
+
centerWindow(self)
|
16
|
+
@view.setupUi(self)
|
17
|
+
@view.rbn_read.setChecked(true)
|
18
|
+
inputRestrict(@view.lie_size, 0)
|
19
|
+
@chip = chip
|
20
|
+
@chip_settings = chip.i2c_setting
|
21
|
+
@bus_id = bus_id
|
22
|
+
@parent = parent
|
23
|
+
end
|
24
|
+
|
25
|
+
def open_generic_cmd
|
26
|
+
return 0 if check_form_param.zero?
|
27
|
+
if @view.rbn_read.isChecked
|
28
|
+
mode = "r"
|
29
|
+
addr = @chip_settings.address_r
|
30
|
+
else
|
31
|
+
mode = "w"
|
32
|
+
addr = @chip_settings.address_w
|
33
|
+
end
|
34
|
+
i2c_cmd_form = Command_editor.new(0, nil, @chip, @bus_id, @parent, :mode => mode, :size => @view.lie_size.text, :addr => addr)
|
35
|
+
i2c_cmd_form.setWindowModality(Qt::ApplicationModal)
|
36
|
+
i2c_cmd_form.show
|
37
|
+
close
|
38
|
+
end
|
39
|
+
|
40
|
+
def check_form_param
|
41
|
+
if @view.lie_size.text.empty? || @view.lie_size.text.to_i.zero?
|
42
|
+
Qt::MessageBox.new(
|
43
|
+
Qt::MessageBox::Information,
|
44
|
+
"Form invalid",
|
45
|
+
"Payload size must be filled and superior to 0"
|
46
|
+
).exec
|
47
|
+
return 0
|
48
|
+
end
|
49
|
+
return 1
|
50
|
+
end
|
51
|
+
end
|
@@ -1,95 +1,95 @@
|
|
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/I2C/HardsploitAPI_I2C'
|
10
|
-
class I2c_export < Qt::Widget
|
11
|
-
slots 'export()'
|
12
|
-
slots 'select_export_file()'
|
13
|
-
|
14
|
-
def initialize(chip)
|
15
|
-
super()
|
16
|
-
@view = Ui_Generic_export.new
|
17
|
-
centerWindow(self)
|
18
|
-
@view.setupUi(self)
|
19
|
-
@view.lbl_chip.setText(chip.reference)
|
20
|
-
inputRestrict(@view.lie_start, 0)
|
21
|
-
inputRestrict(@view.lie_stop, 0)
|
22
|
-
@chip = chip
|
23
|
-
end
|
24
|
-
|
25
|
-
def select_export_file
|
26
|
-
@filepath = Qt::FileDialog.getSaveFileName(self, tr('Select a file'), '/', tr('*.*'))
|
27
|
-
unless @filepath.nil?
|
28
|
-
@view.btn_export.setEnabled(true)
|
29
|
-
@view.btn_full_export.setEnabled(true)
|
30
|
-
@view.lbl_selected_file.setText("#{@filepath.split("/").last}")
|
31
|
-
end
|
32
|
-
rescue Exception => msg
|
33
|
-
ErrorMsg.new.unknown(msg)
|
34
|
-
end
|
35
|
-
|
36
|
-
def export
|
37
|
-
$file = File.open("#{@filepath}", 'w') unless @filepath.nil?
|
38
|
-
if sender.objectName == 'btn_full_export'
|
39
|
-
return false unless control_export_settings('full')
|
40
|
-
start = 0
|
41
|
-
stop = @chip.i2c_setting.total_size - 1
|
42
|
-
control = @chip.i2c_setting.total_size
|
43
|
-
else
|
44
|
-
return false unless control_export_settings('partial')
|
45
|
-
start = @view.lie_start.text.to_i
|
46
|
-
stop = @view.lie_stop.text.to_i
|
47
|
-
control = (stop - start) + 1
|
48
|
-
end
|
49
|
-
Firmware.new('I2C')
|
50
|
-
$pgb = Progress_bar.new("I²C: Exporting...")
|
51
|
-
$pgb.show
|
52
|
-
|
53
|
-
if [40, 100, 400, 1000].include?(@chip.i2c_setting.frequency)
|
54
|
-
speed = 0 if @chip.i2c_setting.frequency == 100
|
55
|
-
speed = 1 if @chip.i2c_setting.frequency == 400
|
56
|
-
speed = 2 if @chip.i2c_setting.frequency == 1000
|
57
|
-
speed = 3 if @chip.i2c_setting.frequency == 40
|
58
|
-
i2c = HardsploitAPI_I2C.new(speed: speed)
|
59
|
-
i2c.i2c_Generic_Dump(
|
60
|
-
i2cBaseAddress: @chip.i2c_setting.address_w.to_i(16),
|
61
|
-
startAddress: start,
|
62
|
-
stopAddress: stop,
|
63
|
-
sizeMax: @chip.i2c_setting.total_size
|
64
|
-
)
|
65
|
-
end
|
66
|
-
$file.close unless $file.nil?
|
67
|
-
ErrorMsg.new.filesize_error unless control == File.size(@filepath)
|
68
|
-
rescue HardsploitAPI::ERROR::HARDSPLOIT_NOT_FOUND
|
69
|
-
ErrorMsg.new.hardsploit_not_found
|
70
|
-
rescue HardsploitAPI::ERROR::USB_ERROR
|
71
|
-
ErrorMsg.new.usb_error
|
72
|
-
rescue Exception => msg
|
73
|
-
ErrorMsg.new.unknown(msg)
|
74
|
-
end
|
75
|
-
|
76
|
-
def control_export_settings(type)
|
77
|
-
return ErrorMsg.new.settings_missing if @chip.i2c_setting.nil?
|
78
|
-
return ErrorMsg.new.frequency_missing if @chip.i2c_setting.frequency.nil?
|
79
|
-
return ErrorMsg.new.mode_missing if @chip.i2c_setting.address_w.nil?
|
80
|
-
return ErrorMsg.new.full_size_error if @chip.i2c_setting.total_size.nil?
|
81
|
-
return ErrorMsg.new.full_size_error if @chip.i2c_setting.total_size.zero?
|
82
|
-
if type == 'partial'
|
83
|
-
return ErrorMsg.new.start_stop_missing if @view.lie_start.text.empty?
|
84
|
-
return ErrorMsg.new.start_stop_missing if @view.lie_stop.text.empty?
|
85
|
-
start = @view.lie_start.text.to_i
|
86
|
-
stop = @view.lie_stop.text.to_i
|
87
|
-
total_size = @chip.i2c_setting.total_size
|
88
|
-
return ErrorMsg.new.start_neq_stop if start == stop
|
89
|
-
return ErrorMsg.new.start_inf_to_stop if start > stop
|
90
|
-
return ErrorMsg.new.inf_to_total_size if start > (total_size - 1)
|
91
|
-
return ErrorMsg.new.inf_to_total_size if stop > (total_size - 1)
|
92
|
-
end
|
93
|
-
return true
|
94
|
-
end
|
95
|
-
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/I2C/HardsploitAPI_I2C'
|
10
|
+
class I2c_export < Qt::Widget
|
11
|
+
slots 'export()'
|
12
|
+
slots 'select_export_file()'
|
13
|
+
|
14
|
+
def initialize(chip)
|
15
|
+
super()
|
16
|
+
@view = Ui_Generic_export.new
|
17
|
+
centerWindow(self)
|
18
|
+
@view.setupUi(self)
|
19
|
+
@view.lbl_chip.setText(chip.reference)
|
20
|
+
inputRestrict(@view.lie_start, 0)
|
21
|
+
inputRestrict(@view.lie_stop, 0)
|
22
|
+
@chip = chip
|
23
|
+
end
|
24
|
+
|
25
|
+
def select_export_file
|
26
|
+
@filepath = Qt::FileDialog.getSaveFileName(self, tr('Select a file'), '/', tr('*.*'))
|
27
|
+
unless @filepath.nil?
|
28
|
+
@view.btn_export.setEnabled(true)
|
29
|
+
@view.btn_full_export.setEnabled(true)
|
30
|
+
@view.lbl_selected_file.setText("#{@filepath.split("/").last}")
|
31
|
+
end
|
32
|
+
rescue Exception => msg
|
33
|
+
ErrorMsg.new.unknown(msg)
|
34
|
+
end
|
35
|
+
|
36
|
+
def export
|
37
|
+
$file = File.open("#{@filepath}", 'w') unless @filepath.nil?
|
38
|
+
if sender.objectName == 'btn_full_export'
|
39
|
+
return false unless control_export_settings('full')
|
40
|
+
start = 0
|
41
|
+
stop = @chip.i2c_setting.total_size - 1
|
42
|
+
control = @chip.i2c_setting.total_size
|
43
|
+
else
|
44
|
+
return false unless control_export_settings('partial')
|
45
|
+
start = @view.lie_start.text.to_i
|
46
|
+
stop = @view.lie_stop.text.to_i
|
47
|
+
control = (stop - start) + 1
|
48
|
+
end
|
49
|
+
Firmware.new('I2C')
|
50
|
+
$pgb = Progress_bar.new("I²C: Exporting...")
|
51
|
+
$pgb.show
|
52
|
+
|
53
|
+
if [40, 100, 400, 1000].include?(@chip.i2c_setting.frequency)
|
54
|
+
speed = 0 if @chip.i2c_setting.frequency == 100
|
55
|
+
speed = 1 if @chip.i2c_setting.frequency == 400
|
56
|
+
speed = 2 if @chip.i2c_setting.frequency == 1000
|
57
|
+
speed = 3 if @chip.i2c_setting.frequency == 40
|
58
|
+
i2c = HardsploitAPI_I2C.new(speed: speed)
|
59
|
+
i2c.i2c_Generic_Dump(
|
60
|
+
i2cBaseAddress: @chip.i2c_setting.address_w.to_i(16),
|
61
|
+
startAddress: start,
|
62
|
+
stopAddress: stop,
|
63
|
+
sizeMax: @chip.i2c_setting.total_size
|
64
|
+
)
|
65
|
+
end
|
66
|
+
$file.close unless $file.nil?
|
67
|
+
ErrorMsg.new.filesize_error unless control == File.size(@filepath)
|
68
|
+
rescue HardsploitAPI::ERROR::HARDSPLOIT_NOT_FOUND
|
69
|
+
ErrorMsg.new.hardsploit_not_found
|
70
|
+
rescue HardsploitAPI::ERROR::USB_ERROR
|
71
|
+
ErrorMsg.new.usb_error
|
72
|
+
rescue Exception => msg
|
73
|
+
ErrorMsg.new.unknown(msg)
|
74
|
+
end
|
75
|
+
|
76
|
+
def control_export_settings(type)
|
77
|
+
return ErrorMsg.new.settings_missing if @chip.i2c_setting.nil?
|
78
|
+
return ErrorMsg.new.frequency_missing if @chip.i2c_setting.frequency.nil?
|
79
|
+
return ErrorMsg.new.mode_missing if @chip.i2c_setting.address_w.nil?
|
80
|
+
return ErrorMsg.new.full_size_error if @chip.i2c_setting.total_size.nil?
|
81
|
+
return ErrorMsg.new.full_size_error if @chip.i2c_setting.total_size.zero?
|
82
|
+
if type == 'partial'
|
83
|
+
return ErrorMsg.new.start_stop_missing if @view.lie_start.text.empty?
|
84
|
+
return ErrorMsg.new.start_stop_missing if @view.lie_stop.text.empty?
|
85
|
+
start = @view.lie_start.text.to_i
|
86
|
+
stop = @view.lie_stop.text.to_i
|
87
|
+
total_size = @chip.i2c_setting.total_size
|
88
|
+
return ErrorMsg.new.start_neq_stop if start == stop
|
89
|
+
return ErrorMsg.new.start_inf_to_stop if start > stop
|
90
|
+
return ErrorMsg.new.inf_to_total_size if start > (total_size - 1)
|
91
|
+
return ErrorMsg.new.inf_to_total_size if stop > (total_size - 1)
|
92
|
+
end
|
93
|
+
return true
|
94
|
+
end
|
95
|
+
end
|
@@ -1,117 +1,117 @@
|
|
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_import'
|
9
|
-
require_relative '../../HardsploitAPI/Modules/I2C/HardsploitAPI_I2C'
|
10
|
-
class I2c_import < Qt::Widget
|
11
|
-
slots 'import()'
|
12
|
-
slots 'select_import_file()'
|
13
|
-
|
14
|
-
def initialize(chip)
|
15
|
-
super()
|
16
|
-
@view = Ui_Generic_import.new
|
17
|
-
centerWindow(self)
|
18
|
-
@view.setupUi(self)
|
19
|
-
@view.lbl_chip.setText(chip.reference)
|
20
|
-
inputRestrict(@view.lie_start, 0)
|
21
|
-
@chip = chip
|
22
|
-
end
|
23
|
-
|
24
|
-
def select_import_file
|
25
|
-
@filepath = Qt::FileDialog.getOpenFileName(self, tr('Select a file'), '/', tr('*.*'))
|
26
|
-
unless @filepath.nil?
|
27
|
-
@view.btn_import.setEnabled(true)
|
28
|
-
@view.lbl_selected_file.setText("#{@filepath.split("/").last}")
|
29
|
-
end
|
30
|
-
rescue Exception => msg
|
31
|
-
ErrorMsg.new.unknown(msg)
|
32
|
-
end
|
33
|
-
|
34
|
-
def import
|
35
|
-
return 0 if control_import_settings.zero?
|
36
|
-
Firmware.new('I2C')
|
37
|
-
$pgb = Progress_bar.new("I²C: Exporting...")
|
38
|
-
$pgb.show
|
39
|
-
if [40, 100, 400, 1000].include?(@chip.i2c_setting.frequency)
|
40
|
-
speed = 0 if @chip.i2c_setting.frequency == 100
|
41
|
-
speed = 1 if @chip.i2c_setting.frequency == 400
|
42
|
-
speed = 2 if @chip.i2c_setting.frequency == 1000
|
43
|
-
speed = 3 if @chip.i2c_setting.frequency == 40
|
44
|
-
i2c = HardsploitAPI_I2C.new(speed: speed)
|
45
|
-
i2c.i2c_Generic_Import(
|
46
|
-
i2cBaseAddress: @chip.i2c_setting.address_w.to_i(16),
|
47
|
-
startAddress: @view.lie_start.text.to_i,
|
48
|
-
pageSize: @chip.i2c_setting.page_size,
|
49
|
-
memorySize: @chip.i2c_setting.total_size,
|
50
|
-
dataFile: @filepath,
|
51
|
-
writePageLatency: @chip.i2c_setting.write_page_latency / 1000.0
|
52
|
-
)
|
53
|
-
end
|
54
|
-
rescue HardsploitAPI::ERROR::HARDSPLOIT_NOT_FOUND
|
55
|
-
ErrorMsg.new.hardsploit_not_found
|
56
|
-
rescue HardsploitAPI::ERROR::USB_ERROR
|
57
|
-
ErrorMsg.new.usb_error
|
58
|
-
rescue HardsploitAPI::ERROR::I2CWrongSpeed
|
59
|
-
ErrorMsg.new.i2c_error
|
60
|
-
rescue Exception => msg
|
61
|
-
ErrorMsg.new.unknown(msg)
|
62
|
-
end
|
63
|
-
|
64
|
-
def control_import_settings
|
65
|
-
if @chip.i2c_setting.nil?
|
66
|
-
Qt::MessageBox.new(
|
67
|
-
Qt::MessageBox::Warning,
|
68
|
-
'Missing I2C setting',
|
69
|
-
'No settings saved for this chip'
|
70
|
-
).exec
|
71
|
-
return 0
|
72
|
-
end
|
73
|
-
if @chip.i2c_setting.total_size.nil?
|
74
|
-
Qt::MessageBox.new(
|
75
|
-
Qt::MessageBox::Warning,
|
76
|
-
'Missing I2C setting',
|
77
|
-
'Total size setting missing'
|
78
|
-
).exec
|
79
|
-
return 0
|
80
|
-
end
|
81
|
-
if @chip.i2c_setting.page_size.nil?
|
82
|
-
Qt::MessageBox.new(
|
83
|
-
Qt::MessageBox::Warning,
|
84
|
-
'Missing I2C setting',
|
85
|
-
'Page size setting missing'
|
86
|
-
).exec
|
87
|
-
return 0
|
88
|
-
end
|
89
|
-
if @chip.i2c_setting.write_page_latency.nil?
|
90
|
-
Qt::MessageBox.new(
|
91
|
-
Qt::MessageBox::Warning,
|
92
|
-
'Missing I2C setting',
|
93
|
-
'Write page latency setting missing'
|
94
|
-
).exec
|
95
|
-
return 0
|
96
|
-
end
|
97
|
-
if @chip.i2c_setting.frequency.nil? || @chip.i2c_setting.address_w.nil?
|
98
|
-
Qt::MessageBox.new(
|
99
|
-
Qt::MessageBox::Warning,
|
100
|
-
'Missing I2C setting',
|
101
|
-
'Write base address or frequency settings missing'
|
102
|
-
).exec
|
103
|
-
return 0
|
104
|
-
end
|
105
|
-
if @view.lie_start.text.empty?
|
106
|
-
Qt::MessageBox.new(
|
107
|
-
Qt::MessageBox::Warning,
|
108
|
-
'Missing start address',
|
109
|
-
'Please fill the Start address field'
|
110
|
-
).exec
|
111
|
-
return 0
|
112
|
-
end
|
113
|
-
return 1
|
114
|
-
rescue Exception => msg
|
115
|
-
ErrorMsg.new.unknown(msg)
|
116
|
-
end
|
117
|
-
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_import'
|
9
|
+
require_relative '../../HardsploitAPI/Modules/I2C/HardsploitAPI_I2C'
|
10
|
+
class I2c_import < Qt::Widget
|
11
|
+
slots 'import()'
|
12
|
+
slots 'select_import_file()'
|
13
|
+
|
14
|
+
def initialize(chip)
|
15
|
+
super()
|
16
|
+
@view = Ui_Generic_import.new
|
17
|
+
centerWindow(self)
|
18
|
+
@view.setupUi(self)
|
19
|
+
@view.lbl_chip.setText(chip.reference)
|
20
|
+
inputRestrict(@view.lie_start, 0)
|
21
|
+
@chip = chip
|
22
|
+
end
|
23
|
+
|
24
|
+
def select_import_file
|
25
|
+
@filepath = Qt::FileDialog.getOpenFileName(self, tr('Select a file'), '/', tr('*.*'))
|
26
|
+
unless @filepath.nil?
|
27
|
+
@view.btn_import.setEnabled(true)
|
28
|
+
@view.lbl_selected_file.setText("#{@filepath.split("/").last}")
|
29
|
+
end
|
30
|
+
rescue Exception => msg
|
31
|
+
ErrorMsg.new.unknown(msg)
|
32
|
+
end
|
33
|
+
|
34
|
+
def import
|
35
|
+
return 0 if control_import_settings.zero?
|
36
|
+
Firmware.new('I2C')
|
37
|
+
$pgb = Progress_bar.new("I²C: Exporting...")
|
38
|
+
$pgb.show
|
39
|
+
if [40, 100, 400, 1000].include?(@chip.i2c_setting.frequency)
|
40
|
+
speed = 0 if @chip.i2c_setting.frequency == 100
|
41
|
+
speed = 1 if @chip.i2c_setting.frequency == 400
|
42
|
+
speed = 2 if @chip.i2c_setting.frequency == 1000
|
43
|
+
speed = 3 if @chip.i2c_setting.frequency == 40
|
44
|
+
i2c = HardsploitAPI_I2C.new(speed: speed)
|
45
|
+
i2c.i2c_Generic_Import(
|
46
|
+
i2cBaseAddress: @chip.i2c_setting.address_w.to_i(16),
|
47
|
+
startAddress: @view.lie_start.text.to_i,
|
48
|
+
pageSize: @chip.i2c_setting.page_size,
|
49
|
+
memorySize: @chip.i2c_setting.total_size,
|
50
|
+
dataFile: @filepath,
|
51
|
+
writePageLatency: @chip.i2c_setting.write_page_latency / 1000.0
|
52
|
+
)
|
53
|
+
end
|
54
|
+
rescue HardsploitAPI::ERROR::HARDSPLOIT_NOT_FOUND
|
55
|
+
ErrorMsg.new.hardsploit_not_found
|
56
|
+
rescue HardsploitAPI::ERROR::USB_ERROR
|
57
|
+
ErrorMsg.new.usb_error
|
58
|
+
rescue HardsploitAPI::ERROR::I2CWrongSpeed
|
59
|
+
ErrorMsg.new.i2c_error
|
60
|
+
rescue Exception => msg
|
61
|
+
ErrorMsg.new.unknown(msg)
|
62
|
+
end
|
63
|
+
|
64
|
+
def control_import_settings
|
65
|
+
if @chip.i2c_setting.nil?
|
66
|
+
Qt::MessageBox.new(
|
67
|
+
Qt::MessageBox::Warning,
|
68
|
+
'Missing I2C setting',
|
69
|
+
'No settings saved for this chip'
|
70
|
+
).exec
|
71
|
+
return 0
|
72
|
+
end
|
73
|
+
if @chip.i2c_setting.total_size.nil?
|
74
|
+
Qt::MessageBox.new(
|
75
|
+
Qt::MessageBox::Warning,
|
76
|
+
'Missing I2C setting',
|
77
|
+
'Total size setting missing'
|
78
|
+
).exec
|
79
|
+
return 0
|
80
|
+
end
|
81
|
+
if @chip.i2c_setting.page_size.nil?
|
82
|
+
Qt::MessageBox.new(
|
83
|
+
Qt::MessageBox::Warning,
|
84
|
+
'Missing I2C setting',
|
85
|
+
'Page size setting missing'
|
86
|
+
).exec
|
87
|
+
return 0
|
88
|
+
end
|
89
|
+
if @chip.i2c_setting.write_page_latency.nil?
|
90
|
+
Qt::MessageBox.new(
|
91
|
+
Qt::MessageBox::Warning,
|
92
|
+
'Missing I2C setting',
|
93
|
+
'Write page latency setting missing'
|
94
|
+
).exec
|
95
|
+
return 0
|
96
|
+
end
|
97
|
+
if @chip.i2c_setting.frequency.nil? || @chip.i2c_setting.address_w.nil?
|
98
|
+
Qt::MessageBox.new(
|
99
|
+
Qt::MessageBox::Warning,
|
100
|
+
'Missing I2C setting',
|
101
|
+
'Write base address or frequency settings missing'
|
102
|
+
).exec
|
103
|
+
return 0
|
104
|
+
end
|
105
|
+
if @view.lie_start.text.empty?
|
106
|
+
Qt::MessageBox.new(
|
107
|
+
Qt::MessageBox::Warning,
|
108
|
+
'Missing start address',
|
109
|
+
'Please fill the Start address field'
|
110
|
+
).exec
|
111
|
+
return 0
|
112
|
+
end
|
113
|
+
return 1
|
114
|
+
rescue Exception => msg
|
115
|
+
ErrorMsg.new.unknown(msg)
|
116
|
+
end
|
117
|
+
end
|