I tried the code above and entered in a few of the missing "require" commands, but I'm getting an error with reading block 0. . I've looked at all the Lua examples in the Luascripts directory and reviewed the Lua libs.
BTW i do have a MF fob on the proxmark as i run this.
Here's the error i'm getting when i run the script:
Couldn't read block .. [0]
[-] ⛔ error - ...oel/proxmark4/proxmark3/client/luascripts/e_test.lua:25: attempt to index local 'b' (a nil value)
Here's the code:
local cmds = require('commands')
local getopt = require('getopt')
local function getblockdata(response)
if not response then
-- print("No response from device")
return nil, "No response from device"
end
if response.Status == PM3_SUCCESS then
return response.Data, "Success"
else
-- print("Couldn't read block .. ["..response.Status.."]")
return nil, "Couldn't read block .. ["..response.Status.."]"
end
end
local function main()
local data = "0000FFFFFFFFFFFF"
local c = Command:newNG{cmd = cmds.CMD_HF_MIFARE_READBL, data = data}
local b, err = getblockdata(c:sendNG(false))
print(b.Data)
end
main()
Instead of doing something like
...
local command="hf mf rdbl 0 A FFFFFFFFFFFF"
core.console(command)
...
you can do this
local function getblockdata(response)
if not response then
-- print("No response from device")
return nil, "No response from device"
end
if response.Status == PM3_SUCCESS then
return response.Data, "Success"
else
-- print("Couldn't read block .. ["..response.Status.."]")
return nil, "Couldn't read block .. ["..response.Status.."]"
end
end
...
local function main()
...
local data = "0000FFFFFFFFFFFF"
local c = Command:newNG{cmd = cmds.CMD_HF_MIFARE_READBL, data = data}
local b, err = getblockdata(c:sendNG(false))
-- you now have access to b.Status, b.Data, ...
...
you need to not use the console command but rather implement that direct calls. Lots of scripts, which lets you get ideas how to solve your problem
Iceman, could you please show an example and we see how it to get?
Scripts has using a core.consele method to send and I never seen way for the returning a responce from the console.
Many Thanks
]]>After sending commands to a tag (e.g. hf mf wrbl ...), a result code is sent to the output : isOk:00 or isOk:01.
I would like to get the value of this return code in order to use it in my scripts. How can I do that ?
Thanks
]]>