]> cvs.zerfleddert.de Git - proxmark3-svn/blame - client/scripts/writeraw.lua
Fix two errors in writeraw (14a)-script that were found by jonor
[proxmark3-svn] / client / scripts / writeraw.lua
CommitLineData
4df3eb3f 1local cmds = require('commands')
2local desc =
3[[
4
5This script is a work in progress, not yet functional. It is an attempt to use the raw-writing
6capabilities already present within the devices
7
8]]
9
10print(desc)
11
12-- Some raw data
13local rawdata = "6000F57b" --mf_auth
14local TIMEOUT = 2000 -- Shouldn't take longer than 2 seconds
15
16function show(usbpacket)
17 if usbpacket then
18 local response = Command.parse(usbpacket)
19 print(response)
20 end
21end
22
23-- Want to do both connect and send raw, so we should AND the two commands
3e69b211 24-- ISO14A_COMMAND.ISO14A_RAW(8) and ISO14A_CONNECT (1). However, we don't have a
4df3eb3f 25-- bitlib yet, so we'll do it manually, 1 & 8 == 9
3e69b211 26-- ISO14A_NO_DISCONNECT = 2 ==> 11
4df3eb3f 27
28print(string.len(rawdata))
29local command = Command:new{cmd = cmds.CMD_READER_ISO_14443a,
3e69b211 30 arg1 = 3, -- Connect (1) and don't disconnect (2)
24d48e60 31 arg2 = 0
3e69b211 32 }
33local mf_auth = Command:new{cmd = cmds.CMD_READER_ISO_14443a,
24d48e60 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!
41
42 arg2 = string.len(rawdata)/2,
4df3eb3f 43 data = rawdata}
3e69b211 44local quit = Command:new{cmd = cmds.CMD_READER_ISO_14443a,
45 arg1 = 0, -- Nothing
46 }
47
4df3eb3f 48core.clearCommandBuffer()
3e69b211 49--print("Sending")
50--print(command)
4df3eb3f 51local err = core.SendCommand(command:getBytes())
52if err then
53 print(err)
54 return nil, err
55end
56local cardselect = core.WaitForResponseTimeout(cmds.CMD_ACK,TIMEOUT)
57print("Card select:")
58show(cardselect)
3e69b211 59--local response = core.WaitForResponseTimeout(cmds.CMD_ACK,TIMEOUT)
60--print("Raw response:")
61--show(response)
62
63local answer = ""
64while answer ~='q' do
65
66 local err = core.SendCommand(mf_auth:getBytes())
67 if err then
68 print(err)
69 return nil, err
70 end
71 local nonce = core.WaitForResponseTimeout(cmds.CMD_ACK,TIMEOUT)
72 print("Nonce:")
73 show(nonce)
74 io.write("Write q to quit, hit any char to get a nonce ")
75 io.flush()
76 answer=io.read(1)
77
78end--]]
Impressum, Datenschutz