hardsploit_gui 2.3 → 2.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (149) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +22 -22
  3. data/Rakefile +1 -1
  4. data/bin/hardsploit_gui +3 -3
  5. data/lib/Firmwares/FPGA/I2C/I2C_INTERACT/HARDSPLOIT_FIRMWARE_FPGA_I2C_INTERACT.rpd +0 -0
  6. data/lib/Firmwares/FPGA/PARALLEL/NO_MUX_PARALLEL_MEMORY/HARDSPLOIT_FIRMWARE_FPGA_NO_MUX_PARALLEL_MEMORY.rpd +0 -0
  7. data/lib/Firmwares/FPGA/SPI/SPI_INTERACT/HARDSPLOIT_FIRMWARE_FPGA_SPI_INTERACT.rpd +0 -0
  8. data/lib/Firmwares/FPGA/SPI/SPI_SNIFFER/HARDSPLOIT_FIRMWARE_FPGA_SPI_SNIFFER.rpd +0 -0
  9. data/lib/Firmwares/FPGA/SWD/SWD_INTERACT/HARDSPLOIT_FIRMWARE_FPGA_SWD_INTERACT.rpd +0 -0
  10. data/lib/Firmwares/FPGA/UART/UART_INTERACT/HARDSPLOIT_FIRMWARE_FPGA_UART_INTERACT.rpd +0 -0
  11. data/lib/Firmwares/FPGA/VersionFPGA.rb +5 -5
  12. data/lib/Firmwares/UC/VersionUC.rb +12 -12
  13. data/lib/HardsploitAPI/Core/HardsploitAPI.rb +210 -210
  14. data/lib/HardsploitAPI/Core/HardsploitAPI_CONSTANT.rb +150 -150
  15. data/lib/HardsploitAPI/Core/HardsploitAPI_ERROR.rb +109 -109
  16. data/lib/HardsploitAPI/Core/HardsploitAPI_FIRMWARE.rb +305 -305
  17. data/lib/HardsploitAPI/Core/HardsploitAPI_PROGRESS.rb +28 -28
  18. data/lib/HardsploitAPI/Core/HardsploitAPI_USB_COMMUNICATION.rb +166 -166
  19. data/lib/HardsploitAPI/Modules/I2C/HardsploitAPI_I2C.rb +356 -356
  20. data/lib/HardsploitAPI/Modules/NO_MUX_PARALLEL_MEMORY/HardsploitAPI_NO_MUX_PARALLEL_MEMORY.rb +206 -206
  21. data/lib/HardsploitAPI/Modules/NRF24L01/HardsploitAPI_NRF24L01.rb +306 -306
  22. data/lib/HardsploitAPI/Modules/SPI/HardsploitAPI_SPI.rb +340 -340
  23. data/lib/HardsploitAPI/Modules/SPI_SNIFFER/HardsploitAPI_SPI_SNIFFER.rb +83 -83
  24. data/lib/HardsploitAPI/Modules/SWD/HardsploitAPI_SWD.rb +367 -367
  25. data/lib/HardsploitAPI/Modules/SWD/HardsploitAPI_SWD_DEBUG.rb +89 -89
  26. data/lib/HardsploitAPI/Modules/SWD/HardsploitAPI_SWD_MEM_AP.rb +61 -61
  27. data/lib/HardsploitAPI/Modules/SWD/HardsploitAPI_SWD_STM32.rb +121 -121
  28. data/lib/HardsploitAPI/Modules/TEST/HardsploitAPI_TEST_INTERACT.rb +98 -98
  29. data/lib/HardsploitAPI/Modules/UART/HardsploitAPI_UART.rb +196 -196
  30. data/lib/Hardsploit_gui.rb +96 -96
  31. data/lib/LICENSE.txt +674 -674
  32. data/lib/README.md +22 -22
  33. data/lib/TRADEMARK +2 -2
  34. data/lib/class/Chip_editor.rb +304 -304
  35. data/lib/class/Chip_management.rb +496 -496
  36. data/lib/class/Command_editor.rb +216 -216
  37. data/lib/class/Command_table.rb +233 -233
  38. data/lib/class/Console.rb +26 -26
  39. data/lib/class/ErrorMsg.rb +312 -312
  40. data/lib/class/Export.rb +140 -140
  41. data/lib/class/Export_manager.rb +124 -124
  42. data/lib/class/Firmware.rb +70 -70
  43. data/lib/class/Generic_commands.rb +260 -260
  44. data/lib/class/{i2c → I2C}/I2c_command.rb +51 -51
  45. data/lib/class/{i2c → I2C}/I2c_export.rb +95 -95
  46. data/lib/class/{i2c → I2C}/I2c_import.rb +117 -117
  47. data/lib/class/{i2c → I2C}/I2c_scanner.rb +114 -114
  48. data/lib/class/{i2c → I2C}/I2c_settings.rb +148 -148
  49. data/lib/class/Import.rb +193 -193
  50. data/lib/class/{parallel → PARALLEL}/Parallel_export.rb +118 -118
  51. data/lib/class/{parallel → PARALLEL}/Parallel_import.rb +113 -113
  52. data/lib/class/{parallel → PARALLEL}/Parallel_settings.rb +81 -81
  53. data/lib/class/Progress_bar.rb +32 -32
  54. data/lib/class/{spi → SPI}/Spi_export.rb +108 -108
  55. data/lib/class/{spi → SPI}/Spi_import.rb +159 -159
  56. data/lib/class/{spi → SPI}/Spi_settings.rb +108 -108
  57. data/lib/class/{spi → SPI}/Spi_sniffer.rb +101 -101
  58. data/lib/class/Signal_mapper.rb +120 -120
  59. data/lib/class/Wire_helper.rb +230 -230
  60. data/lib/class/swd/Swd.rb +125 -125
  61. data/lib/class/swd/Swd_scanner.rb +121 -121
  62. data/lib/class/swd/Swd_settings.rb +76 -76
  63. data/lib/class/uart/Uart_baudrate.rb +62 -62
  64. data/lib/class/uart/Uart_console.rb +115 -115
  65. data/lib/class/uart/Uart_settings.rb +102 -102
  66. data/lib/db/associations.rb +138 -138
  67. data/lib/db/database.rb +4 -4
  68. data/lib/db/development.sqlite3 +0 -0
  69. data/lib/db/migrate/004_create_manufacturers.rb +13 -13
  70. data/lib/db/migrate/005_create_packages.rb +13 -13
  71. data/lib/db/migrate/006_create_chip_types.rb +11 -11
  72. data/lib/db/migrate/007_create_buses.rb +11 -11
  73. data/lib/db/migrate/008_create_signals.rb +14 -14
  74. data/lib/db/migrate/009_create_chips.rb +25 -25
  75. data/lib/db/migrate/010_create_commands.rb +21 -21
  76. data/lib/db/migrate/011_create_bytes.rb +19 -19
  77. data/lib/db/migrate/012_create_i2c_settings.rb +21 -21
  78. data/lib/db/migrate/013_create_spi_settings.rb +26 -26
  79. data/lib/db/migrate/014_create_parallel_settings.rb +21 -21
  80. data/lib/db/migrate/015_create_pins.rb +19 -19
  81. data/lib/db/migrate/016_create_uses.rb +17 -17
  82. data/lib/db/migrate/017_create_swd_settings.rb +19 -19
  83. data/lib/db/migrate/018_create_uart_settings.rb +22 -22
  84. data/lib/db/schema.rb +157 -157
  85. data/lib/db/seeds.rb +161 -161
  86. data/lib/gui/gui_chip_editor.rb +349 -349
  87. data/lib/gui/gui_chip_management.rb +377 -377
  88. data/lib/gui/gui_command_editor.rb +219 -219
  89. data/lib/gui/gui_export.rb +132 -132
  90. data/lib/gui/gui_export_manager.rb +93 -93
  91. data/lib/gui/gui_generic_commands.rb +202 -202
  92. data/lib/gui/gui_generic_export.rb +164 -164
  93. data/lib/gui/gui_generic_import.rb +142 -142
  94. data/lib/gui/gui_i2c_command.rb +116 -116
  95. data/lib/gui/gui_i2c_settings.rb +230 -230
  96. data/lib/gui/gui_import.rb +131 -131
  97. data/lib/gui/gui_parallel_settings.rb +195 -195
  98. data/lib/gui/gui_progress_bar.rb +85 -85
  99. data/lib/gui/gui_signal_mapper.rb +121 -121
  100. data/lib/gui/gui_signal_scanner.rb +146 -146
  101. data/lib/gui/gui_spi_import.rb +126 -126
  102. data/lib/gui/gui_spi_settings.rb +313 -313
  103. data/lib/gui/gui_spi_sniffer.rb +112 -112
  104. data/lib/gui/gui_swd_settings.rb +166 -166
  105. data/lib/gui/gui_uart_baudrate.rb +114 -114
  106. data/lib/gui/gui_uart_console.rb +164 -164
  107. data/lib/gui/gui_uart_settings.rb +243 -243
  108. data/lib/gui/gui_wire_helper.rb +99 -99
  109. data/lib/gui_designer/gui_chip_editor.ui +549 -549
  110. data/lib/gui_designer/gui_chip_management.ui +886 -886
  111. data/lib/gui_designer/gui_command_editor.ui +350 -350
  112. data/lib/gui_designer/gui_export.ui +171 -171
  113. data/lib/gui_designer/gui_export_manager.ui +115 -115
  114. data/lib/gui_designer/gui_generic_commands.ui +342 -342
  115. data/lib/gui_designer/gui_generic_export.ui +202 -202
  116. data/lib/gui_designer/gui_generic_import.ui +165 -165
  117. data/lib/gui_designer/gui_i2c_command.ui +148 -148
  118. data/lib/gui_designer/gui_i2c_settings.ui +292 -292
  119. data/lib/gui_designer/gui_import.ui +168 -168
  120. data/lib/gui_designer/gui_parallel_settings.ui +247 -247
  121. data/lib/gui_designer/gui_progress_bar.ui +86 -86
  122. data/lib/gui_designer/gui_signal_mapper.ui +179 -179
  123. data/lib/gui_designer/gui_signal_scanner.ui +261 -261
  124. data/lib/gui_designer/gui_spi_settings.ui +446 -446
  125. data/lib/gui_designer/gui_spi_sniffer.ui +156 -156
  126. data/lib/gui_designer/gui_swd_settings.ui +189 -189
  127. data/lib/gui_designer/gui_uart_baudrate.ui +161 -161
  128. data/lib/gui_designer/gui_uart_console.ui +284 -284
  129. data/lib/gui_designer/gui_uart_settings.ui +280 -280
  130. data/lib/gui_designer/gui_wire_helper.ui +117 -117
  131. data/lib/images/search.png +0 -0
  132. data/lib/logs/error.log +0 -63
  133. data/lib/models/bus.rb +19 -19
  134. data/lib/models/byte.rb +29 -29
  135. data/lib/models/chip.rb +41 -41
  136. data/lib/models/chip_type.rb +14 -14
  137. data/lib/models/command.rb +20 -20
  138. data/lib/models/i2c_setting.rb +41 -41
  139. data/lib/models/manufacturer.rb +14 -14
  140. data/lib/models/package.rb +26 -26
  141. data/lib/models/parallel_setting.rb +37 -37
  142. data/lib/models/pin.rb +14 -14
  143. data/lib/models/signall.rb +20 -20
  144. data/lib/models/spi_setting.rb +67 -67
  145. data/lib/models/swd_setting.rb +25 -25
  146. data/lib/models/uart_setting.rb +52 -52
  147. data/lib/models/use.rb +6 -6
  148. data/lib/startHardsploit.rb +10 -10
  149. metadata +14 -14
@@ -1,114 +1,114 @@
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_signal_scanner'
9
- require_relative '../../HardsploitAPI/Modules/I2C/HardsploitAPI_I2C'
10
-
11
- class I2c_scanner < Qt::Widget
12
- slots 'scan()'
13
- slots 'autowiring()'
14
- slots 'update_tbl(QString)'
15
- slots 'update_cbx(QString)'
16
-
17
- def initialize
18
- super()
19
- @view = Ui_Signal_scanner.new
20
- centerWindow(self)
21
- @view.setupUi(self)
22
- update_cbx('B0')
23
- end
24
-
25
- def scan
26
- @view.cbx_start.setEnabled(false)
27
- @view.cbx_stop.setEnabled(false)
28
- @view.btn_scan.setEnabled(false)
29
- update_tbl(@view.cbx_stop.currentText)
30
- Firmware.new('I2C')
31
- i2c = HardsploitAPI_I2C.new(speed: 3)
32
- @result = i2c.find(
33
- start_from: @view.cbx_start.currentText[1].to_i + 9,
34
- stop_to: @view.cbx_stop.currentText[1].to_i + 9
35
- )
36
- unless @result[1].is_a? Array
37
- @view.tbl_result.setItem(@result.index(0), 1, Qt::TableWidgetItem.new("CLK"))
38
- @view.tbl_result.setItem(@result.index(1), 1, Qt::TableWidgetItem.new("SDA"))
39
- end
40
- @view.cbx_start.setEnabled(true)
41
- @view.cbx_stop.setEnabled(true)
42
- @view.btn_scan.setEnabled(true)
43
- rescue HardsploitAPI::ERROR::HARDSPLOIT_NOT_FOUND
44
- ErrorMsg.new.hardsploit_not_found
45
- return false
46
- rescue HardsploitAPI::ERROR::USB_ERROR
47
- ErrorMsg.new.usb_error
48
- return false
49
- rescue Exception => msg
50
- ErrorMsg.new.unknown(msg)
51
- return false
52
- end
53
-
54
- def autowiring
55
- signal_found = false
56
- @view.tbl_result.rowCount.times do |i|
57
- if @view.tbl_result.item(i, 1).text == 'SDA'
58
- signal_found = true
59
- current_signal = Signall.find_by(name: 'SDA')
60
- current_signal.update(pin: @view.tbl_result.item(i, 0).text)
61
- elsif @view.tbl_result.item(i, 1).text == 'CLK'
62
- signal_found = true
63
- current_signal = Signall.find_by(name: 'I2C_CLK')
64
- current_signal.update(pin: @view.tbl_result.item(i, 0).text)
65
- else
66
- # Next row
67
- end
68
- end
69
- if signal_found
70
- Qt::MessageBox.new(
71
- Qt::MessageBox::Information,
72
- 'Hardsploit Autowiring',
73
- 'Wiring saved. To change it, go to Menu > Signal mapper'
74
- ).exec
75
- else
76
- Qt::MessageBox.new(
77
- Qt::MessageBox::Information,
78
- 'Hardsploit Autowiring',
79
- 'No signals found in the array'
80
- ).exec
81
- end
82
- rescue Exception => msg
83
- ErrorMsg.new.unknown(msg)
84
- return false
85
- end
86
-
87
- def update_tbl(pin)
88
- unless @view.cbx_stop.count.zero?
89
- @view.tbl_result.setRowCount(0)
90
- nbr = pin[1].to_i - (@view.cbx_start.currentText[1].to_i) + 1
91
- nbr.times do |i|
92
- @view.tbl_result.insertRow(i)
93
- @view.tbl_result.setItem(i, 0, Qt::TableWidgetItem.new("B#{(i + @view.cbx_start.currentText[1].to_i)}"))
94
- @view.tbl_result.setItem(i, 1, Qt::TableWidgetItem.new('-'))
95
- end
96
- resize_to_content
97
- end
98
- end
99
-
100
- def resize_to_content
101
- @view.tbl_result.resizeColumnsToContents
102
- @view.tbl_result.resizeRowsToContents
103
- @view.tbl_result.horizontalHeader.stretchLastSection = true
104
- end
105
-
106
- def update_cbx(pin)
107
- @view.cbx_stop.clear
108
- start_at = pin[1].to_i
109
- end_at = 7
110
- (end_at - start_at).times do |i|
111
- @view.cbx_stop.addItem("B#{(i + start_at) + 1}")
112
- end
113
- end
114
- end
1
+ #===================================================
2
+ # Hardsploit GUI - By Opale Security
3
+ # www.opale-security.com || www.hardsploit.io
4
+ # License: GNU General Public License v3
5
+ # License URI: http://www.gnu.org/licenses/gpl.txt
6
+ #===================================================
7
+
8
+ require_relative '../../gui/gui_signal_scanner'
9
+ require_relative '../../HardsploitAPI/Modules/I2C/HardsploitAPI_I2C'
10
+
11
+ class I2c_scanner < Qt::Widget
12
+ slots 'scan()'
13
+ slots 'autowiring()'
14
+ slots 'update_tbl(QString)'
15
+ slots 'update_cbx(QString)'
16
+
17
+ def initialize
18
+ super()
19
+ @view = Ui_Signal_scanner.new
20
+ centerWindow(self)
21
+ @view.setupUi(self)
22
+ update_cbx('B0')
23
+ end
24
+
25
+ def scan
26
+ @view.cbx_start.setEnabled(false)
27
+ @view.cbx_stop.setEnabled(false)
28
+ @view.btn_scan.setEnabled(false)
29
+ update_tbl(@view.cbx_stop.currentText)
30
+ Firmware.new('I2C')
31
+ i2c = HardsploitAPI_I2C.new(speed: 3)
32
+ @result = i2c.find(
33
+ start_from: @view.cbx_start.currentText[1].to_i + 9,
34
+ stop_to: @view.cbx_stop.currentText[1].to_i + 9
35
+ )
36
+ unless @result[1].is_a? Array
37
+ @view.tbl_result.setItem(@result.index(0), 1, Qt::TableWidgetItem.new("CLK"))
38
+ @view.tbl_result.setItem(@result.index(1), 1, Qt::TableWidgetItem.new("SDA"))
39
+ end
40
+ @view.cbx_start.setEnabled(true)
41
+ @view.cbx_stop.setEnabled(true)
42
+ @view.btn_scan.setEnabled(true)
43
+ rescue HardsploitAPI::ERROR::HARDSPLOIT_NOT_FOUND
44
+ ErrorMsg.new.hardsploit_not_found
45
+ return false
46
+ rescue HardsploitAPI::ERROR::USB_ERROR
47
+ ErrorMsg.new.usb_error
48
+ return false
49
+ rescue Exception => msg
50
+ ErrorMsg.new.unknown(msg)
51
+ return false
52
+ end
53
+
54
+ def autowiring
55
+ signal_found = false
56
+ @view.tbl_result.rowCount.times do |i|
57
+ if @view.tbl_result.item(i, 1).text == 'SDA'
58
+ signal_found = true
59
+ current_signal = Signall.find_by(name: 'SDA')
60
+ current_signal.update(pin: @view.tbl_result.item(i, 0).text)
61
+ elsif @view.tbl_result.item(i, 1).text == 'CLK'
62
+ signal_found = true
63
+ current_signal = Signall.find_by(name: 'I2C_CLK')
64
+ current_signal.update(pin: @view.tbl_result.item(i, 0).text)
65
+ else
66
+ # Next row
67
+ end
68
+ end
69
+ if signal_found
70
+ Qt::MessageBox.new(
71
+ Qt::MessageBox::Information,
72
+ 'Hardsploit Autowiring',
73
+ 'Wiring saved. To change it, go to Menu > Signal mapper'
74
+ ).exec
75
+ else
76
+ Qt::MessageBox.new(
77
+ Qt::MessageBox::Information,
78
+ 'Hardsploit Autowiring',
79
+ 'No signals found in the array'
80
+ ).exec
81
+ end
82
+ rescue Exception => msg
83
+ ErrorMsg.new.unknown(msg)
84
+ return false
85
+ end
86
+
87
+ def update_tbl(pin)
88
+ unless @view.cbx_stop.count.zero?
89
+ @view.tbl_result.setRowCount(0)
90
+ nbr = pin[1].to_i - (@view.cbx_start.currentText[1].to_i) + 1
91
+ nbr.times do |i|
92
+ @view.tbl_result.insertRow(i)
93
+ @view.tbl_result.setItem(i, 0, Qt::TableWidgetItem.new("B#{(i + @view.cbx_start.currentText[1].to_i)}"))
94
+ @view.tbl_result.setItem(i, 1, Qt::TableWidgetItem.new('-'))
95
+ end
96
+ resize_to_content
97
+ end
98
+ end
99
+
100
+ def resize_to_content
101
+ @view.tbl_result.resizeColumnsToContents
102
+ @view.tbl_result.resizeRowsToContents
103
+ @view.tbl_result.horizontalHeader.stretchLastSection = true
104
+ end
105
+
106
+ def update_cbx(pin)
107
+ @view.cbx_stop.clear
108
+ start_at = pin[1].to_i
109
+ end_at = 7
110
+ (end_at - start_at).times do |i|
111
+ @view.cbx_stop.addItem("B#{(i + start_at) + 1}")
112
+ end
113
+ end
114
+ end
@@ -1,148 +1,148 @@
1
- #===================================================
2
- # Hardsploit GUI - By Opale Security
3
- # www.opale-security.com || www.hardsploit.io
4
- # License: GNU General Public License v3
5
- # License URI: http://www.gnu.org/licenses/gpl.txt
6
- #===================================================
7
-
8
- require_relative '../../gui/gui_i2c_settings'
9
- class I2c_settings < Qt::Widget
10
- slots 'save_settings()'
11
- slots 'bus_scan()'
12
-
13
- def initialize(chip)
14
- super()
15
- @view = Ui_I2c_settings.new
16
- centerWindow(self)
17
- @view.setupUi(self)
18
- @view.lbl_chip.setText(chip.reference)
19
- inputRestrict(@view.lie_total_size, 0)
20
- inputRestrict(@view.lie_page_size, 0)
21
- inputRestrict(@view.lie_write_page_latency, 0)
22
- inputRestrict(@view.lie_address_r, 3)
23
- inputRestrict(@view.lie_address_w, 3)
24
- @view.tbl_bus_scan.resizeColumnsToContents
25
- @view.tbl_bus_scan.resizeRowsToContents
26
- @view.tbl_bus_scan.horizontalHeader.stretchLastSection = true
27
- @chip = chip
28
- feed_settings_form unless @chip.i2c_setting.nil?
29
- rescue Exception => msg
30
- ErrorMsg.new.unknown(msg)
31
- end
32
-
33
- def save_settings
34
- @chip.i2c_setting.nil? ? create : update
35
- @chip.reload
36
- end
37
-
38
- def feed_settings_form
39
- @view.lie_address_w.setText(@chip.i2c_setting.address_w)
40
- @view.lie_address_r.setText(@chip.i2c_setting.address_r)
41
- @view.cbx_frequency.setCurrentIndex(@view.cbx_frequency.findText(@chip.i2c_setting.frequency.to_s))
42
- @view.lie_write_page_latency.setText(@chip.i2c_setting.write_page_latency.to_s)
43
- @view.lie_page_size.setText(@chip.i2c_setting.page_size.to_s)
44
- @view.lie_total_size.setText(@chip.i2c_setting.total_size.to_s)
45
- end
46
-
47
- def create
48
- chip_setting = I2cSetting.create(
49
- address_w: @view.lie_address_w.text,
50
- address_r: @view.lie_address_r.text,
51
- frequency: @view.cbx_frequency.currentText.to_i,
52
- write_page_latency: @view.lie_write_page_latency.text,
53
- page_size: @view.lie_page_size.text,
54
- total_size: @view.lie_total_size.text,
55
- chip_id: @chip.id
56
- )
57
- unless check_for_errors(chip_setting)
58
- Qt::MessageBox.new(
59
- Qt::MessageBox::Information,
60
- 'Succes',
61
- 'I2C settings saved'
62
- ).exec
63
- close
64
- end
65
- rescue Exception => msg
66
- ErrorMsg.new.unknown(msg)
67
- end
68
-
69
- def update
70
- @chip.i2c_setting.update(
71
- address_w: @view.lie_address_w.text,
72
- address_r: @view.lie_address_r.text,
73
- frequency: @view.cbx_frequency.currentText.to_i,
74
- write_page_latency: @view.lie_write_page_latency.text,
75
- page_size: @view.lie_page_size.text,
76
- total_size: @view.lie_total_size.text
77
- )
78
- unless check_for_errors(@chip.i2c_setting)
79
- Qt::MessageBox.new(
80
- Qt::MessageBox::Information,
81
- 'Succes',
82
- 'I2C settings updated'
83
- ).exec
84
- close
85
- end
86
- rescue Exception => msg
87
- ErrorMsg.new.unknown(msg)
88
- end
89
-
90
- def bus_scan
91
- @view.tbl_bus_scan.setRowCount(0)
92
- Firmware.new('I2C')
93
- speed = 0
94
- if [40, 100, 400, 1000].include?(@chip.i2c_setting.frequency)
95
- speed = 0 if @chip.i2c_setting.frequency == 100
96
- speed = 1 if @chip.i2c_setting.frequency == 400
97
- speed = 2 if @chip.i2c_setting.frequency == 1000
98
- speed = 3 if @chip.i2c_setting.frequency == 40
99
- end
100
- i2c = HardsploitAPI_I2C.new(speed: speed)
101
- scan_result = i2c.i2c_Scan
102
- if scan_result.include?(1)
103
- scan_result.each_with_index do |v, i|
104
- if v == 1
105
- @view.tbl_bus_scan.insertRow(@view.tbl_bus_scan.rowCount)
106
- @view.tbl_bus_scan.setItem(
107
- @view.tbl_bus_scan.rowCount - 1,
108
- 0,
109
- Qt::TableWidgetItem.new("0x#{i.to_s(16).upcase}")
110
- )
111
- if i % 2 == 0
112
- @view.tbl_bus_scan.setItem(
113
- @view.tbl_bus_scan.rowCount - 1,
114
- 1,
115
- Qt::TableWidgetItem.new('Write')
116
- )
117
- else
118
- @view.tbl_bus_scan.setItem(
119
- @view.tbl_bus_scan.rowCount - 1,
120
- 1,
121
- Qt::TableWidgetItem.new('Read')
122
- )
123
- end
124
- end
125
- end
126
- @view.tbl_bus_scan.resizeColumnsToContents
127
- @view.tbl_bus_scan.resizeRowsToContents
128
- @view.tbl_bus_scan.horizontalHeader.stretchLastSection = true
129
- Qt::MessageBox.new(
130
- Qt::MessageBox::Information,
131
- "Bus Scan",
132
- "Bus scan ended correctly: #{@view.tbl_bus_scan.rowCount} address(es) found"
133
- ).exec
134
- else
135
- Qt::MessageBox.new(
136
- Qt::MessageBox::Information,
137
- "Bus addresses",
138
- "No valid addresses have been returned by the scan"
139
- ).exec
140
- end
141
- rescue HardsploitAPI::ERROR::HARDSPLOIT_NOT_FOUND
142
- ErrorMsg.new.hardsploit_not_found
143
- rescue HardsploitAPI::ERROR::USB_ERROR
144
- ErrorMsg.new.usb_error
145
- rescue Exception => msg
146
- ErrorMsg.new.unknown(msg)
147
- end
148
- end
1
+ #===================================================
2
+ # Hardsploit GUI - By Opale Security
3
+ # www.opale-security.com || www.hardsploit.io
4
+ # License: GNU General Public License v3
5
+ # License URI: http://www.gnu.org/licenses/gpl.txt
6
+ #===================================================
7
+
8
+ require_relative '../../gui/gui_i2c_settings'
9
+ class I2c_settings < Qt::Widget
10
+ slots 'save_settings()'
11
+ slots 'bus_scan()'
12
+
13
+ def initialize(chip)
14
+ super()
15
+ @view = Ui_I2c_settings.new
16
+ centerWindow(self)
17
+ @view.setupUi(self)
18
+ @view.lbl_chip.setText(chip.reference)
19
+ inputRestrict(@view.lie_total_size, 0)
20
+ inputRestrict(@view.lie_page_size, 0)
21
+ inputRestrict(@view.lie_write_page_latency, 0)
22
+ inputRestrict(@view.lie_address_r, 3)
23
+ inputRestrict(@view.lie_address_w, 3)
24
+ @view.tbl_bus_scan.resizeColumnsToContents
25
+ @view.tbl_bus_scan.resizeRowsToContents
26
+ @view.tbl_bus_scan.horizontalHeader.stretchLastSection = true
27
+ @chip = chip
28
+ feed_settings_form unless @chip.i2c_setting.nil?
29
+ rescue Exception => msg
30
+ ErrorMsg.new.unknown(msg)
31
+ end
32
+
33
+ def save_settings
34
+ @chip.i2c_setting.nil? ? create : update
35
+ @chip.reload
36
+ end
37
+
38
+ def feed_settings_form
39
+ @view.lie_address_w.setText(@chip.i2c_setting.address_w)
40
+ @view.lie_address_r.setText(@chip.i2c_setting.address_r)
41
+ @view.cbx_frequency.setCurrentIndex(@view.cbx_frequency.findText(@chip.i2c_setting.frequency.to_s))
42
+ @view.lie_write_page_latency.setText(@chip.i2c_setting.write_page_latency.to_s)
43
+ @view.lie_page_size.setText(@chip.i2c_setting.page_size.to_s)
44
+ @view.lie_total_size.setText(@chip.i2c_setting.total_size.to_s)
45
+ end
46
+
47
+ def create
48
+ chip_setting = I2cSetting.create(
49
+ address_w: @view.lie_address_w.text,
50
+ address_r: @view.lie_address_r.text,
51
+ frequency: @view.cbx_frequency.currentText.to_i,
52
+ write_page_latency: @view.lie_write_page_latency.text,
53
+ page_size: @view.lie_page_size.text,
54
+ total_size: @view.lie_total_size.text,
55
+ chip_id: @chip.id
56
+ )
57
+ unless check_for_errors(chip_setting)
58
+ Qt::MessageBox.new(
59
+ Qt::MessageBox::Information,
60
+ 'Succes',
61
+ 'I2C settings saved'
62
+ ).exec
63
+ close
64
+ end
65
+ rescue Exception => msg
66
+ ErrorMsg.new.unknown(msg)
67
+ end
68
+
69
+ def update
70
+ @chip.i2c_setting.update(
71
+ address_w: @view.lie_address_w.text,
72
+ address_r: @view.lie_address_r.text,
73
+ frequency: @view.cbx_frequency.currentText.to_i,
74
+ write_page_latency: @view.lie_write_page_latency.text,
75
+ page_size: @view.lie_page_size.text,
76
+ total_size: @view.lie_total_size.text
77
+ )
78
+ unless check_for_errors(@chip.i2c_setting)
79
+ Qt::MessageBox.new(
80
+ Qt::MessageBox::Information,
81
+ 'Succes',
82
+ 'I2C settings updated'
83
+ ).exec
84
+ close
85
+ end
86
+ rescue Exception => msg
87
+ ErrorMsg.new.unknown(msg)
88
+ end
89
+
90
+ def bus_scan
91
+ @view.tbl_bus_scan.setRowCount(0)
92
+ Firmware.new('I2C')
93
+ speed = 0
94
+ if [40, 100, 400, 1000].include?(@chip.i2c_setting.frequency)
95
+ speed = 0 if @chip.i2c_setting.frequency == 100
96
+ speed = 1 if @chip.i2c_setting.frequency == 400
97
+ speed = 2 if @chip.i2c_setting.frequency == 1000
98
+ speed = 3 if @chip.i2c_setting.frequency == 40
99
+ end
100
+ i2c = HardsploitAPI_I2C.new(speed: speed)
101
+ scan_result = i2c.i2c_Scan
102
+ if scan_result.include?(1)
103
+ scan_result.each_with_index do |v, i|
104
+ if v == 1
105
+ @view.tbl_bus_scan.insertRow(@view.tbl_bus_scan.rowCount)
106
+ @view.tbl_bus_scan.setItem(
107
+ @view.tbl_bus_scan.rowCount - 1,
108
+ 0,
109
+ Qt::TableWidgetItem.new("0x#{i.to_s(16).upcase}")
110
+ )
111
+ if i % 2 == 0
112
+ @view.tbl_bus_scan.setItem(
113
+ @view.tbl_bus_scan.rowCount - 1,
114
+ 1,
115
+ Qt::TableWidgetItem.new('Write')
116
+ )
117
+ else
118
+ @view.tbl_bus_scan.setItem(
119
+ @view.tbl_bus_scan.rowCount - 1,
120
+ 1,
121
+ Qt::TableWidgetItem.new('Read')
122
+ )
123
+ end
124
+ end
125
+ end
126
+ @view.tbl_bus_scan.resizeColumnsToContents
127
+ @view.tbl_bus_scan.resizeRowsToContents
128
+ @view.tbl_bus_scan.horizontalHeader.stretchLastSection = true
129
+ Qt::MessageBox.new(
130
+ Qt::MessageBox::Information,
131
+ "Bus Scan",
132
+ "Bus scan ended correctly: #{@view.tbl_bus_scan.rowCount} address(es) found"
133
+ ).exec
134
+ else
135
+ Qt::MessageBox.new(
136
+ Qt::MessageBox::Information,
137
+ "Bus addresses",
138
+ "No valid addresses have been returned by the scan"
139
+ ).exec
140
+ end
141
+ rescue HardsploitAPI::ERROR::HARDSPLOIT_NOT_FOUND
142
+ ErrorMsg.new.hardsploit_not_found
143
+ rescue HardsploitAPI::ERROR::USB_ERROR
144
+ ErrorMsg.new.usb_error
145
+ rescue Exception => msg
146
+ ErrorMsg.new.unknown(msg)
147
+ end
148
+ end