mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-14 02:27:26 -07:00
lua: fix mix of spaces & tabs
This commit is contained in:
parent
716c17bac8
commit
05ff45e550
41 changed files with 5185 additions and 5185 deletions
|
@ -11,8 +11,8 @@ usage = [[
|
|||
script run mifare_access -h -a <access bytes>
|
||||
|
||||
Arguments:
|
||||
-h : this help
|
||||
-a <access bytes> : 4 bytes ACCESS CONDITIONS
|
||||
-h : this help
|
||||
-a <access bytes> : 4 bytes ACCESS CONDITIONS
|
||||
]]
|
||||
|
||||
local DEBUG = true
|
||||
|
@ -20,35 +20,35 @@ local bxor = bit32.bxor
|
|||
local band = bit32.band
|
||||
local rshift = bit32.rshift
|
||||
|
||||
---
|
||||
---
|
||||
-- A debug printout-function
|
||||
local function dbg(args)
|
||||
if not DEBUG then return end
|
||||
if type(args) == "table" then
|
||||
local i = 1
|
||||
while args[i] do
|
||||
dbg(args[i])
|
||||
i = i+1
|
||||
end
|
||||
else
|
||||
print("###", args)
|
||||
end
|
||||
end
|
||||
---
|
||||
local i = 1
|
||||
while args[i] do
|
||||
dbg(args[i])
|
||||
i = i+1
|
||||
end
|
||||
else
|
||||
print("###", args)
|
||||
end
|
||||
end
|
||||
---
|
||||
-- This is only meant to be used when errors occur
|
||||
local function oops(err)
|
||||
print("ERROR: ",err)
|
||||
return nil, err
|
||||
print("ERROR: ",err)
|
||||
return nil, err
|
||||
end
|
||||
---
|
||||
---
|
||||
-- Usage help
|
||||
local function help()
|
||||
print(copyright)
|
||||
print(author)
|
||||
print(version)
|
||||
print(desc)
|
||||
print('Example usage')
|
||||
print(example)
|
||||
print(copyright)
|
||||
print(author)
|
||||
print(version)
|
||||
print(desc)
|
||||
print('Example usage')
|
||||
print(example)
|
||||
end
|
||||
|
||||
local access_condition_sector_trailer = {}
|
||||
|
@ -73,58 +73,58 @@ access_condition_data_block[0x7] = {'never','never','never','never'}
|
|||
|
||||
local function main(args)
|
||||
|
||||
print( string.rep('--',20) )
|
||||
print( string.rep('--',20) )
|
||||
print()
|
||||
print( string.rep('--',20) )
|
||||
print( string.rep('--',20) )
|
||||
print()
|
||||
|
||||
local access = ''
|
||||
|
||||
-- Read the parameters
|
||||
for o, a in getopt.getopt(args, 'ha:') do
|
||||
if o == "h" then return help() end
|
||||
if o == "a" then access = a end
|
||||
end
|
||||
|
||||
if access == nil then return oops('empty ACCESS CONDITIONS') end
|
||||
if #access == 0 then return oops('empty ACCESS CONDITIONS') end
|
||||
if #access ~= 8 then return oops("Wrong length. Should be 4 hex bytes ACCESS CONDITIONS (e.g. 7F0F0869)") end
|
||||
|
||||
local c2_b = tonumber(string.sub(access, 1, 1), 16)
|
||||
local c1_b = tonumber(string.sub(access, 2, 2), 16)
|
||||
local c1 = tonumber(string.sub(access, 3, 3), 16)
|
||||
local c3_b = tonumber(string.sub(access, 4, 4), 16)
|
||||
local c3 = tonumber(string.sub(access, 5, 5), 16)
|
||||
local c2 = tonumber(string.sub(access, 6, 6), 16)
|
||||
local gpb = string.sub(access, 7, 8)
|
||||
local access = ''
|
||||
|
||||
if bxor(c1, c1_b) ~= 0xF then print("!!! bitflip in c1") end
|
||||
if bxor(c2, c2_b) ~= 0xF then print("!!! bitflip in c2") end
|
||||
if bxor(c3, c3_b) ~= 0xF then print("!!! bitflip in c3") end
|
||||
-- Read the parameters
|
||||
for o, a in getopt.getopt(args, 'ha:') do
|
||||
if o == "h" then return help() end
|
||||
if o == "a" then access = a end
|
||||
end
|
||||
|
||||
local ab = c1 * 256 + c2 * 16 + c3
|
||||
if access == nil then return oops('empty ACCESS CONDITIONS') end
|
||||
if #access == 0 then return oops('empty ACCESS CONDITIONS') end
|
||||
if #access ~= 8 then return oops("Wrong length. Should be 4 hex bytes ACCESS CONDITIONS (e.g. 7F0F0869)") end
|
||||
|
||||
for block = 0,3 do
|
||||
print("--> block "..block)
|
||||
-- mask bits for block
|
||||
local abi = band(rshift(ab, block), 0x111)
|
||||
-- compress bits
|
||||
abi = band(abi + rshift(abi, 3) + rshift(abi, 6),7)
|
||||
-- print(abi)
|
||||
if block == 3 then
|
||||
print(" KEYSECXA read: "..access_condition_sector_trailer[abi][1])
|
||||
print(" KEYSECXA write: "..access_condition_sector_trailer[abi][2])
|
||||
print(" ACCESS COND. read: "..access_condition_sector_trailer[abi][3])
|
||||
print("ACCESS COND. write: "..access_condition_sector_trailer[abi][4])
|
||||
print(" KEYSECXB read: "..access_condition_sector_trailer[abi][5])
|
||||
print(" KEYSECXB write: "..access_condition_sector_trailer[abi][6])
|
||||
else
|
||||
print(" read: "..access_condition_data_block[abi][1])
|
||||
print(" write: "..access_condition_data_block[abi][2])
|
||||
print(" inc: "..access_condition_data_block[abi][3])
|
||||
print("decr, transfer, restore: "..access_condition_data_block[abi][4])
|
||||
end
|
||||
end
|
||||
local c2_b = tonumber(string.sub(access, 1, 1), 16)
|
||||
local c1_b = tonumber(string.sub(access, 2, 2), 16)
|
||||
local c1 = tonumber(string.sub(access, 3, 3), 16)
|
||||
local c3_b = tonumber(string.sub(access, 4, 4), 16)
|
||||
local c3 = tonumber(string.sub(access, 5, 5), 16)
|
||||
local c2 = tonumber(string.sub(access, 6, 6), 16)
|
||||
local gpb = string.sub(access, 7, 8)
|
||||
|
||||
print("GPB: "..gpb)
|
||||
if bxor(c1, c1_b) ~= 0xF then print("!!! bitflip in c1") end
|
||||
if bxor(c2, c2_b) ~= 0xF then print("!!! bitflip in c2") end
|
||||
if bxor(c3, c3_b) ~= 0xF then print("!!! bitflip in c3") end
|
||||
|
||||
local ab = c1 * 256 + c2 * 16 + c3
|
||||
|
||||
for block = 0,3 do
|
||||
print("--> block "..block)
|
||||
-- mask bits for block
|
||||
local abi = band(rshift(ab, block), 0x111)
|
||||
-- compress bits
|
||||
abi = band(abi + rshift(abi, 3) + rshift(abi, 6),7)
|
||||
-- print(abi)
|
||||
if block == 3 then
|
||||
print(" KEYSECXA read: "..access_condition_sector_trailer[abi][1])
|
||||
print(" KEYSECXA write: "..access_condition_sector_trailer[abi][2])
|
||||
print(" ACCESS COND. read: "..access_condition_sector_trailer[abi][3])
|
||||
print("ACCESS COND. write: "..access_condition_sector_trailer[abi][4])
|
||||
print(" KEYSECXB read: "..access_condition_sector_trailer[abi][5])
|
||||
print(" KEYSECXB write: "..access_condition_sector_trailer[abi][6])
|
||||
else
|
||||
print(" read: "..access_condition_data_block[abi][1])
|
||||
print(" write: "..access_condition_data_block[abi][2])
|
||||
print(" inc: "..access_condition_data_block[abi][3])
|
||||
print("decr, transfer, restore: "..access_condition_data_block[abi][4])
|
||||
end
|
||||
end
|
||||
|
||||
print("GPB: "..gpb)
|
||||
end
|
||||
main(args)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue