mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-03-21 20:52:45 +08:00
Some more lua-scripts and library fixes from iceman, including more default keys
This commit is contained in:
parent
5b1311fba2
commit
fdefed663f
3 changed files with 84 additions and 9 deletions
|
@ -8,7 +8,14 @@ bin = require('bin')
|
||||||
---
|
---
|
||||||
-- A debug printout-function
|
-- A debug printout-function
|
||||||
local function dbg(args)
|
local function dbg(args)
|
||||||
if DEBUG then
|
|
||||||
|
if type(args) == "table" then
|
||||||
|
local i = 1
|
||||||
|
while args[i] do
|
||||||
|
print("###", args[i])
|
||||||
|
i = i+1
|
||||||
|
end
|
||||||
|
else
|
||||||
print("###", args)
|
print("###", args)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -40,20 +47,38 @@ local function save_HTML(javascript, filename)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function save_BIN(data, filename)
|
||||||
|
-- Open the output file
|
||||||
|
|
||||||
|
local outfile = io.open(filename, "wb")
|
||||||
|
if outfile == nil then
|
||||||
|
return oops(string.format("Could not write to file %s",tostring(filename)))
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Write the data into it
|
||||||
|
local i = 1
|
||||||
|
while data[i] do
|
||||||
|
outfile:write(data[i])
|
||||||
|
i = i+1
|
||||||
|
end
|
||||||
|
|
||||||
|
io.close(outfile)
|
||||||
|
return filename
|
||||||
|
end
|
||||||
|
|
||||||
local function convert_ascii_dump_to_JS(infile)
|
local function convert_ascii_dump_to_JS(infile)
|
||||||
local t = infile:read("*all")
|
local t = infile:read("*all")
|
||||||
|
|
||||||
local output = "[";
|
local output = "[";
|
||||||
for line in string.gmatch(t, "[^\n]+") do
|
for line in string.gmatch(t, "[^\n]+") do
|
||||||
output = output .. "'"..line.."',\n"
|
if string.byte(line,1) ~= string.byte("+",1) then
|
||||||
|
output = output .. "'"..line.."',\n"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
output = output .. "]"
|
output = output .. "]"
|
||||||
return output
|
return output
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
local function convert_binary_dump_to_JS(infile, blockLen)
|
local function convert_binary_dump_to_JS(infile, blockLen)
|
||||||
local bindata = infile:read("*all")
|
local bindata = infile:read("*all")
|
||||||
len = string.len(bindata)
|
len = string.len(bindata)
|
||||||
|
@ -78,6 +103,21 @@ local function convert_binary_dump_to_JS(infile, blockLen)
|
||||||
return js
|
return js
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function convert_ascii_dump_to_BIN(infile)
|
||||||
|
local t = infile:read("*all")
|
||||||
|
|
||||||
|
local output = {};
|
||||||
|
for line in string.gmatch(t, "[^\n]+") do
|
||||||
|
if string.byte(line) ~= string.byte("+") then
|
||||||
|
for c in (line or ''):gmatch('..') do
|
||||||
|
output[#output+1] = string.char( tonumber(c,16) )
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return output
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
---
|
---
|
||||||
-- Converts a .eml-file into a HTML/Javascript file.
|
-- Converts a .eml-file into a HTML/Javascript file.
|
||||||
-- @param input the file to convert
|
-- @param input the file to convert
|
||||||
|
@ -118,7 +158,27 @@ local function convert_bin_to_html(input, output, blockLen)
|
||||||
return save_HTML(javascript, output )
|
return save_HTML(javascript, output )
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Converts a eml dump into a binary file
|
||||||
|
-- @param input the file containing the eml-dump (defaults to dumpdata.eml)
|
||||||
|
-- @param output the file to write to ( defaults to dumpdata.bin)
|
||||||
|
local function convert_eml_to_bin(input, output)
|
||||||
|
input = input or 'dumpdata.eml'
|
||||||
|
output = output or 'dumpdata.bin'
|
||||||
|
|
||||||
|
local infile = io.open(input, "rb")
|
||||||
|
if infile == nil then
|
||||||
|
return oops(string.format("Could not read file %s",tostring(input)))
|
||||||
|
end
|
||||||
|
-- Read file, get BIN
|
||||||
|
local data = convert_ascii_dump_to_BIN(infile)
|
||||||
|
io.close(infile)
|
||||||
|
|
||||||
|
return save_BIN(data, output )
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
convert_bin_to_html = convert_bin_to_html,
|
convert_bin_to_html = convert_bin_to_html,
|
||||||
convert_eml_to_html = convert_eml_to_html,
|
convert_eml_to_html = convert_eml_to_html,
|
||||||
|
convert_eml_to_bin = convert_eml_to_bin,
|
||||||
}
|
}
|
||||||
|
|
|
@ -126,6 +126,21 @@ local _keys = {
|
||||||
'eeeeeeeeeeee',
|
'eeeeeeeeeeee',
|
||||||
'0123456789ab',
|
'0123456789ab',
|
||||||
'123456789abc',
|
'123456789abc',
|
||||||
|
|
||||||
|
--[[
|
||||||
|
The keys below are taken from from https://github.com/4ZM/mfterm/blob/master/dictionary.txt
|
||||||
|
--]]
|
||||||
|
|
||||||
|
'abcdef123456', -- Key from ladyada.net
|
||||||
|
|
||||||
|
'000000000001',
|
||||||
|
'000000000002',
|
||||||
|
'00000000000a',
|
||||||
|
'00000000000b',
|
||||||
|
'100000000000',
|
||||||
|
'200000000000',
|
||||||
|
'a00000000000',
|
||||||
|
'b00000000000',
|
||||||
}
|
}
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
|
@ -13,7 +13,7 @@ by the emulator
|
||||||
Arguments:
|
Arguments:
|
||||||
-h This help
|
-h This help
|
||||||
-i <file> Specifies the dump-file (input). If omitted, 'dumpdata.bin' is used
|
-i <file> Specifies the dump-file (input). If omitted, 'dumpdata.bin' is used
|
||||||
-o <filename> Speciies the output file. If omitted, <uid>.eml is used.
|
-o <filename> Specifies the output file. If omitted, <uid>.eml is used.
|
||||||
|
|
||||||
]]
|
]]
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue