mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-02-14 03:03:14 +08:00
text
This commit is contained in:
parent
8548eda9bd
commit
81feb56003
1 changed files with 19 additions and 17 deletions
|
@ -6,7 +6,7 @@ local getopt = require('getopt')
|
||||||
|
|
||||||
copyright = ''
|
copyright = ''
|
||||||
author = "Brian Redbeard"
|
author = "Brian Redbeard"
|
||||||
version = 'v1.0.0'
|
version = 'v1.0.1'
|
||||||
desc = [[
|
desc = [[
|
||||||
Perform bulk enrollment of 26 bit H10301 style RFID Tags
|
Perform bulk enrollment of 26 bit H10301 style RFID Tags
|
||||||
For more info, check the comments in the code
|
For more info, check the comments in the code
|
||||||
|
@ -32,21 +32,22 @@ local lshift = bit32.lshift
|
||||||
-- A debug printout-function
|
-- A debug printout-function
|
||||||
local function dbg(args)
|
local function dbg(args)
|
||||||
if not DEBUG then return end
|
if not DEBUG then return end
|
||||||
if type(args) == "table" then
|
if type(args) == 'table' then
|
||||||
local i = 1
|
local i = 1
|
||||||
while args[i] do
|
while args[i] do
|
||||||
dbg(args[i])
|
dbg(args[i])
|
||||||
i = i+1
|
i = i+1
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
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
|
||||||
local function oops(err)
|
local function oops(err)
|
||||||
print("ERROR: ",err)
|
print('ERROR:', err)
|
||||||
return nil,err
|
core.clearCommandBuffer()
|
||||||
|
return nil, errr
|
||||||
end
|
end
|
||||||
---
|
---
|
||||||
-- Usage help
|
-- Usage help
|
||||||
|
@ -57,6 +58,7 @@ local function help()
|
||||||
print(desc)
|
print(desc)
|
||||||
print('Example usage')
|
print('Example usage')
|
||||||
print(example)
|
print(example)
|
||||||
|
print(usage)
|
||||||
end
|
end
|
||||||
---
|
---
|
||||||
-- Exit message
|
-- Exit message
|
||||||
|
@ -68,7 +70,7 @@ local function exitMsg(msg)
|
||||||
end
|
end
|
||||||
--[[Implement a function to simply visualize the bitstream in a text format
|
--[[Implement a function to simply visualize the bitstream in a text format
|
||||||
--This is especially helpful for troubleshooting bitwise math issues]]--
|
--This is especially helpful for troubleshooting bitwise math issues]]--
|
||||||
function toBits(num,bits)
|
local function toBits(num,bits)
|
||||||
-- returns a table of bits, most significant first.
|
-- returns a table of bits, most significant first.
|
||||||
bits = bits or math.max(1, select(2, math.frexp(num)))
|
bits = bits or math.max(1, select(2, math.frexp(num)))
|
||||||
local t = {} -- will contain the bits
|
local t = {} -- will contain the bits
|
||||||
|
@ -86,7 +88,7 @@ end
|
||||||
default to this and so counting some ones is good enough for me
|
default to this and so counting some ones is good enough for me
|
||||||
]]--
|
]]--
|
||||||
local function evenparity(s)
|
local function evenparity(s)
|
||||||
local _, count = string.gsub(s, "1", "")
|
local _, count = string.gsub(s, '1', '')
|
||||||
local p = count % 2
|
local p = count % 2
|
||||||
if (p == 0) then
|
if (p == 0) then
|
||||||
return false
|
return false
|
||||||
|
@ -126,7 +128,7 @@ local function cardHex(i, f)
|
||||||
preamble = bor(0, lshift(1, 5))
|
preamble = bor(0, lshift(1, 5))
|
||||||
bits = bor(bits, lshift(1, 26))
|
bits = bor(bits, lshift(1, 26))
|
||||||
|
|
||||||
return ("%04x%08x"):format(preamble, bits)
|
return ('%04x%08x'):format(preamble, bits)
|
||||||
end
|
end
|
||||||
---
|
---
|
||||||
-- main
|
-- main
|
||||||
|
@ -145,31 +147,31 @@ local function main(args)
|
||||||
if o == 'h' then return help() end
|
if o == 'h' then return help() end
|
||||||
if o == 'f' then
|
if o == 'f' then
|
||||||
if isempty(a) then
|
if isempty(a) then
|
||||||
print("You did not supply a facility code, using 0")
|
print('You did not supply a facility code, using 0')
|
||||||
facility = 0
|
facility = 0
|
||||||
else
|
else
|
||||||
facility = a
|
facility = a
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if o == 'b' then
|
if o == 'b' then
|
||||||
if isempty(a) then return oops("You must supply the flag -b (base id)") end
|
if isempty(a) then return oops('You must supply the flag -b (base id)') end
|
||||||
baseid = a
|
baseid = a
|
||||||
end
|
end
|
||||||
if o == 'c' then
|
if o == 'c' then
|
||||||
if isempty(a) then return oops("You must supply the flag -c (count)") end
|
if isempty(a) then return oops('You must supply the flag -c (count)') end
|
||||||
count = a
|
count = a
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--Due to my earlier complaints about how this specific getopt library
|
--Due to my earlier complaints about how this specific getopt library
|
||||||
--works, specifying ":" does not enforce supplying a value, thus we
|
--works, specifying ':' does not enforce supplying a value, thus we
|
||||||
--need to do these checks all over again.
|
--need to do these checks all over again.
|
||||||
if isempty(baseid) then return oops("You must supply the flag -b (base id)") end
|
if isempty(baseid) then return oops('You must supply the flag -b (base id)') end
|
||||||
if isempty(count) then return oops("You must supply the flag -c (count)") end
|
if isempty(count) then return oops('You must supply the flag -c (count)') end
|
||||||
|
|
||||||
--If the facility ID is non specified, ensure we code it as zero
|
--If the facility ID is non specified, ensure we code it as zero
|
||||||
if isempty(facility) then
|
if isempty(facility) then
|
||||||
print("Using 0 for the facility code as -f was not supplied")
|
print('Using 0 for the facility code as -f was not supplied')
|
||||||
facility = 0
|
facility = 0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -183,8 +185,8 @@ local function main(args)
|
||||||
|
|
||||||
for cardnum = baseid, endid do
|
for cardnum = baseid, endid do
|
||||||
local card = cardHex(cardnum, facility)
|
local card = cardHex(cardnum, facility)
|
||||||
print("Press enter to program card "..cardnum..":"..facility.." (hex: "..card..")")
|
print('Press enter to program card '..cardnum..':'..facility..' (hex: '..card..')')
|
||||||
--This would be better with "press any key", but we'll take what we can get.
|
--This would be better with 'press any key', but we'll take what we can get.
|
||||||
io.read()
|
io.read()
|
||||||
core.console( ('lf hid clone %s'):format(card) )
|
core.console( ('lf hid clone %s'):format(card) )
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue