1 local cmds = require('commands')
5 This script is a work in progress, not yet functional. It is an attempt to use the raw-writing
6 capabilities already present within the devices
13 local rawdata = "6000F57b" --mf_auth
14 local TIMEOUT = 2000 -- Shouldn't take longer than 2 seconds
16 function show(usbpacket)
18 local response = Command.parse(usbpacket)
23 -- Want to do both connect and send raw, so we should AND the two commands
24 -- ISO14A_COMMAND.ISO14A_RAW(8) and ISO14A_CONNECT (1). However, we don't have a
25 -- bitlib yet, so we'll do it manually, 1 & 8 == 9
26 -- ISO14A_NO_DISCONNECT = 2 ==> 11
28 print(string.len(rawdata))
29 local command = Command:new{cmd = cmds.CMD_READER_ISO_14443a,
30 arg1 = 3, -- Connect (1) and don't disconnect (2)
33 local mf_auth = Command:new{cmd = cmds.CMD_READER_ISO_14443a,
34 arg1 = 10, -- Send raw
35 -- arg2 contains the length.
36 -- Remember; rawdata is an ascii string containing
37 -- ASCII characters. Thus; rawdata= "FF" are two bytes in length
38 -- but when converted to true hexvalues internally inside the Command
39 -- constructor, 0xFF is only one byte. So, the bytelength is the
40 -- length of the ASCII-string divided by two. Thanks jonor!
42 arg2 = string.len(rawdata)/2,
44 local quit = Command:new{cmd = cmds.CMD_READER_ISO_14443a,
48 core.clearCommandBuffer()
51 local err = core.SendCommand(command:getBytes())
56 local cardselect = core.WaitForResponseTimeout(cmds.CMD_ACK,TIMEOUT)
59 --local response = core.WaitForResponseTimeout(cmds.CMD_ACK,TIMEOUT)
60 --print("Raw response:")
66 local err = core.SendCommand(mf_auth:getBytes())
71 local nonce = core.WaitForResponseTimeout(cmds.CMD_ACK,TIMEOUT)
74 io.write("Write q to quit, hit any char to get a nonce ")