pwn 0.4.463 → 0.4.464

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a39a74b8bc26847795f54fdcbd7f48eb5a38c2587da0d233e74bd96a8267c9a9
4
- data.tar.gz: fa37dda7a5e16dc6743da3930b5278d83077e2ba100d65566eef9fd39c373967
3
+ metadata.gz: d77468174376740ae2dd89b5bbb1521f26bdec17189f5f972192993cbaa0a66e
4
+ data.tar.gz: de001049f66cf990004036747c6181c8ead4d8fa30a83606b8d2573e24ce4a39
5
5
  SHA512:
6
- metadata.gz: e08cddc2558b06ed364a65dd058f94d75f2b02241a8adf613818c992ad038e8bb5f23b30d59e8f9061a3d1538a817697eabf4985f484f4076827e4fbbbe28ddc
7
- data.tar.gz: 2b098194d45038d7cc85ba1653a3aa85bb432de6049fcebbcc58575a982eb02b31c4757d425c984e60c88a07a6a62868c411ed52043d79dff649052e65a3c27f
6
+ metadata.gz: 20123d464c7561f517194bbb389973a072356c491bf1dc937a34c69e1dd782b8c4a07862fb95e982ef75309276bd70531cd0126c838c5609b934e686c0b4e88f
7
+ data.tar.gz: 9333bbaced9c278acbb5f96522d5d5fdc40bb6d81c8b34e9fde94fde66d6094fefb26c0fa2cf35665207ebd553a0e0f99d26e059daa4257308e1e09bc88f76c9
data/.rubocop_todo.yml CHANGED
@@ -1,47 +1,47 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2022-05-08 06:06:43 UTC using RuboCop version 1.29.0.
3
+ # on 2022-05-27 23:04:56 UTC using RuboCop version 1.30.0.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
7
7
  # versions of RuboCop, may require this file to be generated again.
8
8
 
9
- # Offense count: 227
9
+ # Offense count: 234
10
10
  Lint/UselessAssignment:
11
11
  Enabled: false
12
12
 
13
- # Offense count: 246
13
+ # Offense count: 253
14
14
  # Configuration parameters: IgnoredMethods, CountRepeatedAttributes.
15
15
  Metrics/AbcSize:
16
16
  Max: 328
17
17
 
18
- # Offense count: 60
18
+ # Offense count: 63
19
19
  # Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
20
20
  # IgnoredMethods: refine
21
21
  Metrics/BlockLength:
22
- Max: 194
22
+ Max: 196
23
23
 
24
24
  # Offense count: 45
25
25
  # Configuration parameters: CountBlocks.
26
26
  Metrics/BlockNesting:
27
27
  Max: 5
28
28
 
29
- # Offense count: 83
29
+ # Offense count: 89
30
30
  # Configuration parameters: IgnoredMethods.
31
31
  Metrics/CyclomaticComplexity:
32
32
  Max: 231
33
33
 
34
- # Offense count: 440
34
+ # Offense count: 459
35
35
  # Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
36
36
  Metrics/MethodLength:
37
37
  Max: 466
38
38
 
39
- # Offense count: 33
39
+ # Offense count: 34
40
40
  # Configuration parameters: CountComments, CountAsOne.
41
41
  Metrics/ModuleLength:
42
42
  Max: 1186
43
43
 
44
- # Offense count: 75
44
+ # Offense count: 81
45
45
  # Configuration parameters: IgnoredMethods.
46
46
  Metrics/PerceivedComplexity:
47
47
  Max: 51
@@ -50,33 +50,33 @@ Metrics/PerceivedComplexity:
50
50
  Style/ClassVars:
51
51
  Enabled: false
52
52
 
53
- # Offense count: 281
54
- # This cop supports safe auto-correction (--auto-correct).
53
+ # Offense count: 285
54
+ # This cop supports safe autocorrection (--autocorrect).
55
55
  # Configuration parameters: EnforcedStyle, SingleLineConditionsOnly, IncludeTernaryExpressions.
56
56
  # SupportedStyles: assign_to_condition, assign_inside_condition
57
57
  Style/ConditionalAssignment:
58
58
  Enabled: false
59
59
 
60
60
  # Offense count: 2
61
- # This cop supports safe auto-correction (--auto-correct).
61
+ # This cop supports safe autocorrection (--autocorrect).
62
62
  Style/ExplicitBlockArgument:
63
63
  Exclude:
64
64
  - 'lib/pwn/plugins/nmap_it.rb'
65
65
 
66
66
  # Offense count: 95
67
- # This cop supports safe auto-correction (--auto-correct).
67
+ # This cop supports safe autocorrection (--autocorrect).
68
68
  Style/RedundantCondition:
69
69
  Exclude:
70
70
  - 'bin/pwn_simple_http_server'
71
71
  - 'lib/pwn/plugins/packet.rb'
72
72
 
73
73
  # Offense count: 44
74
- # This cop supports unsafe auto-correction (--auto-correct-all).
74
+ # This cop supports unsafe autocorrection (--autocorrect-all).
75
75
  Style/SlicingWithRange:
76
76
  Enabled: false
77
77
 
78
- # Offense count: 531
79
- # This cop supports safe auto-correction (--auto-correct).
78
+ # Offense count: 555
79
+ # This cop supports safe autocorrection (--autocorrect).
80
80
  # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns, IgnoredPatterns.
81
81
  # URISchemes: http, https
82
82
  Layout/LineLength:
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.463]:001 >>> PWN.help
40
+ pwn[v0.4.464]:001 >>> PWN.help
41
41
  ```
42
42
 
43
43
  [![Installing the pwn Security Automation Framework](https://raw.githubusercontent.com/0dayInc/pwn/master/documentation/pwn_install.png)](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.463]:001 >>> PWN.help
55
+ pwn[v0.4.464]:001 >>> PWN.help
56
56
  ```
57
57
 
58
58
 
@@ -14,24 +14,24 @@ OptionParser.new do |options|
14
14
  opts[:block_dev] = d
15
15
  end
16
16
 
17
- options.on('-bBAUD', '--baud=DEV', '<Optional - (defaults to 9600)>') do |d|
18
- opts[:block_dev] = d
17
+ options.on('-bBAUD', '--baud=BAUD', '<Optional - (defaults to 9600)>') do |b|
18
+ opts[:baud] = b
19
19
  end
20
20
 
21
- options.on('-DDATABITS', '--data-bits=DATABITS', '<Optional - (defaults to 7)>') do |d|
22
- opts[:block_dev] = d
21
+ options.on('-DDATABITS', '--data-bits=DATABITS', '<Optional - (defaults to 8)>') do |d|
22
+ opts[:data_bits] = d
23
23
  end
24
24
 
25
- options.on('-sSTOPBITS', '--stop-bits=STOPBITS', '<Optional - (defaults to 1)>') do |d|
26
- opts[:block_dev] = d
25
+ options.on('-sSTOPBITS', '--stop-bits=STOPBITS', '<Optional - (defaults to 1)>') do |s|
26
+ opts[:stop_bits] = s
27
27
  end
28
28
 
29
- options.on('-pPARITY', '--parity=PARITY', '<Optional - :even|:mark|:odd|:space|:none (defaults to :odd)>') do |d|
30
- opts[:block_dev] = d
29
+ options.on('-pPARITY', '--parity=PARITY', '<Optional - even|mark|odd|space|none (defaults to none)>') do |p|
30
+ opts[:parity] = p
31
31
  end
32
32
 
33
- options.on('-fFLOW', '--flow-control=FLOW', '<Optional - :none||:hard||:soft (defaults to :none)>') do |d|
34
- opts[:block_dev] = d
33
+ options.on('-fFLOWCTRL', '--flow-control=FLOWCTRL', '<Optional - none||hard||soft (defaults to none)>') do |f|
34
+ opts[:flow_control] = f
35
35
  end
36
36
  end.parse!
37
37
 
@@ -41,7 +41,7 @@ if opts.empty?
41
41
  end
42
42
 
43
43
  begin
44
- block_dev = opts[:block_dev]
44
+ block_dev = opts[:block_dev] if File.exist?(opts[:block_dev])
45
45
  baud = opts[:baud]
46
46
  data_bits = opts[:data_bits]
47
47
  stop_bits = opts[:stop_bits]
@@ -57,10 +57,123 @@ begin
57
57
  flow_control: flow_control
58
58
  )
59
59
 
60
- serial_resp = PWN::Plugins::MSR206.exec(
60
+ puts "- Welcome to #{File.basename($PROGRAM_NAME)} -"
61
+ puts "Connected via: #{block_dev} @ #{msr206_obj[:serial_conn].modem_params}"
62
+ puts "Flow Control: #{msr206_obj[:serial_conn].flow_control}"
63
+ puts "Signals: #{msr206_obj[:serial_conn].signals}"
64
+
65
+ exec_resp = PWN::Plugins::MSR206.exec(
61
66
  msr206_obj: msr206_obj,
62
67
  cmd: :simulate_power_cycle_warm_reset
63
68
  )
69
+
70
+ exec_resp = PWN::Plugins::MSR206.exec(
71
+ msr206_obj: msr206_obj,
72
+ cmd: :version_report
73
+ )
74
+ puts "Firmware Version: #{exec_resp[:decoded]}"
75
+
76
+ # Main Menu
77
+ menu_msg = ''
78
+ loop do
79
+ unless menu_msg.include?('ERROR')
80
+ exec_resp = PWN::Plugins::MSR206.exec(
81
+ msr206_obj: msr206_obj,
82
+ cmd: :yellow_on
83
+ )
84
+ puts exec_resp.inspect
85
+ end
86
+
87
+ puts "\n>> MAIN MENU OPTIONS:"
88
+ puts '[(R)ead Card]'
89
+ puts '[(C)opy Card]'
90
+ puts '[(E)dit Card]'
91
+ puts '[(B)ackup Card]'
92
+ puts '[(W)arm Reset]'
93
+ puts '[(Q)uit]'
94
+ puts menu_msg
95
+ print 'MAIN MENU OPTION >>> '
96
+ menu_msg = ''
97
+ option = gets.scrub.chomp.strip.upcase.to_sym
98
+
99
+ case option
100
+ when :R
101
+ menu_msg = 'READY TO READ - PLEASE SWIPE CARD'
102
+ # Read Card
103
+ PWN::Plugins::MSR206.wait_for_swipe(
104
+ msr206_obj: msr206_obj,
105
+ type: :arm_to_read
106
+ )
107
+ when :C
108
+ menu_msg = 'READY TO COPY - PLEASE SWIPE ORIGINAL CARD'
109
+ # Read Original Card
110
+ PWN::Plugins::MSR206.wait_for_swipe(
111
+ msr206_obj: msr206_obj,
112
+ type: :arm_to_read
113
+ )
114
+
115
+ # TODO: Save Original Card Contents
116
+ # arm_to_write card to clone
117
+ # read cloned card to verify successful write
118
+ when :E
119
+ menu_msg = 'READY TO EDIT - PLEASE SWIPE TARGET CARD'
120
+ # Read Target Card
121
+ PWN::Plugins::MSR206.wait_for_swipe(
122
+ msr206_obj: msr206_obj,
123
+ type: :arm_to_read
124
+ )
125
+
126
+ # TODO: Save Original Card Contents
127
+ # arm_to_write card to edit
128
+ # read edited card to verify successful write
129
+ when :B
130
+ menu_msg = 'READY TO BACKUP - PLEASE SWIPE CARD'
131
+ # Read Card
132
+ PWN::Plugins::MSR206.wait_for_swipe(
133
+ msr206_obj: msr206_obj,
134
+ type: :arm_to_read
135
+ )
136
+ when :W
137
+ exec_resp = PWN::Plugins::MSR206.exec(
138
+ msr206_obj: msr206_obj,
139
+ cmd: :simulate_power_cycle_warm_reset
140
+ )
141
+ puts exec_resp.inspect
142
+ when :Q
143
+ exit
144
+ else
145
+ menu_msg = '****** ERROR: Invalid Menu Option Selected ******'
146
+ exec_resp = PWN::Plugins::MSR206.exec(
147
+ msr206_obj: msr206_obj,
148
+ cmd: :yellow_off
149
+ )
150
+
151
+ exec_resp = PWN::Plugins::MSR206.exec(
152
+ msr206_obj: msr206_obj,
153
+ cmd: :red_flash
154
+ )
155
+ end
156
+ end
157
+ rescue StandardError => e
158
+ raise e
64
159
  rescue SystemExit, Interrupt
65
160
  puts "\nGoodbye."
161
+ ensure
162
+ # Lights Off
163
+ exec_resp = PWN::Plugins::MSR206.exec(
164
+ msr206_obj: msr206_obj,
165
+ cmd: :green_off
166
+ )
167
+
168
+ exec_resp = PWN::Plugins::MSR206.exec(
169
+ msr206_obj: msr206_obj,
170
+ cmd: :yellow_off
171
+ )
172
+
173
+ exec_resp = PWN::Plugins::MSR206.exec(
174
+ msr206_obj: msr206_obj,
175
+ cmd: :red_off
176
+ )
177
+
178
+ msr206_obj = PWN::Plugins::MSR206.disconnect(msr206_obj: msr206_obj) if msr206_obj
66
179
  end
@@ -9,9 +9,9 @@ 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 7)',
12
+ # data_bits: 'optional - (defaults to 8)',
13
13
  # stop_bits: 'optional - (defaults to 1)',
14
- # parity: 'optional - :even|:mark|:odd|:space|:none (defaults to :odd),'
14
+ # parity: 'optional - :even|:mark|:odd|:space|:none (defaults to :none),'
15
15
  # flow_control: 'optional - :none||:hard||:soft (defaults to :none)'
16
16
  # )
17
17
 
@@ -19,9 +19,9 @@ module PWN
19
19
  # Default Baud Rate for this Device is 19200
20
20
  opts[:block_dev] = '/dev/ttyUSB0' unless opts[:block_dev]
21
21
  opts[:baud] = 9_600 unless opts[:baud]
22
- opts[:data_bits] = 7 unless opts[:data_bits]
22
+ opts[:data_bits] = 8 unless opts[:data_bits]
23
23
  opts[:stop_bits] = 1 unless opts[:stop_bits]
24
- opts[:parity] = :odd unless opts[:parity]
24
+ opts[:parity] = :none unless opts[:parity]
25
25
  opts[:flow_control] = :none unless opts[:flow_control]
26
26
  msr206_obj = PWN::Plugins::Serial.connect(opts)
27
27
  rescue StandardError => e
@@ -93,6 +93,221 @@ module PWN
93
93
  raise e
94
94
  end
95
95
 
96
+ # Supported Method Parameters::
97
+ # parsed_cmd_resp_arr = decode(
98
+ # raw_byte_arr: 'required - raw_byte_arr produced in #parse_responses'
99
+ # )
100
+
101
+ private_class_method def self.decode(opts = {})
102
+ raw_byte_arr = opts[:raw_byte_arr]
103
+
104
+ decoded_data_str = ''
105
+ if raw_byte_arr
106
+ raw_byte_arr.first.split.each do |byte_str|
107
+ case byte_str
108
+ when '1B'
109
+ decoded_data_str += ''
110
+ when '20'
111
+ decoded_data_str += ' '
112
+ when '21'
113
+ decoded_data_str += '!'
114
+ when '22'
115
+ decoded_data_str += '"'
116
+ when '23'
117
+ decoded_data_str += '#'
118
+ when '24'
119
+ decoded_data_str += '$'
120
+ when '25'
121
+ decoded_data_str += '%'
122
+ when '26'
123
+ decoded_data_str += '&'
124
+ when '27'
125
+ decoded_data_str += "'"
126
+ when '28'
127
+ decoded_data_str += '('
128
+ when '29'
129
+ decoded_data_str += ')'
130
+ when '2A', 'AA'
131
+ decoded_data_str += '*'
132
+ when '2B', 'AB'
133
+ decoded_data_str += '+'
134
+ when '2C', 'AC'
135
+ decoded_data_str += ','
136
+ when '2D', 'AD'
137
+ decoded_data_str += '-'
138
+ when '2E', 'AE'
139
+ decoded_data_str += '.'
140
+ when '2F', 'AF'
141
+ decoded_data_str += '/'
142
+ when '30', 'B0'
143
+ decoded_data_str += '0'
144
+ when '31', 'B1'
145
+ decoded_data_str += '1'
146
+ when '32', 'B2'
147
+ decoded_data_str += '2'
148
+ when '33', 'B3'
149
+ decoded_data_str += '3'
150
+ when '34', 'B4'
151
+ decoded_data_str += '4'
152
+ when '35', 'B5'
153
+ decoded_data_str += '5'
154
+ when '36', 'B6'
155
+ decoded_data_str += '6'
156
+ when '37', 'B7'
157
+ decoded_data_str += '7'
158
+ when '38', 'B8'
159
+ decoded_data_str += '8'
160
+ when '39', 'B9'
161
+ decoded_data_str += '9'
162
+ when '3A', 'BA'
163
+ decoded_data_str += ':'
164
+ when '3B', 'BB'
165
+ decoded_data_str += ';'
166
+ when '3C', 'BC'
167
+ decoded_data_str += '<'
168
+ when '3D', 'BD'
169
+ decoded_data_str += '='
170
+ when '3E', 'BE'
171
+ decoded_data_str += '>'
172
+ when '3F', 'BF'
173
+ decoded_data_str += '?'
174
+ when '40', 'C0'
175
+ decoded_data_str += '@'
176
+ when '41', 'C1'
177
+ decoded_data_str += 'A'
178
+ when '42', 'C2'
179
+ decoded_data_str += 'B'
180
+ when '43', 'C3'
181
+ decoded_data_str += 'C'
182
+ when '44', 'C4'
183
+ decoded_data_str += 'D'
184
+ when '45', 'C5'
185
+ decoded_data_str += 'E'
186
+ when '46', 'C6'
187
+ decoded_data_str += 'F'
188
+ when '47', 'C7'
189
+ decoded_data_str += 'G'
190
+ when '48', 'C8'
191
+ decoded_data_str += 'H'
192
+ when '49', 'C9'
193
+ decoded_data_str += 'I'
194
+ when '4A', 'CA'
195
+ decoded_data_str += 'J'
196
+ when '4B', 'CB'
197
+ decoded_data_str += 'K'
198
+ when '4C', 'CC'
199
+ decoded_data_str += 'L'
200
+ when '4D', 'CD'
201
+ decoded_data_str += 'M'
202
+ when '4E', 'CE'
203
+ decoded_data_str += 'N'
204
+ when '4F', 'CF'
205
+ decoded_data_str += 'O'
206
+ when '50', 'D0'
207
+ decoded_data_str += 'P'
208
+ when '51', 'D1'
209
+ decoded_data_str += 'Q'
210
+ when '52', 'D2'
211
+ decoded_data_str += 'R'
212
+ when '53', 'D3'
213
+ decoded_data_str += 'S'
214
+ when '54', 'D4'
215
+ decoded_data_str += 'T'
216
+ when '55', 'D5'
217
+ decoded_data_str += 'U'
218
+ when '56', 'D6'
219
+ decoded_data_str += 'V'
220
+ when '57', 'D7'
221
+ decoded_data_str += 'W'
222
+ when '58', 'D8'
223
+ decoded_data_str += 'X'
224
+ when '59', 'D9'
225
+ decoded_data_str += 'Y'
226
+ when '5A', 'DA'
227
+ decoded_data_str += 'Z'
228
+ when '5B', 'DB'
229
+ decoded_data_str += '['
230
+ when '5C', 'DC'
231
+ decoded_data_str += '\\'
232
+ when '5D', 'DD'
233
+ decoded_data_str += ']'
234
+ when '5E', 'DE'
235
+ decoded_data_str += '^'
236
+ when '5F', 'DF'
237
+ decoded_data_str += '_'
238
+ when '60', 'E0'
239
+ decoded_data_str += '`'
240
+ when '61', 'E1'
241
+ decoded_data_str += 'a'
242
+ when '62', 'E2'
243
+ decoded_data_str += 'b'
244
+ when '63', 'E3'
245
+ decoded_data_str += 'c'
246
+ when '64', 'E4'
247
+ decoded_data_str += 'd'
248
+ when '65', 'E5'
249
+ decoded_data_str += 'e'
250
+ when '66', 'E6'
251
+ decoded_data_str += 'f'
252
+ when '67', 'E7'
253
+ decoded_data_str += 'g'
254
+ when '68', 'E8'
255
+ decoded_data_str += 'h'
256
+ when '69', 'E9'
257
+ decoded_data_str += 'i'
258
+ when '6A', 'EA'
259
+ decoded_data_str += 'j'
260
+ when '6B', 'EB'
261
+ decoded_data_str += 'k'
262
+ when '6C', 'EC'
263
+ decoded_data_str += 'l'
264
+ when '6D', 'ED'
265
+ decoded_data_str += 'm'
266
+ when '6E', 'EE'
267
+ decoded_data_str += 'n'
268
+ when '6F', 'EF'
269
+ decoded_data_str += 'o'
270
+ when '70', 'F0'
271
+ decoded_data_str += 'p'
272
+ when '71', 'F1'
273
+ decoded_data_str += 'q'
274
+ when '72', 'F2'
275
+ decoded_data_str += 'r'
276
+ when '73', 'F3'
277
+ decoded_data_str += 's'
278
+ when '74', 'F4'
279
+ decoded_data_str += 't'
280
+ when '75', 'F5'
281
+ decoded_data_str += 'u'
282
+ when '76', 'F6'
283
+ decoded_data_str += 'v'
284
+ when '77', 'F7'
285
+ decoded_data_str += 'w'
286
+ when '78', 'F8'
287
+ decoded_data_str += 'x'
288
+ when '79', 'F9'
289
+ decoded_data_str += 'y'
290
+ when '7A', 'FA'
291
+ decoded_data_str += 'z'
292
+ when '7B', 'FB'
293
+ decoded_data_str += '{'
294
+ when '7C', 'FC'
295
+ decoded_data_str += '|'
296
+ when '7D', 'FD'
297
+ decoded_data_str += '}'
298
+ when '7E', 'FE'
299
+ decoded_data_str += '~'
300
+ else
301
+ decoded_data_str += "\u00BF"
302
+ end
303
+ end
304
+ end
305
+
306
+ decoded_data_str
307
+ rescue StandardError => e
308
+ raise e
309
+ end
310
+
96
311
  # Supported Method Parameters::
97
312
  # parsed_cmd_resp_arr = parse_responses(
98
313
  # cmd_resp: 'required - command response string'
@@ -100,11 +315,15 @@ module PWN
100
315
 
101
316
  private_class_method def self.parse_responses(opts = {})
102
317
  msr206_obj = opts[:msr206_obj]
103
- cmd = opts[:cmd].to_s.scrub.strip.chomp
318
+ cmd = opts[:cmd]
104
319
 
105
320
  keep_parsing_responses = true
106
321
  next_response_detected = false
107
- all_cmd_responses = []
322
+ response = {}
323
+ response[:cmd] = cmd
324
+ response[:cmd] ||= :na
325
+
326
+ raw_byte_arr = []
108
327
  a_cmd_r_len = 0
109
328
  last_a_cmd_r_len = 0
110
329
 
@@ -114,26 +333,57 @@ module PWN
114
333
 
115
334
  while keep_parsing_responses
116
335
  until next_response_detected
117
- all_cmd_responses = PWN::Plugins::Serial.response(serial_obj: msr206_obj)
118
- cmd_resp = all_cmd_responses.last
336
+ raw_byte_arr = PWN::Plugins::Serial.response(serial_obj: msr206_obj)
337
+ cmd_resp = raw_byte_arr.last
119
338
  bytes_in_cmd_resp = cmd_resp.split.length if cmd_resp
120
- a_cmd_r_len = all_cmd_responses.length
339
+ a_cmd_r_len = raw_byte_arr.length
121
340
 
122
341
  next_response_detected = true if a_cmd_r_len > last_a_cmd_r_len
123
342
  end
124
343
 
125
- # cmd_resp = all_cmd_responses.last
126
- # case cmd_resp
127
- # when '21', '28', '29', '2A', '2B', '2D', '2F', '3A', '31', '32', '33', '3E', '3F', '5E', '7E', '98 FE'
128
- # next_response_detected = true
129
- # end
344
+ case cmd_resp
345
+ when '21'
346
+ response[:msg] = :invalid_command
347
+ when '28'
348
+ response[:msg] = :card_speed_measurement_start
349
+ when '29'
350
+ response[:msg] = :card_speed_measurement_end
351
+ when '2A'
352
+ response[:msg] = :error
353
+ when '2B'
354
+ response[:msg] = :no_data_found
355
+ when '2D'
356
+ response[:msg] = :insufficient_leading_zeros_for_custom_writing
357
+ when '2F'
358
+ response[:msg] = :first_lsb_char_not_one_for_custom_writing
359
+ when '3A'
360
+ response[:msg] = :power_on_report
361
+ when '31'
362
+ response[:msg] = :unsuccessful_read_after_write_track1
363
+ when '32'
364
+ response[:msg] = :unsuccessful_read_after_write_track2
365
+ when '33'
366
+ response[:msg] = :unsuccessful_read_after_write_track3
367
+ when '3E'
368
+ response[:msg] = :card_edge_detected
369
+ when '3F'
370
+ response[:msg] = :communications_error
371
+ when '5E'
372
+ response[:msg] = :ack_command_completed
373
+ when '7E'
374
+ response[:msg] = :command_not_supported_by_hardware
375
+ else
376
+ response[:msg] = :na
377
+ end
378
+
130
379
  next_response_detected = false
131
380
  last_a_cmd_r_len = a_cmd_r_len
132
- print "\n"
133
381
  keep_parsing_responses = false
134
382
  end
135
383
 
136
- all_cmd_responses
384
+ response[:raw] = raw_byte_arr
385
+ response[:decoded] = decode(raw_byte_arr: raw_byte_arr)
386
+ response
137
387
  rescue StandardError => e
138
388
  raise e
139
389
  ensure
@@ -281,6 +531,119 @@ module PWN
281
531
  PWN::Plugins::Serial.flush_session_data
282
532
  end
283
533
 
534
+ # Supported Method Parameters::
535
+ # PWN::Plugins::MSR206.wait_for_swipe(
536
+ # msr206_obj: 'required - msr206_obj returned from #connect method'
537
+ # )
538
+
539
+ public_class_method def self.wait_for_swipe(opts = {})
540
+ msr206_obj = opts[:msr206_obj]
541
+ type = opts[:type].to_s.scrub.strip.chomp.to_sym
542
+ types_arr = %i[
543
+ arm_to_read
544
+ arm_to_read_w_speed_prompts
545
+ arm_to_write_no_raw
546
+ arm_to_write_with_raw
547
+ arm_to_write_with_raw_speed_prompts
548
+ ]
549
+
550
+ raise "ERROR Unsupported type in #wait_for_swipe - #{type}. Valid types:\n#{types_arr}" unless types_arr.include?(type)
551
+
552
+ exec_resp = exec(
553
+ msr206_obj: msr206_obj,
554
+ cmd: :red_off
555
+ )
556
+
557
+ exec_resp = exec(
558
+ msr206_obj: msr206_obj,
559
+ cmd: :yellow_off
560
+ )
561
+
562
+ exec_resp = PWN::Plugins::MSR206.exec(
563
+ msr206_obj: msr206_obj,
564
+ cmd: type
565
+ )
566
+
567
+ exec_resp = exec(
568
+ msr206_obj: msr206_obj,
569
+ cmd: :green_on
570
+ )
571
+
572
+ exec_resp = PWN::Plugins::MSR206.exec(
573
+ msr206_obj: msr206_obj,
574
+ cmd: :card_edge_detect
575
+ )
576
+
577
+ print 'Ready. Please Swipe Card Now:'
578
+ loop do
579
+ exec_resp = parse_responses(
580
+ msr206_obj: msr206_obj,
581
+ cmd: :card_edge_detect
582
+ )
583
+
584
+ break if exec_resp[:msg] == :ack_command_completed
585
+ end
586
+
587
+ puts "*** ISO Track Format: Standard #{'*' * 17}"
588
+ print 'TRACK 1 >>> '
589
+ exec_resp = exec(
590
+ msr206_obj: msr206_obj,
591
+ cmd: :tx_iso_std_data_track1,
592
+ params: [0x31]
593
+ )
594
+ puts exec_resp[:decoded]
595
+ puts exec_resp.inspect
596
+
597
+ # print ">> Track 1 (ALT DATA)\n"
598
+ # exec_resp = exec(
599
+ # msr206_obj: msr206_obj,
600
+ # cmd: :alt_tx_iso_std_data_track1,
601
+ # params: [0x31]
602
+ # )
603
+ # puts exec_resp.inspect
604
+
605
+ print "\nTRACK 2 >>> "
606
+ exec_resp = exec(
607
+ msr206_obj: msr206_obj,
608
+ cmd: :tx_iso_std_data_track2,
609
+ params: [0x32]
610
+ )
611
+ puts exec_resp[:decoded]
612
+ puts exec_resp.inspect
613
+
614
+ # print ">> Track 2 (ALT DATA)\n"
615
+ # exec_resp = exec(
616
+ # msr206_obj: msr206_obj,
617
+ # cmd: :alt_tx_iso_std_data_track2,
618
+ # params: [0x32]
619
+ # )
620
+ # puts exec_resp.inspect
621
+
622
+ print "\nTRACK 3 >>> "
623
+ exec_resp = exec(
624
+ msr206_obj: msr206_obj,
625
+ cmd: :tx_iso_std_data_track3,
626
+ params: [0x33]
627
+ )
628
+ puts exec_resp[:decoded]
629
+ puts exec_resp.inspect
630
+
631
+ # print ">> Track 3 (ALT DATA)\n"
632
+ # exec_resp = exec(
633
+ # msr206_obj: msr206_obj,
634
+ # cmd: :alt_tx_iso_std_data_track3,
635
+ # params: [0x33]
636
+ # )
637
+ # puts exec_resp.inspect
638
+ rescue StandardError => e
639
+ raise e
640
+ ensure
641
+ exec_resp = exec(
642
+ msr206_obj: msr206_obj,
643
+ cmd: :green_off
644
+ )
645
+ end
646
+
284
647
  # Supported Method Parameters::
285
648
  # PWN::Plugins::MSR206.disconnect(
286
649
  # msr206_obj: 'required - msr206_obj returned from #connect method'
@@ -309,9 +672,9 @@ module PWN
309
672
  msr206_obj = #{self}.connect(
310
673
  block_dev: 'optional serial block device path (defaults to /dev/ttyUSB0)',
311
674
  baud: 'optional (defaults to 9600)',
312
- data_bits: 'optional (defaults to 7)',
675
+ data_bits: 'optional (defaults to 8)',
313
676
  stop_bits: 'optional (defaults to 1)',
314
- parity: 'optional - :even|:mark|:odd|:space|:none (defaults to :odd),'
677
+ parity: 'optional - :even|:mark|:odd|:space|:none (defaults to :none),'
315
678
  flow_control: 'optional - :none||:hard||:soft (defaults to :none)'
316
679
  )
317
680
 
data/lib/pwn/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PWN
4
- VERSION = '0.4.463'
4
+ VERSION = '0.4.464'
5
5
  end
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.463
4
+ version: 0.4.464
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-26 00:00:00.000000000 Z
11
+ date: 2022-05-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport