mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-14 10:37:23 -07:00
more rework
This commit is contained in:
parent
4443ae5500
commit
e80eb37b5e
1 changed files with 63 additions and 25 deletions
|
@ -2,7 +2,7 @@ local utils = require('utils')
|
|||
local getopt = require('getopt')
|
||||
local read14a = require('read14a')
|
||||
|
||||
[[--
|
||||
--[[
|
||||
---Suggestions of improvement:
|
||||
--- Add support another types of dumps: BIN, JSON
|
||||
--- Maybe it will be not only as `mfc_gen3_writer`, like a universal dump manager.
|
||||
|
@ -14,6 +14,7 @@ local read14a = require('read14a')
|
|||
-- doesn't take consideration filepaths for dump files.
|
||||
-- doesn't allow A keys for authenticating when writing
|
||||
-- doesn't verify that card is magic gen3.
|
||||
-- doesn't take several versions of same dump ( -1, -2, -3 ) styles.
|
||||
--]]
|
||||
|
||||
copyright = ''
|
||||
|
@ -42,6 +43,34 @@ usage = [[
|
|||
Select your *.eml dump from list to write to the card.
|
||||
]]
|
||||
|
||||
-- Some globals
|
||||
local DEBUG = false -- the debug flag
|
||||
|
||||
-------------------------------
|
||||
-- Some utilities
|
||||
-------------------------------
|
||||
|
||||
---
|
||||
-- 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
|
||||
---
|
||||
-- This is only meant to be used when errors occur
|
||||
local function oops(err)
|
||||
print('ERROR:', err)
|
||||
core.clearCommandBuffer()
|
||||
return nil, err
|
||||
end
|
||||
---
|
||||
-- Usage help
|
||||
local function help()
|
||||
|
@ -49,6 +78,7 @@ local function help()
|
|||
print(author)
|
||||
print(version)
|
||||
print(desc)
|
||||
print('Example usage')
|
||||
print(example)
|
||||
print(usage)
|
||||
end
|
||||
|
@ -87,28 +117,31 @@ local function main(args)
|
|||
wait()
|
||||
print(tab)
|
||||
|
||||
local length = 23
|
||||
local e = 14
|
||||
local length = 25
|
||||
local e = 16
|
||||
-- Detect 7 byte card
|
||||
if string.len(GetUID()) == 14 then
|
||||
length = 29
|
||||
e = 20
|
||||
length = 31
|
||||
e = 22
|
||||
end
|
||||
dropfield()
|
||||
|
||||
---List all EML files in /client
|
||||
for _ in io.popen([[dir ".\" /b]]):lines() do -- for UNIX: ls
|
||||
|
||||
if string.find(_, '%.eml$') then
|
||||
|
||||
if string.len(_) == length then -- The length of eml file
|
||||
num_dumps = num_dumps + 1
|
||||
files[num_dumps] = string.sub(tostring(_), 7, e) -- Cut UID from eml file
|
||||
print(' '..num_dumps..' | '..files[a])
|
||||
end
|
||||
|
||||
local dumpEML = "find '.' -iname '*dump.eml' -type f"
|
||||
local p = assert(io.popen(dumpEML))
|
||||
for _ in p:lines() do
|
||||
|
||||
-- The length of eml file
|
||||
if string.len(_) == length then
|
||||
num_dumps = num_dumps + 1
|
||||
-- cut UID from eml file
|
||||
files[num_dumps] = string.sub(_, 9, e)
|
||||
print(' '..num_dumps..' | '..files[num_dumps])
|
||||
end
|
||||
end
|
||||
|
||||
if num_dumps == 0 then return oops("Didn't find any dump files") end
|
||||
|
||||
print(tab)
|
||||
print(' Your card has UID '..GetUID())
|
||||
print('')
|
||||
|
@ -117,10 +150,10 @@ local function main(args)
|
|||
io.write(' --> ')
|
||||
|
||||
local no = tonumber(io.read())
|
||||
local dump = io.open('./hf-mf-' .. files[no] .. '-data.eml', 'r');
|
||||
local dump = assert(io.open('./hf-mf-' .. files[no] .. '-dump.eml', 'r'))
|
||||
|
||||
print(tab)
|
||||
print(' You have been selected ' .. no .. ' card dump, with UID : '..files[no])
|
||||
print(' You have been selected card dump ' .. no .. ', with UID : '..files[no])
|
||||
|
||||
--- Load eml file
|
||||
for _ in dump:lines() do table.insert(eml, _); end
|
||||
|
@ -128,22 +161,23 @@ local function main(args)
|
|||
--- Extract B key from EML file
|
||||
local b = 0
|
||||
for i = 1, #eml do
|
||||
print('line is type: ', type(eml[i]) )
|
||||
|
||||
if (i % 4 == 0) then
|
||||
repeat
|
||||
b = b + 1
|
||||
-- Cut key from block
|
||||
b_keys[b] = string.sub(tostring(eml[i]), (string.len(eml[i]) - 11), string.len(eml[i]))
|
||||
b_keys[b] = string.sub(eml[i], (#eml[i] - 11), #eml[i])
|
||||
until b % 4 == 0
|
||||
end
|
||||
end
|
||||
print(tab)
|
||||
dbg(b_keys)
|
||||
dbg(eml)
|
||||
|
||||
--- Change UID on certain version of magic Gen3 card.
|
||||
if (utils.confirm(' Change UID ?') == true) then
|
||||
wait()
|
||||
core.console('hf 14a raw -s -c -t 2000 90f0cccc10'..tostring(eml[1]))
|
||||
--core.console('hf 14a raw -s -c -t 2000 90f0cccc10'..tostring(eml[1]))
|
||||
print('hf 14a raw -s -c -t 2000 90f0cccc10'..tostring(eml[1]))
|
||||
print(tab)
|
||||
print(' The new card UID : ' .. GetUID())
|
||||
end
|
||||
|
@ -165,7 +199,8 @@ local function main(args)
|
|||
if (utils.confirm(' Are you using a empty card with default key?') == true) then
|
||||
wait()
|
||||
for i = 1, #eml do
|
||||
core.console(string.format(cmd_wrbl, (i-1), default_key, eml[i]))
|
||||
--core.console(string.format(cmd_wrbl, (i-1), default_key, eml[i]))
|
||||
print(string.format(cmd_wrbl, (i-1), default_key, eml[i]))
|
||||
end
|
||||
else
|
||||
print(tab)
|
||||
|
@ -173,9 +208,11 @@ local function main(args)
|
|||
wait()
|
||||
for i = 1, #eml do
|
||||
if (i % 4 == 0) then
|
||||
core.console(string.format(cmd_wrbl, (i-1), b_keys[i], default_key_blk))
|
||||
--core.console(string.format(cmd_wrbl, (i-1), b_keys[i], default_key_blk))
|
||||
print(string.format(cmd_wrbl, (i-1), b_keys[i], default_key_blk))
|
||||
else
|
||||
core.console(string.format(cmd_wrbl, (i-1), b_keys[i], empty))
|
||||
--core.console(string.format(cmd_wrbl, (i-1), b_keys[i], empty))
|
||||
print(string.format(cmd_wrbl, (i-1), b_keys[i], empty))
|
||||
end
|
||||
end
|
||||
else
|
||||
|
@ -183,7 +220,8 @@ local function main(args)
|
|||
print('Writing to card')
|
||||
wait()
|
||||
for i = 1, #eml do
|
||||
core.console(string.format(cmd_wrbl, (i-1), b_keys[i], eml[i]))
|
||||
--core.console(string.format(cmd_wrbl, (i-1), b_keys[i], eml[i]))
|
||||
print(string.format(cmd_wrbl, (i-1), b_keys[i], eml[i]))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue