]>
Commit | Line | Data |
---|---|---|
1 | local cmds = require('commands') | |
2 | local desc = | |
3 | [[ | |
4 | ||
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 | |
7 | ||
8 | ]] | |
9 | ||
10 | print(desc) | |
11 | ||
12 | -- Some raw data | |
13 | local rawdata = "6000F57b" --mf_auth | |
14 | local TIMEOUT = 2000 -- Shouldn't take longer than 2 seconds | |
15 | ||
16 | function show(usbpacket) | |
17 | if usbpacket then | |
18 | local response = Command.parse(usbpacket) | |
19 | print(response) | |
20 | end | |
21 | end | |
22 | ||
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 | |
27 | ||
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) | |
31 | arg2 = 0-- string.len(rawdata), | |
32 | --data = rawdata | |
33 | } | |
34 | local mf_auth = Command:new{cmd = cmds.CMD_READER_ISO_14443a, | |
35 | arg1 = 6, -- Send raw | |
36 | arg2 = string.len(rawdata), | |
37 | data = rawdata} | |
38 | local quit = Command:new{cmd = cmds.CMD_READER_ISO_14443a, | |
39 | arg1 = 0, -- Nothing | |
40 | } | |
41 | ||
42 | core.clearCommandBuffer() | |
43 | --print("Sending") | |
44 | --print(command) | |
45 | local err = core.SendCommand(command:getBytes()) | |
46 | if err then | |
47 | print(err) | |
48 | return nil, err | |
49 | end | |
50 | local cardselect = core.WaitForResponseTimeout(cmds.CMD_ACK,TIMEOUT) | |
51 | print("Card select:") | |
52 | show(cardselect) | |
53 | --local response = core.WaitForResponseTimeout(cmds.CMD_ACK,TIMEOUT) | |
54 | --print("Raw response:") | |
55 | --show(response) | |
56 | ||
57 | local answer = "" | |
58 | while answer ~='q' do | |
59 | ||
60 | local err = core.SendCommand(mf_auth:getBytes()) | |
61 | if err then | |
62 | print(err) | |
63 | return nil, err | |
64 | end | |
65 | local nonce = core.WaitForResponseTimeout(cmds.CMD_ACK,TIMEOUT) | |
66 | print("Nonce:") | |
67 | show(nonce) | |
68 | io.write("Write q to quit, hit any char to get a nonce ") | |
69 | io.flush() | |
70 | answer=io.read(1) | |
71 | ||
72 | end--]] |