]> git.zerfleddert.de Git - proxmark3-svn/blobdiff - client/scripts/writeraw.lua
Fix two errors in writeraw (14a)-script that were found by jonor
[proxmark3-svn] / client / scripts / writeraw.lua
index 25250864642994ecc0c77bbfc75107357a7042dc..1dc8c0df047deaf9602daf24ac94da4987f4c106 100644 (file)
@@ -21,18 +21,33 @@ function show(usbpacket)
 end
 
 -- Want to do both connect and send raw, so we should AND the two commands
--- ISO14A_COMMAND.ISO14A_RAW and ISO14A_CONNECT. However, we don't have a 
+-- ISO14A_COMMAND.ISO14A_RAW(8) and ISO14A_CONNECT (1). However, we don't have a 
 -- bitlib yet, so we'll do it manually, 1 & 8 == 9
--- ISO14A_NO_DISCONNECT = 2
+-- ISO14A_NO_DISCONNECT = 2 ==> 11
 
 print(string.len(rawdata))
 local command = Command:new{cmd = cmds.CMD_READER_ISO_14443a, 
-                                                                       arg1 = 9, 
-                                                                       arg2 = string.len(rawdata), 
+                                                                       arg1 = 3, -- Connect (1) and don't disconnect (2)
+                                                                       arg2 = 0
+                  }
+local mf_auth = Command:new{cmd = cmds.CMD_READER_ISO_14443a, 
+                                                                       arg1 = 10, -- Send raw 
+                                                                       -- arg2 contains the length. 
+                                                                       -- Remember; rawdata is an ascii string containing
+                                                                       -- ASCII characters. Thus; rawdata= "FF" are two bytes in length
+                                                                       -- but when converted to true hexvalues internally inside the Command 
+                                                                       -- constructor, 0xFF is only one byte. So, the bytelength is the 
+                                                                       -- length of the ASCII-string divided by two. Thanks jonor!
+
+                                                                       arg2 = string.len(rawdata)/2, 
                                                                        data = rawdata}
+local quit = Command:new{cmd = cmds.CMD_READER_ISO_14443a, 
+                                                                       arg1 = 0, -- Nothing 
+                                                                       }
+                                                                       
 core.clearCommandBuffer()
-print("Sending")
-print(command)
+--print("Sending")
+--print(command)
 local err = core.SendCommand(command:getBytes())
 if err then
        print(err)
@@ -41,6 +56,23 @@ end
 local cardselect = core.WaitForResponseTimeout(cmds.CMD_ACK,TIMEOUT)
 print("Card select:")
 show(cardselect)
-local response = core.WaitForResponseTimeout(cmds.CMD_ACK,TIMEOUT)
-print("Raw response:")
-show(response)
+--local response = core.WaitForResponseTimeout(cmds.CMD_ACK,TIMEOUT)
+--print("Raw response:")
+--show(response)
+
+local answer = ""
+while answer ~='q' do
+       
+       local err = core.SendCommand(mf_auth:getBytes())
+               if err then
+                       print(err)
+                       return nil, err
+               end
+       local nonce = core.WaitForResponseTimeout(cmds.CMD_ACK,TIMEOUT)
+       print("Nonce:")
+       show(nonce)
+       io.write("Write q to quit, hit any char to get a nonce ")
+       io.flush()
+       answer=io.read(1)
+
+end--]]
Impressum, Datenschutz