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
@@ -1,88 +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 Parallel_import < Qt::Widget
|
12
|
-
slots 'import()'
|
13
|
-
slots 'select_import_file()'
|
14
|
-
|
15
|
-
def initialize(api, chip)
|
16
|
-
super()
|
17
|
-
@parallel_import_gui = Ui_Generic_import.new
|
18
|
-
centerWindow(self)
|
19
|
-
@parallel_import_gui.setupUi(self)
|
20
|
-
@parallel_import_gui.lbl_chip.setText(chip.chip_reference)
|
21
|
-
inputRestrict(@parallel_import_gui.lie_start, 0)
|
22
|
-
@api = api
|
23
|
-
@chip_settings = Parallel.find_by(parallel_chip: chip.chip_id)
|
24
|
-
end
|
25
|
-
|
26
|
-
def select_import_file
|
27
|
-
@filepath = Qt::FileDialog.getOpenFileName(self, tr('Select a file'), '/', tr('Bin file (*.bin)'))
|
28
|
-
unless @filepath.nil?
|
29
|
-
$file = File.open("#{@filepath}", 'w')
|
30
|
-
@parallel_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 close_file
|
39
|
-
unless $file.nil?
|
40
|
-
$file.close
|
41
|
-
end
|
42
|
-
rescue Exception => msg
|
43
|
-
logger = Logger.new($logFilePath)
|
44
|
-
logger.error msg
|
45
|
-
Qt::MessageBox.new(Qt::MessageBox::Critical, 'Critical error', 'Error occured while closing the export file. Consult the logs for more details').exec
|
46
|
-
end
|
47
|
-
|
48
|
-
def import
|
49
|
-
return 0 if control_import_settings.zero?
|
50
|
-
start = @parallel_import_gui.lie_start.text.to_i
|
51
|
-
Firmware.new(@api, 'PARALLEL')
|
52
|
-
time = Time.new
|
53
|
-
# API COMMAND GOES HERE
|
54
|
-
rescue Exception => msg
|
55
|
-
logger = Logger.new($logFilePath)
|
56
|
-
logger.error msg
|
57
|
-
Qt::MessageBox.new(Qt::MessageBox::Critical, 'Critical error', 'Error occured while partial import operation. Consult the logs for more details').exec
|
58
|
-
end
|
59
|
-
|
60
|
-
def control_import_settings
|
61
|
-
file_size = File.size("#{@filepath}")
|
62
|
-
if @chip_settings.nil?
|
63
|
-
Qt::MessageBox.new(Qt::MessageBox::Warning, 'Missing parallel settings', 'No settings saved for this chip').exec
|
64
|
-
return 0
|
65
|
-
end
|
66
|
-
if @chip_settings.parallel_total_size.nil? || @chip_settings.parallel_word_size.nil?
|
67
|
-
Qt::MessageBox.new(Qt::MessageBox::Warning, 'Missing parallel settings', 'Total size or word size settings missing').exec
|
68
|
-
return 0
|
69
|
-
end
|
70
|
-
if @chip_settings.parallel_page_size.nil? || @chip_settings.parallel_write_latency.nil?
|
71
|
-
Qt::MessageBox.new(Qt::MessageBox::Warning, 'Missing parallel settings', 'Page size or write latency settings missing').exec
|
72
|
-
return 0
|
73
|
-
end
|
74
|
-
if @parallel_import_gui.lie_start.text.empty?
|
75
|
-
Qt::MessageBox.new(Qt::MessageBox::Warning, 'Missing start address', 'Please fill the start address field').exec
|
76
|
-
return 0
|
77
|
-
end
|
78
|
-
if file_size > @chip_settings.parallel_total_size
|
79
|
-
Qt::MessageBox.new(Qt::MessageBox::Warning, 'Incorrect file size', 'The file size is superior to the chip capacity').exec
|
80
|
-
return 0
|
81
|
-
end
|
82
|
-
if file_size > (@chip_settings.parallel_total_size - @parallel_import_gui.lie_start)
|
83
|
-
Qt::MessageBox.new(Qt::MessageBox::Warning, 'Incorrect file size', 'Starting at this address, the file size is superior to the chip capacity').exec
|
84
|
-
return 0
|
85
|
-
end
|
86
|
-
return 1
|
87
|
-
end
|
88
|
-
end
|
@@ -1,102 +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 '../../gui/gui_parallel_settings'
|
9
|
-
class Parallel_settings < Qt::Widget
|
10
|
-
slots 'save_settings()'
|
11
|
-
|
12
|
-
def initialize(chip)
|
13
|
-
super()
|
14
|
-
@parallel_settings_gui = Ui_Parallel_settings.new
|
15
|
-
centerWindow(self)
|
16
|
-
@parallel_settings_gui.setupUi(self)
|
17
|
-
@parallel_settings_gui.lbl_chip.setText(chip.chip_reference)
|
18
|
-
inputRestrict(@parallel_settings_gui.lie_total_size, 0)
|
19
|
-
inputRestrict(@parallel_settings_gui.lie_write_latency, 0)
|
20
|
-
inputRestrict(@parallel_settings_gui.lie_read_latency, 0)
|
21
|
-
inputRestrict(@parallel_settings_gui.lie_page_size, 0)
|
22
|
-
@chip_settings = Parallel.find_by(parallel_chip: chip.chip_id)
|
23
|
-
@chip = chip
|
24
|
-
feed_settings_form
|
25
|
-
end
|
26
|
-
|
27
|
-
def save_settings
|
28
|
-
if @chip_settings.nil?
|
29
|
-
create
|
30
|
-
else
|
31
|
-
@chip_settings = Parallel.find_by(parallel_chip: @chip.chip_id)
|
32
|
-
update
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
def feed_settings_form
|
37
|
-
unless @chip_settings.nil?
|
38
|
-
@parallel_settings_gui.lie_read_latency.setText(@chip_settings.parallel_read_latency.to_s)
|
39
|
-
@parallel_settings_gui.lie_write_latency.setText(@chip_settings.parallel_write_latency.to_s)
|
40
|
-
@parallel_settings_gui.lie_page_size.setText(@chip_settings.parallel_page_size.to_s)
|
41
|
-
@parallel_settings_gui.lie_total_size.setText(@chip_settings.parallel_total_size.to_s)
|
42
|
-
if @chip_settings.parallel_word_size.zero?
|
43
|
-
@parallel_settings_gui.rbn_8b.setChecked(true)
|
44
|
-
else
|
45
|
-
@parallel_settings_gui.rbn_16b.setChecked(true)
|
46
|
-
end
|
47
|
-
end
|
48
|
-
rescue Exception => msg
|
49
|
-
logger = Logger.new($logFilePath)
|
50
|
-
logger.error msg
|
51
|
-
Qt::MessageBox.new(Qt::MessageBox::Critical, 'Critical error', 'Error while loading the form. Consult the log for more details').exec
|
52
|
-
end
|
53
|
-
|
54
|
-
def create
|
55
|
-
if @parallel_settings_gui.rbn_8b.isChecked
|
56
|
-
word_size = 0
|
57
|
-
else
|
58
|
-
word_size = 1
|
59
|
-
end
|
60
|
-
@chip_settings = Parallel.create(
|
61
|
-
parallel_word_size: word_size,
|
62
|
-
parallel_write_latency: @parallel_settings_gui.lie_write_latency,
|
63
|
-
parallel_read_latency: @parallel_settings_gui.lie_read_latency.text,
|
64
|
-
parallel_page_size: @parallel_settings_gui.lie_page_size.text,
|
65
|
-
parallel_total_size: @parallel_settings_gui.lie_total_size.text,
|
66
|
-
parallel_chip: @chip.chip_id
|
67
|
-
)
|
68
|
-
Qt::MessageBox.new(Qt::MessageBox::Information, 'Succes', 'Parallel 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 saving the parallel parameters. Consult the log for more details').exec
|
73
|
-
end
|
74
|
-
|
75
|
-
def update
|
76
|
-
if @parallel_settings_gui.rbn_8b.isChecked
|
77
|
-
word_size = 0
|
78
|
-
else
|
79
|
-
word_size = 1
|
80
|
-
end
|
81
|
-
if @chip_settings.parallel_page_size != @parallel_settings_gui.lie_page_size
|
82
|
-
@chip_settings.update(parallel_page_size: @parallel_settings_gui.lie_page_size.text)
|
83
|
-
end
|
84
|
-
if @chip_settings.parallel_total_size != @parallel_settings_gui.lie_total_size
|
85
|
-
@chip_settings.update(parallel_total_size: @parallel_settings_gui.lie_total_size.text)
|
86
|
-
end
|
87
|
-
if @chip_settings.parallel_read_latency != @parallel_settings_gui.lie_read_latency
|
88
|
-
@chip_settings.update(parallel_read_latency: @parallel_settings_gui.lie_read_latency.text)
|
89
|
-
end
|
90
|
-
if @chip_settings.parallel_write_latency != @parallel_settings_gui.lie_write_latency
|
91
|
-
@chip_settings.update(parallel_write_latency: @parallel_settings_gui.lie_write_latency.text)
|
92
|
-
end
|
93
|
-
if @chip_settings.parallel_word_size != word_size
|
94
|
-
@chip_settings.update(parallel_word_size: word_size)
|
95
|
-
end
|
96
|
-
Qt::MessageBox.new(Qt::MessageBox::Information, 'Succes', 'Parallel parameters saved successfully').exec
|
97
|
-
rescue Exception => msg
|
98
|
-
logger = Logger.new($logFilePath)
|
99
|
-
logger.error msg
|
100
|
-
Qt::MessageBox.new(Qt::MessageBox::Critical, 'Critical error', 'Error occured when saving the parallel parameters. Consult the log for more details').exec
|
101
|
-
end
|
102
|
-
end
|
data/lib/class/SPI/Spi_export.rb
DELETED
@@ -1,138 +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 Spi_export < Qt::Widget
|
12
|
-
slots 'export()'
|
13
|
-
slots 'select_export_file()'
|
14
|
-
|
15
|
-
def initialize(api, chip)
|
16
|
-
super()
|
17
|
-
@spi_export_gui = Ui_Generic_export.new
|
18
|
-
centerWindow(self)
|
19
|
-
@spi_export_gui.setupUi(self)
|
20
|
-
@spi_export_gui.lbl_chip.setText(chip.chip_reference)
|
21
|
-
inputRestrict(@spi_export_gui.lie_start, 0)
|
22
|
-
inputRestrict(@spi_export_gui.lie_stop, 0)
|
23
|
-
@api = api
|
24
|
-
@chip_settings = Spi.find_by(spi_chip: chip.chip_id)
|
25
|
-
@speeds = {
|
26
|
-
'25.00' => 3,
|
27
|
-
'18.75' => 4,
|
28
|
-
'15.00' => 5,
|
29
|
-
'12.50' => 6,
|
30
|
-
'10.71' => 7,
|
31
|
-
'9.38' => 8,
|
32
|
-
'7.50' => 10,
|
33
|
-
'5.00' => 15,
|
34
|
-
'3.95' => 19,
|
35
|
-
'3.00' => 25,
|
36
|
-
'2.03' => 37,
|
37
|
-
'1.00' => 75,
|
38
|
-
'0.50' => 150,
|
39
|
-
'0.29' => 255
|
40
|
-
}
|
41
|
-
end
|
42
|
-
|
43
|
-
def select_export_file
|
44
|
-
@filepath = Qt::FileDialog.getSaveFileName(self, tr('Select a file'), '/', tr('Bin file (*.bin)'))
|
45
|
-
unless @filepath.nil?
|
46
|
-
$file = File.open("#{@filepath}", 'w')
|
47
|
-
@spi_export_gui.btn_export.setEnabled(true)
|
48
|
-
@spi_export_gui.btn_full_export.setEnabled(true)
|
49
|
-
end
|
50
|
-
rescue Exception => msg
|
51
|
-
logger = Logger.new($logFilePath)
|
52
|
-
logger.error msg
|
53
|
-
Qt::MessageBox.new(Qt::MessageBox::Critical, 'Critical error', 'Error occured while openning the export file. Consult the logs for more details').exec
|
54
|
-
end
|
55
|
-
|
56
|
-
def close_file
|
57
|
-
unless $file.nil?
|
58
|
-
$file.close
|
59
|
-
end
|
60
|
-
rescue Exception => msg
|
61
|
-
logger = Logger.new($logFilePath)
|
62
|
-
logger.error msg
|
63
|
-
Qt::MessageBox.new(Qt::MessageBox::Critical, 'Critical error', 'Error occured while closing the export file. Consult the logs for more details').exec
|
64
|
-
end
|
65
|
-
|
66
|
-
def export
|
67
|
-
if sender.objectName == 'btn_full_export'
|
68
|
-
return 0 if control_export_settings('full').zero?
|
69
|
-
else
|
70
|
-
return 0 if control_export_settings('partial').zero?
|
71
|
-
end
|
72
|
-
Firmware.new(@api, 'SPI')
|
73
|
-
$pgb = Progress_bar.new("SPI: Exporting...")
|
74
|
-
$pgb.show
|
75
|
-
if sender.objectName == 'btn_full_export'
|
76
|
-
@api.spi_Generic_Dump(@chip_settings.spi_mode, @speeds[@chip_settings.spi_frequency], @chip_settings.spi_command_read, 0, @chip_settings.spi_total_size - 1, @chip_settings.spi_total_size.to_i)
|
77
|
-
close_file
|
78
|
-
control_export_result('full', @chip_settings.spi_total_size - 1)
|
79
|
-
else
|
80
|
-
@api.spi_Generic_Dump(@chip_settings.spi_mode, @speeds[@chip_settings.spi_frequency], @chip_settings.spi_command_read, @spi_export_gui.lie_start.text.to_i, @spi_export_gui.lie_stop.text.to_i, @chip_settings.spi_total_size.to_i)
|
81
|
-
close_file
|
82
|
-
control_export_result('partial', @spi_export_gui.lie_stop.text.to_i)
|
83
|
-
end
|
84
|
-
@spi_export_gui.btn_export.setEnabled(false)
|
85
|
-
@spi_export_gui.btn_full_export.setEnabled(false)
|
86
|
-
rescue Exception => msg
|
87
|
-
logger = Logger.new($logFilePath)
|
88
|
-
logger.error msg
|
89
|
-
Qt::MessageBox.new(Qt::MessageBox::Critical, 'Critical error', 'Error occured while full export operation. Consult the logs for more details').exec
|
90
|
-
end
|
91
|
-
|
92
|
-
def control_export_result(type, stop)
|
93
|
-
if type == 'partial'
|
94
|
-
toCompare = ((stop - @spi_export_gui.lie_start.text.to_i) + 1)
|
95
|
-
else
|
96
|
-
toCompare = @chip_settings.spi_total_size
|
97
|
-
end
|
98
|
-
file_size = File.size(@filepath)
|
99
|
-
if toCompare != file_size
|
100
|
-
Qt::MessageBox.new(Qt::MessageBox::Critical, 'Error', 'Dump error: Size does not match').exec
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
|
-
def control_export_settings(type)
|
105
|
-
if @chip_settings.nil?
|
106
|
-
Qt::MessageBox.new(Qt::MessageBox::Warning, 'Missing SPI settings', 'No settings saved for this chip').exec
|
107
|
-
return 0
|
108
|
-
end
|
109
|
-
if @chip_settings.spi_command_read.nil? || @chip_settings.spi_frequency.nil?
|
110
|
-
Qt::MessageBox.new(Qt::MessageBox::Warning, 'Missing SPI settings', 'Read command or frequency settings missing').exec
|
111
|
-
return 0
|
112
|
-
end
|
113
|
-
if @chip_settings.spi_mode.nil?
|
114
|
-
Qt::MessageBox.new(Qt::MessageBox::Warning, 'Missing SPI setting', 'Mode setting missing').exec
|
115
|
-
return 0
|
116
|
-
end
|
117
|
-
if type == 'full'
|
118
|
-
if @chip_settings.spi_total_size.zero? || @chip_settings.spi_total_size.nil?
|
119
|
-
Qt::MessageBox.new(Qt::MessageBox::Warning, 'Empty field', 'Full size setting missing or equal 0').exec
|
120
|
-
return 0
|
121
|
-
end
|
122
|
-
else
|
123
|
-
if @spi_export_gui.lie_start.text.empty? || @spi_export_gui.lie_stop.text.empty?
|
124
|
-
Qt::MessageBox.new(Qt::MessageBox::Warning, 'Empty field', 'Start and stop address must be filled').exec
|
125
|
-
return 0
|
126
|
-
end
|
127
|
-
if @spi_export_gui.lie_start.text.to_i > @spi_export_gui.lie_stop.text.to_i
|
128
|
-
Qt::MessageBox.new(Qt::MessageBox::Warning, 'Wrong value', 'Start address must be inforior to the stop address').exec
|
129
|
-
return 0
|
130
|
-
end
|
131
|
-
if @spi_export_gui.lie_start.text.to_i > (@chip_settings.spi_total_size - 1) || @spi_export_gui.lie_stop.text.to_i > (@chip_settings.spi_total_size - 1)
|
132
|
-
Qt::MessageBox.new(Qt::MessageBox::Warning, 'Wrong value', 'Start and stop address must be inforior to the chip total size').exec
|
133
|
-
return 0
|
134
|
-
end
|
135
|
-
end
|
136
|
-
return 1
|
137
|
-
end
|
138
|
-
end
|
data/lib/class/SPI/Spi_import.rb
DELETED
@@ -1,113 +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 Spi_import < Qt::Widget
|
12
|
-
slots 'import()'
|
13
|
-
slots 'select_import_file()'
|
14
|
-
|
15
|
-
def initialize(api, chip)
|
16
|
-
super()
|
17
|
-
@spi_import_gui = Ui_Generic_import.new
|
18
|
-
centerWindow(self)
|
19
|
-
@spi_import_gui.setupUi(self)
|
20
|
-
@spi_import_gui.lbl_chip.setText(chip.chip_reference)
|
21
|
-
inputRestrict(@spi_import_gui.lie_start, 0)
|
22
|
-
@api = api
|
23
|
-
@chip = chip
|
24
|
-
@chip_settings = Spi.find_by(spi_chip: chip.chip_id)
|
25
|
-
@speeds = {
|
26
|
-
'25.00' => 3,
|
27
|
-
'18.75' => 4,
|
28
|
-
'15.00' => 5,
|
29
|
-
'12.50' => 6,
|
30
|
-
'10.71' => 7,
|
31
|
-
'9.38' => 8,
|
32
|
-
'7.50' => 10,
|
33
|
-
'5.00' => 15,
|
34
|
-
'3.95' => 19,
|
35
|
-
'3.00' => 25,
|
36
|
-
'2.03' => 37,
|
37
|
-
'1.00' => 75,
|
38
|
-
'0.50' => 150,
|
39
|
-
'0.29' => 255
|
40
|
-
}
|
41
|
-
end
|
42
|
-
|
43
|
-
def select_import_file
|
44
|
-
@filepath = Qt::FileDialog.getOpenFileName(self, tr('Select a file'), '/', tr('Bin file (*.bin)'))
|
45
|
-
@spi_import_gui.btn_import.setEnabled(true) unless @filepath.nil?
|
46
|
-
rescue Exception => msg
|
47
|
-
logger = Logger.new($logFilePath)
|
48
|
-
logger.error msg
|
49
|
-
Qt::MessageBox.new(Qt::MessageBox::Critical, 'Critical error', 'Error occured while openning the export file. Consult the logs for more details').exec
|
50
|
-
end
|
51
|
-
|
52
|
-
def import
|
53
|
-
return 0 if control_import_settings.zero?
|
54
|
-
start = @spi_import_gui.lie_start.text.to_i
|
55
|
-
Firmware.new(@api, 'SPI')
|
56
|
-
$pgb = Progress_bar.new("SPI: Importing...")
|
57
|
-
$pgb.show
|
58
|
-
if @chip_settings.spi_is_flash.zero?
|
59
|
-
flash = false
|
60
|
-
else
|
61
|
-
flash = true
|
62
|
-
end
|
63
|
-
@api.spi_Generic_Import(@chip_settings.spi_mode, @speeds[@chip_settings.spi_frequency], start, @chip_settings.spi_page_size, @chip_settings.spi_total_size, @filepath, @chip_settings.spi_command_write, @chip_settings.spi_write_page_latency/1000.0, @chip_settings.spi_command_write_enable, @chip_settings.spi_command_erase, @chip_settings.spi_erase_time, flash)
|
64
|
-
rescue Exception => msg
|
65
|
-
logger = Logger.new($logFilePath)
|
66
|
-
logger.error msg
|
67
|
-
Qt::MessageBox.new(Qt::MessageBox::Critical, 'Critical error', 'Error occured while partial import operation. Consult the logs for more details').exec
|
68
|
-
end
|
69
|
-
|
70
|
-
def control_import_settings
|
71
|
-
@chip_settings = Spi.find_by(spi_chip: @chip.chip_id)
|
72
|
-
if @chip_settings.nil?
|
73
|
-
Qt::MessageBox.new(Qt::MessageBox::Warning, 'Missing SPI settings', 'No settings saved for this chip').exec
|
74
|
-
return 0
|
75
|
-
end
|
76
|
-
if @chip_settings.spi_total_size.nil? || @chip_settings.spi_page_size.nil?
|
77
|
-
Qt::MessageBox.new(Qt::MessageBox::Warning, 'Missing SPI settings', 'Total size or page size missing').exec
|
78
|
-
return 0
|
79
|
-
end
|
80
|
-
if @chip_settings.spi_command_read.nil? || @chip_settings.spi_frequency.nil?
|
81
|
-
Qt::MessageBox.new(Qt::MessageBox::Warning, 'Missing SPI settings', 'Read command or frequency missing').exec
|
82
|
-
return 0
|
83
|
-
end
|
84
|
-
if @chip_settings.spi_command_write.nil?
|
85
|
-
Qt::MessageBox.new(Qt::MessageBox::Warning, 'Missing SPI settings', 'Write command missing').exec
|
86
|
-
return 0
|
87
|
-
end
|
88
|
-
if @chip_settings.spi_write_page_latency.nil?
|
89
|
-
Qt::MessageBox.new(Qt::MessageBox::Warning, 'Missing SPI setting', 'SPI write page latency missing').exec
|
90
|
-
return 0
|
91
|
-
end
|
92
|
-
if @chip_settings.spi_is_flash.nil?
|
93
|
-
Qt::MessageBox.new(Qt::MessageBox::Warning, 'Missing SPI setting', 'SPI flash nature missing').exec
|
94
|
-
return 0
|
95
|
-
else
|
96
|
-
if @chip_settings.spi_is_flash == 1
|
97
|
-
if @chip_settings.spi_erase_time.nil? || @chip_settings.spi_command_erase.nil?
|
98
|
-
Qt::MessageBox.new(Qt::MessageBox::Warning, 'Missing SPI setting', 'SPI erase time or command missing').exec
|
99
|
-
return 0
|
100
|
-
end
|
101
|
-
end
|
102
|
-
end
|
103
|
-
if @chip_settings.spi_mode.nil?
|
104
|
-
Qt::MessageBox.new(Qt::MessageBox::Warning, 'Missing SPI setting', 'Mode missing').exec
|
105
|
-
return 0
|
106
|
-
end
|
107
|
-
if @spi_import_gui.lie_start.text.empty?
|
108
|
-
Qt::MessageBox.new(Qt::MessageBox::Warning, 'Missing start address', 'Please fill the Start address field').exec
|
109
|
-
return 0
|
110
|
-
end
|
111
|
-
return 1
|
112
|
-
end
|
113
|
-
end
|
@@ -1,134 +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 '../../gui/gui_spi_settings'
|
9
|
-
class Spi_settings < Qt::Widget
|
10
|
-
slots 'save_settings()'
|
11
|
-
|
12
|
-
def initialize(chip)
|
13
|
-
super()
|
14
|
-
@spi_settings_gui = Ui_Spi_settings.new
|
15
|
-
centerWindow(self)
|
16
|
-
@spi_settings_gui.setupUi(self)
|
17
|
-
@spi_settings_gui.lbl_chip.setText(chip.chip_reference)
|
18
|
-
inputRestrict(@spi_settings_gui.lie_total_size, 0)
|
19
|
-
inputRestrict(@spi_settings_gui.lie_page_size, 0)
|
20
|
-
inputRestrict(@spi_settings_gui.lie_write_page_latency, 0)
|
21
|
-
inputRestrict(@spi_settings_gui.lie_cmd_read, 0)
|
22
|
-
inputRestrict(@spi_settings_gui.lie_cmd_write, 0)
|
23
|
-
inputRestrict(@spi_settings_gui.lie_cmd_write_enable, 0)
|
24
|
-
inputRestrict(@spi_settings_gui.lie_cmd_erase, 0)
|
25
|
-
inputRestrict(@spi_settings_gui.lie_erase_time, 0)
|
26
|
-
@chip_settings = Spi.find_by(spi_chip: chip.chip_id)
|
27
|
-
@chip = chip
|
28
|
-
feed_settings_form
|
29
|
-
end
|
30
|
-
|
31
|
-
def save_settings
|
32
|
-
if @chip_settings.nil?
|
33
|
-
create
|
34
|
-
else
|
35
|
-
@chip_settings = Spi.find_by(spi_chip: @chip.chip_id)
|
36
|
-
update
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
def feed_settings_form
|
41
|
-
unless @chip_settings.nil?
|
42
|
-
@spi_settings_gui.cbx_mode.setCurrentIndex(@spi_settings_gui.cbx_mode.findText(@chip_settings.spi_mode.to_s))
|
43
|
-
@spi_settings_gui.cbx_frequency.setCurrentIndex(@spi_settings_gui.cbx_frequency.findText(@chip_settings.spi_frequency))
|
44
|
-
@spi_settings_gui.lie_cmd_read.setText(@chip_settings.spi_command_read.to_s)
|
45
|
-
@spi_settings_gui.lie_cmd_write.setText(@chip_settings.spi_command_write.to_s)
|
46
|
-
@spi_settings_gui.lie_write_page_latency.setText(@chip_settings.spi_write_page_latency.to_s)
|
47
|
-
@spi_settings_gui.lie_cmd_write_enable.setText(@chip_settings.spi_command_write_enable.to_s)
|
48
|
-
@spi_settings_gui.lie_cmd_erase.setText(@chip_settings.spi_command_erase.to_s)
|
49
|
-
@spi_settings_gui.lie_erase_time.setText(@chip_settings.spi_erase_time.to_s)
|
50
|
-
@spi_settings_gui.lie_page_size.setText(@chip_settings.spi_page_size.to_s)
|
51
|
-
@spi_settings_gui.lie_total_size.setText(@chip_settings.spi_total_size.to_s)
|
52
|
-
if @chip_settings.spi_is_flash.zero?
|
53
|
-
@spi_settings_gui.rbn_no.setChecked(true)
|
54
|
-
else
|
55
|
-
@spi_settings_gui.rbn_yes.setChecked(true)
|
56
|
-
end
|
57
|
-
end
|
58
|
-
rescue Exception => msg
|
59
|
-
logger = Logger.new($logFilePath)
|
60
|
-
logger.error msg
|
61
|
-
Qt::MessageBox.new(Qt::MessageBox::Critical, 'Critical error', 'Error while loading the form. Consult the log for more details').exec
|
62
|
-
end
|
63
|
-
|
64
|
-
def is_flash?
|
65
|
-
if @spi_settings_gui.rbn_no.isChecked
|
66
|
-
return 0
|
67
|
-
else
|
68
|
-
return 1
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
def create
|
73
|
-
@chip_settings = Spi.create(
|
74
|
-
spi_mode: @spi_settings_gui.cbx_mode.currentText,
|
75
|
-
spi_frequency: @spi_settings_gui.cbx_frequency.currentText,
|
76
|
-
spi_write_page_latency: @spi_settings_gui.lie_write_page_latency.text,
|
77
|
-
spi_command_read: @spi_settings_gui.lie_cmd_read.text,
|
78
|
-
spi_command_write: @spi_settings_gui.lie_cmd_write.text,
|
79
|
-
spi_command_write_enable: @spi_settings_gui.lie_cmd_write_enable.text,
|
80
|
-
spi_command_erase: @spi_settings_gui.lie_cmd_erase.text,
|
81
|
-
spi_erase_time: @spi_settings_gui.lie_erase_time.text,
|
82
|
-
spi_is_flash: is_flash?,
|
83
|
-
spi_page_size: @spi_settings_gui.lie_page_size.text,
|
84
|
-
spi_total_size: @spi_settings_gui.lie_total_size.text,
|
85
|
-
spi_chip: @chip.chip_id
|
86
|
-
)
|
87
|
-
Qt::MessageBox.new(Qt::MessageBox::Information, 'Succes', 'SPI parameters created successfully').exec
|
88
|
-
rescue Exception => msg
|
89
|
-
logger = Logger.new($logFilePath)
|
90
|
-
logger.error msg
|
91
|
-
Qt::MessageBox.new(Qt::MessageBox::Critical, 'Critical error', 'Error occured when saving the SPI parameters. Consult the log for more details').exec
|
92
|
-
end
|
93
|
-
|
94
|
-
def update
|
95
|
-
if @chip_settings.spi_mode != @spi_settings_gui.cbx_mode.currentText.to_i
|
96
|
-
@chip_settings.update(spi_mode: @spi_settings_gui.cbx_mode.currentText.to_i)
|
97
|
-
end
|
98
|
-
if @chip_settings.spi_frequency != @spi_settings_gui.cbx_frequency.currentText
|
99
|
-
@chip_settings.update(spi_frequency: @spi_settings_gui.cbx_frequency.currentText)
|
100
|
-
end
|
101
|
-
if @chip_settings.spi_write_page_latency != @spi_settings_gui.lie_write_page_latency.text
|
102
|
-
@chip_settings.update(spi_write_page_latency: @spi_settings_gui.lie_write_page_latency.text)
|
103
|
-
end
|
104
|
-
if @chip_settings.spi_command_read != @spi_settings_gui.lie_cmd_read.text
|
105
|
-
@chip_settings.update(spi_command_read: @spi_settings_gui.lie_cmd_read.text)
|
106
|
-
end
|
107
|
-
if @chip_settings.spi_command_write != @spi_settings_gui.lie_cmd_write.text
|
108
|
-
@chip_settings.update(spi_command_write: @spi_settings_gui.lie_cmd_write.text)
|
109
|
-
end
|
110
|
-
if @chip_settings.spi_command_write_enable != @spi_settings_gui.lie_cmd_write_enable.text
|
111
|
-
@chip_settings.update(spi_command_write_enable: @spi_settings_gui.lie_cmd_write_enable.text)
|
112
|
-
end
|
113
|
-
if @chip_settings.spi_command_erase != @spi_settings_gui.lie_cmd_erase.text
|
114
|
-
@chip_settings.update(spi_command_erase: @spi_settings_gui.lie_cmd_erase.text)
|
115
|
-
end
|
116
|
-
if @chip_settings.spi_erase_time != @spi_settings_gui.lie_erase_time.text
|
117
|
-
@chip_settings.update(spi_erase_time: @spi_settings_gui.lie_erase_time.text)
|
118
|
-
end
|
119
|
-
if @chip_settings.spi_page_size != @spi_settings_gui.lie_page_size.text
|
120
|
-
@chip_settings.update(spi_page_size: @spi_settings_gui.lie_page_size.text)
|
121
|
-
end
|
122
|
-
if @chip_settings.spi_total_size != @spi_settings_gui.lie_total_size.text
|
123
|
-
@chip_settings.update(spi_total_size: @spi_settings_gui.lie_total_size.text)
|
124
|
-
end
|
125
|
-
if @chip_settings.spi_is_flash != is_flash?
|
126
|
-
@chip_settings.update(spi_is_flash: is_flash?)
|
127
|
-
end
|
128
|
-
Qt::MessageBox.new(Qt::MessageBox::Information, 'Succes', 'SPI parameters saved successfully').exec
|
129
|
-
rescue Exception => msg
|
130
|
-
logger = Logger.new($logFilePath)
|
131
|
-
logger.error msg
|
132
|
-
Qt::MessageBox.new(Qt::MessageBox::Critical, 'Critical error', 'Error occured when saving the SPI parameters. Consult the log for more details').exec
|
133
|
-
end
|
134
|
-
end
|