added a ToC
[RRG-proxmark3.git] / tools / pm3_reblay-reading.py
blob26fa96844ff04d2a14dc5baf61ff5c0a27ae8a79
1 """
2 //-----------------------------------------------------------------------------
3 // Salvador Mendoza (salmg.net), 2021
4 //
5 // This code is licensed to you under the terms of the GNU GPL, version 2 or,
6 // at your option, any later version. See the LICENSE.txt file for the text of
7 // the license.
8 //-----------------------------------------------------------------------------
9 // Code to test Proxmark3 Standalone mode aka reblay by Salvador Mendoza
10 //-----------------------------------------------------------------------------
11 """
13 import serial
14 from smartcard.util import toHexString
16 ser = serial.Serial('/dev/rfcomm0') # open Proxmark3 Bluetooth port
18 def pd(data):
19 rapdu = map(ord, data)
20 return rapdu
22 apdu = [
23 [0x00, 0xA4, 0x04, 0x00, 0x0e, 0x32, 0x50, 0x41, 0x59, 0x2e, 0x53, 0x59, 0x53, 0x2e, 0x44, 0x44, 0x46, 0x30, 0x31, 0x00], # PPSE
24 [0x00, 0xA4, 0x04, 0x00, 0x07, 0xa0, 0x00, 0x00, 0x00, 0x03, 0x10, 0x10, 0x00], # Visa card
25 [0x80, 0xA8, 0x00, 0x00, 0x02, 0x83, 0x00, 0x00], # GET PROCESSING
26 [0x00, 0xb2, 0x01, 0x0c, 0x00] # SFI
29 print('Testing code: bluetooth has to be connected with the right rfcomm port!')
30 print('Waiting for data...')
31 initd = ser.read(1)
33 bufferlen = pd(initd)[0]
34 rping = ser.read(bufferlen)
36 ping = pd(rping)
37 if (len(ping) == 7):
38 print('UID:'),
39 print(toHexString(ping[:4]))
40 print('ATQA:'),
41 print(toHexString(ping[4:-1]))
42 print('SAK:'),
43 print(toHexString(ping[-1:]))
44 elif (len(ping) == 10):
45 print('UID:'),
46 print(toHexString(ping[:7]))
47 print('ATQA:'),
48 print(toHexString(ping[7:-1]))
49 print('SAK:'),
50 print(toHexString(ping[-1:]))
51 else:
52 print('got ping, no sure what it means: '),
53 print(ping)
55 for x in apdu:
56 print('Sending cmd: '),
57 ser.write(x)
58 print(toHexString(x))
60 lenpk = ser.read(1) #first byte is the buffer length
61 bufferlen = pd(lenpk)[0]
63 buffer = pd(ser.read(bufferlen))
64 print('Card Response:'),
65 print(toHexString(buffer))
66 print('--')
68 ser.write(b'1') #tell Proxmark3 that we finish the communication
69 ser.close()