RfidResearchGroup / proxmark3

Iceman Fork - Proxmark3
http://www.icedev.se
GNU General Public License v3.0
3.65k stars 981 forks source link

Cannot save and load data using "trace" command #1252

Closed wh201906 closed 3 years ago

wh201906 commented 3 years ago

Describe the bug When I use "hf mf sniff" then "trace save" for many times, it will only save the first trace data, even I use different filename.
Also, the "trace load" cannot load the file into the trace buffer.

To Reproduce Just "hf mf sniff" and "trace save". The logs might be better to show how to reproduce.

Expected behavior The trace files should be different.

Screenshots For the bug in "trace save":

[usb] pm3 --> hf 14a sniff -c

[#] Starting to sniff. Press PM3 Button to stop.
[#] trace len = 2298
[usb] pm3 --> trace list

Annotate trace buffer with selected protocol data
You can load a trace from file (see `trace load -h`) or it be downloaded from device by default

usage:
    trace listoptions:

examples/notes:
    trace list -t raw              -> just show raw data without annotations
    trace list -t 14a              -> interpret as ISO14443-A communications
    trace list -t thinfilm         -> interpret as Thinfilm communications
    trace list -t topaz            -> interpret as Topaz communications
    trace list -t mf               -> interpret as MIFARE Classic communications and decrypt crypto1 stream
    trace list -t des              -> interpret as MIFARE DESFire communications
    trace list -t 14b              -> interpret as ISO14443-B communications
    trace list -t 7816             -> interpret as ISO7816-4 communications
    trace list -t 15               -> interpret as ISO15693 communications
    trace list -t iclass           -> interpret as iCLASS communications
    trace list -t legic            -> interpret as LEGIC communications
    trace list -t felica           -> interpret as ISO18092 / FeliCa communications
    trace list -t hitag1           -> interpret as Hitag1 communications
    trace list -t hitag2           -> interpret as Hitag2 communications
    trace list -t hitags           -> interpret as HitagS communications
    trace list -t lto              -> interpret as LTO-CM communications
    trace list -t cryptorf         -> interpret as CryptoRF communitcations
    trace list -t mf --dict <mfc_default_keys>         -> use dictionary keys file
    trace list -t 14a -f                               -> show frame delay times
    trace list -t 14a -1                               -> use trace buffer

[usb] pm3 --> trace
[usb] pm3 --> trace save

Save protocol data from trace buffer to binary file
File extension is <.trace>

usage:
    trace saveoptions:

examples/notes:
    trace save -f mytracefile      -> w/o file extension

[usb] pm3 --> trace save -f 111.trc
[=] downloading tracelog data from device
[+] saved 2298 bytes to binary file 111.trc.trace
[usb] pm3 --> hf 14a sniff -c

[#] Starting to sniff. Press PM3 Button to stop.
[#] trace len = 2517
[usb] pm3 --> trace save -f 112.trc
[+] saved 2298 bytes to binary file 112.trc.trace
[usb] pm3 --> hf 14a sniff -c

[#] Starting to sniff. Press PM3 Button to stop.
[#] trace len = 202
[usb] pm3 --> trace save -f 211.trc
[+] saved 2298 bytes to binary file 211.trc.trace

For the bug in "trace load"

[usb] pm3 --> trace load -f 111.trc
[+] loaded 2298 bytes from binary file 111.trc
[+] Recorded Activity (TraceLen = 2298 bytes)
[usb] pm3 --> trace list -t mf
[=] downloading tracelog data from device
[+] Recorded activity (trace len = 48 bytes)
[=] start = start of start frame end = end of frame. src = source of transfer
[=] ISO14443A - all times are in carrier periods (1/13.56MHz)

      Start |        End | Src | Data (! denotes parity error)                                           | CRC | Annotation
------------+------------+-----+-------------------------------------------------------------------------+-----+--------------------
          0 |       2368 | Tag |04  00                                                                   |     |
     236828 |     239292 | Rdr |93  20                                                                   |     | ANTICOLL

Desktop (please complete the following information):

iceman1001 commented 3 years ago

No bug. Its related to user handling error.

If you read the help text, you find that you need to specify that you don't want to download a trace from device per automatic by specifying -1 param.

You also seem to struggle with the params in general when loading file. Its quite simple.

 trace load -f traces/hf_14a_reader_4b_rats.trace
 trace list -1 -t 14b
wh201906 commented 3 years ago

@iceman1001 I didn't check the help text carefully. Sorry about that. I know how to load trace files now.

How about saving trace files? I called "hf 14a sniff" then "trace save -f xxx" for many times with different filenames, but the traces files are all the same(I used cmp command and it returned nothing, the size of them are also the same). You can look at the logs above. The traceLen was changing after each "hf 14a sniff" but the "trace save" always returned "saved 2298 bytes..." I just went through the help text about "trace load" and "trace save", I don't know whether I am operating wrongly. Thanks for your help!

wh201906 commented 3 years ago

I got the point. After "hf 14a sniff", I need to call "trace list -t xx" to dump the trace from device to the client buffer then list it, and "trace save" only save the data from the client buffer. "trace list --buffer -t xx" will NOT dump the trace from the device, it will use the data from client buffer directly.

iceman1001 commented 3 years ago

Trace save will download if graph buffer is empty. If you already downloaded something, it will save that.

    if (g_traceLen == 0) {
        download_trace();
        if (g_traceLen == 0) {
            PrintAndLogEx(WARNING, "trace is empty, nothing to save");
            return PM3_SUCCESS;
        }
    }

data clear will empty both graphbuffer and bigbuf on device side.

data clear
hf 14a sniff -cr

trace save -f xxxx
or 
trace list -t 14a
trace save -f xxx