proxmark3/client/luascripts/legic_buffer2card.lua

68 lines
1.6 KiB
Lua
Raw Normal View History

local utils = require('utils')
local getopt = require('getopt')
2020-04-05 18:28:49 +08:00
local ansicolors = require('ansicolors')
-- this script writes bytes 8 to 256 on the Legic MIM256
copyright = ''
author = 'Mosci'
2020-04-05 18:28:49 +08:00
version = 'v1.0.2'
desc =
[[
This is a script which writes value 0x01 to bytes from position 0x07 until 0xFF on a Legic Prime Tag (MIM256 or MIM1024) -- (created with 'hf legic save my_dump.hex') --
]]
example = [[
script run legic_buffer2card
]]
usage = [[
script run legic_buffer2card -h
2020-04-05 18:28:49 +08:00
]]
arguments = [[
2019-03-09 17:34:43 +08:00
-h - Help text
]]
2019-03-09 17:34:43 +08:00
---
-- This is only meant to be used when errors occur
local function oops(err)
print('ERROR:', err)
core.clearCommandBuffer()
2019-03-09 17:34:43 +08:00
return nil, err
end
2019-03-09 17:34:43 +08:00
---
-- Usage help
local function help()
print(copyright)
print(author)
print(version)
2019-03-09 17:34:43 +08:00
print(desc)
2020-04-05 18:28:49 +08:00
print(ansicolors.cyan..'Usage'..ansicolors.reset)
print(usage)
2020-04-05 18:28:49 +08:00
print(ansicolors.cyan..'Arguments'..ansicolors.reset)
print(arguments)
print(ansicolors.cyan..'Example usage'..ansicolors.reset)
print(example)
end
--
-- simple loop-write from 0x07 to 0xff
function main()
2019-03-09 17:34:43 +08:00
-- parse arguments for the script
for o, a in getopt.getopt(args, 'h') do
if o == 'h' then return help() end
2019-03-09 17:34:43 +08:00
end
local cmd = ''
local i
for i = 7, 255 do
cmd = ('hf legic write o %02x d 01'):format(i)
2019-03-09 17:34:43 +08:00
print(cmd)
core.clearCommandBuffer()
core.console(cmd)
2019-03-09 17:34:43 +08:00
-- got a 'cmd-buffer overflow' on my mac - so just wait a little
-- works without that pause on my linux-box
utils.Sleep(0.1)
end
end
main()