pwn 0.4.459 → 0.4.460
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.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/README.md +2 -2
- data/bin/pwn_serial_check_voicemail +4 -4
- data/bin/pwn_serial_qualcomm_commands +1 -1
- data/lib/pwn/plugins/bus_pirate.rb +8 -8
- data/lib/pwn/plugins/msr206.rb +19 -58
- data/lib/pwn/plugins/serial.rb +84 -38
- data/lib/pwn/plugins/son_micro_rfid.rb +19 -58
- data/lib/pwn/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4aff2b2297397beff4fba5e51932807f004fc20a7887e841f86a108e2c172963
|
4
|
+
data.tar.gz: fd217091245e04376f6355e9ae95f7e78a6611b01446f855291843631cb89891
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3818021d9ceac8a67ecd67d59c71a483cdfff3048f44897f41f7ffb383ce46df038af62a9cebc0e19715fe465839c1dd95a0d6ffe2234ba63fd684cbc21aa6c9
|
7
|
+
data.tar.gz: 6c3c935cf2d5bc4590a28b6f8da486db377a16e3880af813835540a0adbdfe54f6e959aea8a9c1083feab9eb4e405e42b38ee3919b7b89f098a0b2bbc6333d39
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -37,7 +37,7 @@ $ rvm use ruby-3.1.2@pwn
|
|
37
37
|
$ rvm list gemsets
|
38
38
|
$ gem install --verbose pwn
|
39
39
|
$ pwn
|
40
|
-
pwn[v0.4.
|
40
|
+
pwn[v0.4.460]:001 >>> PWN.help
|
41
41
|
```
|
42
42
|
|
43
43
|
[](https://youtu.be/G7iLUY4FzsI)
|
@@ -52,7 +52,7 @@ $ rvm use ruby-3.1.2@pwn
|
|
52
52
|
$ gem uninstall --all --executables pwn
|
53
53
|
$ gem install --verbose pwn
|
54
54
|
$ pwn
|
55
|
-
pwn[v0.4.
|
55
|
+
pwn[v0.4.460]:001 >>> PWN.help
|
56
56
|
```
|
57
57
|
|
58
58
|
|
@@ -35,7 +35,7 @@ serial_obj = PWN::Plugins::Serial.connect
|
|
35
35
|
|
36
36
|
PWN::Plugins::Serial.request(
|
37
37
|
serial_obj: serial_obj,
|
38
|
-
|
38
|
+
payload: "ATDT#{voicemail_num};\r\n"
|
39
39
|
)
|
40
40
|
|
41
41
|
# TODO: Loop until data received indicates call picked up instead of sleep
|
@@ -44,18 +44,18 @@ sleep 13
|
|
44
44
|
voicemail_pin.each_char do |pin_char|
|
45
45
|
PWN::Plugins::Serial.request(
|
46
46
|
serial_obj: serial_obj,
|
47
|
-
|
47
|
+
payload: "AT+VTS=#{pin_char}\r\n"
|
48
48
|
)
|
49
49
|
end
|
50
50
|
|
51
51
|
PWN::Plugins::Serial.request(
|
52
52
|
serial_obj: serial_obj,
|
53
|
-
|
53
|
+
payload: "AT+VTS=#\r\n"
|
54
54
|
)
|
55
55
|
|
56
56
|
PWN::Plugins::Serial.request(
|
57
57
|
serial_obj: serial_obj,
|
58
|
-
|
58
|
+
payload: "AT+CHUP;\r\n"
|
59
59
|
)
|
60
60
|
|
61
61
|
session_data = PWN::Plugins::Serial.dump_session_data
|
@@ -63,28 +63,28 @@ module PWN
|
|
63
63
|
case mode
|
64
64
|
when 'BBI01'
|
65
65
|
# Enter reset binary mode
|
66
|
-
PWN::Plugins::Serial.request(serial_obj: bus_pirate_obj,
|
66
|
+
PWN::Plugins::Serial.request(serial_obj: bus_pirate_obj, byte_arr: [0x00])
|
67
67
|
when 'SPI1'
|
68
68
|
# Enter binary SPI mode
|
69
|
-
PWN::Plugins::Serial.request(serial_obj: bus_pirate_obj,
|
69
|
+
PWN::Plugins::Serial.request(serial_obj: bus_pirate_obj, byte_arr: [0x01])
|
70
70
|
when 'I2C1'
|
71
71
|
# Enter I2C mode
|
72
|
-
PWN::Plugins::Serial.request(serial_obj: bus_pirate_obj,
|
72
|
+
PWN::Plugins::Serial.request(serial_obj: bus_pirate_obj, byte_arr: [0x02])
|
73
73
|
when 'ART1'
|
74
74
|
# Enter UART mode
|
75
|
-
PWN::Plugins::Serial.request(serial_obj: bus_pirate_obj,
|
75
|
+
PWN::Plugins::Serial.request(serial_obj: bus_pirate_obj, byte_arr: [0x03])
|
76
76
|
when '1W01'
|
77
77
|
# Enter 1-Wire mode
|
78
|
-
PWN::Plugins::Serial.request(serial_obj: bus_pirate_obj,
|
78
|
+
PWN::Plugins::Serial.request(serial_obj: bus_pirate_obj, byte_arr: [0x04])
|
79
79
|
when 'RAW1'
|
80
80
|
# Enter raw-wire mode
|
81
|
-
PWN::Plugins::Serial.request(serial_obj: bus_pirate_obj,
|
81
|
+
PWN::Plugins::Serial.request(serial_obj: bus_pirate_obj, byte_arr: [0x05])
|
82
82
|
when 'RESET'
|
83
83
|
# Reset Bus Pirate
|
84
|
-
PWN::Plugins::Serial.request(serial_obj: bus_pirate_obj,
|
84
|
+
PWN::Plugins::Serial.request(serial_obj: bus_pirate_obj, byte_arr: [0x0F])
|
85
85
|
when 'STEST'
|
86
86
|
# Bus Pirate self-tests
|
87
|
-
PWN::Plugins::Serial.request(serial_obj: bus_pirate_obj,
|
87
|
+
PWN::Plugins::Serial.request(serial_obj: bus_pirate_obj, byte_arr: [0x10])
|
88
88
|
else
|
89
89
|
raise "Invalid mode: #{mode}"
|
90
90
|
end
|
data/lib/pwn/plugins/msr206.rb
CHANGED
@@ -9,15 +9,18 @@ module PWN
|
|
9
9
|
# msr206_obj = PWN::Plugins::MSR206.connect(
|
10
10
|
# block_dev: 'optional - serial block device path (defaults to /dev/ttyUSB0)',
|
11
11
|
# baud: 'optional - (defaults to 9600)',
|
12
|
-
# data_bits: 'optional - (defaults to
|
12
|
+
# data_bits: 'optional - (defaults to 7)',
|
13
13
|
# stop_bits: 'optional - (defaults to 1)',
|
14
|
-
# parity: 'optional - (defaults to SerialPort::
|
14
|
+
# parity: 'optional - (defaults to SerialPort::ODD)',
|
15
15
|
# flow_control: 'optional - (defaults to SerialPort::HARD) SerialPort::NONE|SerialPort::SOFT|SerialPort::HARD'
|
16
16
|
# )
|
17
17
|
|
18
18
|
public_class_method def self.connect(opts = {})
|
19
19
|
# Default Baud Rate for this Device is 19200
|
20
|
-
opts[:baud] =
|
20
|
+
opts[:baud] = 9_600 unless opts[:baud]
|
21
|
+
opts[:data_bits] = 7 unless opts[:data_bits]
|
22
|
+
opts[:stop_bits] = 1 unless opts[:stop_bits]
|
23
|
+
opts[:parity] = :odd unless opts[:parity]
|
21
24
|
msr206_obj = PWN::Plugins::Serial.connect(opts)
|
22
25
|
rescue StandardError => e
|
23
26
|
disconnect(msr206_obj: msr206_obj) unless msr206_obj.nil?
|
@@ -88,47 +91,6 @@ module PWN
|
|
88
91
|
raise e
|
89
92
|
end
|
90
93
|
|
91
|
-
# Supported Method Parameters::
|
92
|
-
# cmd_response_arr = get_cmd_responses(
|
93
|
-
# msr206_obj: 'required - msr206_obj returned from #connect method'
|
94
|
-
# )
|
95
|
-
|
96
|
-
public_class_method def self.get_cmd_responses(opts = {})
|
97
|
-
msr206_obj = opts[:msr206_obj]
|
98
|
-
|
99
|
-
raw_byte_arr = PWN::Plugins::Serial.dump_session_data(
|
100
|
-
serial_obj: msr206_obj
|
101
|
-
)
|
102
|
-
|
103
|
-
hex_esc_raw_resp = ''
|
104
|
-
raw_byte_arr.each do |byte|
|
105
|
-
this_byte = byte.unpack1('H*')
|
106
|
-
# Needed when #unpack1 returns 2 bytes instead of one
|
107
|
-
# e.g."ް" translates to deb0 (that's not a double quote ")
|
108
|
-
# instead of de b0
|
109
|
-
# this condition is ghetto-hacker-ish.
|
110
|
-
if this_byte.length == 4
|
111
|
-
byte_one = this_byte[1..2]
|
112
|
-
byte_two = this_byte[-2..-1]
|
113
|
-
hex_esc_raw_resp = "#{hex_esc_raw_resp}\s#{byte_one}"
|
114
|
-
hex_esc_raw_resp = "#{hex_esc_raw_resp}\s#{byte_two}"
|
115
|
-
else
|
116
|
-
hex_esc_raw_resp = "#{hex_esc_raw_resp}\s#{this_byte}"
|
117
|
-
end
|
118
|
-
end
|
119
|
-
|
120
|
-
# Return command response array in space-delimited hex
|
121
|
-
cmd_response_arr = hex_esc_raw_resp.upcase.strip.split(/(?=FF)/)
|
122
|
-
cmd_response_arr.map(&:strip)
|
123
|
-
rescue StandardError => e
|
124
|
-
# Flush Responses for Next Request
|
125
|
-
PWN::Plugins::Serial.flush_session_data(
|
126
|
-
serial_obj: msr206_obj
|
127
|
-
)
|
128
|
-
|
129
|
-
raise e
|
130
|
-
end
|
131
|
-
|
132
94
|
# Supported Method Parameters::
|
133
95
|
# parsed_cmd_resp_arr = parse_responses(
|
134
96
|
# cmd_resp: 'required - command response string'
|
@@ -150,10 +112,9 @@ module PWN
|
|
150
112
|
|
151
113
|
while keep_parsing_responses
|
152
114
|
until next_response_detected
|
153
|
-
all_cmd_responses =
|
154
|
-
|
155
|
-
|
156
|
-
# bytes_in_cmd_resp = cmd_resp.split.length if cmd_resp
|
115
|
+
all_cmd_responses = PWN::Plugins::Serial.response(serial_obj: msr206_obj)
|
116
|
+
cmd_resp = all_cmd_responses.last
|
117
|
+
bytes_in_cmd_resp = cmd_resp.split.length if cmd_resp
|
157
118
|
a_cmd_r_len = all_cmd_responses.length
|
158
119
|
|
159
120
|
next_response_detected = true if a_cmd_r_len > last_a_cmd_r_len
|
@@ -175,9 +136,7 @@ module PWN
|
|
175
136
|
raise e
|
176
137
|
ensure
|
177
138
|
# Flush Responses for Next Request
|
178
|
-
PWN::Plugins::Serial.flush_session_data
|
179
|
-
serial_obj: msr206_obj
|
180
|
-
)
|
139
|
+
PWN::Plugins::Serial.flush_session_data
|
181
140
|
end
|
182
141
|
|
183
142
|
# Supported Method Parameters::
|
@@ -211,8 +170,6 @@ module PWN
|
|
211
170
|
cmd_bytes = [0x29]
|
212
171
|
when :version_report
|
213
172
|
cmd_bytes = [0x39]
|
214
|
-
when :power_on_report
|
215
|
-
cmd_bytes = [0x3A]
|
216
173
|
when :set_write_density
|
217
174
|
cmd_bytes = [0x3B]
|
218
175
|
when :set_temp_write_current
|
@@ -304,9 +261,10 @@ module PWN
|
|
304
261
|
# If parameters to a command are set, append them.
|
305
262
|
cmd_bytes += params_bytes unless params_bytes.empty?
|
306
263
|
# Execute the command.
|
307
|
-
|
308
|
-
msr206_obj
|
309
|
-
|
264
|
+
PWN::Plugins::Serial.request(
|
265
|
+
serial_obj: msr206_obj,
|
266
|
+
payload: cmd_bytes
|
267
|
+
)
|
310
268
|
|
311
269
|
# Parse commands response(s).
|
312
270
|
# Return an array of hashes.
|
@@ -316,6 +274,9 @@ module PWN
|
|
316
274
|
)
|
317
275
|
rescue StandardError => e
|
318
276
|
raise e
|
277
|
+
ensure
|
278
|
+
# Flush Responses for Next Request
|
279
|
+
PWN::Plugins::Serial.flush_session_data
|
319
280
|
end
|
320
281
|
|
321
282
|
# Supported Method Parameters::
|
@@ -346,9 +307,9 @@ module PWN
|
|
346
307
|
msr206_obj = #{self}.connect(
|
347
308
|
block_dev: 'optional serial block device path (defaults to /dev/ttyUSB0)',
|
348
309
|
baud: 'optional (defaults to 9600)',
|
349
|
-
data_bits: 'optional (defaults to
|
310
|
+
data_bits: 'optional (defaults to 7)',
|
350
311
|
stop_bits: 'optional (defaults to 1)',
|
351
|
-
parity: 'optional (defaults to SerialPort::
|
312
|
+
parity: 'optional (defaults to SerialPort::ODD)',
|
352
313
|
flow_control: 'optional (defaults to SerialPort::NONE)'
|
353
314
|
)
|
354
315
|
|
data/lib/pwn/plugins/serial.rb
CHANGED
@@ -8,7 +8,6 @@ module PWN
|
|
8
8
|
# This plugin is used for interacting with serial devices including, but not limited to,
|
9
9
|
# modems (including cellphone radios), legacy equipment, arduinos, & other misc ftdi devices
|
10
10
|
module Serial
|
11
|
-
# @session_data = ""
|
12
11
|
@session_data = []
|
13
12
|
|
14
13
|
# Supported Method Parameters::
|
@@ -45,17 +44,27 @@ module PWN
|
|
45
44
|
opts[:stop_bits].to_i
|
46
45
|
end
|
47
46
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
47
|
+
case opts[:parity]
|
48
|
+
when :even
|
49
|
+
parity = SerialPort::EVEN
|
50
|
+
when :mark
|
51
|
+
parity = SerialPort::MARK
|
52
|
+
when :odd
|
53
|
+
parity = SerialPort::ODD
|
54
|
+
when :space
|
55
|
+
parity = SerialPort::SPACE
|
56
|
+
else
|
57
|
+
parity = SerialPort::NONE
|
58
|
+
end
|
53
59
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
60
|
+
case opts[:flow_control]
|
61
|
+
when :hard
|
62
|
+
flow_control = SerialPort::HARD
|
63
|
+
when :soft
|
64
|
+
flow_control = SerialPort::SOFT
|
65
|
+
else
|
66
|
+
flow_control = SerialPort::NONE
|
67
|
+
end
|
59
68
|
|
60
69
|
serial_conn = SerialPort.new(
|
61
70
|
block_dev,
|
@@ -138,21 +147,39 @@ module PWN
|
|
138
147
|
# Supported Method Parameters::
|
139
148
|
# PWN::Plugins::Serial.request(
|
140
149
|
# serial_obj: 'required serial_obj returned from #connect method',
|
141
|
-
#
|
150
|
+
# payload: 'required - array of bytes OR string to write to serial device (e.g. [0x00, 0x41, 0x90, 0x00] OR "ATDT+15555555\r\n"'
|
142
151
|
# )
|
143
152
|
|
144
153
|
public_class_method def self.request(opts = {})
|
145
154
|
serial_obj = opts[:serial_obj]
|
146
|
-
|
155
|
+
payload = opts[:payload]
|
147
156
|
serial_conn = serial_obj[:serial_conn]
|
148
|
-
|
157
|
+
|
158
|
+
byte_arr = payload
|
159
|
+
byte_arr = payload.chars if payload.instance_of?(String)
|
160
|
+
|
161
|
+
byte_arr.each do |byte|
|
162
|
+
serial_conn.putc(byte)
|
163
|
+
end
|
164
|
+
|
149
165
|
serial_conn.flush
|
150
|
-
chars_written
|
151
166
|
rescue StandardError => e
|
152
167
|
disconnect(serial_obj: serial_obj) unless serial_obj.nil?
|
153
168
|
raise e
|
154
169
|
end
|
155
170
|
|
171
|
+
# public_class_method def self.request(opts = {})
|
172
|
+
# serial_obj = opts[:serial_obj]
|
173
|
+
# request = opts[:request].to_s.scrub
|
174
|
+
# serial_conn = serial_obj[:serial_conn]
|
175
|
+
# chars_written = serial_conn.write(request)
|
176
|
+
# serial_conn.flush
|
177
|
+
# chars_written
|
178
|
+
# rescue StandardError => e
|
179
|
+
# disconnect(serial_obj: serial_obj) unless serial_obj.nil?
|
180
|
+
# raise e
|
181
|
+
# end
|
182
|
+
|
156
183
|
# Supported Method Parameters::
|
157
184
|
# PWN::Plugins::Serial.response(
|
158
185
|
# serial_obj: 'required - serial_obj returned from #connect method'
|
@@ -160,37 +187,60 @@ module PWN
|
|
160
187
|
|
161
188
|
public_class_method def self.response(opts = {})
|
162
189
|
serial_obj = opts[:serial_obj]
|
163
|
-
|
190
|
+
|
191
|
+
raw_byte_arr = dump_session_data
|
192
|
+
|
193
|
+
hex_esc_raw_resp = ''
|
194
|
+
raw_byte_arr.each do |byte|
|
195
|
+
# this_byte = "\s#{byte.unpack1('H*')}"
|
196
|
+
this_byte = byte.unpack1('H*')
|
197
|
+
# Needed when #unpack1 returns 2 bytes instead of one
|
198
|
+
# e.g."ް" translates to deb0 (that's not a double quote ")
|
199
|
+
# instead of de b0
|
200
|
+
# this condition is ghetto-hacker-ish.
|
201
|
+
if this_byte.length == 4
|
202
|
+
byte_one = this_byte[1..2]
|
203
|
+
byte_two = this_byte[-2..-1]
|
204
|
+
hex_esc_raw_resp = "#{hex_esc_raw_resp}\s#{byte_one}"
|
205
|
+
hex_esc_raw_resp = "#{hex_esc_raw_resp}\s#{byte_two}"
|
206
|
+
else
|
207
|
+
hex_esc_raw_resp = "#{hex_esc_raw_resp}\s#{this_byte}"
|
208
|
+
end
|
209
|
+
end
|
210
|
+
|
211
|
+
# Return command response array in space-delimited hex
|
212
|
+
cmd_response_arr = hex_esc_raw_resp.upcase.strip.split(/(?=FF)/)
|
213
|
+
cmd_response_arr.map(&:strip)
|
164
214
|
rescue StandardError => e
|
165
|
-
|
215
|
+
# Flush Responses for Next Request
|
216
|
+
flush_session_data(serial_obj: serial_obj)
|
217
|
+
|
166
218
|
raise e
|
167
219
|
end
|
168
220
|
|
169
|
-
#
|
170
|
-
#
|
171
|
-
#
|
172
|
-
#
|
221
|
+
# public_class_method def self.response(opts = {})
|
222
|
+
# serial_obj = opts[:serial_obj]
|
223
|
+
# @session_data.last
|
224
|
+
# rescue StandardError => e
|
225
|
+
# disconnect(serial_obj: serial_obj) unless serial_obj.nil?
|
226
|
+
# raise e
|
227
|
+
# end
|
173
228
|
|
174
|
-
|
175
|
-
|
229
|
+
# Supported Method Parameters::
|
230
|
+
# session_data = PWN::Plugins::Serial.dump_session_data
|
176
231
|
|
232
|
+
public_class_method def self.dump_session_data
|
177
233
|
@session_data
|
178
234
|
rescue StandardError => e
|
179
|
-
disconnect(serial_obj: serial_obj) unless serial_obj.nil?
|
180
235
|
raise e
|
181
236
|
end
|
182
237
|
|
183
238
|
# Supported Method Parameters::
|
184
|
-
# session_data = PWN::Plugins::Serial.flush_session_data
|
185
|
-
# serial_obj: 'required - serial_obj returned from #connect method'
|
186
|
-
# )
|
187
|
-
|
188
|
-
public_class_method def self.flush_session_data(opts = {})
|
189
|
-
serial_obj = opts[:serial_obj]
|
239
|
+
# session_data = PWN::Plugins::Serial.flush_session_data
|
190
240
|
|
241
|
+
public_class_method def self.flush_session_data
|
191
242
|
@session_data.clear
|
192
243
|
rescue StandardError => e
|
193
|
-
disconnect(serial_obj: serial_obj) unless serial_obj.nil?
|
194
244
|
raise e
|
195
245
|
end
|
196
246
|
|
@@ -203,7 +253,7 @@ module PWN
|
|
203
253
|
serial_obj = opts[:serial_obj]
|
204
254
|
serial_conn = serial_obj[:serial_conn]
|
205
255
|
session_thread = serial_obj[:session_thread]
|
206
|
-
flush_session_data
|
256
|
+
flush_session_data
|
207
257
|
session_thread.terminate
|
208
258
|
serial_conn.close
|
209
259
|
serial_conn = nil
|
@@ -242,20 +292,16 @@ module PWN
|
|
242
292
|
|
243
293
|
#{self}.request(
|
244
294
|
serial_obj: 'required serial_obj returned from #connect method',
|
245
|
-
|
295
|
+
payload: 'required - array of bytes OR string to write to serial device (e.g. [0x00, 0x41, 0x90, 0x00] OR \"ATDT+15555555\r\n\"'
|
246
296
|
)
|
247
297
|
|
248
298
|
#{self}.response(
|
249
299
|
serial_obj: 'required serial_obj returned from #connect method'
|
250
300
|
)
|
251
301
|
|
252
|
-
session_data_arr = #{self}.dump_session_data
|
253
|
-
serial_obj: 'required serial_obj returned from #connect method'
|
254
|
-
)
|
302
|
+
session_data_arr = #{self}.dump_session_data
|
255
303
|
|
256
304
|
#{self}.flush_session_data
|
257
|
-
serial_obj: 'required serial_obj returned from #connect method'
|
258
|
-
)
|
259
305
|
|
260
306
|
#{self}.disconnect(
|
261
307
|
serial_obj: 'required serial_obj returned from #connect method'
|
@@ -8,7 +8,7 @@ module PWN
|
|
8
8
|
# Supported Method Parameters::
|
9
9
|
# son_micro_rfid_obj = PWN::Plugins::SonMicroRFID.connect(
|
10
10
|
# block_dev: 'optional - serial block device path (defaults to /dev/ttyUSB0)',
|
11
|
-
# baud: 'optional - (defaults to
|
11
|
+
# baud: 'optional - (defaults to 19_200)',
|
12
12
|
# data_bits: 'optional - (defaults to 8)',
|
13
13
|
# stop_bits: 'optional - (defaults to 1)',
|
14
14
|
# parity: 'optional - (defaults to SerialPort::NONE)',
|
@@ -17,7 +17,10 @@ module PWN
|
|
17
17
|
|
18
18
|
public_class_method def self.connect(opts = {})
|
19
19
|
# Default Baud Rate for this Device is 19200
|
20
|
-
opts[:baud] = 19_200
|
20
|
+
opts[:baud] = 19_200 unless opts[:baud]
|
21
|
+
opts[:data_bits] = 8 unless opts[:data_bits]
|
22
|
+
opts[:stop_bits] = 1 unless opts[:stop_bits]
|
23
|
+
opts[:parity] = :none unless opts[:parity]
|
21
24
|
son_micro_rfid_obj = PWN::Plugins::Serial.connect(opts)
|
22
25
|
rescue StandardError => e
|
23
26
|
disconnect(son_micro_rfid_obj: son_micro_rfid_obj) unless son_micro_rfid_obj.nil?
|
@@ -108,50 +111,9 @@ module PWN
|
|
108
111
|
raise e
|
109
112
|
end
|
110
113
|
|
111
|
-
# Supported Method Parameters::
|
112
|
-
# cmd_response_arr = get_cmd_responses(
|
113
|
-
# son_micro_rfid_obj: 'required - son_micro_rfid_obj returned from #connect method'
|
114
|
-
# )
|
115
|
-
|
116
|
-
public_class_method def self.get_cmd_responses(opts = {})
|
117
|
-
son_micro_rfid_obj = opts[:son_micro_rfid_obj]
|
118
|
-
|
119
|
-
raw_byte_arr = PWN::Plugins::Serial.dump_session_data(
|
120
|
-
serial_obj: son_micro_rfid_obj
|
121
|
-
)
|
122
|
-
|
123
|
-
hex_esc_raw_resp = ''
|
124
|
-
raw_byte_arr.each do |byte|
|
125
|
-
# this_byte = "\s#{byte.unpack1('H*')}"
|
126
|
-
this_byte = byte.unpack1('H*')
|
127
|
-
# Needed when #unpack1 returns 2 bytes instead of one
|
128
|
-
# e.g."ް" translates to deb0 (that's not a double quote ")
|
129
|
-
# instead of de b0
|
130
|
-
# this condition is ghetto-hacker-ish.
|
131
|
-
if this_byte.length == 4
|
132
|
-
byte_one = this_byte[1..2]
|
133
|
-
byte_two = this_byte[-2..-1]
|
134
|
-
hex_esc_raw_resp = "#{hex_esc_raw_resp}\s#{byte_one}"
|
135
|
-
hex_esc_raw_resp = "#{hex_esc_raw_resp}\s#{byte_two}"
|
136
|
-
else
|
137
|
-
hex_esc_raw_resp = "#{hex_esc_raw_resp}\s#{this_byte}"
|
138
|
-
end
|
139
|
-
end
|
140
|
-
|
141
|
-
# Return command response array in space-delimited hex
|
142
|
-
cmd_response_arr = hex_esc_raw_resp.upcase.strip.split(/(?=FF)/)
|
143
|
-
cmd_response_arr.map(&:strip)
|
144
|
-
rescue StandardError => e
|
145
|
-
# Flush Responses for Next Request
|
146
|
-
PWN::Plugins::Serial.flush_session_data(
|
147
|
-
serial_obj: son_micro_rfid_obj
|
148
|
-
)
|
149
|
-
|
150
|
-
raise e
|
151
|
-
end
|
152
|
-
|
153
114
|
# Supported Method Parameters::
|
154
115
|
# parsed_cmd_resp_arr = parse_responses(
|
116
|
+
# son_micro_rfid_obj: 'required - son_micro_rfid_obj returned from #connect method'
|
155
117
|
# cmd_resp: 'required - command response string'
|
156
118
|
# )
|
157
119
|
|
@@ -173,13 +135,14 @@ module PWN
|
|
173
135
|
while keep_parsing_responses
|
174
136
|
until next_response_detected
|
175
137
|
print '.'
|
176
|
-
all_cmd_responses =
|
177
|
-
|
138
|
+
all_cmd_responses = PWN::Plugins::Serial.response(
|
139
|
+
serial_obj: son_micro_rfid_obj
|
178
140
|
)
|
179
141
|
cmd_resp = all_cmd_responses.last
|
180
142
|
bytes_in_cmd_resp = cmd_resp.split.length if cmd_resp
|
181
143
|
a_cmd_r_len = all_cmd_responses.length
|
182
144
|
|
145
|
+
# Dont proceed until the expected_cmd_resp_byte_len byte appears
|
183
146
|
next_response_detected = true if bytes_in_cmd_resp > 3 &&
|
184
147
|
a_cmd_r_len > last_a_cmd_r_len
|
185
148
|
end
|
@@ -194,8 +157,8 @@ module PWN
|
|
194
157
|
cmd_hex = cmd_resp.split[3]
|
195
158
|
|
196
159
|
while bytes_in_cmd_resp < expected_cmd_resp_byte_len
|
197
|
-
all_cmd_responses =
|
198
|
-
|
160
|
+
all_cmd_responses = PWN::Plugins::Serial.response(
|
161
|
+
serial_obj: son_micro_rfid_obj
|
199
162
|
)
|
200
163
|
|
201
164
|
cmd_resp = all_cmd_responses.last
|
@@ -210,6 +173,7 @@ module PWN
|
|
210
173
|
puts "#{all_cmd_responses}\n\n\n"
|
211
174
|
|
212
175
|
parsed_cmd_resp_hash = {}
|
176
|
+
parsed_cmd_resp_hash[:raw_resp] = PWN::Plugins::Serial.dump_session_data.inspect
|
213
177
|
parsed_cmd_resp_hash[:hex_resp] = cmd_resp
|
214
178
|
parsed_cmd_resp_hash[:cmd_hex] = cmd_hex
|
215
179
|
parsed_cmd_resp_hash[:cmd_desc] = cmd.to_sym
|
@@ -268,9 +232,7 @@ module PWN
|
|
268
232
|
raise e
|
269
233
|
ensure
|
270
234
|
# Flush Responses for Next Request
|
271
|
-
PWN::Plugins::Serial.flush_session_data
|
272
|
-
serial_obj: son_micro_rfid_obj
|
273
|
-
)
|
235
|
+
PWN::Plugins::Serial.flush_session_data
|
274
236
|
end
|
275
237
|
|
276
238
|
# Supported Method Parameters::
|
@@ -355,9 +317,10 @@ module PWN
|
|
355
317
|
# If parameters to a command are set, append them.
|
356
318
|
cmd_bytes += params_bytes unless params_bytes.empty?
|
357
319
|
# Execute the command.
|
358
|
-
|
359
|
-
son_micro_rfid_obj
|
360
|
-
|
320
|
+
PWN::Plugins::Serial.request(
|
321
|
+
serial_obj: son_micro_rfid_obj,
|
322
|
+
payload: cmd_bytes
|
323
|
+
)
|
361
324
|
|
362
325
|
# Parse commands response(s).
|
363
326
|
# Return an array of hashes.
|
@@ -369,9 +332,7 @@ module PWN
|
|
369
332
|
raise e
|
370
333
|
ensure
|
371
334
|
# Flush Responses for Next Request
|
372
|
-
PWN::Plugins::Serial.flush_session_data
|
373
|
-
serial_obj: son_micro_rfid_obj
|
374
|
-
)
|
335
|
+
PWN::Plugins::Serial.flush_session_data
|
375
336
|
end
|
376
337
|
|
377
338
|
# Supported Method Parameters::
|
@@ -401,7 +362,7 @@ module PWN
|
|
401
362
|
puts "USAGE:
|
402
363
|
son_micro_rfid_obj = #{self}.connect(
|
403
364
|
block_dev: 'optional serial block device path (defaults to /dev/ttyUSB0)',
|
404
|
-
baud: 'optional (defaults to
|
365
|
+
baud: 'optional (defaults to 19_200)',
|
405
366
|
data_bits: 'optional (defaults to 8)',
|
406
367
|
stop_bits: 'optional (defaults to 1)',
|
407
368
|
parity: 'optional (defaults to SerialPort::NONE)',
|
data/lib/pwn/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pwn
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.460
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- 0day Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-05-
|
11
|
+
date: 2022-05-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -674,14 +674,14 @@ dependencies:
|
|
674
674
|
requirements:
|
675
675
|
- - '='
|
676
676
|
- !ruby/object:Gem::Version
|
677
|
-
version: 1.
|
677
|
+
version: 1.30.0
|
678
678
|
type: :runtime
|
679
679
|
prerelease: false
|
680
680
|
version_requirements: !ruby/object:Gem::Requirement
|
681
681
|
requirements:
|
682
682
|
- - '='
|
683
683
|
- !ruby/object:Gem::Version
|
684
|
-
version: 1.
|
684
|
+
version: 1.30.0
|
685
685
|
- !ruby/object:Gem::Dependency
|
686
686
|
name: rubocop-rake
|
687
687
|
requirement: !ruby/object:Gem::Requirement
|