hardsploit_gui 2.4.0 → 2.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/Hardsploit_gui.rb +4 -5
- data/lib/class/Chip_clone.rb +70 -0
- data/lib/class/Chip_editor.rb +1 -0
- data/lib/class/Chip_management.rb +73 -52
- data/lib/class/ErrorMsg.rb +1 -0
- data/lib/class/Firmware.rb +1 -1
- data/lib/class/Progress_bar.rb +1 -1
- data/lib/class/Wire_helper.rb +6 -3
- data/lib/class/{I2C → i2c}/I2c_command.rb +0 -0
- data/lib/class/{I2C/I2c_export.rb → i2c/I2c_read.rb} +15 -15
- data/lib/class/{I2C → i2c}/I2c_scanner.rb +2 -1
- data/lib/class/{I2C → i2c}/I2c_settings.rb +1 -0
- data/lib/class/{I2C/I2c_import.rb → i2c/I2c_write.rb} +13 -12
- data/lib/class/{PARALLEL/Parallel_export.rb → parallel/Parallel_read.rb} +17 -18
- data/lib/class/{PARALLEL → parallel}/Parallel_settings.rb +0 -0
- data/lib/class/{PARALLEL/Parallel_import.rb → parallel/Parallel_write.rb} +11 -10
- data/lib/class/{SPI/Spi_export.rb → spi/Spi_read.rb} +15 -15
- data/lib/class/{SPI → spi}/Spi_settings.rb +0 -0
- data/lib/class/{SPI → spi}/Spi_sniffer.rb +2 -1
- data/lib/class/{SPI/Spi_import.rb → spi/Spi_write.rb} +13 -12
- data/lib/class/swd/Swd.rb +10 -10
- data/lib/class/swd/Swd_scanner.rb +2 -1
- data/lib/class/uart/Uart_baudrate.rb +1 -1
- data/lib/class/uart/Uart_console.rb +1 -1
- data/lib/class/uart/Uart_settings.rb +1 -0
- data/lib/db/development.sqlite3 +0 -0
- data/lib/gui/gui_chip_clone.rb +87 -0
- data/lib/gui/gui_chip_editor.rb +349 -349
- data/lib/gui/gui_chip_management.rb +378 -377
- data/lib/gui/gui_command_editor.rb +219 -219
- data/lib/gui/gui_export.rb +132 -132
- data/lib/gui/gui_export_manager.rb +93 -93
- data/lib/gui/gui_generic_commands.rb +202 -202
- data/lib/gui/gui_generic_read.rb +185 -0
- data/lib/gui/gui_generic_write.rb +142 -0
- data/lib/gui/gui_i2c_command.rb +116 -116
- data/lib/gui/gui_i2c_settings.rb +242 -230
- data/lib/gui/gui_import.rb +131 -131
- data/lib/gui/gui_parallel_settings.rb +195 -195
- data/lib/gui/gui_progress_bar.rb +85 -85
- data/lib/gui/gui_signal_mapper.rb +121 -121
- data/lib/gui/gui_signal_scanner.rb +146 -146
- data/lib/gui/gui_spi_settings.rb +313 -313
- data/lib/gui/gui_spi_sniffer.rb +112 -112
- data/lib/gui/gui_swd_settings.rb +166 -166
- data/lib/gui/gui_uart_baudrate.rb +114 -114
- data/lib/gui/gui_uart_console.rb +164 -164
- data/lib/gui/gui_uart_settings.rb +243 -243
- data/lib/gui/gui_wire_helper.rb +99 -99
- data/lib/gui_designer/compile_to_ruby.sh +14 -0
- data/lib/gui_designer/gui_chip_clone.ui +96 -0
- data/lib/gui_designer/gui_chip_management.ui +25 -22
- data/lib/gui_designer/{gui_generic_export.ui → gui_generic_read.ui} +152 -72
- data/lib/gui_designer/{gui_generic_import.ui → gui_generic_write.ui} +47 -47
- data/lib/gui_designer/gui_i2c_settings.ui +68 -60
- data/lib/hardsploit-api/Examples/swdProgrammer.rb +76 -0
- data/lib/hardsploit-api/Examples/testI2C.rb +183 -0
- data/lib/hardsploit-api/Examples/testNRF24L01.rb +122 -0
- data/lib/hardsploit-api/Examples/testParralel.rb +84 -0
- data/lib/hardsploit-api/Examples/testSPI.rb +113 -0
- data/lib/hardsploit-api/Examples/testSPISniffer.rb +91 -0
- data/lib/hardsploit-api/Examples/testSWD.rb +224 -0
- data/lib/hardsploit-api/Examples/testUARTBufferOverflow.rb +113 -0
- data/lib/hardsploit-api/Examples/testUARTConsole.rb +74 -0
- data/lib/hardsploit-api/Examples/testUARTFuzzer.rb +109 -0
- data/lib/{Firmwares → hardsploit-api/Firmwares}/FPGA/I2C/I2C_INTERACT/HARDSPLOIT_FIRMWARE_FPGA_I2C_INTERACT.rpd +0 -0
- data/lib/{Firmwares → hardsploit-api/Firmwares}/FPGA/PARALLEL/NO_MUX_PARALLEL_MEMORY/HARDSPLOIT_FIRMWARE_FPGA_NO_MUX_PARALLEL_MEMORY.rpd +0 -0
- data/lib/{Firmwares → hardsploit-api/Firmwares}/FPGA/SPI/SPI_INTERACT/HARDSPLOIT_FIRMWARE_FPGA_SPI_INTERACT.rpd +0 -0
- data/lib/{Firmwares → hardsploit-api/Firmwares}/FPGA/SPI/SPI_SNIFFER/HARDSPLOIT_FIRMWARE_FPGA_SPI_SNIFFER.rpd +0 -0
- data/lib/{Firmwares → hardsploit-api/Firmwares}/FPGA/SWD/SWD_INTERACT/HARDSPLOIT_FIRMWARE_FPGA_SWD_INTERACT.rpd +0 -0
- data/lib/{Firmwares → hardsploit-api/Firmwares}/FPGA/TEST/TEST_INTERACT/HARDSPLOIT_FIRMWARE_FPGA_TEST_INTERACT.rpd +0 -0
- data/lib/{Firmwares → hardsploit-api/Firmwares}/FPGA/UART/UART_INTERACT/HARDSPLOIT_FIRMWARE_FPGA_UART_INTERACT.rpd +0 -0
- data/lib/{Firmwares → hardsploit-api/Firmwares}/FPGA/VersionFPGA.rb +0 -0
- data/lib/{Firmwares → hardsploit-api/Firmwares}/UC/HARDSPLOIT_FIRMWARE_UC.bin +0 -0
- data/lib/{Firmwares → hardsploit-api/Firmwares}/UC/VersionUC.rb +0 -0
- data/lib/{HardsploitAPI → hardsploit-api/HardsploitAPI}/Core/HardsploitAPI.rb +0 -0
- data/lib/{HardsploitAPI → hardsploit-api/HardsploitAPI}/Core/HardsploitAPI_CONSTANT.rb +0 -0
- data/lib/{HardsploitAPI → hardsploit-api/HardsploitAPI}/Core/HardsploitAPI_ERROR.rb +0 -0
- data/lib/{HardsploitAPI → hardsploit-api/HardsploitAPI}/Core/HardsploitAPI_FIRMWARE.rb +0 -0
- data/lib/{HardsploitAPI → hardsploit-api/HardsploitAPI}/Core/HardsploitAPI_PROGRESS.rb +0 -0
- data/lib/{HardsploitAPI → hardsploit-api/HardsploitAPI}/Core/HardsploitAPI_USB_COMMUNICATION.rb +0 -0
- data/lib/{HardsploitAPI → hardsploit-api/HardsploitAPI}/Modules/I2C/HardsploitAPI_I2C.rb +0 -0
- data/lib/{HardsploitAPI → hardsploit-api/HardsploitAPI}/Modules/NO_MUX_PARALLEL_MEMORY/HardsploitAPI_NO_MUX_PARALLEL_MEMORY.rb +0 -0
- data/lib/{HardsploitAPI → hardsploit-api/HardsploitAPI}/Modules/NRF24L01/HardsploitAPI_NRF24L01.rb +0 -0
- data/lib/{HardsploitAPI → hardsploit-api/HardsploitAPI}/Modules/SPI/HardsploitAPI_SPI.rb +0 -0
- data/lib/{HardsploitAPI → hardsploit-api/HardsploitAPI}/Modules/SPI_SNIFFER/HardsploitAPI_SPI_SNIFFER.rb +0 -0
- data/lib/{HardsploitAPI → hardsploit-api/HardsploitAPI}/Modules/SWD/HardsploitAPI_SWD.rb +0 -0
- data/lib/{HardsploitAPI → hardsploit-api/HardsploitAPI}/Modules/SWD/HardsploitAPI_SWD_DEBUG.rb +0 -0
- data/lib/{HardsploitAPI → hardsploit-api/HardsploitAPI}/Modules/SWD/HardsploitAPI_SWD_MEM_AP.rb +0 -0
- data/lib/{HardsploitAPI → hardsploit-api/HardsploitAPI}/Modules/SWD/HardsploitAPI_SWD_STM32.rb +0 -0
- data/lib/{HardsploitAPI → hardsploit-api/HardsploitAPI}/Modules/TEST/HardsploitAPI_TEST_INTERACT.rb +0 -0
- data/lib/{HardsploitAPI → hardsploit-api/HardsploitAPI}/Modules/UART/HardsploitAPI_UART.rb +0 -0
- data/lib/hardsploit-api/LICENSE.txt +674 -0
- data/lib/hardsploit-api/README.md +22 -0
- data/lib/hardsploit-api/TRADEMARK +3 -0
- data/lib/logs/error.log +80 -0
- metadata +65 -49
- data/lib/gui/gui_generic_export.rb +0 -164
- data/lib/gui/gui_generic_import.rb +0 -142
- data/lib/gui/gui_spi_import.rb +0 -126
@@ -0,0 +1,183 @@
|
|
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
|
+
require 'io/console'
|
9
|
+
require_relative '../HardsploitAPI/Core/HardsploitAPI'
|
10
|
+
require_relative '../HardsploitAPI/Modules/I2C/HardsploitAPI_I2C'
|
11
|
+
|
12
|
+
def callbackInfo(receiveData)
|
13
|
+
#print receiveData + "\n"
|
14
|
+
end
|
15
|
+
|
16
|
+
def callbackData(receiveData)
|
17
|
+
if receiveData != nil then
|
18
|
+
puts "received #{receiveData.size}"
|
19
|
+
p receiveData
|
20
|
+
else
|
21
|
+
puts "ISSUE BECAUSE DATA IS NIL"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def callbackSpeedOfTransfert(receiveData)
|
26
|
+
#puts "Speed : #{receiveData}"
|
27
|
+
end
|
28
|
+
|
29
|
+
def callbackProgress(percent:,startTime:,endTime:)
|
30
|
+
print "\r\e[#{31}mUpload of FPGA firmware in progress : #{percent}%\e[0m"
|
31
|
+
#puts "Progress : #{percent}% Start@ #{startTime} Stop@ #{endTime}"
|
32
|
+
#puts "Elasped time #{(endTime-startTime).round(4)} sec"
|
33
|
+
end
|
34
|
+
|
35
|
+
#puts "Number of hardsploit detected :#{HardsploitAPI.getNumberOfBoardAvailable}"
|
36
|
+
|
37
|
+
HardsploitAPI.callbackInfo = method(:callbackInfo)
|
38
|
+
HardsploitAPI.callbackData = method(:callbackData)
|
39
|
+
HardsploitAPI.callbackSpeedOfTransfert = method(:callbackSpeedOfTransfert)
|
40
|
+
HardsploitAPI.callbackProgress = method(:callbackProgress)
|
41
|
+
HardsploitAPI.id = 0 # id of hardsploit 0 for the first one, 1 for the second etc
|
42
|
+
|
43
|
+
HardsploitAPI.instance.getAllVersions
|
44
|
+
|
45
|
+
if ARGV[0] != "nofirmware" then
|
46
|
+
HardsploitAPI.instance.loadFirmware("I2C")
|
47
|
+
end
|
48
|
+
|
49
|
+
def i2cCustomScan
|
50
|
+
begin
|
51
|
+
#Create an instance of I2C
|
52
|
+
i2c = HardsploitAPI_I2C.new(speed:HardsploitAPI::I2C::KHZ_100)
|
53
|
+
|
54
|
+
#Change the speed
|
55
|
+
i2c.speed = HardsploitAPI::I2C::KHZ_100
|
56
|
+
|
57
|
+
#scan I2C
|
58
|
+
puts "I2C SCAN :"
|
59
|
+
scan_result = i2c.i2c_Scan
|
60
|
+
#check parity of array index to know if a Read or Write address
|
61
|
+
# Index 0 is write address because is is even
|
62
|
+
# Index 1 is read address because it is odd
|
63
|
+
|
64
|
+
# Index 160 (0xA0) is write address because is is even
|
65
|
+
# Index 161 (0xA1) is read address because is is odd
|
66
|
+
|
67
|
+
#If value is 0 slave address is not available
|
68
|
+
#If valude is 1 slave address is available
|
69
|
+
|
70
|
+
for i in (0..scan_result.size-1) do
|
71
|
+
if scan_result[i] == 1 then
|
72
|
+
puts " #{(i).to_s(16)} #{scan_result[i]}"
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
rescue HardsploitAPI::ERROR::HARDSPLOIT_NOT_FOUND
|
77
|
+
puts "Hardsploit not found"
|
78
|
+
rescue HardsploitAPI::ERROR::USB_ERROR
|
79
|
+
puts "USB ERRROR"
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def i2cCustomInteract
|
84
|
+
begin
|
85
|
+
#Create an instance of I2C
|
86
|
+
i2c = HardsploitAPI_I2C.new(speed:HardsploitAPI::I2C::KHZ_100)
|
87
|
+
|
88
|
+
testpack = Array.new
|
89
|
+
|
90
|
+
#interact I2C
|
91
|
+
# write with even address
|
92
|
+
# read with odd address
|
93
|
+
|
94
|
+
#Write 4 bytes at 0x00 0x00
|
95
|
+
# testpack.push HardAPI.lowByte(4) #Count Low Byte
|
96
|
+
# testpack.push HardAPI.highByte(4) #Count High Byte
|
97
|
+
# testpack.push 0xA0
|
98
|
+
# testpack.push 41 #First data byte
|
99
|
+
# testpack.push 42 #Second data byte
|
100
|
+
# testpack.push 43
|
101
|
+
# testpack.push 44
|
102
|
+
|
103
|
+
|
104
|
+
#Write pointer of I2C memorie at 0x00 0x00
|
105
|
+
# testpack.push HardsploitAPI.lowByte(word:2) #Count Low Byte
|
106
|
+
# testpack.push HardsploitAPI.highByte(word:2) #Count High Byte
|
107
|
+
# testpack.push 0xA0
|
108
|
+
# testpack.push 0x00
|
109
|
+
# testpack.push 0x00
|
110
|
+
|
111
|
+
testpack.push HardsploitAPI.lowByte(word:2) #Count Low Byte
|
112
|
+
testpack.push HardsploitAPI.highByte(word:2) #Count High Byte
|
113
|
+
testpack.push 0xA0
|
114
|
+
testpack.push 0x00
|
115
|
+
testpack.push 0x00
|
116
|
+
|
117
|
+
testpack.push HardsploitAPI.lowByte(word:4) #Count Low Byte
|
118
|
+
testpack.push HardsploitAPI.highByte(word:4) #Count High Byte
|
119
|
+
testpack.push 0xA1
|
120
|
+
|
121
|
+
|
122
|
+
|
123
|
+
|
124
|
+
begin
|
125
|
+
#result contient les ACK NACK ou les data si dispo cf wiki
|
126
|
+
# https://github.com/OPALESECURITY/hardsploit-api/wiki#i2c-interact
|
127
|
+
result = i2c.i2c_Interact(payload:testpack)
|
128
|
+
p result
|
129
|
+
rescue HardsploitAPI::ERROR::USB_ERROR
|
130
|
+
puts "Error during USB communication, please retry"
|
131
|
+
end
|
132
|
+
|
133
|
+
rescue HardsploitAPI::ERROR::HARDSPLOIT_NOT_FOUND
|
134
|
+
puts "Hardsploit not found"
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
while true
|
139
|
+
char = STDIN.getch
|
140
|
+
puts char
|
141
|
+
if char == "\u0003"
|
142
|
+
puts "Finished"
|
143
|
+
exit
|
144
|
+
|
145
|
+
elsif char == "z" then
|
146
|
+
crossvalue = Array.new
|
147
|
+
#Default wiring
|
148
|
+
for i in 0..63
|
149
|
+
crossvalue.push i
|
150
|
+
end
|
151
|
+
|
152
|
+
#swap 2 first signal
|
153
|
+
crossvalue[0] = 8
|
154
|
+
crossvalue[1] = 9
|
155
|
+
|
156
|
+
crossvalue[8] = 0
|
157
|
+
crossvalue[9] = 1
|
158
|
+
|
159
|
+
HardsploitAPI.instance.setCrossWiring(value:crossvalue)
|
160
|
+
|
161
|
+
puts "cross SWAP"
|
162
|
+
|
163
|
+
elsif char == "e" then
|
164
|
+
crossvalue = Array.new
|
165
|
+
#Default wiring
|
166
|
+
for i in 0..63
|
167
|
+
crossvalue.push i
|
168
|
+
end
|
169
|
+
HardsploitAPI.instance.setCrossWiring(value:crossvalue)
|
170
|
+
puts "cross Normal"
|
171
|
+
|
172
|
+
elsif char == "w" then
|
173
|
+
HardsploitAPI.instance.setStatutLed(led:HardsploitAPI::USB_COMMAND::GREEN_LED,state:true);
|
174
|
+
elsif char == "x" then
|
175
|
+
HardsploitAPI.instance.setStatutLed(led:HardsploitAPI::USB_COMMAND::GREEN_LED,state:false);
|
176
|
+
elsif char == "i" then
|
177
|
+
i2cCustomInteract
|
178
|
+
elsif char == "s" then
|
179
|
+
i2cCustomScan
|
180
|
+
elsif char == "p" then
|
181
|
+
print "Upload Firmware check : #{HardsploitAPI.instance.uploadFirmware(pathFirmware:File.expand_path(File.dirname(__FILE__)) + "/../../HARDSPLOIT-VHDL/Firmware/FPGA/I2C/I2C_INTERACT/HARDSPLOIT_FIRMWARE_FPGA_I2C_INTERACT.rpd",checkFirmware:false)}\n"
|
182
|
+
end
|
183
|
+
end
|
@@ -0,0 +1,122 @@
|
|
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
|
+
require 'io/console'
|
9
|
+
require_relative '../HardsploitAPI/Core/HardsploitAPI'
|
10
|
+
require_relative '../HardsploitAPI/Modules/NRF24L01/HardsploitAPI_NRF24L01'
|
11
|
+
|
12
|
+
def callbackInfo(receiveData)
|
13
|
+
#print receiveData + "\n"
|
14
|
+
end
|
15
|
+
|
16
|
+
def callbackData(receiveData)
|
17
|
+
if receiveData != nil then
|
18
|
+
puts "received #{receiveData.size}"
|
19
|
+
p receiveData
|
20
|
+
else
|
21
|
+
puts "ISSUE BECAUSE DATA IS NIL"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def callbackSpeedOfTransfert(receiveData)
|
26
|
+
#puts "Speed : #{receiveData}"
|
27
|
+
end
|
28
|
+
|
29
|
+
def callbackProgress(percent:,startTime:,endTime:)
|
30
|
+
print "\r\e[#{31}mUpload of FPGA firmware in progress : #{percent}%\e[0m"
|
31
|
+
#puts "Progress : #{percent}% Start@ #{startTime} Stop@ #{endTime}"
|
32
|
+
#puts "Elasped time #{(endTime-startTime).round(4)} sec"
|
33
|
+
end
|
34
|
+
|
35
|
+
puts "Number of hardsploit detected :#{HardsploitAPI.getNumberOfBoardAvailable}"
|
36
|
+
HardsploitAPI.callbackInfo = method(:callbackInfo)
|
37
|
+
HardsploitAPI.callbackData = method(:callbackData)
|
38
|
+
HardsploitAPI.callbackSpeedOfTransfert = method(:callbackSpeedOfTransfert)
|
39
|
+
HardsploitAPI.callbackProgress = method(:callbackProgress)
|
40
|
+
HardsploitAPI.id = 0
|
41
|
+
|
42
|
+
HardsploitAPI.instance.getAllVersions
|
43
|
+
|
44
|
+
if ARGV[0] != "nofirmware" then
|
45
|
+
HardsploitAPI.instance.loadFirmware("SPI")
|
46
|
+
end
|
47
|
+
|
48
|
+
# HARDSPLOIT NRF24L01
|
49
|
+
# SPI_CLK (pin A0) ===> SCK
|
50
|
+
# SPI_CS (pin A1) ===> CSN
|
51
|
+
# SPI_MOSI (pin A2) ===> MOSI
|
52
|
+
# SPI_MISO (pin A3) ===> MISO
|
53
|
+
# SPI_PULSE (pin A4) ===> CE
|
54
|
+
|
55
|
+
begin
|
56
|
+
@nrf = HardsploitAPI_NRF24L01.new
|
57
|
+
if @nrf.reset then
|
58
|
+
#You need to change your channel and you address
|
59
|
+
@nrf.initDrone(channel:98,address:[0x66, 0x88, 0x68, 0x68, 0x68])
|
60
|
+
else
|
61
|
+
raise "NRF24L01 not found"
|
62
|
+
end
|
63
|
+
|
64
|
+
rescue HardsploitAPI::ERROR::HARDSPLOIT_NOT_FOUND
|
65
|
+
puts "Hardsploit not found"
|
66
|
+
rescue HardsploitAPI::ERROR::USB_ERROR
|
67
|
+
puts "USB ERRROR"
|
68
|
+
end
|
69
|
+
|
70
|
+
puts "NRF24L01+"
|
71
|
+
puts "Press p to program hardsploit"
|
72
|
+
puts "Press r to received"
|
73
|
+
puts "Press t to transmit"
|
74
|
+
puts "Press s to sniff all channel"
|
75
|
+
|
76
|
+
while true
|
77
|
+
char = STDIN.getch
|
78
|
+
puts char
|
79
|
+
if char == "\u0003"
|
80
|
+
puts "Finished"
|
81
|
+
exit
|
82
|
+
elsif char == "t" then
|
83
|
+
datat = [0xFF,0xFF]
|
84
|
+
@nrf.Send(datat)
|
85
|
+
puts "Send data"
|
86
|
+
p datat
|
87
|
+
elsif char == "r" then
|
88
|
+
puts "Listen :"
|
89
|
+
while 1
|
90
|
+
data = @nrf.Read
|
91
|
+
if data.size > 0 then
|
92
|
+
p data
|
93
|
+
end
|
94
|
+
end
|
95
|
+
elsif char == "s" then
|
96
|
+
puts "Sniffing in progress :"
|
97
|
+
for i in 90..110
|
98
|
+
@nrf.NRF24L01_FlushTx()
|
99
|
+
@nrf.NRF24L01_FlushRx()
|
100
|
+
@nrf.changeChannel(channel:i)
|
101
|
+
timeoutValue = 1 # timeout in seconds
|
102
|
+
|
103
|
+
#read during 1 second to verify if something is available
|
104
|
+
timeBegin = Time.now
|
105
|
+
while(1)
|
106
|
+
if(Time.now - timeBegin) > timeoutValue then
|
107
|
+
puts "Nothing to read on channel #{i} after #{timeoutValue} second"
|
108
|
+
break
|
109
|
+
end
|
110
|
+
data = @nrf.Read
|
111
|
+
if data.size > 0 then
|
112
|
+
puts "Something is available on channel #{i}, you need to read this channel now"
|
113
|
+
p data
|
114
|
+
break
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
elsif char == "p" then
|
120
|
+
HardsploitAPI.instance.loadFirmware("SPI")
|
121
|
+
end
|
122
|
+
end
|
@@ -0,0 +1,84 @@
|
|
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
|
+
require 'io/console'
|
9
|
+
require_relative '../HardsploitAPI/Core/HardsploitAPI'
|
10
|
+
require_relative '../HardsploitAPI/Modules/NO_MUX_PARALLEL_MEMORY/HardsploitAPI_NO_MUX_PARALLEL_MEMORY'
|
11
|
+
|
12
|
+
def callbackInfo(receiveData)
|
13
|
+
#print receiveData + "\n"
|
14
|
+
end
|
15
|
+
|
16
|
+
def callbackData(receiveData)
|
17
|
+
if receiveData != nil then
|
18
|
+
puts "received #{receiveData.size}"
|
19
|
+
p receiveData
|
20
|
+
else
|
21
|
+
puts "ISSUE BECAUSE DATA IS NIL"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def callbackSpeedOfTransfert(receiveData)
|
26
|
+
#puts "Speed : #{receiveData}"
|
27
|
+
end
|
28
|
+
def callbackProgress(percent:,startTime:,endTime:)
|
29
|
+
print "\r\e[#{31}mUpload of FPGA firmware in progress : #{percent}%\e[0m"
|
30
|
+
#puts "Progress : #{percent}% Start@ #{startTime} Stop@ #{endTime}"
|
31
|
+
#puts "Elasped time #{(endTime-startTime).round(4)} sec"
|
32
|
+
end
|
33
|
+
|
34
|
+
#puts "Number of hardsploit detected :#{HardsploitAPI.getNumberOfBoardAvailable}"
|
35
|
+
|
36
|
+
HardsploitAPI.callbackInfo = method(:callbackInfo)
|
37
|
+
HardsploitAPI.callbackData = method(:callbackData)
|
38
|
+
HardsploitAPI.callbackSpeedOfTransfert = method(:callbackSpeedOfTransfert)
|
39
|
+
HardsploitAPI.callbackProgress = method(:callbackProgress)
|
40
|
+
HardsploitAPI.id = 0 # id of hardsploit 0 for the first one, 1 for the second etc
|
41
|
+
|
42
|
+
HardsploitAPI.instance.getAllVersions
|
43
|
+
|
44
|
+
if ARGV[0] != "nofirmware" then
|
45
|
+
HardsploitAPI.instance.loadFirmware("PARALLEL")
|
46
|
+
end
|
47
|
+
|
48
|
+
@para = HardsploitAPI_PARALLEL.new
|
49
|
+
|
50
|
+
while true
|
51
|
+
char = STDIN.getch
|
52
|
+
puts char
|
53
|
+
if char == "\u0003"
|
54
|
+
puts "Finished"
|
55
|
+
exit
|
56
|
+
|
57
|
+
#Dump parallele 8 bits at 100ns for latency
|
58
|
+
elsif char == "a" then
|
59
|
+
time = Time.new
|
60
|
+
#dump_size =65536 #ROM
|
61
|
+
dump_size =65536 #RAM
|
62
|
+
|
63
|
+
|
64
|
+
@para.read_Memory_WithoutMultiplexing(path:"file.bin",addressStart:0,addressStop:dump_size-1,bits8_or_bits16_DataSize:true,latency:1600 ) # true = 8 bits 1600ns latency
|
65
|
+
time = Time.new - time
|
66
|
+
puts "DUMP #{((dump_size/time)).round(2)}Bytes/s #{(dump_size)}Bytes in #{time.round(4)} s"
|
67
|
+
|
68
|
+
#Dump parallele 16 bits at 100ns for latency
|
69
|
+
elsif char == "z" then
|
70
|
+
time = Time.new
|
71
|
+
dump_size = 5
|
72
|
+
@para.read_Memory_WithoutMultiplexing(path:"file.bin",addressStart:0,addressStop:dump_size-1,bits8_or_bits16_DataSize:false,latency:1600) #false = 16 bits 1600ns latency
|
73
|
+
time = Time.new - time
|
74
|
+
puts "DUMP #{((2*(dump_size)/(1024*time))).round(2)}KBytes/s #{(2*dump_size)}Bytes in #{time.round(4)} s"
|
75
|
+
|
76
|
+
elsif char == "w" then
|
77
|
+
HardsploitAPI.instance.setStatutLed(led:HardsploitAPI::USB_COMMAND::GREEN_LED,state:true);
|
78
|
+
elsif char == "x" then
|
79
|
+
HardsploitAPI.instance.setStatutLed(led:HardsploitAPI::USB_COMMAND::GREEN_LED,state:false);
|
80
|
+
|
81
|
+
elsif char == "p" then
|
82
|
+
HardsploitAPI.instance.loadFirmware("PARALLEL")
|
83
|
+
end
|
84
|
+
end
|
@@ -0,0 +1,113 @@
|
|
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
|
+
require 'io/console'
|
9
|
+
require_relative '../HardsploitAPI/Core/HardsploitAPI'
|
10
|
+
require_relative '../HardsploitAPI/Modules/SPI/HardsploitAPI_SPI'
|
11
|
+
|
12
|
+
def callbackInfo(receiveData)
|
13
|
+
#print receiveData + "\n"
|
14
|
+
end
|
15
|
+
|
16
|
+
def callbackData(receiveData)
|
17
|
+
if receiveData != nil then
|
18
|
+
puts "received #{receiveData.size}"
|
19
|
+
p receiveData
|
20
|
+
else
|
21
|
+
puts "ISSUE BECAUSE DATA IS NIL"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def callbackSpeedOfTransfert(receiveData)
|
26
|
+
#puts "Speed : #{receiveData}"
|
27
|
+
end
|
28
|
+
def callbackProgress(percent:,startTime:,endTime:)
|
29
|
+
puts "Progress : #{percent}% Start@ #{startTime} Stop@ #{endTime}"
|
30
|
+
puts "Elasped time #{(endTime-startTime).round(4)} sec"
|
31
|
+
end
|
32
|
+
|
33
|
+
#puts "Number of hardsploit detected :#{HardsploitAPI.getNumberOfBoardAvailable}"
|
34
|
+
|
35
|
+
HardsploitAPI.callbackInfo = method(:callbackInfo)
|
36
|
+
HardsploitAPI.callbackData = method(:callbackData)
|
37
|
+
HardsploitAPI.callbackSpeedOfTransfert = method(:callbackSpeedOfTransfert)
|
38
|
+
HardsploitAPI.callbackProgress = method(:callbackProgress)
|
39
|
+
HardsploitAPI.id = 0 # id of hardsploit 0 for the first one, 1 for the second etc
|
40
|
+
|
41
|
+
HardsploitAPI.instance.getAllVersions
|
42
|
+
|
43
|
+
if ARGV[0] != "nofirmware" then
|
44
|
+
HardsploitAPI.instance.loadFirmware("SPI")
|
45
|
+
end
|
46
|
+
|
47
|
+
@spi = HardsploitAPI_SPI.new(speed:60,mode:0)
|
48
|
+
#The current API version
|
49
|
+
#p HardsploitAPI::VERSION::API
|
50
|
+
|
51
|
+
def spiCustomCommand
|
52
|
+
#Speed Range 1-255 SPI clock = 150Mhz / (2*speed) tested from 3 to 255 (25Mhz to about 0.3Khz)
|
53
|
+
|
54
|
+
testpack = Array.new
|
55
|
+
for i in (0..10) do
|
56
|
+
testpack.push i
|
57
|
+
end
|
58
|
+
result = @spi.spi_Interact(payload:testpack)
|
59
|
+
p result
|
60
|
+
end
|
61
|
+
|
62
|
+
while true
|
63
|
+
char = STDIN.getch
|
64
|
+
puts char
|
65
|
+
if char == "\u0003"
|
66
|
+
puts "Finished"
|
67
|
+
exit
|
68
|
+
|
69
|
+
elsif char == "z" then
|
70
|
+
crossvalue = Array.new
|
71
|
+
#Default wiring
|
72
|
+
for i in 0..63
|
73
|
+
crossvalue.push i
|
74
|
+
end
|
75
|
+
|
76
|
+
#swap 2 first signal
|
77
|
+
crossvalue[0] = 1
|
78
|
+
crossvalue[1] = 0
|
79
|
+
crossvalue[2] = 2
|
80
|
+
crossvalue[3] = 3
|
81
|
+
|
82
|
+
crossvalue[60] = 60
|
83
|
+
crossvalue[61] = 61
|
84
|
+
crossvalue[62] = 62
|
85
|
+
crossvalue[63] = 63
|
86
|
+
|
87
|
+
HardsploitAPI.setCrossWiring(value:crossvalue)
|
88
|
+
|
89
|
+
puts "cross SWAP"
|
90
|
+
|
91
|
+
elsif char == "e" then
|
92
|
+
crossvalue = Array.new
|
93
|
+
#Default wiring
|
94
|
+
for i in 0..63
|
95
|
+
crossvalue.push i
|
96
|
+
end
|
97
|
+
|
98
|
+
#swap 2 first signal
|
99
|
+
|
100
|
+
HardsploitAPI.setCrossWiring(value:crossvalue)
|
101
|
+
puts "cross Normal"
|
102
|
+
elsif char == "w" then
|
103
|
+
HardsploitAPI.instance.setStatutLed(led:HardsploitAPI::USB_COMMAND::GREEN_LED,state:true);
|
104
|
+
@spi.pulse=1
|
105
|
+
elsif char == "x" then
|
106
|
+
HardsploitAPI.instance.setStatutLed(led:HardsploitAPI::USB_COMMAND::GREEN_LED,state:false);
|
107
|
+
@spi.pulse=0
|
108
|
+
elsif char == "i" then
|
109
|
+
spiCustomCommand
|
110
|
+
elsif char == "p" then
|
111
|
+
HardsploitAPI.instance.loadFirmware("SPI")
|
112
|
+
end
|
113
|
+
end
|