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 2020-04-03 10:46:30

pizza_4u
Contributor
Registered: 2018-07-28
Posts: 8

[Solved] Getting Data of sendMIX command

Hi,

I’m currently try to refactor the Legic_clone.lua script so that it is working again with the current rrg repo (Issue 209).

I’ve got stuck with handling commands.
I want to get the first 4 bytes of a legic tag. On CLI I would call

hf legic rdmem 0 4

.

To get the bytes in LUA I use a function readlegicdata()

- read LEGIC data
local function readlegicdata( offset, length, iv )
    -- Read data
    local command = Command:newMIX{
                    cmd = cmds.CMD_HF_LEGIC_READER
                    , arg1 = offset
                    , arg2 = length
                    , arg3 = iv
                    , data = nil
                    }
    local result, err = command:sendMIX()
    if not result then return oops(err) end
    print("DEBUG: "..type(result).." "..#result.." "..result.." "..('%02x'):format(result:byte(1))..('%02x'):format(result:byte(2))..('%02x'):format(result:byte(3))..('%02x'):format(result:byte(4)))
    return result
end

When calling the function like

readbytes = readlegicdata(0, 4, 0x55)

result seems to be a string with 544 length. So I guess I have to

bin.unpack(????, result)

the result. However I have currently no clue of the structure of result.

Any hints, ideas how to get on here?

Thanks!

Last edited by pizza_4u (2020-04-04 07:59:29)

Offline

#2 2020-04-03 11:12:05

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

Re: [Solved] Getting Data of sendMIX command

I though the legic script problem was releated to the import reading of a binary file vs eml file.

Offline

#3 2020-04-03 11:39:36

pizza_4u
Contributor
Registered: 2018-07-28
Posts: 8

Re: [Solved] Getting Data of sendMIX command

Yes. That is/was one problem. However there are some more problems.

One of them is that the script uses outdated commands like

hf legic read 0x00 0x04

With the current implementation the user has to type in the returned bytes. Therefore I wanted to have a  direct call to skip the user input.

Offline

#4 2020-04-04 07:50:35

pizza_4u
Contributor
Registered: 2018-07-28
Posts: 8

Re: [Solved] Getting Data of sendMIX command

OK, I've figured out that data starts at offset 33. So I will use this dirty but working way ;-)

Offline

#5 2020-04-04 09:35:44

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

Re: [Solved] Getting Data of sendMIX command

there is under lualibs/ folder some help libs,  which uses the unpack function to extract different parts of data.

And now I have changed many legic commands input params...so you are up for a bumpy ride wink

Offline

Board footer

Powered by FluxBB