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/I2C/I2c_export.rb
DELETED
@@ -1,118 +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
|
-
require_relative '../../gui/gui_generic_export'
|
10
|
-
|
11
|
-
class I2c_export < Qt::Widget
|
12
|
-
slots 'export()'
|
13
|
-
slots 'select_export_file()'
|
14
|
-
|
15
|
-
def initialize(api, chip)
|
16
|
-
super()
|
17
|
-
@i2c_export_gui = Ui_Generic_export.new
|
18
|
-
centerWindow(self)
|
19
|
-
@i2c_export_gui.setupUi(self)
|
20
|
-
@i2c_export_gui.lbl_chip.setText(chip.chip_reference)
|
21
|
-
inputRestrict(@i2c_export_gui.lie_start, 0)
|
22
|
-
inputRestrict(@i2c_export_gui.lie_stop, 0)
|
23
|
-
@api = api
|
24
|
-
@chip_settings = I2C.find_by(i2c_chip: chip.chip_id)
|
25
|
-
end
|
26
|
-
|
27
|
-
def select_export_file
|
28
|
-
@filepath = Qt::FileDialog.getSaveFileName(self, tr('Select a file'), '/', tr('Bin file (*.bin)'))
|
29
|
-
unless @filepath.nil?
|
30
|
-
$file = File.open("#{@filepath}", 'w')
|
31
|
-
@i2c_export_gui.btn_export.setEnabled(true)
|
32
|
-
@i2c_export_gui.btn_full_export.setEnabled(true)
|
33
|
-
end
|
34
|
-
rescue Exception => msg
|
35
|
-
logger = Logger.new($logFilePath)
|
36
|
-
logger.error msg
|
37
|
-
Qt::MessageBox.new(Qt::MessageBox::Critical, 'Critical error', 'Error occured while openning the export file. Consult the logs for more details').exec
|
38
|
-
end
|
39
|
-
|
40
|
-
def close_file
|
41
|
-
unless $file.nil?
|
42
|
-
$file.close
|
43
|
-
end
|
44
|
-
rescue Exception => msg
|
45
|
-
logger = Logger.new($logFilePath)
|
46
|
-
logger.error msg
|
47
|
-
Qt::MessageBox.new(Qt::MessageBox::Critical, 'Critical error', 'Error occured while closing the export file. Consult the logs for more details').exec
|
48
|
-
end
|
49
|
-
|
50
|
-
def export
|
51
|
-
if sender.objectName == 'btn_full_export'
|
52
|
-
return 0 if control_export_settings('full').zero?
|
53
|
-
else
|
54
|
-
return 0 if control_export_settings('partial').zero?
|
55
|
-
end
|
56
|
-
Firmware.new(@api, 'I2C')
|
57
|
-
$pgb = Progress_bar.new("I²C: Exporting...")
|
58
|
-
$pgb.show
|
59
|
-
if sender.objectName == 'btn_full_export'
|
60
|
-
@api.i2c_Generic_Dump(@chip_settings.i2c_frequency, @chip_settings.i2c_address_w.to_i(16), 0, @chip_settings.i2c_total_size - 1, @chip_settings.i2c_total_size)
|
61
|
-
close_file
|
62
|
-
control_export_result('full', @chip_settings.i2c_total_size - 1)
|
63
|
-
else
|
64
|
-
@api.i2c_Generic_Dump(@chip_settings.i2c_frequency, @chip_settings.i2c_address_w.to_i(16), @i2c_export_gui.lie_start.text.to_i, @i2c_export_gui.lie_stop.text.to_i, @chip_settings.i2c_total_size)
|
65
|
-
close_file
|
66
|
-
control_export_result('partial', @i2c_export_gui.lie_stop.text.to_i)
|
67
|
-
end
|
68
|
-
@i2c_export_gui.btn_export.setEnabled(false)
|
69
|
-
@i2c_export_gui.btn_full_export.setEnabled(false)
|
70
|
-
rescue Exception => msg
|
71
|
-
logger = Logger.new($logFilePath)
|
72
|
-
logger.error msg
|
73
|
-
Qt::MessageBox.new(Qt::MessageBox::Critical, 'Critical error', 'Error occured while full export operation. Consult the logs for more details').exec
|
74
|
-
end
|
75
|
-
|
76
|
-
def control_export_result(type, stop)
|
77
|
-
if type == 'partial'
|
78
|
-
toCompare = ((stop - @i2c_export_gui.lie_start.text.to_i) + 1)
|
79
|
-
else
|
80
|
-
toCompare = @chip_settings.i2c_total_size
|
81
|
-
end
|
82
|
-
file_size = File.size(@filepath)
|
83
|
-
if toCompare != file_size
|
84
|
-
Qt::MessageBox.new(Qt::MessageBox::Critical, 'Error', 'Dump error: Size does not match').exec
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
def control_export_settings(type)
|
89
|
-
if @chip_settings.nil?
|
90
|
-
Qt::MessageBox.new(Qt::MessageBox::Warning, 'Missing I2C settings', 'No settings saved for this chip').exec
|
91
|
-
return 0
|
92
|
-
end
|
93
|
-
if @chip_settings.i2c_frequency.nil? || @chip_settings.i2c_address_w.nil?
|
94
|
-
Qt::MessageBox.new(Qt::MessageBox::Warning, 'Missing I2C settings', 'Write base address or frequency settings missing').exec
|
95
|
-
return 0
|
96
|
-
end
|
97
|
-
if type == 'full'
|
98
|
-
if @chip_settings.i2c_total_size.zero? || @chip_settings.i2c_total_size.nil?
|
99
|
-
Qt::MessageBox.new(Qt::MessageBox::Warning, 'Empty field', 'Full size setting missing or equal 0').exec
|
100
|
-
return 0
|
101
|
-
end
|
102
|
-
else
|
103
|
-
if @i2c_export_gui.lie_start.text.empty? || @i2c_export_gui.lie_stop.text.empty?
|
104
|
-
Qt::MessageBox.new(Qt::MessageBox::Warning, 'Empty field', 'Start and stop address must be filled').exec
|
105
|
-
return 0
|
106
|
-
end
|
107
|
-
if @i2c_export_gui.lie_start.text.to_i > @i2c_export_gui.lie_stop.text.to_i
|
108
|
-
Qt::MessageBox.new(Qt::MessageBox::Warning, 'Wrong value', 'Start address must be inforior to the stop address').exec
|
109
|
-
return 0
|
110
|
-
end
|
111
|
-
if @i2c_export_gui.lie_start.text.to_i > (@chip_settings.i2c_total_size - 1) || @i2c_export_gui.lie_stop.text.to_i > (@chip_settings.i2c_total_size - 1)
|
112
|
-
Qt::MessageBox.new(Qt::MessageBox::Warning, 'Wrong value', 'Start and stop address must be inforior to the chip total size').exec
|
113
|
-
return 0
|
114
|
-
end
|
115
|
-
end
|
116
|
-
return 1
|
117
|
-
end
|
118
|
-
end
|
data/lib/class/I2C/I2c_import.rb
DELETED
@@ -1,79 +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
|
-
require_relative '../../gui/gui_generic_import'
|
10
|
-
|
11
|
-
class I2c_import < Qt::Widget
|
12
|
-
slots 'import()'
|
13
|
-
slots 'select_import_file()'
|
14
|
-
|
15
|
-
def initialize(api, chip)
|
16
|
-
super()
|
17
|
-
@i2c_import_gui = Ui_Generic_import.new
|
18
|
-
centerWindow(self)
|
19
|
-
@i2c_import_gui.setupUi(self)
|
20
|
-
@i2c_import_gui.lbl_chip.setText(chip.chip_reference)
|
21
|
-
inputRestrict(@i2c_import_gui.lie_start, 0)
|
22
|
-
@api = api
|
23
|
-
@chip = chip
|
24
|
-
@chip_settings = I2C.find_by(i2c_chip: chip.chip_id)
|
25
|
-
end
|
26
|
-
|
27
|
-
def select_import_file
|
28
|
-
@filepath = Qt::FileDialog.getOpenFileName(self, tr('Select a file'), '/', tr('Bin file (*.bin)'))
|
29
|
-
unless @filepath.nil?
|
30
|
-
@i2c_import_gui.btn_import.setEnabled(true)
|
31
|
-
end
|
32
|
-
rescue Exception => msg
|
33
|
-
logger = Logger.new($logFilePath)
|
34
|
-
logger.error msg
|
35
|
-
Qt::MessageBox.new(Qt::MessageBox::Critical, 'Critical error', 'Error occured while openning the export file. Consult the logs for more details').exec
|
36
|
-
end
|
37
|
-
|
38
|
-
def import
|
39
|
-
return 0 if control_import_settings.zero?
|
40
|
-
start = @i2c_import_gui.lie_start.text.to_i
|
41
|
-
Firmware.new(@api, 'I2C')
|
42
|
-
$pgb = Progress_bar.new("I2C: Importing...")
|
43
|
-
$pgb.show
|
44
|
-
@api.i2c_Generic_Import(@chip_settings.i2c_frequency, @chip_settings.i2c_address_w.to_i(16), start, @chip_settings.i2c_page_size, @chip_settings.i2c_total_size, @filepath, @chip_settings.i2c_write_page_latency/1000.0)
|
45
|
-
rescue Exception => msg
|
46
|
-
logger = Logger.new($logFilePath)
|
47
|
-
logger.error msg
|
48
|
-
Qt::MessageBox.new(Qt::MessageBox::Critical, 'Critical error', 'Error occured while partial import operation. Consult the logs for more details').exec
|
49
|
-
end
|
50
|
-
|
51
|
-
def control_import_settings
|
52
|
-
@chip_settings = I2C.find_by(i2c_chip: @chip.chip_id)
|
53
|
-
if @chip_settings.nil?
|
54
|
-
Qt::MessageBox.new(Qt::MessageBox::Warning, 'Missing I2C setting', 'No settings saved for this chip').exec
|
55
|
-
return 0
|
56
|
-
end
|
57
|
-
if @chip_settings.i2c_total_size.nil?
|
58
|
-
Qt::MessageBox.new(Qt::MessageBox::Warning, 'Missing I2C setting', 'Total size setting missing').exec
|
59
|
-
return 0
|
60
|
-
end
|
61
|
-
if @chip_settings.i2c_page_size.nil?
|
62
|
-
Qt::MessageBox.new(Qt::MessageBox::Warning, 'Missing I2C setting', 'Page size setting missing').exec
|
63
|
-
return 0
|
64
|
-
end
|
65
|
-
if @chip_settings.i2c_write_page_latency.nil?
|
66
|
-
Qt::MessageBox.new(Qt::MessageBox::Warning, 'Missing I2C setting', 'Write page latency setting missing').exec
|
67
|
-
return 0
|
68
|
-
end
|
69
|
-
if @chip_settings.i2c_frequency.nil? || @chip_settings.i2c_address_w.nil?
|
70
|
-
Qt::MessageBox.new(Qt::MessageBox::Warning, 'Missing I2C setting', 'Write base address or frequency settings missing').exec
|
71
|
-
return 0
|
72
|
-
end
|
73
|
-
if @i2c_import_gui.lie_start.text.empty?
|
74
|
-
Qt::MessageBox.new(Qt::MessageBox::Warning, 'Missing start address', 'Please fill the Start address field').exec
|
75
|
-
return 0
|
76
|
-
end
|
77
|
-
return 1
|
78
|
-
end
|
79
|
-
end
|
@@ -1,129 +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
|
-
require_relative '../../gui/gui_i2c_settings'
|
10
|
-
class I2c_settings < Qt::Widget
|
11
|
-
slots 'save_settings()'
|
12
|
-
slots 'bus_scan()'
|
13
|
-
|
14
|
-
def initialize(api, chip)
|
15
|
-
super()
|
16
|
-
@i2c_settings_gui = Ui_I2c_settings.new
|
17
|
-
centerWindow(self)
|
18
|
-
@i2c_settings_gui.setupUi(self)
|
19
|
-
@i2c_settings_gui.lbl_chip.setText(chip.chip_reference)
|
20
|
-
inputRestrict(@i2c_settings_gui.lie_total_size, 0)
|
21
|
-
inputRestrict(@i2c_settings_gui.lie_page_size, 0)
|
22
|
-
inputRestrict(@i2c_settings_gui.lie_write_page_latency, 0)
|
23
|
-
inputRestrict(@i2c_settings_gui.lie_address_r, 3)
|
24
|
-
inputRestrict(@i2c_settings_gui.lie_address_w, 3)
|
25
|
-
@i2c_settings_gui.tbl_bus_scan.resizeColumnsToContents
|
26
|
-
@i2c_settings_gui.tbl_bus_scan.resizeRowsToContents
|
27
|
-
@i2c_settings_gui.tbl_bus_scan.horizontalHeader.stretchLastSection = true
|
28
|
-
@chip_settings = I2C.find_by(i2c_chip: chip.chip_id)
|
29
|
-
@chip = chip
|
30
|
-
@api = api
|
31
|
-
feed_settings_form
|
32
|
-
end
|
33
|
-
|
34
|
-
def save_settings
|
35
|
-
if @chip_settings.nil?
|
36
|
-
create
|
37
|
-
else
|
38
|
-
@chip_settings = I2C.find_by(i2c_chip: @chip.chip_id)
|
39
|
-
update
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
def feed_settings_form
|
44
|
-
unless @chip_settings.nil?
|
45
|
-
@i2c_settings_gui.lie_address_w.setText(@chip_settings.i2c_address_w)
|
46
|
-
@i2c_settings_gui.lie_address_r.setText(@chip_settings.i2c_address_r)
|
47
|
-
@i2c_settings_gui.cbx_frequency.setCurrentIndex(@i2c_settings_gui.cbx_frequency.findText(@chip_settings.i2c_frequency.to_s))
|
48
|
-
@i2c_settings_gui.lie_write_page_latency.setText(@chip_settings.i2c_write_page_latency.to_s)
|
49
|
-
@i2c_settings_gui.lie_page_size.setText(@chip_settings.i2c_page_size.to_s)
|
50
|
-
@i2c_settings_gui.lie_total_size.setText(@chip_settings.i2c_total_size.to_s)
|
51
|
-
end
|
52
|
-
rescue Exception => msg
|
53
|
-
logger = Logger.new($logFilePath)
|
54
|
-
logger.error msg
|
55
|
-
Qt::MessageBox.new(Qt::MessageBox::Critical, 'Critical error', 'Error while loading the form. Consult the log for more details').exec
|
56
|
-
end
|
57
|
-
|
58
|
-
def create
|
59
|
-
@chip_settings = I2C.create(
|
60
|
-
i2c_address_w: @i2c_settings_gui.lie_address_w.text,
|
61
|
-
i2c_address_r: @i2c_settings_gui.lie_address_r.text,
|
62
|
-
i2c_frequency: @i2c_settings_gui.cbx_frequency.currentText,
|
63
|
-
i2c_write_page_latency: @i2c_settings_gui.lie_write_page_latency.text,
|
64
|
-
i2c_page_size: @i2c_settings_gui.lie_page_size.text,
|
65
|
-
i2c_total_size: @i2c_settings_gui.lie_total_size.text,
|
66
|
-
i2c_chip: @chip.chip_id
|
67
|
-
)
|
68
|
-
Qt::MessageBox.new(Qt::MessageBox::Information, 'Succes', 'I2C parameters created successfully').exec
|
69
|
-
rescue Exception => msg
|
70
|
-
logger = Logger.new($logFilePath)
|
71
|
-
logger.error msg
|
72
|
-
Qt::MessageBox.new(Qt::MessageBox::Critical, 'Critical error', 'Error occured when creating the I2C parameters. Consult the log for more details').exec
|
73
|
-
end
|
74
|
-
|
75
|
-
def update
|
76
|
-
if @chip_settings.i2c_address_w != @i2c_settings_gui.lie_address_w.text
|
77
|
-
@chip_settings.update(i2c_address_w: @i2c_settings_gui.lie_address_w.text)
|
78
|
-
end
|
79
|
-
if @chip_settings.i2c_address_r != @i2c_settings_gui.lie_address_r.text
|
80
|
-
@chip_settings.update(i2c_address_r: @i2c_settings_gui.lie_address_r.text)
|
81
|
-
end
|
82
|
-
if @chip_settings.i2c_frequency != @i2c_settings_gui.cbx_frequency.currentText.to_i
|
83
|
-
@chip_settings.update(i2c_frequency: @i2c_settings_gui.cbx_frequency.currentText.to_i)
|
84
|
-
end
|
85
|
-
if @chip_settings.i2c_write_page_latency != @i2c_settings_gui.lie_write_page_latency.text
|
86
|
-
@chip_settings.update(i2c_write_page_latency: @i2c_settings_gui.lie_write_page_latency.text)
|
87
|
-
end
|
88
|
-
if @chip_settings.i2c_page_size != @i2c_settings_gui.lie_page_size.text
|
89
|
-
@chip_settings.update(i2c_page_size: @i2c_settings_gui.lie_page_size.text)
|
90
|
-
end
|
91
|
-
if @chip_settings.i2c_total_size != @i2c_settings_gui.lie_total_size.text
|
92
|
-
@chip_settings.update(i2c_total_size: @i2c_settings_gui.lie_total_size.text)
|
93
|
-
end
|
94
|
-
Qt::MessageBox.new(Qt::MessageBox::Information, 'Succes', 'I2C parameters saved successfully').exec
|
95
|
-
rescue Exception => msg
|
96
|
-
logger = Logger.new($logFilePath)
|
97
|
-
logger.error msg
|
98
|
-
Qt::MessageBox.new(Qt::MessageBox::Critical, 'Critical error', 'Error occured when saving the I2C parameters. Consult the log for more details').exec
|
99
|
-
end
|
100
|
-
|
101
|
-
def bus_scan
|
102
|
-
@i2c_settings_gui.tbl_bus_scan.setRowCount(0)
|
103
|
-
Firmware.new(@api, 'I2C')
|
104
|
-
scan_result = @api.i2c_Scan(0)
|
105
|
-
if scan_result.include?(1)
|
106
|
-
scan_result.each_with_index do |v, i|
|
107
|
-
if v == 1
|
108
|
-
@i2c_settings_gui.tbl_bus_scan.insertRow(@i2c_settings_gui.tbl_bus_scan.rowCount)
|
109
|
-
@i2c_settings_gui.tbl_bus_scan.setItem(@i2c_settings_gui.tbl_bus_scan.rowCount - 1, 0, Qt::TableWidgetItem.new(i.to_s(16).upcase))
|
110
|
-
if i % 2 == 0
|
111
|
-
@i2c_settings_gui.tbl_bus_scan.setItem(@i2c_settings_gui.tbl_bus_scan.rowCount - 1, 1, Qt::TableWidgetItem.new('Write'))
|
112
|
-
else
|
113
|
-
@i2c_settings_gui.tbl_bus_scan.setItem(@i2c_settings_gui.tbl_bus_scan.rowCount - 1, 1, Qt::TableWidgetItem.new('Read'))
|
114
|
-
end
|
115
|
-
end
|
116
|
-
end
|
117
|
-
@i2c_settings_gui.tbl_bus_scan.resizeColumnsToContents
|
118
|
-
@i2c_settings_gui.tbl_bus_scan.resizeRowsToContents
|
119
|
-
@i2c_settings_gui.tbl_bus_scan.horizontalHeader.stretchLastSection = true
|
120
|
-
Qt::MessageBox.new(Qt::MessageBox::Information, "Bus Scan", "Bus scan ended correctly: #{@i2c_settings_gui.tbl_bus_scan.rowCount} address(es) found").exec
|
121
|
-
else
|
122
|
-
Qt::MessageBox.new(Qt::MessageBox::Information, "Bus addresses", "No valid addresses have been returned by the scan").exec
|
123
|
-
end
|
124
|
-
rescue Exception => msg
|
125
|
-
logger = Logger.new($logFilePath)
|
126
|
-
logger.error msg
|
127
|
-
Qt::MessageBox.new(Qt::MessageBox::Critical, "Critical error", "Error occured when scanning I2C. Consult the log for more details").exec
|
128
|
-
end
|
129
|
-
end
|
@@ -1,146 +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
|
-
require_relative '../../gui/gui_generic_export'
|
10
|
-
|
11
|
-
class Parallel_export < Qt::Widget
|
12
|
-
slots 'export()'
|
13
|
-
slots 'select_export_file()'
|
14
|
-
|
15
|
-
def initialize(api, chip)
|
16
|
-
super()
|
17
|
-
@parallel_export_gui = Ui_Generic_export.new
|
18
|
-
centerWindow(self)
|
19
|
-
@parallel_export_gui.setupUi(self)
|
20
|
-
@parallel_export_gui.lbl_chip.setText(chip.chip_reference)
|
21
|
-
inputRestrict(@parallel_export_gui.lie_start, 0)
|
22
|
-
inputRestrict(@parallel_export_gui.lie_stop, 0)
|
23
|
-
@api = api
|
24
|
-
@chip_settings = Parallel.find_by(parallel_chip: chip.chip_id)
|
25
|
-
end
|
26
|
-
|
27
|
-
def select_export_file
|
28
|
-
@filepath = Qt::FileDialog.getSaveFileName(self, tr('Select a file'), '/', tr('Bin file (*.bin)'))
|
29
|
-
unless @filepath.nil?
|
30
|
-
$file = File.open("#{@filepath}", 'w')
|
31
|
-
@parallel_export_gui.btn_export.setEnabled(true)
|
32
|
-
@parallel_export_gui.btn_full_export.setEnabled(true)
|
33
|
-
end
|
34
|
-
rescue Exception => msg
|
35
|
-
logger = Logger.new($logFilePath)
|
36
|
-
logger.error msg
|
37
|
-
Qt::MessageBox.new(Qt::MessageBox::Critical, 'Critical error', 'Error occured while openning the export file. Consult the logs for more details').exec
|
38
|
-
end
|
39
|
-
|
40
|
-
def close_file
|
41
|
-
unless $file.nil?
|
42
|
-
$file.close
|
43
|
-
end
|
44
|
-
rescue Exception => msg
|
45
|
-
logger = Logger.new($logFilePath)
|
46
|
-
logger.error msg
|
47
|
-
Qt::MessageBox.new(Qt::MessageBox::Critical, 'Critical error', 'Error occured while closing the export file. Consult the logs for more details').exec
|
48
|
-
end
|
49
|
-
|
50
|
-
def export
|
51
|
-
if sender.objectName == 'btn_full_export'
|
52
|
-
return 0 if control_export_settings('full').zero?
|
53
|
-
else
|
54
|
-
return 0 if control_export_settings('partial').zero?
|
55
|
-
end
|
56
|
-
Firmware.new(@api, 'PARALLEL')
|
57
|
-
time = Time.new
|
58
|
-
if sender.objectName == 'btn_full_export'
|
59
|
-
if @chip_settings.parallel_word_size.zero?
|
60
|
-
check_SendAndReceivedData(@api.read_Memory_WithoutMultiplexing(0, @chip_settings.parallel_total_size - 1, true, @chip_settings.parallel_read_latency))
|
61
|
-
else
|
62
|
-
check_SendAndReceivedData(@api.read_Memory_WithoutMultiplexing(0, @chip_settings.parallel_total_size - 1, false, @chip_settings.parallel_read_latency))
|
63
|
-
end
|
64
|
-
close_file
|
65
|
-
control_export_result(@chip_settings.parallel_total_size - 1, time)
|
66
|
-
else
|
67
|
-
if @chip_settings.parallel_word_size.zero?
|
68
|
-
check_SendAndReceivedData(@api.read_Memory_WithoutMultiplexing(@parallel_export_gui.lie_start.text.to_i, @parallel_export_gui.lie_stop.text.to_i, true, @chip_settings.parallel_read_latency))
|
69
|
-
else
|
70
|
-
check_SendAndReceivedData(@api.read_Memory_WithoutMultiplexing(@parallel_export_gui.lie_start.text.to_i, @parallel_export_gui.lie_stop.text.to_i, true, @chip_settings.parallel_read_latency))
|
71
|
-
end
|
72
|
-
close_file
|
73
|
-
control_export_result(@parallel_export_gui.lie_stop.text.to_i, time)
|
74
|
-
end
|
75
|
-
@parallel_export_gui.btn_export.setEnabled(false)
|
76
|
-
@parallel_export_gui.btn_full_export.setEnabled(false)
|
77
|
-
rescue Exception => msg
|
78
|
-
logger = Logger.new($logFilePath)
|
79
|
-
logger.error msg
|
80
|
-
Qt::MessageBox.new(Qt::MessageBox::Critical, 'Critical error', 'Error occured while full export operation. Consult the logs for more details').exec
|
81
|
-
end
|
82
|
-
|
83
|
-
def control_export_result(stop, time)
|
84
|
-
time = Time.new - time
|
85
|
-
file_size = File.size("#{@filepath}")
|
86
|
-
# 8 bits test
|
87
|
-
if @chip_settings.parallel_word_size.zero?
|
88
|
-
if (stop - @cw.lie_start.text.to_i + 1) == file_size
|
89
|
-
Qt::MessageBox.new(Qt::MessageBox::Information, "Information", "Dump finished at #{((file_size / time)).round(2)}Bytes/s (#{(file_size)} Bytes in #{time.round(4)} s)").exec
|
90
|
-
else
|
91
|
-
Qt::MessageBox.new(Qt::MessageBox::Critical, "Error", "Dump error: Size does not match").exec
|
92
|
-
end
|
93
|
-
else
|
94
|
-
if (stop - @cw.lie_start.text.to_i + 1) == (file_size / 2)
|
95
|
-
Qt::MessageBox.new(Qt::MessageBox::Information, "Information", "Dump finished at #{((file_size / time)).round(2)}Bytes/s (#{(file_size)} Bytes in #{time.round(4)} s)").exec
|
96
|
-
else
|
97
|
-
Qt::MessageBox.new(Qt::MessageBox::Critical, "Error", "Dump error: File size and dump size does not match").exec
|
98
|
-
end
|
99
|
-
end
|
100
|
-
p "DUMP #{((file_size/time)).round(2)}Bytes/s (#{(file_size)}Bytes in #{time.round(4)} s)"
|
101
|
-
end
|
102
|
-
|
103
|
-
def control_export_settings(type)
|
104
|
-
if @chip_settings.nil?
|
105
|
-
Qt::MessageBox.new(Qt::MessageBox::Warning, 'Missing parallel settings', 'No settings saved for this chip').exec
|
106
|
-
return 0
|
107
|
-
end
|
108
|
-
if @chip_settings.parallel_read_latency.nil? || @chip_settings.parallel_word_size.nil?
|
109
|
-
Qt::MessageBox.new(Qt::MessageBox::Warning, 'Missing parallel settings', 'Read latency or word size settings missing').exec
|
110
|
-
return 0
|
111
|
-
end
|
112
|
-
if type == 'full'
|
113
|
-
if @chip_settings.parallel_total_size.zero? || @chip_settings.parallel_total_size.nil?
|
114
|
-
Qt::MessageBox.new(Qt::MessageBox::Warning, 'Empty field', 'Full size setting missing or equal 0').exec
|
115
|
-
return 0
|
116
|
-
end
|
117
|
-
else
|
118
|
-
if @parallel_export_gui.lie_start.text.empty? || @parallel_export_gui.lie_stop.text.empty?
|
119
|
-
Qt::MessageBox.new(Qt::MessageBox::Warning, 'Empty field', 'Start and stop address must be filled').exec
|
120
|
-
return 0
|
121
|
-
end
|
122
|
-
if @parallel_export_gui.lie_start.text.to_i > @parallel_export_gui.lie_stop.text.to_i
|
123
|
-
Qt::MessageBox.new(Qt::MessageBox::Warning, 'Wrong value', 'Start address must be inforior to the stop address').exec
|
124
|
-
return 0
|
125
|
-
end
|
126
|
-
if @parallel_export_gui.lie_start.text.to_i > (@chip_settings.parallel_total_size - 1) || @parallel_export_gui.lie_stop.text.to_i > (@chip_settings.parallel_total_size - 1)
|
127
|
-
Qt::MessageBox.new(Qt::MessageBox::Warning, 'Wrong value', 'Start and stop address must be inforior to the chip total size').exec
|
128
|
-
return 0
|
129
|
-
end
|
130
|
-
end
|
131
|
-
return 1
|
132
|
-
end
|
133
|
-
|
134
|
-
def check_SendAndReceivedData(value)
|
135
|
-
case value
|
136
|
-
when HardsploitAPI::USB_STATE::PACKET_IS_TOO_LARGE
|
137
|
-
Qt::MessageBox.new(Qt::MessageBox::Critical, "Critical error", "PACKET_IS_TOO_LARGE max: #{HardsploitAPI::USB::USB_TRAME_SIZE}").exec
|
138
|
-
when HardsploitAPI::USB_STATE::ERROR_SEND
|
139
|
-
Qt::MessageBox.new(Qt::MessageBox::Critical, "Critical error", "ERROR_SEND").exec
|
140
|
-
when HardsploitAPI::USB_STATE::BUSY
|
141
|
-
Qt::MessageBox.new(Qt::MessageBox::Warning, "BUSY", "Device busy").exec
|
142
|
-
else
|
143
|
-
return value
|
144
|
-
end
|
145
|
-
end
|
146
|
-
end
|