hardsploit_gui 2.3 → 2.4.0

Sign up to get free protection for your applications and to get access to all the features.
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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 740436397cfcd4b59bb8dfb2f56f553eec501a91
4
- data.tar.gz: 426ea68b4a548332b7b77118e1ad3216cfee823f
3
+ metadata.gz: 33cac9a06b6835cd33abb3a2b9937152f2d9d0f1
4
+ data.tar.gz: 0cd2a410c28964b3cbd40be6a1ccfe533e4d7fa7
5
5
  SHA512:
6
- metadata.gz: bdacc3c5aecaafd699973412afde50e6e8aaefc822aeca401e94b522e0dfc8125ce46670143a76fc87f7335dcb2d4789b7aee58bd327a4eaef677f5cf34468cc
7
- data.tar.gz: 3c93bed4532a6c89d161f6f229035e6b32733da62693f60f012f8c20c33303cebd33805ac81d87455bbdadef3ca671ed68810438383b5da18400f65e66f6f741
6
+ metadata.gz: 2356ccef654cc626ba4ab9b23e50708727f73233d0b46d92e61a0ac11f468f8b2d4a4faf03995f6a383289ef4eb6a110e47940bfc8a979d19209dc0557936e30
7
+ data.tar.gz: 1ec86ba60d5fffe6c512c6bf0709a595ad24f702507fbc521e9dfc5c7dfe341c1c335c33f1d78946272be9a7302b5b66c7a3a8053d5c9bfab080cc08525d996b
data/README.md CHANGED
@@ -1,22 +1,22 @@
1
- # Hardsploit
2
-
3
- The essential security auditing tool for Internet of Things devices you'll need in your toolbox
4
-
5
- ### [GO TO HARDSPLOIT](http://www.hardsploit.io)
6
-
7
- TO LEARN ABOUT IT
8
-
9
- ### [GO TO SHOP](https://www.shop-hardsploit.com)
10
- TO BUY
11
-
12
- ### [GO TO WIKI](http://wiki.hardsploit.io)
13
-
14
- TO UNDERSTAND HOW USE IT
15
-
16
- ### [GO TO FORUM](http://forum.hardsploit.io)
17
-
18
- FOR SUPPORT / HELP
19
-
20
- ### [GO TO BUG TRACKER] (http://issues.hardsploit.io)
21
-
22
- FOR BUGS OR IMPROVEMENTS
1
+ # Hardsploit
2
+
3
+ The essential security auditing tool for Internet of Things devices you'll need in your toolbox
4
+
5
+ ### [GO TO HARDSPLOIT](http://www.hardsploit.io)
6
+
7
+ TO LEARN ABOUT IT
8
+
9
+ ### [GO TO SHOP](https://www.shop-hardsploit.com)
10
+ TO BUY
11
+
12
+ ### [GO TO WIKI](http://wiki.hardsploit.io)
13
+
14
+ TO UNDERSTAND HOW USE IT
15
+
16
+ ### [GO TO FORUM](http://forum.hardsploit.io)
17
+
18
+ FOR SUPPORT / HELP
19
+
20
+ ### [GO TO BUG TRACKER] (http://issues.hardsploit.io)
21
+
22
+ FOR BUGS OR IMPROVEMENTS
data/Rakefile CHANGED
@@ -1 +1 @@
1
- require "bundler/gem_tasks"
1
+ require "bundler/gem_tasks"
data/bin/hardsploit_gui CHANGED
@@ -1,3 +1,3 @@
1
- #!/usr/bin/env ruby
2
- require 'Hardsploit_gui'
3
- Hardsploit_gui.new
1
+ #!/usr/bin/env ruby
2
+ require "Hardsploit_gui"
3
+ Hardsploit_gui.new
@@ -1,5 +1,5 @@
1
- class VersionFPGA
2
- module VERSION_FPGA
3
- FPGA = "V1.2.0"
4
- end
5
- end
1
+ class VersionFPGA
2
+ module VERSION_FPGA
3
+ FPGA = "V1.2.0"
4
+ end
5
+ end
@@ -1,12 +1,12 @@
1
- #===================================================
2
- # Hardsploit UC - 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
- class VersionUC
9
- module VERSION_UC
10
- UC = "V1.0.3"
11
- end
12
- end
1
+ #===================================================
2
+ # Hardsploit UC - 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
+ class VersionUC
9
+ module VERSION_UC
10
+ UC = "V1.0.3"
11
+ end
12
+ end
@@ -1,210 +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
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