RfidResearchGroup / proxmark3

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

[idea] implement json/bin everywhere #129

Open iceman1001 opened 5 years ago

iceman1001 commented 5 years ago

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 commented 4 years ago

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

doegox commented 4 years ago

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

iceman1001 commented 4 years ago

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

iceman1001 commented 4 years ago

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:

iceman1001 commented 2 years ago

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 commented 2 years ago

MFU commands now fully support bin/json format.

iceman1001 commented 2 years ago

all relevant Legic commands now supports bin/json