proxmark3/client/luascripts/tests/lf_t55xx_defaultfsk.lua

151 lines
3.3 KiB
Lua
Raw Normal View History

local cmds = require('commands')
local getopt = require('getopt')
local bin = require('bin')
local utils = require('utils')
2020-04-05 18:56:35 +08:00
local ansicolors = require('ansicolors')
2019-04-29 01:26:26 +08:00
copyright = ''
author = 'Iceman'
2020-04-05 18:56:35 +08:00
version = 'v1.0.2'
2019-04-29 01:26:26 +08:00
desc = [[
This script will program a T55x7 TAG with the configuration: block 0x00 data 0x000100
The outlined procedure is as following:
2019-03-09 17:34:43 +08:00
--ASK
00 00 80 40
-- max 2 blocks
-- FSK1
-- bit rate
2019-03-09 17:34:43 +08:00
2021-03-08 05:00:33 +08:00
"lf t55xx write -b 0 -d 00007040"
"lf t55xx detect"
"lf t55xx info"
Loop:
2019-03-09 17:34:43 +08:00
change the configuretion block 0 with:
-xx 00 xxxx = RF/8
-xx 04 xxxx = RF/16
2019-03-09 17:34:43 +08:00
-xx 08 xxxx = RF/32
-xx 0C xxxx = RF/40
-xx 10 xxxx = RF/50
-xx 14 xxxx = RF/64
-xx 18 xxxx = RF/100
-xx 1C xxxx = RF/128
testsuit for the ASK/MANCHESTER demod
2019-04-29 01:26:26 +08:00
]]
example = [[
1. script run lf_t55xx_defaultfsk
2019-04-29 01:26:26 +08:00
]]
usage = [[
script run lf_t55xx_defaultfsk [-h]
2020-04-05 18:56:35 +08:00
]]
arguments = [[
2019-03-09 17:34:43 +08:00
-h : this help
]]
local DEBUG = true -- the debug flag
local TIMEOUT = 1500
--BLOCK 0 = 00008040 FSK
local config1 = '00'
local config2 = '040'
local procedurecmds = {
2019-03-09 17:34:43 +08:00
[1] = '%s%02X%X%s',
[2] = 'lf t55xx detect',
[3] = 'lf t55xx info',
}
2019-03-09 17:34:43 +08:00
---
-- A debug printout-function
local function dbg(args)
2019-04-29 01:26:26 +08:00
if not DEBUG then return end
if type(args) == 'table' then
2019-03-09 17:34:43 +08:00
local i = 1
while args[i] do
dbg(args[i])
i = i+1
end
else
2019-04-29 01:26:26 +08:00
print('###', args)
2019-03-09 17:34:43 +08:00
end
end
---
-- This is only meant to be used when errors occur
local function oops(err)
2019-04-29 01:26:26 +08:00
print('ERROR:', err)
core.clearCommandBuffer()
return nil, err
end
2019-03-09 17:34:43 +08:00
---
-- Usage help
local function help()
2019-04-29 01:26:26 +08:00
print(copyright)
print(author)
print(version)
2019-03-09 17:34:43 +08:00
print(desc)
2020-04-05 18:56:35 +08:00
print(ansicolors.cyan..'Usage'..ansicolors.reset)
2019-04-29 01:26:26 +08:00
print(usage)
2020-04-05 18:56:35 +08:00
print(ansicolors.cyan..'Arguments'..ansicolors.reset)
print(arguments)
print(ansicolors.cyan..'Example usage'..ansicolors.reset)
print(example)
end
--
-- Exit message
local function ExitMsg(msg)
2019-03-09 17:34:43 +08:00
print( string.rep('--',20) )
print( string.rep('--',20) )
print(msg)
print()
end
local function test(modulation)
2019-03-09 17:34:43 +08:00
local y
local password = '00000000'
2019-04-29 01:26:26 +08:00
local block = '00'
local flags = '00'
2019-03-09 17:34:43 +08:00
for y = 0x0, 0x1d, 0x4 do
for _ = 1, #procedurecmds do
local pcmd = procedurecmds[_]
if #pcmd == 0 then
elseif _ == 1 then
local config = pcmd:format(config1, y, modulation, config2)
2021-03-08 05:00:33 +08:00
dbg(('lf t55xx write -b 0 -d %s'):format(config))
local data = ('%s%s%s%s'):format(utils.SwapEndiannessStr(config, 32), password, block, flags)
2019-03-09 17:34:43 +08:00
local wc = Command:newNG{cmd = cmds.CMD_LF_T55XX_WRITEBL, data = data}
local response, err = wc:sendNG(false, TIMEOUT)
2019-04-29 01:26:26 +08:00
if not response then return oops(err) end
2019-03-09 17:34:43 +08:00
else
dbg(pcmd)
core.console( pcmd )
end
end
core.clearCommandBuffer()
end
print( string.rep('--',20) )
end
local function main(args)
2019-03-09 17:34:43 +08:00
print( string.rep('--',20) )
print( string.rep('--',20) )
2019-03-09 17:34:43 +08:00
-- Arguments for the script
for o, arg in getopt.getopt(args, 'h') do
2019-04-29 01:26:26 +08:00
if o == 'h' then return help() end
2019-03-09 17:34:43 +08:00
end
2019-03-09 17:34:43 +08:00
core.clearCommandBuffer()
test(4)
test(5)
test(6)
test(7)
print( string.rep('--',20) )
end
2019-03-12 07:12:26 +08:00
main(args)