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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c7307c772e8b3f54b1002fab4f345ebe6cedf03a
4
- data.tar.gz: f8c2fa22801cccd46aba0827e7df99f53d7f082a
3
+ metadata.gz: 740436397cfcd4b59bb8dfb2f56f553eec501a91
4
+ data.tar.gz: 426ea68b4a548332b7b77118e1ad3216cfee823f
5
5
  SHA512:
6
- metadata.gz: c9e513dff9867a765efcd05b201adc6ef65f4400048e33ae9e919d5c5618ece34437f55460e91ce118346d1f9305819335a64fce9736997682d323d73051320c
7
- data.tar.gz: cd870eb9329e07c4b695fecc88a764ef45265004122bc332b9451c302847e6d9cd953463af3ef1a47f396ace36f580dfd88d074fd871bcd5869dd77ea1ab35a2
6
+ metadata.gz: bdacc3c5aecaafd699973412afde50e6e8aaefc822aeca401e94b522e0dfc8125ce46670143a76fc87f7335dcb2d4789b7aee58bd327a4eaef677f5cf34468cc
7
+ data.tar.gz: 3c93bed4532a6c89d161f6f229035e6b32733da62693f60f012f8c20c33303cebd33805ac81d87455bbdadef3ca671ed68810438383b5da18400f65e66f6f741
data/bin/hardsploit_gui CHANGED
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env ruby
2
- require "hardsploit"
3
- Hardsploit_GUI.new
2
+ require 'Hardsploit_gui'
3
+ Hardsploit_gui.new
@@ -1,5 +1,5 @@
1
1
  class VersionFPGA
2
2
  module VERSION_FPGA
3
- FPGA = "V1.1.0"
3
+ FPGA = "V1.2.0"
4
4
  end
5
5
  end
@@ -7,6 +7,6 @@
7
7
 
8
8
  class VersionUC
9
9
  module VERSION_UC
10
- UC = "V1.0.2"
10
+ UC = "V1.0.3"
11
11
  end
12
12
  end
@@ -0,0 +1,210 @@
1
+ require 'singleton'
2
+ require 'libusb'
3
+ require 'thread'
4
+ require_relative 'HardsploitAPI_CONSTANT'
5
+ require_relative 'HardsploitAPI_USB_COMMUNICATION'
6
+ require_relative 'HardsploitAPI_FIRMWARE'
7
+ require_relative 'HardsploitAPI_ERROR'
8
+ require_relative '../../Firmwares/FPGA/VersionFPGA'
9
+ require_relative '../../Firmwares/UC/VersionUC'
10
+ class String
11
+ def black; "\e[30m#{self}\e[0m" end
12
+ def red; "\e[31m#{self}\e[0m" end
13
+ def green; "\e[32m#{self}\e[0m" end
14
+ def brown; "\e[33m#{self}\e[0m" end
15
+ def blue; "\e[34m#{self}\e[0m" end
16
+ def magenta; "\e[35m#{self}\e[0m" end
17
+ def cyan; "\e[36m#{self}\e[0m" end
18
+ def gray; "\e[37m#{self}\e[0m" end
19
+
20
+ def bg_black; "\e[40m#{self}\e[0m" end
21
+ def bg_red; "\e[41m#{self}\e[0m" end
22
+ def bg_green; "\e[42m#{self}\e[0m" end
23
+ def bg_brown; "\e[43m#{self}\e[0m" end
24
+ def bg_blue; "\e[44m#{self}\e[0m" end
25
+ def bg_magenta; "\e[45m#{self}\e[0m" end
26
+ def bg_cyan; "\e[46m#{self}\e[0m" end
27
+ def bg_gray; "\e[47m#{self}\e[0m" end
28
+
29
+ def bold; "\e[1m#{self}\e[22m" end
30
+ def italic; "\e[3m#{self}\e[23m" end
31
+ def underline; "\e[4m#{self}\e[24m" end
32
+ def blink; "\e[5m#{self}\e[25m" end
33
+ def reverse_color; "\e[7m#{self}\e[27m" end
34
+ end
35
+
36
+ class HardsploitAPI
37
+ include Singleton
38
+ include USB_COMMAND
39
+ include USB
40
+ include VERSION
41
+ include ERROR
42
+
43
+ @@callbackData = nil
44
+ @@callbackInfo = nil
45
+ @@callbackProgress = nil
46
+ @@callbackSpeedOfTransfert = nil
47
+ @@id = 0
48
+ @@crossWiringValue = Array.new
49
+
50
+ def self.callbackData= fn
51
+ @@callbackData = fn
52
+ end
53
+ def self.callbackInfo= fn
54
+ @@callbackInfo = fn
55
+ end
56
+ def self.callbackProgress= fn
57
+ @@callbackProgress = fn
58
+ end
59
+ def self.callbackSpeedOfTransfert= fn
60
+ @@callbackSpeedOfTransfert = fn
61
+ end
62
+
63
+ def self.crossWiringValue
64
+ return @@crossWiringValue
65
+ end
66
+
67
+ def self.id=id
68
+ if (id < 0) then
69
+ raise ERROR::HARDSPLOIT_NOT_FOUND
70
+ else
71
+ @@id = id
72
+ end
73
+ end
74
+
75
+ def initialize
76
+ if @@callbackData == nil or @@callbackInfo == nil or @@callbackProgress == nil or @@callbackSpeedOfTransfert == nil then
77
+ raise "Error you need to specify callbackData callbackInfo callbackProgress callbackSpeedOfTransfert first"
78
+ else
79
+ #Default wiring
80
+ for i in 0..63
81
+ @@crossWiringValue.push i
82
+ end
83
+ self.connect
84
+ puts "Hardsploit is connected".green.bold
85
+ end
86
+ end
87
+
88
+ # Set the leds of uC returning nothing
89
+ # * +led+:: USB_COMMAND::GREEN_LED or USB_COMMAND::RED_LED
90
+ # * +state+:: callback to return +data for dump function+
91
+ def setStatutLed(led:,state:)
92
+ packet_send = Array.new
93
+ packet_send.push 0 #size set before send automatic
94
+ packet_send.push 0 #size set before send automatic
95
+ packet_send.push HardsploitAPI.lowByte(word:led)
96
+ packet_send.push HardsploitAPI.highByte(word:led)
97
+ packet_send.push (state ? 1 : 0)
98
+ return sendPacket(packet_send)
99
+ end
100
+
101
+
102
+ # Set custom value to wiring led
103
+ # * +value+:: 64 bits (8x8 Bytes) values to represent led (PortH PortG PortF PortE PortD PortC PortB PortA)
104
+ def setWiringLeds(value:)
105
+ # parametters = HardsploitAPI.checkParametters(["value"],args)
106
+ # val = parametters[:value]
107
+
108
+ packet = Array.new
109
+ packet.push 0 #low byte of lenght of trame refresh automaticly before send by usb
110
+ packet.push 0 #high byte of lenght of trame refresh automaticly before send by usb
111
+ packet.push HardsploitAPI.lowByte(word:USB_COMMAND::FPGA_COMMAND)
112
+ packet.push HardsploitAPI.highByte(word:USB_COMMAND::FPGA_COMMAND)
113
+
114
+ packet.push 0x23 #Command SPI write wiring led
115
+
116
+ packet.push HardsploitAPI.reverseBit((value & 0x00000000000000FF) >> 0)
117
+ packet.push HardsploitAPI.reverseBit((value & 0x000000000000FF00) >> 8 )
118
+ packet.push HardsploitAPI.reverseBit((value & 0x0000000000FF0000) >> 16 )
119
+ packet.push HardsploitAPI.reverseBit((value & 0x00000000FF000000) >> 24 )
120
+ packet.push HardsploitAPI.reverseBit((value & 0x000000FF00000000) >> 32 )
121
+ packet.push HardsploitAPI.reverseBit((value & 0x0000FF0000000000) >> 40 )
122
+ packet.push HardsploitAPI.reverseBit((value & 0x00FF000000000000) >> 48 )
123
+ packet.push HardsploitAPI.reverseBit((value & 0xFF00000000000000) >> 56 )
124
+
125
+ return HardsploitAPI.instance.sendPacket(packet)
126
+ end
127
+
128
+ # Obtaint the version number of the board
129
+ def getVersionNumber
130
+ packet = Array.new
131
+ packet.push 0 #low byte of lenght of trame refresh automaticly before send by usb
132
+ packet.push 0 #high byte of lenght of trame refresh automaticly before send by usb
133
+ packet.push HardsploitAPI.lowByte(word:USB_COMMAND::GET_VERSION_NUMBER)
134
+ packet.push HardsploitAPI.highByte(word:USB_COMMAND::GET_VERSION_NUMBER)
135
+
136
+ #remove header
137
+ version_number = self.sendAndReceiveDATA(packet,1000).drop(4)
138
+ if version_number.size < 20 then #if size more thant 20 char error when reading version number
139
+ return version_number.pack('U*')
140
+ else
141
+ return "BAD VERSION NUMBER"
142
+ end
143
+ end
144
+
145
+ def getAllVersions
146
+ puts "API : #{VERSION::API}".blue.bold
147
+ puts "Board : #{getVersionNumber}".blue.bold
148
+ puts "FPGA : #{VersionFPGA::VERSION_FPGA::FPGA}".blue.bold
149
+ puts "Microcontroller : #{VersionUC::VERSION_UC::UC}".blue.bold
150
+ end
151
+
152
+ def self.reverseBit(byte)
153
+ return byte.to_s(2).rjust(8, "0").reverse.to_i(2)
154
+ end
155
+
156
+ # Set cross wiring
157
+ # * +value+:: 64*8 bits to represent wiring
158
+ def setCrossWiring(value:)
159
+ if not value.size == 64 then
160
+ raise HardsploitAPI::ERROR::API_CROSS_WIRING
161
+ end
162
+
163
+ packet = Array.new
164
+ packet.push 0 #low byte of lenght of trame refresh automaticly before send by usb
165
+ packet.push 0 #high byte of lenght of trame refresh automaticly before send by usb
166
+ packet.push HardsploitAPI.lowByte(word:USB_COMMAND::FPGA_COMMAND)
167
+ packet.push HardsploitAPI.highByte(word:USB_COMMAND::FPGA_COMMAND)
168
+
169
+ packet.push 0x75 #Cross wiring command
170
+ packet.push *value
171
+ @@crossWiringValue = value
172
+ return self.sendPacket(packet)
173
+ end
174
+
175
+ def self.allPosibility(numberOfConnectedPinFromA0:,numberOfSignalsForBus:)
176
+ if numberOfConnectedPinFromA0 < numberOfSignalsForBus then
177
+ raise HardsploitAPI::ERROR::API_SCANNER_WRONG_PIN_NUMBER
178
+ end
179
+ a = Array.new
180
+ for i in 0..numberOfConnectedPinFromA0-1
181
+ a.push i
182
+ end
183
+ return a.permutation.to_a
184
+ end
185
+
186
+ def self.prepare_packet
187
+ packet = []
188
+ packet.push 0 #low byte of lenght of trame refresh automaticly before send by usb
189
+ packet.push 0 #high byte of lenght of trame refresh automaticly before send by usb
190
+ packet.push HardsploitAPI.lowByte(word:HardsploitAPI::USB_COMMAND::FPGA_COMMAND)
191
+ packet.push HardsploitAPI.highByte(word:HardsploitAPI::USB_COMMAND::FPGA_COMMAND)
192
+ packet.push 0x50 #Command RAW COMMUNICATION TO FPGA FIFO
193
+ return packet
194
+ end
195
+
196
+ #call back
197
+ def consoleProgress(percent:,startTime:,endTime:)
198
+ @@callbackProgress.call(percent:percent,startTime:startTime,endTime:endTime)
199
+ end
200
+ def consoleData(value)
201
+ @@callbackData.call(value)
202
+ end
203
+ def consoleSpeed(value)
204
+ @@callbackSpeedOfTransfert.call(value)
205
+ end
206
+ def consoleInfo(value)
207
+ @@callbackInfo.call(value)
208
+ end
209
+
210
+ end
@@ -0,0 +1,150 @@
1
+ #!/usr/bin/ruby
2
+ #===================================================
3
+ # Hardsploit API - By Opale Security
4
+ # www.opale-security.com || www.hardsploit.io
5
+ # License: GNU General Public License v3
6
+ # License URI: http://www.gnu.org/licenses/gpl.txt
7
+ #===================================================
8
+
9
+ class HardsploitAPI
10
+ public
11
+
12
+ # Obtain signal Id
13
+ # Params:
14
+ # +signal+:: Name of signal you want obtain ud
15
+ def self.getSignalId(signal:)
16
+ wires = Hash.new
17
+
18
+ #Parallel module
19
+ wires["A0"] = 0
20
+ wires["A1"] = 1
21
+ wires["A2"] = 2
22
+ wires["A3"] = 3
23
+ wires["A4"] = 4
24
+ wires["A5"] = 5
25
+ wires["A6"] = 6
26
+ wires["A7"] = 7
27
+ wires["A8"] = 8
28
+ wires["A9"] = 9
29
+ wires["A10"] = 10
30
+ wires["A11"] = 11
31
+ wires["A12"] = 12
32
+ wires["A13"] = 13
33
+ wires["A14"] = 14
34
+ wires["A15"] = 15
35
+ wires["A16"] = 16
36
+ wires["A17"] = 17
37
+ wires["A18"] = 18
38
+ wires["A19"] = 19
39
+ wires["A20"] = 20
40
+ wires["A21"] = 21
41
+ wires["A22"] = 22
42
+ wires["A23"] = 23
43
+ wires["A24"] = 24
44
+ wires["A25"] = 25
45
+ wires["A26"] = 26
46
+ wires["A27"] = 27
47
+ wires["A28"] = 28
48
+ wires["A29"] = 29
49
+ wires["A30"] = 30
50
+ wires["A31"] = 31
51
+
52
+ wires["D0"] = 32
53
+ wires["D1"] = 33
54
+ wires["D2"] = 34
55
+ wires["D3"] = 35
56
+ wires["D4"] = 36
57
+ wires["D5"] = 37
58
+ wires["D6"] = 38
59
+ wires["D7"] = 39
60
+ wires["D8"] = 40
61
+ wires["D9"] = 41
62
+ wires["D10"] = 42
63
+ wires["D11"] = 43
64
+ wires["D12"] = 44
65
+ wires["D13"] = 45
66
+ wires["D14"] = 46
67
+ wires["D15"] = 47
68
+
69
+ wires["RST"] = 48
70
+ wires["CE"] = 49
71
+ wires["OE"] = 50
72
+ wires["WE"] = 51
73
+ wires["PARA_CLK"] = 52
74
+ wires["WP"] = 53
75
+ wires["ADV"] = 54
76
+
77
+ #SPI module
78
+ wires["SPI_CLK"] = 0
79
+ wires["CS"] = 1
80
+ wires["MOSI"] = 2
81
+ wires["MISO"] = 3
82
+ wires["PULSE"] = 4
83
+
84
+ #I2C module
85
+ wires["I2C_CLK"] = 0
86
+ wires["SDA"] = 1
87
+
88
+ #UART module
89
+ wires["TX"] = 0
90
+ wires["RX"] = 1
91
+
92
+ #SWD module
93
+ wires["SWD_CLK"] = 0
94
+ wires["SWD_IO"] = 1
95
+
96
+ return wires[signal]
97
+ end
98
+
99
+ # Power on the led for each signal specified
100
+ # Params:
101
+ # +signal+:: Name of signal you want visual help (set the led)
102
+ def signalHelpingWiring(signal:)
103
+ begin
104
+ HardsploitAPI.instance.setWiringLeds(value:2**HardsploitAPI.crossWiringValue.index(HardsploitAPI.getSignalId(signal:signal)))
105
+ rescue
106
+ raise 'UNKNOWN SIGNAL'
107
+ end
108
+ end
109
+
110
+ module USB_COMMAND
111
+ GREEN_LED = 0
112
+ RED_LED = 1
113
+ LOOPBACK = 2
114
+ ERASE_FIRMWARE = 3
115
+ WRITE_PAGE_FIRMWARE = 4
116
+ READ_PAGE_FIRMWARE = 5
117
+ READ_ID_FLASH = 6
118
+ START_FPGA = 7
119
+ STOP_FPGA = 8
120
+ FPGA_COMMAND = 9
121
+ FPGA_DATA = 10
122
+ STOP_FPGA_DATA = 11
123
+ START_FPGA_DATA = 12
124
+ GET_SERIAL_NUMBER = 13
125
+ GET_VERSION_NUMBER = 14
126
+ VCP_ERROR = 0xFFFF
127
+ end
128
+
129
+ module I2C
130
+ KHZ_100 = 0
131
+ KHZ_400 = 1
132
+ KHZ_1000 = 2
133
+ KHZ_40 = 3
134
+ end
135
+
136
+ module SPISniffer
137
+ MOSI = 1
138
+ MISO = 2
139
+ MISO_MOSI = 3
140
+ end
141
+
142
+ module USB
143
+ OUT_ENDPOINT = 0X02
144
+ IN_ENDPOINT = 0X81
145
+ USB_TRAME_SIZE = 8192
146
+ end
147
+ module VERSION
148
+ API = "2.0.0"
149
+ end
150
+ end
@@ -0,0 +1,109 @@
1
+ #!/usr/bin/ruby
2
+ #===================================================
3
+ # Hardsploit API - By Opale Security
4
+ # www.opale-security.com || www.hardsploit.io
5
+ # License: GNU General Public License v3
6
+ # License URI: http://www.gnu.org/licenses/gpl.txt
7
+ #===================================================
8
+
9
+ class HardsploitAPI
10
+ module ERROR
11
+ class Standard < StandardError; end
12
+
13
+ class HARDSPLOIT_NOT_FOUND < Standard
14
+ def initialize(msg="HARDSPLOIT NOT FOUND")
15
+ super(msg)
16
+ end
17
+ end
18
+ class API_CROSS_WIRING < Standard
19
+ def initialize(msg="The crossWiring array must be a 64 items array")
20
+ super(msg)
21
+ end
22
+ end
23
+ class API_SCANNER_WRONG_PIN_NUMBER < Standard
24
+ def initialize(msg="You need to connect more thant pins needed by the module 2 for swd, 2 for I2C etc")
25
+ super(msg)
26
+ end
27
+ end
28
+ class FileIssue < Standard
29
+ def initialize(msg="Issue with file")
30
+ super(msg)
31
+ end
32
+ end
33
+
34
+ class I2CWrongSpeed < Standard
35
+ def initialize(msg="Uknown speed, speed must be KHZ_100 = 0, KHZ_400 = 1,KHZ_1000 = 2")
36
+ super(msg)
37
+ end
38
+ end
39
+ class SPIWrongPulse < Standard
40
+ def initialize(msg="Wrong, Pulse must be 0 or 1")
41
+ super(msg)
42
+ end
43
+ end
44
+ class SPIWrongSpeed < Standard
45
+ def initialize(msg="Speed must be between 3 and 255")
46
+ super(msg)
47
+ end
48
+ end
49
+ class SPIWrongMode < Standard
50
+ def initialize(msg="Mode must be between 0 and 3")
51
+ super(msg)
52
+ end
53
+ end
54
+
55
+ class SPIWrongPayloadSize < Standard
56
+ def initialize(msg="Size of the data need to be less than 4000")
57
+ super(msg)
58
+ end
59
+ end
60
+
61
+ class WrongStartAddress < Standard
62
+ def initialize(msg="Start address can't be negative and not more than size max - 1")
63
+ super(msg)
64
+ end
65
+ end
66
+
67
+ class SpiError < Standard
68
+ def initialize(msg="Error during SPI processing")
69
+ super(msg)
70
+ end
71
+ end
72
+
73
+ class USB_PACKET_IS_TOO_LARGE < Standard
74
+ def initialize(msg="USB_PACKET_IS_TOO_LARGE")
75
+ super(msg)
76
+ end
77
+ end
78
+
79
+ class USB_ERROR < Standard
80
+ def initialize(msg="USB ERROR")
81
+ super(msg)
82
+ end
83
+ end
84
+
85
+ class SWD_ERROR < Standard
86
+ def initialize(msg="SWD ERROR, WAIT, FAUL, ACK or something like that")
87
+ super(msg)
88
+ end
89
+ end
90
+
91
+ class UART_WrongSettings < Standard
92
+ def initialize(msg="Wrong UART settings")
93
+ super(msg)
94
+ end
95
+ end
96
+
97
+ class UART_WrongTxPayloadSize < Standard
98
+ def initialize(msg="Wrong TX payload size")
99
+ super(msg)
100
+ end
101
+ end
102
+
103
+ class UART_WrongPayloadSize < Standard
104
+ def initialize(msg="Size of the data need to be less than 4000")
105
+ super(msg)
106
+ end
107
+ end
108
+ end
109
+ end