mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-22 06:13:51 -07:00
Merge pull request #2393 from uhei/fix-legic-clone
fix: hf_legic_clone.lua script
This commit is contained in:
commit
1e6915fcd7
1 changed files with 10 additions and 11 deletions
|
@ -167,12 +167,11 @@ local function help()
|
||||||
print(ansicolors.cyan..'Example usage'..ansicolors.reset)
|
print(ansicolors.cyan..'Example usage'..ansicolors.reset)
|
||||||
print(example)
|
print(example)
|
||||||
end
|
end
|
||||||
-- read LEGIC data
|
-- read LEGIC info
|
||||||
local function readlegicdata(offset, len, iv)
|
local function readlegicinfo()
|
||||||
-- Read data
|
-- Read data
|
||||||
local d0 = ('%04X%04X%02X'):format(offset, len, iv)
|
local c = Command:newNG{cmd = cmds.CMD_HF_LEGIC_INFO, data = nil}
|
||||||
local c = Command:newNG{cmd = cmds.CMD_HF_LEGIC_READER, data = d0}
|
local result, err = c:sendNG(false, 2000)
|
||||||
local result, err = c:sendNG()
|
|
||||||
if not result then return oops(err) end
|
if not result then return oops(err) end
|
||||||
-- result is a packed data structure, data starts at offset 33
|
-- result is a packed data structure, data starts at offset 33
|
||||||
return result
|
return result
|
||||||
|
@ -404,15 +403,15 @@ local function writeToTag(plainBytes)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
readbytes = readlegicdata(0, 4, 0x55)
|
readbytes = readlegicinfo()
|
||||||
-- gather MCD & MSN from new Tag - this must be enterd manually
|
-- gather MCD & MSN from new Tag - this must be enterd manually
|
||||||
print("\nthese are the MCD MSN0 MSN1 MSN2 from the Tag that has being read:")
|
print("\nthese are the MCD MSN0 MSN1 MSN2 from the Tag that has being read:")
|
||||||
|
|
||||||
-- readbytes is a usbcommandOLD package, hence 32 bytes offset until data.
|
-- readbytes is a table with uid data as hex string in Data key
|
||||||
plainBytes[1] = ('%02x'):format(readbytes:byte(33))
|
plainBytes[1] = readbytes.Data:sub(1,2)
|
||||||
plainBytes[2] = ('%02x'):format(readbytes:byte(34))
|
plainBytes[2] = readbytes.Data:sub(3,4)
|
||||||
plainBytes[3] = ('%02x'):format(readbytes:byte(35))
|
plainBytes[3] = readbytes.Data:sub(5,6)
|
||||||
plainBytes[4] = ('%02x'):format(readbytes:byte(36))
|
plainBytes[4] = readbytes.Data:sub(7,8)
|
||||||
|
|
||||||
MCD = plainBytes[1]
|
MCD = plainBytes[1]
|
||||||
MSN0 = plainBytes[2]
|
MSN0 = plainBytes[2]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue