mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-19 21:03:48 -07:00
CHG: added key gen algo. removed inparameter.
This commit is contained in:
parent
2d0341403e
commit
e093a375ef
1 changed files with 24 additions and 12 deletions
|
@ -5,17 +5,16 @@ local lib14a = require('read14a')
|
||||||
|
|
||||||
example =[[
|
example =[[
|
||||||
script run didump
|
script run didump
|
||||||
script run didump -k aabbccddeeff
|
script run didump -t
|
||||||
]]
|
]]
|
||||||
author = "Iceman"
|
author = "Iceman"
|
||||||
usage = "script run didump -k <key> "
|
usage = "script run didump -h -t"
|
||||||
desc = [[
|
desc = [[
|
||||||
This is a script to dump and decrypt the data of a specific type of Mifare Mini token.
|
This is a script to dump and decrypt the data of a specific type of Mifare Mini token.
|
||||||
|
|
||||||
Arguments:
|
Arguments:
|
||||||
-h : this help
|
-h : this help
|
||||||
-t : selftest
|
-t : selftest
|
||||||
-k <key> : Mifare Key A.
|
|
||||||
]]
|
]]
|
||||||
|
|
||||||
local band=bit32.band
|
local band=bit32.band
|
||||||
|
@ -27,6 +26,7 @@ local rshift=bit32.rshift
|
||||||
|
|
||||||
local FOO = 'AF62D2EC0491968CC52A1A7165F865FE'
|
local FOO = 'AF62D2EC0491968CC52A1A7165F865FE'
|
||||||
local BAR = '286329204469736E65792032303133'
|
local BAR = '286329204469736E65792032303133'
|
||||||
|
local MIS = '0A14FD0507FF4BCD026BA83F0A3B89A9'
|
||||||
local RANDOM = FOO..BAR
|
local RANDOM = FOO..BAR
|
||||||
local outputTemplate = os.date("toydump_%Y-%m-%d_%H%M%S");
|
local outputTemplate = os.date("toydump_%Y-%m-%d_%H%M%S");
|
||||||
local TIMEOUT = 2000
|
local TIMEOUT = 2000
|
||||||
|
@ -362,6 +362,19 @@ local function waitCmd()
|
||||||
return nil, "No response from device"
|
return nil, "No response from device"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function keygen(uid)
|
||||||
|
local data = MIS..uid..BAR
|
||||||
|
local hash = utils.ConvertAsciiToBytes(utils.Sha1Hex(data))
|
||||||
|
return string.format("%02X%02X%02X%02X%02X%02X",
|
||||||
|
hash[3+1],
|
||||||
|
hash[2+1],
|
||||||
|
hash[1+1],
|
||||||
|
hash[0+1],
|
||||||
|
hash[7+1],
|
||||||
|
hash[6+1]
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
local function selftest()
|
local function selftest()
|
||||||
local testdata = '000F42430D0A14000001D11F'..'5D738517'
|
local testdata = '000F42430D0A14000001D11F'..'5D738517'
|
||||||
local chksum = getChecksum(testdata)
|
local chksum = getChecksum(testdata)
|
||||||
|
@ -381,6 +394,10 @@ local function selftest()
|
||||||
print ('DATA :: '..testdata:sub(1,24))
|
print ('DATA :: '..testdata:sub(1,24))
|
||||||
print (('VALID CHKSUM :: %s'):format(validStr ))
|
print (('VALID CHKSUM :: %s'):format(validStr ))
|
||||||
print (('UPDATE CHKSUM :: %s'):format(revalidated))
|
print (('UPDATE CHKSUM :: %s'):format(revalidated))
|
||||||
|
|
||||||
|
local testkey = keygen('0456263a873a80')
|
||||||
|
print ('TEST KEY :: '..testkey)
|
||||||
|
print ('VALID KEY :: 29564af75805')
|
||||||
end
|
end
|
||||||
---
|
---
|
||||||
-- The main entry point
|
-- The main entry point
|
||||||
|
@ -394,18 +411,11 @@ function main(args)
|
||||||
local magic = ''
|
local magic = ''
|
||||||
|
|
||||||
-- Read the parameters
|
-- Read the parameters
|
||||||
for o, a in getopt.getopt(args, 'hk:t') do
|
for o, a in getopt.getopt(args, 'ht') do
|
||||||
if o == "h" then help() return end
|
if o == "h" then help() return end
|
||||||
if o == "k" then keyA = a end
|
|
||||||
if o == "t" then return selftest() end
|
if o == "t" then return selftest() end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- validate input args.
|
|
||||||
keyA = keyA or '6dd747e86975'
|
|
||||||
if #(keyA) ~= 12 then
|
|
||||||
return oops( string.format('Wrong length of write key (was %d) expected 12', #keyA))
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Turn off Debug
|
-- Turn off Debug
|
||||||
local cmdSetDbgOff = "hf mf dbg 0"
|
local cmdSetDbgOff = "hf mf dbg 0"
|
||||||
core.console( cmdSetDbgOff)
|
core.console( cmdSetDbgOff)
|
||||||
|
@ -418,6 +428,8 @@ function main(args)
|
||||||
end
|
end
|
||||||
core.clearCommandBuffer()
|
core.clearCommandBuffer()
|
||||||
|
|
||||||
|
local keyA = keygen(result.uid)
|
||||||
|
|
||||||
-- Show tag info
|
-- Show tag info
|
||||||
print((' Found tag %s'):format(result.name))
|
print((' Found tag %s'):format(result.name))
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue