mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-22 06:13:51 -07:00
fix: 'script run legic' - at last, it now saves in EML and BIN format.
This commit is contained in:
parent
da09131aa3
commit
8bfe669430
1 changed files with 15 additions and 15 deletions
|
@ -641,29 +641,25 @@ end
|
||||||
local function save_BIN(data, filename)
|
local function save_BIN(data, filename)
|
||||||
local outfile
|
local outfile
|
||||||
local counter = 1
|
local counter = 1
|
||||||
local ext = filename:match("^.+(%..+)$")
|
local ext = filename:match("^.+(%..+)$") or ''
|
||||||
local fn = filename
|
local fn = filename
|
||||||
|
|
||||||
-- Make sure we don't overwrite a file
|
-- Make sure we don't overwrite a file
|
||||||
while file_check(fn) do
|
while file_check(fn) do
|
||||||
fn = filename:gsub(ext, tostring(counter)..ext)
|
fn = filename:gsub(ext, tostring(counter)..ext)
|
||||||
print(filename, fn)
|
|
||||||
counter = counter + 1
|
counter = counter + 1
|
||||||
end
|
end
|
||||||
|
|
||||||
outfile = io.open(fn, 'wb')
|
outfile = io.open(fn, 'wb')
|
||||||
|
|
||||||
local bytes = utils.ConvertHexToBytes(data)
|
|
||||||
|
|
||||||
local i = 1
|
local i = 1
|
||||||
while bytes[i] do
|
while data[i] do
|
||||||
|
local byte = string.char(tonumber(data[i], 16))
|
||||||
outfile:write(bytes[i])
|
outfile:write(byte)
|
||||||
i = i + 1
|
i = i + 1
|
||||||
end
|
end
|
||||||
|
|
||||||
outfile:close()
|
outfile:close()
|
||||||
return fn, #bytes
|
return fn, #data
|
||||||
end
|
end
|
||||||
---
|
---
|
||||||
-- write bytes to file
|
-- write bytes to file
|
||||||
|
@ -701,10 +697,14 @@ function writeFile(bytes, filename)
|
||||||
fho:close()
|
fho:close()
|
||||||
|
|
||||||
-- save binary
|
-- save binary
|
||||||
local fn_bin, num_of_bytes = save_BIN(bytes, filename)
|
local fn_bin, fn_bin_num = save_BIN(bytes, filename)
|
||||||
|
|
||||||
|
print("\nwrote "..acyellow..(#bytes * 3)..acoff.." bytes to " ..acyellow..filename..acoff)
|
||||||
|
|
||||||
|
if fn_bin and fn_bin_num then
|
||||||
|
print("\nwrote "..acyellow..fn_bin_num..acoff.." bytes to BINARY file "..acyellow..fn_bin..acoff)
|
||||||
|
end
|
||||||
|
|
||||||
print("\nwrote ".. #bytes * 3 .." bytes to " .. filename)
|
|
||||||
print("\nwrote ".. num_of_bytes .." bytes to " .. fn_bin)
|
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue