Update hf-writer.lua

Adapted your script to the coding standards
This commit is contained in:
Winds 2020-03-18 13:39:10 +03:00
commit 6b30e1ab00

View file

@ -7,6 +7,28 @@ local a = 0
local b = 0 local b = 0
local tab = string.rep('-', 64) local tab = string.rep('-', 64)
copyright = ''
author = 'Winds'
version = 'v1.0.0'
desc = [[
That's script gives for you a easy way to write your an *.eml dumps, using a Proxmark 3.
It's working for 4 and 7 bytes NXP MIFARE Classic 1K cards.
The script has including an injection of UID changig for the Chinese Magic Cards GEN 3.
Whith choosen an *.eml file you can do:
1. Write it to the equals of current card UID.
2. Write it to anther card with changable UID.
3. Send command to lock UID for the Chinese Magic Cards GEN 3.
4. Erease all data at the card and set the FFFFFFFFFFFF keys, and Access Conditions to 78778800.
]]
example = [[
1. script run hf-writer
]]
usage = [[
You should choose your *.eml dump from being list to write it to the card by wizard
]]
local function read() local function read()
u = read14a.read(true, true).uid u = read14a.read(true, true).uid
return u return u
@ -22,12 +44,14 @@ local function finish()
core.clearCommandBuffer() core.clearCommandBuffer()
end end
local function wait() read14a.waitFor14443a() end local function wait()
read14a.waitFor14443a()
end
local function main(args)
--File lienght check for detect 4 or 7 bytes
wait() wait()
print(tab) print(tab)
if string.len(read()) == 14 then -- Detect 7 byte card if string.len(read()) == 14 then -- Detect 7 byte card
l = 29 -- 7 byte length of eml file l = 29 -- 7 byte length of eml file
s = 7 s = 7
@ -37,7 +61,7 @@ else
s = 7 s = 7
e = 14 e = 14
end end
---Listern EML files at Client catalog
for _ in io.popen([[dir ".\" /b]]):lines() do -- for UNIX: ls for _ in io.popen([[dir ".\" /b]]):lines() do -- for UNIX: ls
if string.find(_, '%.eml$') then if string.find(_, '%.eml$') then
if string.len(_) == l then -- There length of eml file if string.len(_) == l then -- There length of eml file
@ -59,7 +83,7 @@ local dump = io.open('./hf-mf-' .. uid[no] .. '-data.eml', 'r');
print(tab) print(tab)
print(' You have been selected ' .. no .. ' card dump, it UID is ' .. uid[no]) print(' You have been selected ' .. no .. ' card dump, it UID is ' .. uid[no])
---EML get B key from opened EML file
for _ in dump:lines() do table.insert(eml, _); end for _ in dump:lines() do table.insert(eml, _); end
for i = 1, #eml do for i = 1, #eml do
if (i % 4 == 0) then if (i % 4 == 0) then
@ -72,7 +96,7 @@ for i = 1, #eml do
end end
print(tab) print(tab)
---UID Changing
if (utils.confirm(' Do the UID changing?') == true) then if (utils.confirm(' Do the UID changing?') == true) then
wait() 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]))
@ -81,14 +105,14 @@ if (utils.confirm(' Do the UID changing?') == true) then
end end
print(tab) print(tab)
---UID Blocking
if (utils.confirm(' Would you like to BLOCK the UID for any changing?') == true) then if (utils.confirm(' Would you like to BLOCK the UID for any changing?') == true) then
wait() wait()
core.console('hf 14a raw -s -c -t 2000 90fd111100') core.console('hf 14a raw -s -c -t 2000 90fd111100')
end end
print(tab) print(tab)
---Wriiting block
if (utils.confirm(' At this case are you using a Blank Card?') == true) then if (utils.confirm(' At this case are you using a Blank Card?') == true) then
wait() wait()
for i = 1, #eml do for i = 1, #eml do
@ -122,3 +146,12 @@ else
end end
end end
finish() finish()
end
main(args)
---General thinks for the future:
---Add support another types of dumps: BIN, JSON
---Maybe it will be not only as `hf-writer`, like a universal dump manager.
---Add undependence from the operation system. At the moment code not working in Linux.
---Add more chinesse backdoors RAW commands for UID changing (find RAW for the 4 byte familiar chinese card, from native it soft: http://bit.ly/39VIDsU)
---Hide system messages when you writing a dumps, replace it to some of like [#####----------] 40%