Makefile: display firmware size
[RRG-proxmark3.git] / tools / pm3_reblay-emulating.py
blobe59dd3b6ae539362c23178d4400fa48f09c7d183
1 #!/usr/bin/env python3
3 """
4 //-----------------------------------------------------------------------------
5 // Salvador Mendoza (salmg.net), 2021
6 //
7 // This code is licensed to you under the terms of the GNU GPL, version 2 or,
8 // at your option, any later version. See the LICENSE.txt file for the text of
9 // the license.
10 //-----------------------------------------------------------------------------
11 // Code to test Proxmark3 Standalone mode aka reblay by Salvador Mendoza
12 //-----------------------------------------------------------------------------
13 """
15 import serial
16 from smartcard.util import toHexString, toBytes
17 from smartcard.CardType import AnyCardType
18 from smartcard.CardRequest import CardRequest
20 ser = serial.Serial('/dev/rfcomm0') # open Proxmark3 Bluetooth port
22 def pd(data):
23 rapdu = map(ord, data)
24 return rapdu
26 apdu = [
27 [0x6F, 0x23, 0x84, 0x0E, 0x32, 0x50, 0x41, 0x59, 0x2E, 0x53, 0x59, 0x53, 0x2E, 0x44, 0x44, 0x46, 0x30, 0x31, 0xA5, 0x11, 0xBF, 0x0C, 0x0E, 0x61, 0x0C, 0x4F, 0x07, 0xA0, 0x00, 0x00, 0x00, 0x03, 0x10, 0x10, 0x87, 0x01, 0x01, 0x90, 0x00],
28 [0x6F, 0x1E, 0x84, 0x07, 0xA0, 0x00, 0x00, 0x00, 0x03, 0x10, 0x10, 0xA5, 0x13, 0x50, 0x0B, 0x56, 0x49, 0x53, 0x41, 0x20, 0x43, 0x52, 0x45, 0x44, 0x49, 0x54, 0x9F, 0x38, 0x03, 0x9F, 0x66, 0x02, 0x90, 0x00],
29 [0x80, 0x06, 0x00, 0x80, 0x08, 0x01, 0x01, 0x00, 0x90, 0x00],
30 [0x70,0x15,0x57,0x13,0x46,0x50,0x98,0x29,0x81,0x62,0x29,0x58,0xd2,0x40,0x32,0x01,0x14,0x69,0x00,0x00,0x13,0x83,0x44,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xd0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x8f,0x90,0x00],
31 [0x6f, 0x00],
32 [0x6f, 0x00]
35 print('Testing code: bluetooth has to be connected with the right rfcomm port!')
36 print('Waiting for data...')
37 initd = ser.read(1)
39 bufferlen = pd(initd)[0]
40 rping = ser.read(bufferlen)
41 ping = pd(rping)
43 print('Terminal command:'),
44 print(toHexString(ping))
46 for x in apdu:
47 print('Sending cmd: '),
48 ser.write(x)
49 print(toHexString(x))
50 print('--')
52 lenpk = ser.read(1) #first byte is the buffer length
53 bufferlen = pd(lenpk)[0]
55 buffer = pd(ser.read(bufferlen))
56 print('Terminal command:'),
57 print(toHexString(buffer))