mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-20 05:13:46 -07:00
this should fix the ~ (tilde) bug I introduced... In lua, you need to evaluate false ie; statement == false, not like in C-style ~statement
This commit is contained in:
parent
eae8c2f7be
commit
69c8970201
1 changed files with 99 additions and 104 deletions
|
@ -346,8 +346,7 @@ function getInputBytes(infile)
|
||||||
if err then oops("faild to read from file ".. infile); return false; end
|
if err then oops("faild to read from file ".. infile); return false; end
|
||||||
|
|
||||||
file_data = fhi:read("*a");
|
file_data = fhi:read("*a");
|
||||||
for i = 1, #file_data
|
for i = 1, #file_data do
|
||||||
do
|
|
||||||
bytes[i] = string.format("%x",file_data:byte(i))
|
bytes[i] = string.format("%x",file_data:byte(i))
|
||||||
end
|
end
|
||||||
fhi:close()
|
fhi:close()
|
||||||
|
@ -386,9 +385,7 @@ end
|
||||||
---
|
---
|
||||||
-- put bytes into tag-table
|
-- put bytes into tag-table
|
||||||
function bytesToTag(bytes, tag)
|
function bytesToTag(bytes, tag)
|
||||||
if ~istable(tag) then
|
if istable(tag) == false then return oops("tag is no table in: bytesToTag ("..type(tag)..")") end
|
||||||
return oops("tag is no table in: bytesToTag ("..type(tag)..")")
|
|
||||||
end
|
|
||||||
|
|
||||||
tag.MCD =bytes[1];
|
tag.MCD =bytes[1];
|
||||||
tag.MSN0=bytes[2];
|
tag.MSN0=bytes[2];
|
||||||
|
@ -456,9 +453,7 @@ end
|
||||||
---
|
---
|
||||||
-- read Tag-Table in bytes-table
|
-- read Tag-Table in bytes-table
|
||||||
function tagToBytes(tag)
|
function tagToBytes(tag)
|
||||||
if ~istable(tag) then
|
if istable(tag) == false then return oops("tag is no table in tagToBytes ("..type(tag)..")") end
|
||||||
return oops("tag is no table in tagToBytes ("..type(tag)..")")
|
|
||||||
end
|
|
||||||
|
|
||||||
local bytes = {}
|
local bytes = {}
|
||||||
local i, i2
|
local i, i2
|
||||||
|
@ -602,11 +597,11 @@ function readFile(filename)
|
||||||
print(accyan)
|
print(accyan)
|
||||||
local bytes = {}
|
local bytes = {}
|
||||||
local tag = {}
|
local tag = {}
|
||||||
if ~file_check(filename) then return oops("input file: "..filename.." not found") end
|
if file_check(filename) == false then return oops("input file: "..filename.." not found") end
|
||||||
|
|
||||||
bytes = getInputBytes(filename)
|
bytes = getInputBytes(filename)
|
||||||
|
|
||||||
if ~bytes then return oops('couldnt get input bytes') end
|
if bytes == false then return oops('couldnt get input bytes') end
|
||||||
|
|
||||||
-- make plain bytes
|
-- make plain bytes
|
||||||
bytes = xorBytes(bytes,bytes[5])
|
bytes = xorBytes(bytes,bytes[5])
|
||||||
|
@ -1357,7 +1352,7 @@ end
|
||||||
-- dump Legic-Cash data
|
-- dump Legic-Cash data
|
||||||
function dumpLegicCash(tag, x)
|
function dumpLegicCash(tag, x)
|
||||||
|
|
||||||
if ~istable(tag.SEG[x]) then return end
|
if istable(tag.SEG[x]) == false then return end
|
||||||
|
|
||||||
io.write("in Segment "..tag.SEG[x].index.." :\n")
|
io.write("in Segment "..tag.SEG[x].index.." :\n")
|
||||||
print("--------------------------------\n\tLegic-Cash Values\n--------------------------------")
|
print("--------------------------------\n\tLegic-Cash Values\n--------------------------------")
|
||||||
|
@ -1383,7 +1378,7 @@ function dumpLegicCash(tag, x)
|
||||||
-- raw 3rd-party
|
-- raw 3rd-party
|
||||||
function print3rdPartyCash1(tag, x)
|
function print3rdPartyCash1(tag, x)
|
||||||
|
|
||||||
if ~istable(tag.SEG[x]) then return end
|
if istable(tag.SEG[x]) == false then return end
|
||||||
|
|
||||||
local uid=tag.MCD..tag.MSN0..tag.MSN1..tag.MSN2
|
local uid=tag.MCD..tag.MSN0..tag.MSN1..tag.MSN2
|
||||||
print("\n\t\tStamp : "..dumpTable(tag.SEG[x].data, "", 0 , 2))
|
print("\n\t\tStamp : "..dumpTable(tag.SEG[x].data, "", 0 , 2))
|
||||||
|
@ -1457,11 +1452,14 @@ function makeToken()
|
||||||
end
|
end
|
||||||
-- fill bytes
|
-- fill bytes
|
||||||
for i = #bytes, 1023 do table.insert(bytes, "00") end
|
for i = #bytes, 1023 do table.insert(bytes, "00") end
|
||||||
|
|
||||||
-- if Master-Token -> calc Master-Token-CRC
|
-- if Master-Token -> calc Master-Token-CRC
|
||||||
if (mtq>1) then bytes[22] = calcMtCrc(bytes) end
|
if (mtq>1) then bytes[22] = calcMtCrc(bytes) end
|
||||||
|
|
||||||
local tempTag = createTagTable()
|
local tempTag = createTagTable()
|
||||||
-- remove segment if MasterToken
|
-- remove segment if MasterToken
|
||||||
if (mtq>1) then tempTag.SEG[0] = nil end
|
if (mtq>1) then tempTag.SEG[0] = nil end
|
||||||
|
|
||||||
return bytesToTag(bytes, tempTag)
|
return bytesToTag(bytes, tempTag)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1531,10 +1529,9 @@ end
|
||||||
---
|
---
|
||||||
-- calculates header-byte (addr 0x07)
|
-- calculates header-byte (addr 0x07)
|
||||||
function calcHeaderRaw(wrp, wrc, rd)
|
function calcHeaderRaw(wrp, wrc, rd)
|
||||||
local res
|
|
||||||
wrp = ("%02x"):format(tonumber(wrp, 10))
|
wrp = ("%02x"):format(tonumber(wrp, 10))
|
||||||
rd = tonumber(rd, 16)
|
rd = tonumber(rd, 16)
|
||||||
res=("%02x"):format(tonumber(wrp, 16)+tonumber(wrc.."0", 16)+((rd>0) and tonumber("8"..(rd-1), 16) or 0))
|
local res = ("%02x"):format(tonumber(wrp, 16)+tonumber(wrc.."0", 16)+((rd>0) and tonumber("8"..(rd-1), 16) or 0))
|
||||||
return res
|
return res
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1700,9 +1697,7 @@ end
|
||||||
-- edit Segment Data
|
-- edit Segment Data
|
||||||
function editSegmentData(data)
|
function editSegmentData(data)
|
||||||
io.write("\n")
|
io.write("\n")
|
||||||
if ~istable(data) then
|
if istable(data) == false then print("no Segment-Data found") end
|
||||||
print("no Segment-Data found")
|
|
||||||
end
|
|
||||||
|
|
||||||
local lc = check4LegicCash(data)
|
local lc = check4LegicCash(data)
|
||||||
|
|
||||||
|
@ -2686,7 +2681,7 @@ function main(args)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- file conversion (output to file)
|
-- file conversion (output to file)
|
||||||
if ~ofs then return end
|
if ofs == false then return end
|
||||||
|
|
||||||
-- dump infile / tag-read
|
-- dump infile / tag-read
|
||||||
if (dfs) then
|
if (dfs) then
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue