proxmark3 icon indicating copy to clipboard operation
proxmark3 copied to clipboard

[idea] implement json/bin everywhere

Open iceman1001 opened this issue 5 years ago • 7 comments

Is your feature request related to a problem? Please describe. As of now only parts of the commands has implemented BIN/JSON formats.

Describe the solution you'd like All commands that involves files, should support BIN/JSON formats.

Describe alternatives you've considered as an alternative, lua scripts can be made. No more python scripts.

Additional context All formats we support helps when other tools needs to import/export from a proxmark generated file. Today we have Chameleon Mini GUI, MCT tool interoperability, and hopefully also Project Walrus in the near future.

iceman1001 avatar Mar 10 '19 15:03 iceman1001

Need a list on which more places the client is creating files in order to cover all cases. Some rgmagic @doegox ?

iceman1001 avatar Jun 02 '20 07:06 iceman1001

read/write: rg fopen write/append: rg 'fopen.*"[aw]'

doegox avatar Jun 02 '20 08:06 doegox

Excellent! rg 'fopen'|egrep -v "(mbedtls|zlib|liblua|fpga|tinycbo|whereami|armsrc|hitag2crack|deprecated|fileutils|jansson|reveng)"

iceman1001 avatar Jun 02 '20 08:06 iceman1001

I don't know why but there are files created and read a little bit everywhere. In the dependencies its not much to do about it. Currently these left to convert to use fileutils.c,


// these two are the "data load" command
client/src/cmddata.c:        f = fopen(path, "rb");       
client/src/cmddata.c:        f = fopen(path, "r");

// load UID's from a txt file
client/src/cmdlfem410x.c:   if ((f = fopen(filename, "r")) == NULL) { 
// load python script file
client/src/cmdscript.c:         FILE *f = fopen(script_path, "r");

client/src/flash.c:    fd = fopen(ctx->filename, "rb");

// open handler for each command script files
client/src/proxmark3.c:    FILE *f = fopen(path, "r");                             

// proxmark3 client log file append writing to text file
client/src/ui.c:            logfile = fopen(my_logfile_path, "a");                   

// load CA Public Key from text file
client/src/emv/emv_pk.c:    FILE *f = fopen(fname, "r");                        


client/src/cmdhfmfhard.c:    FILE *statesfile = fopen(path, "rb");
client/src/cmdhfmfhard.c:    if ((fnonces = fopen(filename, "rb")) == NULL) {
client/src/cmdhfmfhard.c:    if ((fnonces = fopen(filename, "wb")) == NULL) {
client/src/cmdhfmfhard.c:    if ((fstats = fopen("hardnested_stats.txt", "a")) == NULL) {

client/deps/hardnested/hardnested_tables.c:    FILE *outfile = fopen(filename, "wb");
client/deps/hardnested/hardnested_bruteforce.c:    FILE *benchfile = fopen(RESOURCES_SUBDIR TEST_BENCH_FILENAME, "wb");
client/deps/hardnested/hardnested_bruteforce.c:    FILE *benchfile = fopen(path, "rb");

// ignore these
client/deps/amiitool/amiitool.c:        f = fopen(infile, "rb");
client/deps/amiitool/amiitool.c:        f = fopen(savefile, "rb");
client/deps/amiitool/amiitool.c:        f = fopen(outfile, "wb");

// ignore, inside a comment section
client/src/cmdlfhitag.c:        f = fopen(filename, "wb");

TODO:

  • [x] convert to use fileutils.c for load
  • [x] convert to use fileutils.c for save
  • [x] convert cli commands to take any bin/json files via auto detect.

iceman1001 avatar Jun 04 '20 07:06 iceman1001

I realize two different things being discussed in here.

  1. bin/json support in all commands that handles dumps
  2. read/write to be centralized into fileutils.c, instead of having custom file access across the pm3 client.

For 1, haven't checked which commands that still doesn't accept it.
For 2. some might fit into fileutils.c direct, then we have generic binary files written / saved which would demand re-writing those fcts.

iceman1001 avatar Feb 05 '22 11:02 iceman1001

MFU commands now fully support bin/json format.

iceman1001 avatar Feb 12 '22 16:02 iceman1001

all relevant Legic commands now supports bin/json

iceman1001 avatar Feb 14 '22 08:02 iceman1001