mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-07-16 10:03:04 -07:00
CHG: NO_RATS adjustments to luascripts.
This commit is contained in:
parent
2ca0ea8cb4
commit
9701643fdd
11 changed files with 35 additions and 29 deletions
|
@ -22,7 +22,8 @@ local ISO14A_COMMAND = {
|
||||||
ISO14A_APPEND_CRC = 0x20,
|
ISO14A_APPEND_CRC = 0x20,
|
||||||
ISO14A_SET_TIMEOUT = 0x40,
|
ISO14A_SET_TIMEOUT = 0x40,
|
||||||
ISO14A_NO_SELECT = 0x80,
|
ISO14A_NO_SELECT = 0x80,
|
||||||
ISO14A_TOPAZMODE = 0x100
|
ISO14A_TOPAZMODE = 0x100,
|
||||||
|
ISO14A_NO_RATS = 0x200
|
||||||
}
|
}
|
||||||
|
|
||||||
local ISO14443a_TYPES = {}
|
local ISO14443a_TYPES = {}
|
||||||
|
@ -94,14 +95,17 @@ end
|
||||||
-- @param dont_disconnect - if true, does not disable the field
|
-- @param dont_disconnect - if true, does not disable the field
|
||||||
-- @return if successfull: an table containing card info
|
-- @return if successfull: an table containing card info
|
||||||
-- @return if unsuccessfull : nil, error
|
-- @return if unsuccessfull : nil, error
|
||||||
local function read14443a(dont_disconnect)
|
local function read14443a(dont_disconnect, no_rats)
|
||||||
local command, result, info, err, data
|
local command, result, info, err, data
|
||||||
|
|
||||||
command = Command:new{cmd = cmds.CMD_READER_ISO_14443a,
|
command = Command:new{cmd = cmds.CMD_READER_ISO_14443a,
|
||||||
arg1 = ISO14A_COMMAND.ISO14A_CONNECT}
|
arg1 = ISO14A_COMMAND.ISO14A_CONNECT }
|
||||||
if dont_disconnect then
|
if dont_disconnect then
|
||||||
command.arg1 = command.arg1 + ISO14A_COMMAND.ISO14A_NO_DISCONNECT
|
command.arg1 = command.arg1 + ISO14A_COMMAND.ISO14A_NO_DISCONNECT
|
||||||
end
|
end
|
||||||
|
if no_rats then
|
||||||
|
command.arg1 = command.arg1 + ISO14A_COMMAND.ISO14A_NO_RATS
|
||||||
|
end
|
||||||
local result,err = sendToDevice(command)
|
local result,err = sendToDevice(command)
|
||||||
if result then
|
if result then
|
||||||
local count,cmd,arg0,arg1,arg2 = bin.unpack('LLLL',result)
|
local count,cmd,arg0,arg1,arg2 = bin.unpack('LLLL',result)
|
||||||
|
@ -135,7 +139,6 @@ local function waitFor14443a()
|
||||||
return nil, "Aborted by user"
|
return nil, "Aborted by user"
|
||||||
end
|
end
|
||||||
local library = {
|
local library = {
|
||||||
|
|
||||||
read1443a = read14443a,
|
read1443a = read14443a,
|
||||||
read = read14443a,
|
read = read14443a,
|
||||||
waitFor14443a = waitFor14443a,
|
waitFor14443a = waitFor14443a,
|
||||||
|
|
|
@ -15,6 +15,8 @@ Arguments:
|
||||||
-p stay connected - dont inactivate the field
|
-p stay connected - dont inactivate the field
|
||||||
-x <payload> Data to send (NO SPACES!)
|
-x <payload> Data to send (NO SPACES!)
|
||||||
-d Debug flag
|
-d Debug flag
|
||||||
|
-t Topaz mode
|
||||||
|
-3 ISO14443-4 (use RATS)
|
||||||
|
|
||||||
Examples :
|
Examples :
|
||||||
|
|
||||||
|
@ -78,15 +80,19 @@ function main(args)
|
||||||
local stayconnected = false
|
local stayconnected = false
|
||||||
local payload = nil
|
local payload = nil
|
||||||
local doconnect = true
|
local doconnect = true
|
||||||
|
local topaz_mode = false
|
||||||
|
local no_rats = false
|
||||||
|
|
||||||
-- Read the parameters
|
-- Read the parameters
|
||||||
for o, a in getopt.getopt(args, 'corcpx:') do
|
for o, a in getopt.getopt(args, 'corcpx:t3') do
|
||||||
if o == "o" then doconnect = false end
|
if o == "o" then doconnect = false end
|
||||||
if o == "r" then ignore_response = true end
|
if o == "r" then ignore_response = true end
|
||||||
if o == "c" then appendcrc = true end
|
if o == "c" then appendcrc = true end
|
||||||
if o == "p" then stayconnected = true end
|
if o == "p" then stayconnected = true end
|
||||||
if o == "x" then payload = a end
|
if o == "x" then payload = a end
|
||||||
if o == "d" then DEBUG = true end
|
if o == "d" then DEBUG = true end
|
||||||
|
if o == "t" then topaz_mode = true end
|
||||||
|
if o == "3" then no_rats = true end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- First of all, connect
|
-- First of all, connect
|
||||||
|
@ -94,7 +100,7 @@ function main(args)
|
||||||
dbg("doconnect")
|
dbg("doconnect")
|
||||||
-- We reuse the connect functionality from a
|
-- We reuse the connect functionality from a
|
||||||
-- common library
|
-- common library
|
||||||
info, err = lib14a.read1443a(true)
|
info, err = lib14a.read1443a(true, no_rats)
|
||||||
|
|
||||||
if err then return oops(err) end
|
if err then return oops(err) end
|
||||||
print(("Connected to card, uid = %s"):format(info.uid))
|
print(("Connected to card, uid = %s"):format(info.uid))
|
||||||
|
@ -102,7 +108,7 @@ function main(args)
|
||||||
|
|
||||||
-- The actual raw payload, if any
|
-- The actual raw payload, if any
|
||||||
if payload then
|
if payload then
|
||||||
res,err = sendRaw(payload,{ignore_response = ignore_response})
|
res,err = sendRaw(payload,{ignore_response = ignore_response, topaz_mode = topaz_mode})
|
||||||
if err then return oops(err) end
|
if err then return oops(err) end
|
||||||
|
|
||||||
if not ignoreresponse then
|
if not ignoreresponse then
|
||||||
|
@ -131,13 +137,15 @@ function showdata(usbpacket)
|
||||||
--print("----------------")
|
--print("----------------")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function sendRaw(rawdata, options)
|
function sendRaw(rawdata, options)
|
||||||
print(">> ", rawdata)
|
print(">> ", rawdata)
|
||||||
|
|
||||||
local flags = lib14a.ISO14A_COMMAND.ISO14A_NO_DISCONNECT + lib14a.ISO14A_COMMAND.ISO14A_RAW
|
local flags = lib14a.ISO14A_COMMAND.ISO14A_NO_DISCONNECT + lib14a.ISO14A_COMMAND.ISO14A_RAW
|
||||||
|
|
||||||
|
if options.topaz_mode then
|
||||||
|
flags = flags + lib14a.ISO14A_COMMAND.ISO14A_TOPAZMODE
|
||||||
|
end
|
||||||
|
|
||||||
local command = Command:new{cmd = cmds.CMD_READER_ISO_14443a,
|
local command = Command:new{cmd = cmds.CMD_READER_ISO_14443a,
|
||||||
arg1 = flags, -- Send raw
|
arg1 = flags, -- Send raw
|
||||||
-- arg2 contains the length, which is half the length
|
-- arg2 contains the length, which is half the length
|
||||||
|
@ -149,14 +157,12 @@ end
|
||||||
|
|
||||||
-- Sends an instruction to do nothing, only disconnect
|
-- Sends an instruction to do nothing, only disconnect
|
||||||
function disconnect()
|
function disconnect()
|
||||||
|
|
||||||
local command = Command:new{cmd = cmds.CMD_READER_ISO_14443a, arg1 = 0, }
|
local command = Command:new{cmd = cmds.CMD_READER_ISO_14443a, arg1 = 0, }
|
||||||
-- We can ignore the response here, no ACK is returned for this command
|
-- We can ignore the response here, no ACK is returned for this command
|
||||||
-- Check /armsrc/iso14443a.c, ReaderIso14443a() for details
|
-- Check /armsrc/iso14443a.c, ReaderIso14443a() for details
|
||||||
return lib14a.sendToDevice(command,true)
|
return lib14a.sendToDevice(command,true)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-------------------------
|
-------------------------
|
||||||
-- Testing
|
-- Testing
|
||||||
-------------------------
|
-------------------------
|
||||||
|
|
|
@ -152,7 +152,7 @@ local function main(args)
|
||||||
if #uid ~= 14 then return oops('uid wrong length. Should be 7 hex bytes') end
|
if #uid ~= 14 then return oops('uid wrong length. Should be 7 hex bytes') end
|
||||||
else
|
else
|
||||||
-- GET TAG UID
|
-- GET TAG UID
|
||||||
local tag, err = lib14a.read1443a(false)
|
local tag, err = lib14a.read1443a(false, true)
|
||||||
if not tag then return oops(err) end
|
if not tag then return oops(err) end
|
||||||
core.clearCommandBuffer()
|
core.clearCommandBuffer()
|
||||||
|
|
||||||
|
|
|
@ -159,7 +159,7 @@ local function main(args)
|
||||||
if #uid ~= 14 then return oops('uid wrong length. Should be 7 hex bytes') end
|
if #uid ~= 14 then return oops('uid wrong length. Should be 7 hex bytes') end
|
||||||
else
|
else
|
||||||
-- GET TAG UID
|
-- GET TAG UID
|
||||||
local tag, err = lib14a.read1443a(false)
|
local tag, err = lib14a.read1443a(false, true)
|
||||||
if not tag then return oops(err) end
|
if not tag then return oops(err) end
|
||||||
core.clearCommandBuffer()
|
core.clearCommandBuffer()
|
||||||
uid = tag.uid
|
uid = tag.uid
|
||||||
|
|
|
@ -173,7 +173,7 @@ local function main(args)
|
||||||
if #uid ~= 8 then return oops('uid wrong length. Should be 4 hex bytes') end
|
if #uid ~= 8 then return oops('uid wrong length. Should be 4 hex bytes') end
|
||||||
else
|
else
|
||||||
-- GET TAG UID
|
-- GET TAG UID
|
||||||
local tag, err = lib14a.read1443a(false)
|
local tag, err = lib14a.read1443a(false, true)
|
||||||
if not tag then return oops(err) end
|
if not tag then return oops(err) end
|
||||||
core.clearCommandBuffer()
|
core.clearCommandBuffer()
|
||||||
|
|
||||||
|
|
|
@ -561,7 +561,7 @@ function main(args)
|
||||||
setdevicedebug(false)
|
setdevicedebug(false)
|
||||||
|
|
||||||
-- GET TAG UID
|
-- GET TAG UID
|
||||||
tag, err = lib14a.read1443a(false)
|
tag, err = lib14a.read1443a(false, true)
|
||||||
if not tag then return oops(err) end
|
if not tag then return oops(err) end
|
||||||
core.clearCommandBuffer()
|
core.clearCommandBuffer()
|
||||||
|
|
||||||
|
|
|
@ -81,7 +81,7 @@ end
|
||||||
--
|
--
|
||||||
-- Read information from a card
|
-- Read information from a card
|
||||||
function GetCardInfo()
|
function GetCardInfo()
|
||||||
result, err = lib14a.read1443a(false)
|
result, err = lib14a.read1443a(false, true)
|
||||||
if not result then
|
if not result then
|
||||||
print(err)
|
print(err)
|
||||||
return
|
return
|
||||||
|
|
|
@ -259,7 +259,7 @@ local function main( args)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- identify tag
|
-- identify tag
|
||||||
tag, err = lib14a.read1443a(false)
|
tag, err = lib14a.read1443a(false, true)
|
||||||
if not tag then return oops(err) end
|
if not tag then return oops(err) end
|
||||||
|
|
||||||
-- detect sectors and print taginfo
|
-- detect sectors and print taginfo
|
||||||
|
|
|
@ -122,7 +122,7 @@ local function main(args)
|
||||||
|
|
||||||
|
|
||||||
-- find tag
|
-- find tag
|
||||||
result, err = lib14a.read1443a(false)
|
result, err = lib14a.read1443a(false, true)
|
||||||
if not result then return oops(err) end
|
if not result then return oops(err) end
|
||||||
|
|
||||||
-- load keys
|
-- load keys
|
||||||
|
|
|
@ -126,7 +126,7 @@ local function main(args)
|
||||||
local cmdSetDbgOff = "hf mf dbg 0"
|
local cmdSetDbgOff = "hf mf dbg 0"
|
||||||
core.console( cmdSetDbgOff)
|
core.console( cmdSetDbgOff)
|
||||||
|
|
||||||
result, err = lib14a.read1443a(false)
|
result, err = lib14a.read1443a(false, true)
|
||||||
if not result then
|
if not result then
|
||||||
return oops(err)
|
return oops(err)
|
||||||
end
|
end
|
||||||
|
|
|
@ -24,20 +24,20 @@ local TIMEOUT = 2000 -- Shouldn't take longer than 2 seconds
|
||||||
local DEBUG = false -- the debug flag
|
local DEBUG = false -- the debug flag
|
||||||
---
|
---
|
||||||
-- A debug printout-function
|
-- A debug printout-function
|
||||||
function dbg(args)
|
local function dbg(args)
|
||||||
if DEBUG then
|
if DEBUG then
|
||||||
print("###", args)
|
print("###", args)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
---
|
---
|
||||||
-- This is only meant to be used when errors occur
|
-- This is only meant to be used when errors occur
|
||||||
function oops(err)
|
local function oops(err)
|
||||||
print("ERROR: ",err)
|
print("ERROR: ",err)
|
||||||
core.clearCommandBuffer()
|
core.clearCommandBuffer()
|
||||||
end
|
end
|
||||||
---
|
---
|
||||||
-- Usage help
|
-- Usage help
|
||||||
function help()
|
local function help()
|
||||||
print(desc)
|
print(desc)
|
||||||
print("Example usage")
|
print("Example usage")
|
||||||
print(example)
|
print(example)
|
||||||
|
@ -92,7 +92,7 @@ end
|
||||||
-- Send a "raw" iso14443a package, ie "hf 14a raw" command
|
-- Send a "raw" iso14443a package, ie "hf 14a raw" command
|
||||||
function sendRaw(rawdata, options)
|
function sendRaw(rawdata, options)
|
||||||
--print(">> ", rawdata)
|
--print(">> ", rawdata)
|
||||||
local flags = lib14a.ISO14A_COMMAND.ISO14A_NO_DISCONNECT + lib14a.ISO14A_COMMAND.ISO14A_RAW + lib14a.ISO14A_COMMAND.ISO14A_APPEND_CRC
|
local flags = lib14a.ISO14A_COMMAND.ISO14A_NO_DISCONNECT + lib14a.ISO14A_COMMAND.ISO14A_RAW + lib14a.ISO14A_COMMAND.ISO14A_APPEND_CRC + lib14a.ISO14A_COMMAND.ISO14A_NO_RATS
|
||||||
local command = Command:new{cmd = cmds.CMD_READER_ISO_14443a,
|
local command = Command:new{cmd = cmds.CMD_READER_ISO_14443a,
|
||||||
arg1 = flags, -- Send raw
|
arg1 = flags, -- Send raw
|
||||||
-- arg2 contains the length, which is half the length
|
-- arg2 contains the length, which is half the length
|
||||||
|
@ -125,7 +125,7 @@ function main(args)
|
||||||
endblock = endblock or 20
|
endblock = endblock or 20
|
||||||
|
|
||||||
-- First of all, connect
|
-- First of all, connect
|
||||||
info, err = lib14a.read1443a(true)
|
info, err = lib14a.read1443a(true, true)
|
||||||
if err then disconnect() return oops(err) end
|
if err then disconnect() return oops(err) end
|
||||||
core.clearCommandBuffer()
|
core.clearCommandBuffer()
|
||||||
|
|
||||||
|
@ -157,9 +157,6 @@ function main(args)
|
||||||
print(string.format("\nDumped data into %s", filename))
|
print(string.format("\nDumped data into %s", filename))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
-------------------------
|
-------------------------
|
||||||
-- Testing
|
-- Testing
|
||||||
-------------------------
|
-------------------------
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue