Proxmark3 developers community

Research, development and trades concerning the powerful Proxmark3 device.

Remember; sharing is caring. Bring something back to the community.


"Learn the tools of the trade the hard way." +Fravia

You are not logged in.

#1 2019-03-18 14:16:38

loupetre
Contributor
Registered: 2019-01-21
Posts: 20

How can I get the return code in lua ?

Hi everybody,

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

Offline

#2 2019-03-18 19:51:18

iceman
Administrator
Registered: 2013-04-25
Posts: 6,553
Website

Re: How can I get the return code in lua ?

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


If you feel the love,  https://www.patreon.com/iceman1001

modhex(hkhehghthbhudcfcdchkigiehgduiehg)

Offline

#3 2020-02-12 22:13:48

Winds
Contributor
Registered: 2020-01-28
Posts: 43

Re: How can I get the return code in lua ?

iceman wrote:

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

Offline

#4 2020-03-26 21:21:21

loupetre
Contributor
Registered: 2019-01-21
Posts: 20

Re: How can I get the return code in lua ?

Here is an example :

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, ...
...

Last edited by loupetre (2020-03-26 21:24:28)

Offline

Board footer

Powered by FluxBB