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

Announcement

Time changes and with it the technology
Proxmark3 @ discord

Users of this forum, please be aware that information stored on this site is not private.

#1 2017-01-19 22:47:56

chintandarji
Contributor
Registered: 2016-10-06
Posts: 19

Lua script to encode cards.

Hi everyone,
I'm trying to write a script which takes facility code,  card number, and format as an argument and the script will encode the card. But I'm stuck at a point where I send the command and It says the number is malformed.

what I did is take FC, CN, and format. Creates three blocks data accordingly and trying to write each block one by one.

local writecmd = Command:new{cmd = cmds.CMD_T55XX_WRITE_BLOCK,arg1 ="60107060", arg2 ="00", arg3 =      "00", data = "00"}
    local writecmd1 = Command:new{cmd = cmds.CMD_T55XX_WRITE_BLOCK,arg1 ="01D55955", arg2 ="01", arg3 ="00" , data = "00"}
    local writecmd2 = Command:new{cmd = cmds.CMD_T55XX_WRITE_BLOCK,arg1 ="5569A569", arg2 ="02", arg3 ="00" , data = "00"}
    local writecmd3 = Command:new{cmd = cmds.CMD_T55XX_WRITE_BLOCK,arg1 ="5A956599", arg2 ="03", arg3 ="00" , data = "00"}
    local err = core.SendCommand(writecmd:getBytes())
    if err then return oops(err) end
           err = core.SendCommand(writecmd1:getBytes())
    if err then return oops(err) end
       err = core.SendCommand(writecmd2:getBytes())
    if err then return oops(err) end
       err = core.SendCommand(writecmd3:getBytes())
    if err then return oops(err) end   
    local response = core.WaitForResponseTimeout(cmds.CMD_ACK,TIMEOUT)


So, here I got error While writing block 1. Error says "number is Malformed"
I don't know what does it mean.

Offline

#2 2017-01-20 18:10:21

chintandarji
Contributor
Registered: 2016-10-06
Posts: 19

Re: Lua script to encode cards.

Now I'm trying it with this
        core.console("lf t55xx wr b 0 d 60107060")
    core.console("lf t55xx wr b 1 d 01D55955")
    core.console("lf t55xx wr b 2 d 5569A569")
    core.console("lf t55xx wr b 3 d 5A956599")
and now I want script to verify that is it correct or not. any help guys??

Offline

#3 2017-01-21 15:29:08

iceman
Administrator
Registered: 2013-04-25
Posts: 9,538
Website

Re: Lua script to encode cards.

On your way,  just need to understand the difference between strings and byte arrays regarding yr first post.

What is the purpose with the script besides the obvious "write to a t55x7 tag".  With yr four core.console commands you archive it.

core.console mimics running a command on commandprompt in the client.  So you see the feedback on screen as normal but you don't get "access" to the response inside the luascript. Concerning yr question about verify,  it comes down to how to verify it.  Do you mean to verfiy that the writes went well? or do you mean that the t55xx tag is mimicing a valid tag (ie test 'lf search')  ?   Do you want it to be automatic or human verification?

Offline

#4 2017-01-23 17:43:32

chintandarji
Contributor
Registered: 2016-10-06
Posts: 19

Re: Lua script to encode cards.

Thanks, @iceman for the response.  I will convert a string to byte array.
Now regarding my question of verifying, I want to check that tag mimic specific tag that I want.

Offline

#5 2017-01-23 17:48:35

iceman
Administrator
Registered: 2013-04-25
Posts: 9,538
Website

Re: Lua script to encode cards.

then I suggest 

core.console("lf search")

It will easily show you if pm3 client does recoqnise it..  (which it doesnt since I tried it)

Offline

#6 2017-01-23 17:57:20

chintandarji
Contributor
Registered: 2016-10-06
Posts: 19

Re: Lua script to encode cards.

That's true, But I want it to automatically verify. and if I use core.console("lf search") I have to check it manually at each card.

Offline

#7 2017-01-23 18:39:42

iceman
Administrator
Registered: 2013-04-25
Posts: 9,538
Website

Re: Lua script to encode cards.

If you want to do it automatically, you need to know what you are verifying against and how it all fits in together in the client code.

Not much I can help you with there.

Offline

#8 2017-01-23 18:43:01

chintandarji
Contributor
Registered: 2016-10-06
Posts: 19

Re: Lua script to encode cards.

Is there a way I can store the output of "core.console()" to any variable or file??
That will make it easy for me

Offline

#9 2017-01-23 18:50:03

iceman
Administrator
Registered: 2013-04-25
Posts: 9,538
Website

Re: Lua script to encode cards.

check out the proxmark3.log file...

Offline

#10 2017-01-24 18:34:45

chintandarji
Contributor
Registered: 2016-10-06
Posts: 19

Re: Lua script to encode cards.

Thanks @iceman I will write with core.console("lf t55xx wr b d") and use core.console("lf search") to vrify it from log file.
thanks again

Offline

Board footer

Powered by FluxBB