mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-01-26 10:04:24 +08:00
fix: lua bit32 can actually take several values. How did I miss this?
This commit is contained in:
parent
3f9024eeaf
commit
1629287291
3 changed files with 7 additions and 7 deletions
|
@ -38,7 +38,7 @@ local function ApplyPermutationAndShifts( pos, value, nibble)
|
|||
local shiftbytes = shifts[pos]
|
||||
local shiftElem = shiftbytes[nibble+1] --one indexed
|
||||
local shiftOne = shiftbytes[1]
|
||||
local rs = bit32.bxor(value, bit32.bxor(shiftOne, shiftElem))
|
||||
local rs = bit32.bxor(value, shiftOne, shiftElem)
|
||||
return rs
|
||||
end
|
||||
|
||||
|
|
|
@ -108,7 +108,7 @@ local function findEntryByUid( uid )
|
|||
|
||||
-- xor UID4,UID5,UID6,UID7
|
||||
-- mod 0x20 (dec 32)
|
||||
local pos = (bxor(bxor(bxor(uid[4],uid[5]), uid[6]),uid[7])) % 32
|
||||
local pos = (bxor(uid[4], uid[5], uid[6], uid[7])) % 32
|
||||
|
||||
-- convert to hexstring
|
||||
pos = string.format('%02X', pos)
|
||||
|
@ -132,9 +132,9 @@ local function pwdgen(uid)
|
|||
local entry = findEntryByUid(uidbytes)
|
||||
if entry == nil then return nil, "Can't find a xor entry" end
|
||||
|
||||
local pwd0 = bxor( bxor( bxor( entry[1], uidbytes[2]), uidbytes[3]), uidbytes[4])
|
||||
local pwd1 = bxor( bxor( bxor( entry[2], uidbytes[1]), uidbytes[3]), uidbytes[5])
|
||||
local pwd2 = bxor( bxor( bxor( entry[3], uidbytes[1]), uidbytes[2]), uidbytes[6])
|
||||
local pwd0 = bxor( entry[1], uidbytes[2], uidbytes[3], uidbytes[4])
|
||||
local pwd1 = bxor( entry[2], uidbytes[1], uidbytes[3], uidbytes[5])
|
||||
local pwd2 = bxor( entry[3], uidbytes[1], uidbytes[2], uidbytes[6])
|
||||
local pwd3 = bxor( entry[4], uidbytes[7])
|
||||
return string.format('%02X%02X%02X%02X', pwd0, pwd1, pwd2, pwd3)
|
||||
end
|
||||
|
|
|
@ -120,8 +120,8 @@ function main(args)
|
|||
|
||||
local uidbytes = utils.ConvertHexToBytes(uid)
|
||||
|
||||
local bcc1 = bxor(bxor(bxor(uidbytes[1], uidbytes[2]), uidbytes[3]), 0x88)
|
||||
local bcc2 = bxor(bxor(bxor(uidbytes[4], uidbytes[5]), uidbytes[6]), uidbytes[7])
|
||||
local bcc1 = bxor(0x88, uidbytes[1], uidbytes[2], uidbytes[3])
|
||||
local bcc2 = bxor(uidbytes[4], uidbytes[5], uidbytes[6], uidbytes[7])
|
||||
|
||||
local block0 = string.format('%02X%02X%02X%02X', uidbytes[1], uidbytes[2], uidbytes[3], bcc1)
|
||||
local block1 = string.format('%02X%02X%02X%02X', uidbytes[4], uidbytes[5], uidbytes[6], uidbytes[7])
|
||||
|
|
Loading…
Reference in a new issue