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