hardsploit_gui 2.2 → 2.3

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.
Files changed (166) hide show
  1. checksums.yaml +4 -4
  2. data/bin/hardsploit_gui +2 -2
  3. data/lib/{Firmware → Firmwares}/FPGA/I2C/I2C_INTERACT/HARDSPLOIT_FIRMWARE_FPGA_I2C_INTERACT.rpd +0 -0
  4. 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
  5. data/lib/Firmwares/FPGA/SPI/SPI_INTERACT/HARDSPLOIT_FIRMWARE_FPGA_SPI_INTERACT.rpd +0 -0
  6. 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
  7. data/lib/Firmwares/FPGA/SWD/SWD_INTERACT/HARDSPLOIT_FIRMWARE_FPGA_SWD_INTERACT.rpd +0 -0
  8. data/lib/{Firmware → Firmwares}/FPGA/TEST/TEST_INTERACT/HARDSPLOIT_FIRMWARE_FPGA_TEST_INTERACT.rpd +0 -0
  9. data/lib/Firmwares/FPGA/UART/UART_INTERACT/HARDSPLOIT_FIRMWARE_FPGA_UART_INTERACT.rpd +0 -0
  10. data/lib/{Firmware → Firmwares}/FPGA/VersionFPGA.rb +1 -1
  11. data/lib/{Firmware → Firmwares}/UC/HARDSPLOIT_FIRMWARE_UC.bin +0 -0
  12. data/lib/{Firmware → Firmwares}/UC/VersionUC.rb +1 -1
  13. data/lib/HardsploitAPI/Core/HardsploitAPI.rb +210 -0
  14. data/lib/HardsploitAPI/Core/HardsploitAPI_CONSTANT.rb +150 -0
  15. data/lib/HardsploitAPI/Core/HardsploitAPI_ERROR.rb +109 -0
  16. data/lib/HardsploitAPI/Core/HardsploitAPI_FIRMWARE.rb +305 -0
  17. data/lib/HardsploitAPI/{HardsploitAPI_PROGRESS.rb → Core/HardsploitAPI_PROGRESS.rb} +0 -0
  18. data/lib/HardsploitAPI/Core/HardsploitAPI_USB_COMMUNICATION.rb +166 -0
  19. data/lib/HardsploitAPI/Modules/I2C/HardsploitAPI_I2C.rb +356 -0
  20. data/lib/HardsploitAPI/{HardsploitAPI_NO_MUX_PARALLELE_MEMORY.rb → Modules/NO_MUX_PARALLEL_MEMORY/HardsploitAPI_NO_MUX_PARALLEL_MEMORY.rb} +26 -49
  21. data/lib/HardsploitAPI/Modules/NRF24L01/HardsploitAPI_NRF24L01.rb +306 -0
  22. data/lib/HardsploitAPI/Modules/SPI/HardsploitAPI_SPI.rb +340 -0
  23. data/lib/HardsploitAPI/Modules/SPI_SNIFFER/HardsploitAPI_SPI_SNIFFER.rb +83 -0
  24. data/lib/HardsploitAPI/Modules/SWD/HardsploitAPI_SWD.rb +367 -0
  25. data/lib/HardsploitAPI/Modules/SWD/HardsploitAPI_SWD_DEBUG.rb +89 -0
  26. data/lib/HardsploitAPI/Modules/SWD/HardsploitAPI_SWD_MEM_AP.rb +61 -0
  27. data/lib/HardsploitAPI/{SWD → Modules/SWD}/HardsploitAPI_SWD_STM32.rb +32 -15
  28. data/lib/HardsploitAPI/{HardsploitAPI_TEST_INTERACT.rb → Modules/TEST/HardsploitAPI_TEST_INTERACT.rb} +1 -1
  29. data/lib/HardsploitAPI/Modules/UART/HardsploitAPI_UART.rb +196 -0
  30. data/lib/Hardsploit_gui.rb +96 -0
  31. data/lib/class/Chip_editor.rb +186 -330
  32. data/lib/class/Chip_management.rb +496 -0
  33. data/lib/class/Command_editor.rb +130 -182
  34. data/lib/class/Command_table.rb +16 -22
  35. data/lib/class/Console.rb +0 -2
  36. data/lib/class/ErrorMsg.rb +312 -0
  37. data/lib/class/Export.rb +140 -0
  38. data/lib/class/Export_manager.rb +43 -43
  39. data/lib/class/Firmware.rb +52 -11
  40. data/lib/class/Generic_commands.rb +180 -190
  41. data/lib/class/Import.rb +193 -0
  42. data/lib/class/Progress_bar.rb +1 -0
  43. data/lib/class/Signal_mapper.rb +120 -0
  44. data/lib/class/Wire_helper.rb +132 -148
  45. data/lib/class/{I2C → i2c}/I2c_command.rb +16 -13
  46. data/lib/class/i2c/I2c_export.rb +95 -0
  47. data/lib/class/i2c/I2c_import.rb +117 -0
  48. data/lib/class/i2c/I2c_scanner.rb +114 -0
  49. data/lib/class/i2c/I2c_settings.rb +148 -0
  50. data/lib/class/parallel/Parallel_export.rb +118 -0
  51. data/lib/class/parallel/Parallel_import.rb +113 -0
  52. data/lib/class/parallel/Parallel_settings.rb +81 -0
  53. data/lib/class/spi/Spi_export.rb +108 -0
  54. data/lib/class/spi/Spi_import.rb +159 -0
  55. data/lib/class/spi/Spi_settings.rb +108 -0
  56. data/lib/class/spi/Spi_sniffer.rb +101 -0
  57. data/lib/class/swd/Swd.rb +125 -0
  58. data/lib/class/swd/Swd_scanner.rb +121 -0
  59. data/lib/class/swd/Swd_settings.rb +76 -0
  60. data/lib/class/uart/Uart_baudrate.rb +62 -0
  61. data/lib/class/uart/Uart_console.rb +115 -0
  62. data/lib/class/uart/Uart_settings.rb +102 -0
  63. data/lib/db/associations.rb +42 -29
  64. data/lib/db/database.rb +4 -0
  65. data/lib/db/development.sqlite3 +0 -0
  66. data/lib/db/migrate/004_create_manufacturers.rb +13 -0
  67. data/lib/db/migrate/005_create_packages.rb +13 -0
  68. data/lib/db/migrate/006_create_chip_types.rb +11 -0
  69. data/lib/db/migrate/007_create_buses.rb +11 -0
  70. data/lib/db/migrate/008_create_signals.rb +14 -0
  71. data/lib/db/migrate/009_create_chips.rb +25 -0
  72. data/lib/db/migrate/010_create_commands.rb +21 -0
  73. data/lib/db/migrate/011_create_bytes.rb +19 -0
  74. data/lib/db/migrate/012_create_i2c_settings.rb +21 -0
  75. data/lib/db/migrate/013_create_spi_settings.rb +26 -0
  76. data/lib/db/migrate/014_create_parallel_settings.rb +21 -0
  77. data/lib/db/migrate/015_create_pins.rb +19 -0
  78. data/lib/db/migrate/016_create_uses.rb +17 -0
  79. data/lib/db/migrate/017_create_swd_settings.rb +19 -0
  80. data/lib/db/migrate/018_create_uart_settings.rb +22 -0
  81. data/lib/db/schema.rb +157 -0
  82. data/lib/db/seeds.rb +161 -0
  83. data/lib/gui/gui_chip_editor.rb +23 -22
  84. data/lib/gui/gui_chip_management.rb +43 -38
  85. data/lib/gui/gui_command_editor.rb +2 -1
  86. data/lib/gui/gui_export.rb +132 -0
  87. data/lib/gui/gui_generic_commands.rb +69 -31
  88. data/lib/gui/gui_generic_export.rb +18 -2
  89. data/lib/gui/gui_generic_import.rb +18 -2
  90. data/lib/gui/gui_i2c_command.rb +2 -1
  91. data/lib/gui/gui_i2c_settings.rb +2 -2
  92. data/lib/gui/gui_import.rb +131 -0
  93. data/lib/gui/gui_parallel_settings.rb +2 -1
  94. data/lib/gui/gui_progress_bar.rb +2 -1
  95. data/lib/gui/gui_signal_mapper.rb +121 -0
  96. data/lib/gui/gui_signal_scanner.rb +146 -0
  97. data/lib/gui/gui_spi_settings.rb +6 -2
  98. data/lib/gui/gui_spi_sniffer.rb +112 -0
  99. data/lib/gui/gui_swd_settings.rb +166 -0
  100. data/lib/gui/gui_uart_baudrate.rb +114 -0
  101. data/lib/gui/gui_uart_console.rb +164 -0
  102. data/lib/gui/gui_uart_settings.rb +243 -0
  103. data/lib/gui_designer/gui_chip_editor.ui +9 -6
  104. data/lib/gui_designer/gui_chip_management.ui +79 -35
  105. data/lib/gui_designer/gui_command_editor.ui +3 -0
  106. data/lib/gui_designer/gui_export.ui +171 -0
  107. data/lib/gui_designer/gui_generic_commands.ui +274 -190
  108. data/lib/gui_designer/gui_generic_export.ui +24 -1
  109. data/lib/gui_designer/gui_generic_import.ui +25 -2
  110. data/lib/gui_designer/gui_i2c_command.ui +3 -0
  111. data/lib/gui_designer/gui_i2c_settings.ui +2 -2
  112. data/lib/gui_designer/gui_import.ui +168 -0
  113. data/lib/gui_designer/gui_parallel_settings.ui +4 -1
  114. data/lib/gui_designer/gui_progress_bar.ui +3 -0
  115. data/lib/gui_designer/gui_signal_mapper.ui +179 -0
  116. data/lib/gui_designer/gui_signal_scanner.ui +261 -0
  117. data/lib/gui_designer/gui_spi_settings.ui +15 -2
  118. data/lib/gui_designer/gui_spi_sniffer.ui +156 -0
  119. data/lib/gui_designer/gui_swd_settings.ui +189 -0
  120. data/lib/gui_designer/gui_uart_baudrate.ui +161 -0
  121. data/lib/gui_designer/gui_uart_console.ui +284 -0
  122. data/lib/gui_designer/gui_uart_settings.ui +280 -0
  123. data/lib/logs/error.log +63 -0
  124. data/lib/models/bus.rb +19 -0
  125. data/lib/models/byte.rb +29 -0
  126. data/lib/models/chip.rb +41 -0
  127. data/lib/models/chip_type.rb +14 -0
  128. data/lib/models/command.rb +20 -0
  129. data/lib/models/i2c_setting.rb +41 -0
  130. data/lib/models/manufacturer.rb +14 -0
  131. data/lib/models/package.rb +26 -0
  132. data/lib/models/parallel_setting.rb +37 -0
  133. data/lib/models/pin.rb +14 -0
  134. data/lib/models/signall.rb +20 -0
  135. data/lib/models/spi_setting.rb +67 -0
  136. data/lib/models/swd_setting.rb +25 -0
  137. data/lib/models/uart_setting.rb +52 -0
  138. data/lib/models/use.rb +6 -0
  139. data/lib/startHardsploit.rb +2 -2
  140. metadata +106 -41
  141. data/lib/Firmware/FPGA/PARALLEL/NO_MUX_PARALLEL_MEMORY/HARDSPLOIT_FIRMWARE_FPGA_NO_MUX_PARALLEL_MEMORY.rpd +0 -0
  142. data/lib/HardsploitAPI/HardsploitAPI.rb +0 -133
  143. data/lib/HardsploitAPI/HardsploitAPI_CONSTANT.rb +0 -145
  144. data/lib/HardsploitAPI/HardsploitAPI_ERROR.rb +0 -38
  145. data/lib/HardsploitAPI/HardsploitAPI_FIRMWARE.rb +0 -311
  146. data/lib/HardsploitAPI/HardsploitAPI_I2C.rb +0 -360
  147. data/lib/HardsploitAPI/HardsploitAPI_SPI.rb +0 -369
  148. data/lib/HardsploitAPI/HardsploitAPI_USB_COMMUNICATION.rb +0 -148
  149. data/lib/HardsploitAPI/LICENSE.txt +0 -674
  150. data/lib/HardsploitAPI/README.md +0 -22
  151. data/lib/HardsploitAPI/SWD/HardsploitAPI_SWD.rb +0 -249
  152. data/lib/HardsploitAPI/SWD/HardsploitAPI_SWD_DEBUG.rb +0 -102
  153. data/lib/HardsploitAPI/SWD/HardsploitAPI_SWD_MEM_AP.rb +0 -78
  154. data/lib/HardsploitAPI/TRADEMARK +0 -3
  155. data/lib/class/HardsploitGUI.rb +0 -463
  156. data/lib/class/I2C/I2c_export.rb +0 -118
  157. data/lib/class/I2C/I2c_import.rb +0 -79
  158. data/lib/class/I2C/I2c_settings.rb +0 -129
  159. data/lib/class/PARALLEL/Parallel_export.rb +0 -146
  160. data/lib/class/PARALLEL/Parallel_import.rb +0 -88
  161. data/lib/class/PARALLEL/Parallel_settings.rb +0 -102
  162. data/lib/class/SPI/Spi_export.rb +0 -138
  163. data/lib/class/SPI/Spi_import.rb +0 -113
  164. data/lib/class/SPI/Spi_settings.rb +0 -134
  165. data/lib/db/hs.db +0 -0
  166. data/lib/hardsploit.rb +0 -131
@@ -0,0 +1,118 @@
1
+ #===================================================
2
+ # Hardsploit GUI - By Opale Security
3
+ # www.opale-security.com || www.hardsploit.io
4
+ # License: GNU General Public License v3
5
+ # License URI: http://www.gnu.org/licenses/gpl.txt
6
+ #===================================================
7
+
8
+ require_relative '../../gui/gui_generic_export'
9
+ require_relative '../../HardsploitAPI/Modules/NO_MUX_PARALLEL_MEMORY/HardsploitAPI_NO_MUX_PARALLEL_MEMORY'
10
+
11
+ class Parallel_export < Qt::Widget
12
+ slots 'export()'
13
+ slots 'select_export_file()'
14
+
15
+ def initialize(chip)
16
+ super()
17
+ @view = Ui_Generic_export.new
18
+ centerWindow(self)
19
+ @view.setupUi(self)
20
+ @view.lbl_chip.setText(chip.reference)
21
+ inputRestrict(@view.lie_start, 0)
22
+ inputRestrict(@view.lie_stop, 0)
23
+ @chip = chip
24
+ end
25
+
26
+ def select_export_file
27
+ @filepath = Qt::FileDialog.getSaveFileName(self, tr('Select a file'), '/', tr('Bin file (*.bin)'))
28
+ unless @filepath.nil?
29
+ @view.btn_export.setEnabled(true)
30
+ @view.btn_full_export.setEnabled(true)
31
+ end
32
+ rescue Exception => msg
33
+ ErrorMsg.new.unknown(msg)
34
+ end
35
+
36
+ def export
37
+ if sender.objectName == 'btn_full_export'
38
+ return false unless control_export_settings('full')
39
+ start = 0
40
+ stop = @chip.parallel_setting.total_size - 1
41
+ else
42
+ return false unless control_export_settings('partial')
43
+ start = @view.lie_start.text.to_i
44
+ stop = @view.lie_stop.text.to_i
45
+ end
46
+ @chip.parallel_setting.word_size == 0 ? word_size = true : word_size = false
47
+ Firmware.new('PARALLEL')
48
+ parallel = HardsploitAPI_PARALLEL.new
49
+ time = Time.new
50
+
51
+ parallel.read_Memory_WithoutMultiplexing(
52
+ path: @filepath,
53
+ addressStart: start,
54
+ addressStop: stop,
55
+ bits8_or_bits16_DataSize: word_size,
56
+ latency: @chip.parallel_setting.read_latency
57
+ )
58
+
59
+ control_export_result(stop, time)
60
+ @view.btn_export.setEnabled(false)
61
+ @view.btn_full_export.setEnabled(false)
62
+ @filepath = nil
63
+ rescue HardsploitAPI::ERROR::HARDSPLOIT_NOT_FOUND
64
+ ErrorMsg.new.hardsploit_not_found
65
+ rescue HardsploitAPI::ERROR::USB_ERROR
66
+ ErrorMsg.new.usb_error
67
+ rescue Exception => msg
68
+ ErrorMsg.new.unknown(msg)
69
+ end
70
+
71
+ def control_export_result(stop, time)
72
+ time = Time.new - time
73
+ file_size = File.size("#{@filepath}")
74
+ # 8 bits test
75
+ if @chip.parallel_setting.word_size.zero?
76
+ if (stop - @view.lie_start.text.to_i + 1) == file_size
77
+ Qt::MessageBox.new(
78
+ Qt::MessageBox::Information,
79
+ "Information",
80
+ "Dump finished at #{((file_size / time)).round(2)}Bytes/s (#{(file_size)} Bytes in #{time.round(4)} s)"
81
+ ).exec
82
+ else
83
+ ErrorMsg.new.filesize_error
84
+ end
85
+ else
86
+ if (stop - @view.lie_start.text.to_i + 1) == (file_size / 2)
87
+ Qt::MessageBox.new(
88
+ Qt::MessageBox::Information,
89
+ "Information",
90
+ "Dump finished at #{((file_size / time)).round(2)}Bytes/s (#{(file_size)} Bytes in #{time.round(4)} s)"
91
+ ).exec
92
+ else
93
+ ErrorMsg.new.filesize_error
94
+ end
95
+ end
96
+ p "DUMP #{((file_size/time)).round(2)}Bytes/s (#{(file_size)}Bytes in #{time.round(4)} s)"
97
+ end
98
+
99
+ def control_export_settings(type)
100
+ return ErrorMsg.new.settings_missing if @chip.parallel_setting.nil?
101
+ return ErrorMsg.new.para_read_latency if @chip.parallel_setting.read_latency.nil?
102
+ return ErrorMsg.new.para_word_size if @chip.parallel_setting.word_size.nil?
103
+ return ErrorMsg.new.full_size_error if @chip.parallel_setting.total_size.nil?
104
+ return ErrorMsg.new.full_size_error if @chip.parallel_setting.total_size.zero?
105
+ if type == 'partial'
106
+ return ErrorMsg.new.start_stop_missing if @view.lie_start.text.empty?
107
+ return ErrorMsg.new.start_stop_missing if @view.lie_stop.text.empty?
108
+ start = @view.lie_start.text.to_i
109
+ stop = @view.lie_stop.text.to_i
110
+ total_size = @chip.parallel_setting.total_size
111
+ return ErrorMsg.new.start_neq_stop if start == stop
112
+ return ErrorMsg.new.start_inf_to_stop if start > stop
113
+ return ErrorMsg.new.inf_to_total_size if start > (total_size - 1)
114
+ return ErrorMsg.new.inf_to_total_size if stop > (total_size - 1)
115
+ end
116
+ return true
117
+ end
118
+ end
@@ -0,0 +1,113 @@
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
+
10
+ class Parallel_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
+ end
22
+
23
+ def select_import_file
24
+ @filepath = Qt::FileDialog.getOpenFileName(self, tr('Select a file'), '/', tr('Bin file (*.bin)'))
25
+ unless @filepath.nil?
26
+ $file = File.open("#{@filepath}", 'w')
27
+ @view.btn_import.setEnabled(true)
28
+ end
29
+ rescue Exception => msg
30
+ ErrorMsg.new.unknow(msg)
31
+ end
32
+
33
+ def close_file
34
+ unless $file.nil?
35
+ $file.close
36
+ end
37
+ rescue Exception => msg
38
+ ErrorMsg.new.unknow(msg)
39
+ end
40
+
41
+ def import
42
+ return 0 if control_import_settings.zero?
43
+ start = @view.lie_start.text.to_i
44
+ Firmware.new('PARALLEL')
45
+ time = Time.new
46
+ # API COMMAND GOES HERE
47
+ rescue HardsploitAPI::ERROR::HARDSPLOIT_NOT_FOUND
48
+ ErrorMsg.new.hardsploit_not_found
49
+ return false
50
+ rescue HardsploitAPI::ERROR::USB_ERROR
51
+ ErrorMsg.new.usb_error
52
+ return false
53
+ rescue HardsploitAPI::ERROR::PARALLEL_ERROR
54
+ ErrorMsg.new.swd_error
55
+ return false
56
+ rescue Exception => msg
57
+ ErrorMsg.new.unknown(msg)
58
+ return false
59
+ end
60
+
61
+ def control_import_settings
62
+ file_size = File.size("#{@filepath}")
63
+ if @chip.parallel_setting.nil?
64
+ Qt::MessageBox.new(
65
+ Qt::MessageBox::Warning,
66
+ 'Missing parallel settings',
67
+ 'No settings saved for this chip'
68
+ ).exec
69
+ return 0
70
+ end
71
+ if @chip.parallel_setting.total_size.nil? || @chip.parallel_setting.word_size.nil?
72
+ Qt::MessageBox.new(
73
+ Qt::MessageBox::Warning,
74
+ 'Missing parallel settings',
75
+ 'Total size or word size settings missing'
76
+ ).exec
77
+ return 0
78
+ end
79
+ if @chip.parallel_setting.page_size.nil? || @chip.parallel_setting.write_latency.nil?
80
+ Qt::MessageBox.new(
81
+ Qt::MessageBox::Warning,
82
+ 'Missing parallel settings',
83
+ 'Page size or write latency settings missing'
84
+ ).exec
85
+ return 0
86
+ end
87
+ if @view.lie_start.text.empty?
88
+ Qt::MessageBox.new(
89
+ Qt::MessageBox::Warning,
90
+ 'Missing start address',
91
+ 'Please fill the start address field'
92
+ ).exec
93
+ return 0
94
+ end
95
+ if file_size > @chip.parallel_setting.total_size
96
+ Qt::MessageBox.new(
97
+ Qt::MessageBox::Warning,
98
+ 'Incorrect file size',
99
+ 'The file size is superior to the chip capacity'
100
+ ).exec
101
+ return 0
102
+ end
103
+ if file_size > (@chip.parallel_setting.total_size - @view.lie_start)
104
+ Qt::MessageBox.new(
105
+ Qt::MessageBox::Warning,
106
+ 'Incorrect file size',
107
+ 'Starting at this address, the file size is superior to the chip capacity'
108
+ ).exec
109
+ return 0
110
+ end
111
+ return 1
112
+ end
113
+ end
@@ -0,0 +1,81 @@
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
+ @view = Ui_Parallel_settings.new
15
+ centerWindow(self)
16
+ @view.setupUi(self)
17
+ @view.lbl_chip.setText(chip.reference)
18
+ inputRestrict(@view.lie_total_size, 0)
19
+ inputRestrict(@view.lie_write_latency, 0)
20
+ inputRestrict(@view.lie_read_latency, 0)
21
+ inputRestrict(@view.lie_page_size, 0)
22
+ @chip = chip
23
+ feed_settings_form unless @chip.parallel_setting.nil?
24
+ end
25
+
26
+ def save_settings
27
+ @chip.parallel_setting.nil? ? create : update
28
+ @chip.reload
29
+ end
30
+
31
+ def feed_settings_form
32
+ @view.lie_read_latency.setText(@chip.parallel_setting.read_latency.to_s)
33
+ @view.lie_write_latency.setText(@chip.parallel_setting.write_latency.to_s)
34
+ @view.lie_page_size.setText(@chip.parallel_setting.page_size.to_s)
35
+ @view.lie_total_size.setText(@chip.parallel_setting.total_size.to_s)
36
+ @view.rbn_16b.setChecked(true) unless @chip.parallel_setting.word_size.zero?
37
+ end
38
+
39
+ def create
40
+ @view.rbn_8b.isChecked ? word_size = 0 : word_size = 1
41
+ chip_setting = ParallelSetting.create(
42
+ total_size: @view.lie_total_size.text,
43
+ page_size: @view.lie_page_size.text,
44
+ word_size: word_size,
45
+ read_latency: @view.lie_read_latency.text,
46
+ write_latency: @view.lie_write_latency.text,
47
+ chip_id: @chip.id
48
+ )
49
+ unless check_for_errors(chip_setting)
50
+ Qt::MessageBox.new(
51
+ Qt::MessageBox::Information,
52
+ 'Succes',
53
+ 'Parallel settings saved'
54
+ ).exec
55
+ close
56
+ end
57
+ rescue Exception => msg
58
+ ErrorMsg.new.unknown(msg)
59
+ end
60
+
61
+ def update
62
+ @view.rbn_8b.isChecked ? word_size = 0 : word_size = 1
63
+ @chip.parallel_setting.update(
64
+ total_size: @view.lie_total_size.text,
65
+ page_size: @view.lie_page_size.text,
66
+ word_size: word_size,
67
+ read_latency: @view.lie_read_latency.text,
68
+ write_latency: @view.lie_write_latency.text
69
+ )
70
+ unless check_for_errors(@chip.parallel_setting)
71
+ Qt::MessageBox.new(
72
+ Qt::MessageBox::Information,
73
+ 'Succes',
74
+ 'Parallel settings updated'
75
+ ).exec
76
+ close
77
+ end
78
+ rescue Exception => msg
79
+ ErrorMsg.new.unknown(msg)
80
+ end
81
+ end
@@ -0,0 +1,108 @@
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/SPI/HardsploitAPI_SPI'
10
+
11
+ class Spi_export < Qt::Widget
12
+ slots 'export()'
13
+ slots 'select_export_file()'
14
+
15
+ def initialize(chip)
16
+ super()
17
+ @view = Ui_Generic_export.new
18
+ centerWindow(self)
19
+ @view.setupUi(self)
20
+ @view.lbl_chip.setText(chip.reference)
21
+ inputRestrict(@view.lie_start, 0)
22
+ inputRestrict(@view.lie_stop, 0)
23
+ @chip = chip
24
+ @speeds = {
25
+ '25.00' => 3,
26
+ '18.75' => 4,
27
+ '15.00' => 5,
28
+ '12.50' => 6,
29
+ '10.71' => 7,
30
+ '9.38' => 8,
31
+ '7.50' => 10,
32
+ '5.00' => 15,
33
+ '3.95' => 19,
34
+ '3.00' => 25,
35
+ '2.03' => 37,
36
+ '1.00' => 75,
37
+ '0.50' => 150,
38
+ '0.29' => 255
39
+ }
40
+ end
41
+
42
+ def select_export_file
43
+ @filepath = Qt::FileDialog.getSaveFileName(self, tr('Select a file'), '/', tr('*.*'))
44
+ unless @filepath.nil?
45
+ @view.btn_export.setEnabled(true)
46
+ @view.btn_full_export.setEnabled(true)
47
+ @view.lbl_selected_file.setText("#{@filepath.split("/").last}")
48
+ end
49
+ rescue Exception => msg
50
+ ErrorMsg.new.unknown(msg)
51
+ end
52
+
53
+ def export
54
+ $file = File.open("#{@filepath}", 'w') unless @filepath.nil?
55
+ if sender.objectName == 'btn_full_export'
56
+ return false unless control_export_settings('full')
57
+ start = 0
58
+ stop = @chip.spi_setting.total_size - 1
59
+ control = @chip.spi_setting.total_size
60
+ else
61
+ return false unless control_export_settings('partial')
62
+ start = @view.lie_start.text.to_i
63
+ stop = @view.lie_stop.text.to_i
64
+ control = (stop - start) + 1
65
+ end
66
+ Firmware.new('SPI')
67
+ $pgb = Progress_bar.new("SPI: Exporting...")
68
+ $pgb.show
69
+ spi = HardsploitAPI_SPI.new(
70
+ speed: @speeds[@chip.spi_setting.frequency],
71
+ mode: @chip.spi_setting.mode
72
+ )
73
+ spi.spi_Generic_Dump(
74
+ readSpiCommand: @chip.spi_setting.command_read,
75
+ startAddress: start,
76
+ stopAddress: stop,
77
+ sizeMax: @chip.spi_setting.total_size.to_i
78
+ )
79
+ $file.close unless $file.nil?
80
+ ErrorMsg.new.filesize_error unless control == File.size(@filepath)
81
+ rescue HardsploitAPI::ERROR::HARDSPLOIT_NOT_FOUND
82
+ ErrorMsg.new.hardsploit_not_found
83
+ rescue HardsploitAPI::ERROR::USB_ERROR
84
+ ErrorMsg.new.usb_error
85
+ rescue Exception => msg
86
+ ErrorMsg.new.unknown(msg)
87
+ end
88
+
89
+ def control_export_settings(type)
90
+ return ErrorMsg.new.settings_missing if @chip.spi_setting.nil?
91
+ return ErrorMsg.new.frequency_missing if @chip.spi_setting.frequency.nil?
92
+ return ErrorMsg.new.mode_missing if @chip.spi_setting.command_read.nil?
93
+ return ErrorMsg.new.full_size_error if @chip.spi_setting.total_size.nil?
94
+ return ErrorMsg.new.full_size_error if @chip.spi_setting.total_size.zero?
95
+ if type == 'partial'
96
+ return ErrorMsg.new.start_stop_missing if @view.lie_start.text.empty?
97
+ return ErrorMsg.new.start_stop_missing if @view.lie_stop.text.empty?
98
+ start = @view.lie_start.text.to_i
99
+ stop = @view.lie_stop.text.to_i
100
+ total_size = @chip.spi_setting.total_size
101
+ return ErrorMsg.new.start_neq_stop if start == stop
102
+ return ErrorMsg.new.start_inf_to_stop if start > stop
103
+ return ErrorMsg.new.inf_to_total_size if start > (total_size - 1)
104
+ return ErrorMsg.new.inf_to_total_size if stop > (total_size - 1)
105
+ end
106
+ return true
107
+ end
108
+ end
@@ -0,0 +1,159 @@
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/SPI/HardsploitAPI_SPI'
10
+
11
+ class Spi_import < Qt::Widget
12
+ slots 'import()'
13
+ slots 'select_import_file()'
14
+
15
+ def initialize(chip)
16
+ super()
17
+ @view = Ui_Generic_import.new
18
+ centerWindow(self)
19
+ @view.setupUi(self)
20
+ @view.lbl_chip.setText(chip.reference)
21
+ inputRestrict(@view.lie_start, 0)
22
+ @chip = chip
23
+ @speeds = {
24
+ '25.00' => 3,
25
+ '18.75' => 4,
26
+ '15.00' => 5,
27
+ '12.50' => 6,
28
+ '10.71' => 7,
29
+ '9.38' => 8,
30
+ '7.50' => 10,
31
+ '5.00' => 15,
32
+ '3.95' => 19,
33
+ '3.00' => 25,
34
+ '2.03' => 37,
35
+ '1.00' => 75,
36
+ '0.50' => 150,
37
+ '0.29' => 255
38
+ }
39
+ end
40
+
41
+ def select_import_file
42
+ @filepath = Qt::FileDialog.getOpenFileName(self, tr('Select a file'), '/', tr('*.*'))
43
+ unless @filepath.nil?
44
+ @view.btn_import.setEnabled(true)
45
+ @view.lbl_selected_file.setText("#{@filepath.split("/").last}")
46
+ end
47
+ rescue Exception => msg
48
+ ErrorMsg.new.unknown(msg)
49
+ end
50
+
51
+ def import
52
+ return 0 if control_import_settings.zero?
53
+ spi = HardsploitAPI_SPI.new(
54
+ speed: @speeds[@chip.spi_setting.frequency],
55
+ mode: @chip.spi_setting.mode
56
+ )
57
+ Firmware.new('SPI')
58
+ $pgb = Progress_bar.new("SPI: Importing...")
59
+ $pgb.show
60
+ @chip.spi_setting.is_flash.zero? ? flash = false : flash = true
61
+ spi.spi_Generic_Import(
62
+ startAddress: @view.lie_start.text.to_i,
63
+ pageSize: @chip.spi_setting.page_size,
64
+ memorySize: @chip.spi_setting.total_size,
65
+ dataFile: @filepath,
66
+ writeSpiCommand: @chip.spi_setting.command_write,
67
+ writePageLatency: @chip.spi_setting.write_page_latency / 1000.0,
68
+ enableWriteSpiCommand: @chip.spi_setting.command_write_enable,
69
+ clearSpiCommand: @chip.spi_setting.command_erase,
70
+ clearChipTime: @chip.spi_setting.erase_time,
71
+ isFLASH: flash
72
+ )
73
+ rescue HardsploitAPI::ERROR::HARDSPLOIT_NOT_FOUND
74
+ ErrorMsg.new.hardsploit_not_found
75
+ rescue HardsploitAPI::ERROR::USB_ERROR
76
+ ErrorMsg.new.usb_error
77
+ rescue Exception => msg
78
+ ErrorMsg.new.unknown(msg)
79
+ end
80
+
81
+ def control_import_settings
82
+ if @chip.spi_setting.nil?
83
+ Qt::MessageBox.new(
84
+ Qt::MessageBox::Warning,
85
+ 'Missing SPI settings',
86
+ 'No settings saved for this chip'
87
+ ).exec
88
+ return 0
89
+ end
90
+ if @chip.spi_setting.total_size.nil? || @chip.spi_setting.page_size.nil?
91
+ Qt::MessageBox.new(
92
+ Qt::MessageBox::Warning,
93
+ 'Missing SPI settings',
94
+ 'Total size or page size missing'
95
+ ).exec
96
+ return 0
97
+ end
98
+ if @chip.spi_setting.command_read.nil? || @chip.spi_setting.frequency.nil?
99
+ Qt::MessageBox.new(
100
+ Qt::MessageBox::Warning,
101
+ 'Missing SPI settings',
102
+ 'Read command or frequency missing'
103
+ ).exec
104
+ return 0
105
+ end
106
+ if @chip.spi_setting.command_write.nil?
107
+ Qt::MessageBox.new(
108
+ Qt::MessageBox::Warning,
109
+ 'Missing SPI settings',
110
+ 'Write command missing'
111
+ ).exec
112
+ return 0
113
+ end
114
+ if @chip.spi_setting.write_page_latency.nil?
115
+ Qt::MessageBox.new(
116
+ Qt::MessageBox::Warning,
117
+ 'Missing SPI setting',
118
+ 'SPI write page latency missing'
119
+ ).exec
120
+ return 0
121
+ end
122
+ if @chip.spi_setting.is_flash.nil?
123
+ Qt::MessageBox.new(
124
+ Qt::MessageBox::Warning,
125
+ 'Missing SPI setting',
126
+ 'SPI flash nature missing'
127
+ ).exec
128
+ return 0
129
+ else
130
+ if @chip.spi_setting.is_flash == 1
131
+ if @chip.spi_setting.erase_time.nil? || @chip.spi_setting.command_erase.nil?
132
+ Qt::MessageBox.new(
133
+ Qt::MessageBox::Warning,
134
+ 'Missing SPI setting',
135
+ 'SPI erase time or command missing'
136
+ ).exec
137
+ return 0
138
+ end
139
+ end
140
+ end
141
+ if @chip.spi_setting.mode.nil?
142
+ Qt::MessageBox.new(
143
+ Qt::MessageBox::Warning,
144
+ 'Missing SPI setting',
145
+ 'Mode missing'
146
+ ).exec
147
+ return 0
148
+ end
149
+ if @view.lie_start.text.empty?
150
+ Qt::MessageBox.new(
151
+ Qt::MessageBox::Warning,
152
+ 'Missing start address',
153
+ 'Please fill the Start address field'
154
+ ).exec
155
+ return 0
156
+ end
157
+ return 1
158
+ end
159
+ end