RfidResearchGroup / proxmark3

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

printf -> PrintAndLogEx #879

Closed doegox closed 4 years ago

doegox commented 4 years ago

There are still quite a number of printf in the client code. Maybe a few are legit, but most should be converted to make sure they get logged as well.

     28 cliparser/argtable3.c:
     27 emv/emv_pki.c:
     18 fido/cbortools.c:
     13 cmdhfmf.c:
     11 loclass/ikeys.c:
     10 hardnested/hardnested_bf_core.c:
      9 cliparser/cliparser.c:
      8 util.c:
      8 emv/test/cda_test.c:
      7 emv/test/dda_test.c:
      7 emv/crypto_polarssl.c:
      6 uart/uart_posix.c:
      6 crypto/libpcrypto.c:
      6 cmdhflegic.c:
      5 loclass/hash1_brute.c:
      5 emv/test/sda_test.c:
      5 cmdlf.c:
      4 uart/uart_win32.c:
      4 scripting.c:
      4 comms.c:
      4 cmdsmartcard.c:
      4 cmdhffido.c:
      3 mifare/mifarehost.c:
      3 loclass/elite_crack.c:
      3 emv/test/crypto_test.c:
      3 emv/emv_pk.c:
      3 cmdhfmfp.c:
      2 proxguiqt.cpp:
      2 emv/emv_roca.c:
      2 cmdlft55xx.c:
      2 cmdhficlass.c:
      2 cmddata.c:
      2 cmdanalyse.c:
      1 wiegand_formatutils.c:
      1 ui.c:
      1 tinycbor/cborpretty.c:
      1 jansson/strconv.c:
      1 hardnested/hardnested_bruteforce.c:
      1 guidummy.cpp:
      1 cmdhw.c:
      1 cmdhfmfu.c:
      1 cmdhffelica.c:
      1 cmdhf15.c:
      1 cmdhf14b.c:

(magic grep: rg printf|egrep -v "(snprintf|sprintf|liblua|fprintf|:[[:space:]]*/|hardnested_tables.c|//.*printf|\.git)"|grep -o "[^:]*\.c:"|sort|uniq -c|sort -n -r)

iceman1001 commented 4 years ago

yup. we can skip print(".") aswell.

iceman1001 commented 4 years ago

How many of these do we have?

doegox commented 4 years ago

a lot apparently

doegox commented 4 years ago

rg printf|egrep -v "(snprintf|sprintf|liblua|fprintf|Dbprintf|armsrc|:[[:space:]]*/|hardnested_tables.c|zlib|mbedtls|hitag2crack|mfkey|nonce2key|//.*printf|\.git|Makefile|sh:|deprecated|argtable3|cliparser)"|grep -o "[^:]*\.c:"|sort|uniq -c|sort -n -r

     27 client/src/emv/emv_pki.c:
     18 client/src/fido/cbortools.c:
     13 client/src/cmdhfmf.c:
     11 client/src/loclass/ikeys.c:
     11 client/src/cmdhfmfp.c:
     10 client/deps/hardnested/hardnested_bf_core.c:
      8 client/src/util.c:
      7 client/src/emv/test/cda_test.c:
      7 client/src/emv/crypto_polarssl.c:
      6 client/src/emv/test/dda_test.c:
      6 client/src/crypto/libpcrypto.c:
      6 client/src/cmdhflegic.c:
      5 client/src/loclass/hash1_brute.c:
      4 client/src/uart/uart_win32.c:
      4 client/src/scripting.c:
      4 client/src/emv/test/sda_test.c:
      4 client/src/comms.c:
      4 client/src/cmdsmartcard.c:
      4 client/src/cmdlf.c:
      4 client/src/cmdhfmfdes.c:
      4 client/src/cmdhffido.c:
      3 client/src/mifare/mifarehost.c:
      3 client/src/loclass/elite_crack.c:
      3 client/src/emv/test/crypto_test.c:
      3 client/src/emv/emv_pk.c:
      2 client/src/ui.c:
      2 client/src/uart/uart_posix.c:
      2 client/src/emv/emv_roca.c:
      2 client/src/cmdlft55xx.c:
      2 client/src/cmdlfgallagher.c:
      2 client/src/cmdhficlass.c:
      2 client/src/cmddata.c:
      2 client/src/cmdanalyse.c:
      1 common/crc.c:
      1 client/src/wiegand_formatutils.c:
      1 client/src/proxmark3.c:
      1 client/src/cmdhw.c:
      1 client/src/cmdhfmfu.c:
      1 client/src/cmdhffelica.c:
      1 client/src/cmdhfcryptorf.c:
      1 client/src/cmdhf.c:
      1 client/src/cmdhf15.c:
      1 client/src/cmdhf14b.c:
      1 client/deps/tinycbor/cborpretty.c:
      1 client/deps/jansson/strconv.c:
iceman1001 commented 4 years ago

well... you take took many. s*printf , dbprintf, shouldn't be changed.

Well, if you don't wanna start with "PrintAndLogEx" on device side... NOoooo. Stop it.

doegox commented 4 years ago

well... you take took many. s*printf , dbprintf, shouldn't be changed.

They were filtered out

Well, if you don't wanna start with "PrintAndLogEx" on device side... NOoooo. Stop it.

ARM was filtered out

See the list of concerned files. Still there can be a few positive, e.g. in a /* comment

iceman1001 commented 4 years ago

Adapted to exclude the new folders

rg printf|egrep -v "(snprintf|sprintf|liblua|fprintf|Dbprintf|armsrc|:[[:space:]]*/|hardnested_tables.c|zlib|mbedtls|cryptorf|mf_nonce_brute|hitag2crack|mfkey|nonce2key|//.*printf|\.git|Makefile|sh:|deprecated|argtable3|cliparser)"|grep -o "[^:]*\.c:"|sort|uniq -c|sort -n -r
  4 client/src/ui.c:                            --> printing before "log"
  2 tools/fpga_compress/fpga_compress.c:        --> the tools are ignored.
  2 client/src/proxmark3.c:                     --> is not included in the "lib" idea
  1 common/crc.c:                               --> commented out
  1 client/deps/tinycbor/cborpretty.c           --> commented out
  1 client/deps/jansson/strconv.c:              --> commented out
iceman1001 commented 3 years ago

So, reducing the filter (add cliparse, argtable)

rg printf|egrep -v "(snprintf|sprintf|liblua|fprintf|Dbprintf|armsrc|:[[:space:]]*/|hardnested_tables.c|zlib|mbedtls|cryptorf|mf_nonce_brute|hitag2crack|mfkey|nonce2key|//.*printf|\.git|Makefile|sh:|deprecated)"|grep -o "[^:]*\.c:"|sort|uniq -c|sort -n -r
     28 client/deps/cliparser/argtable3.c:
     19 client/src/pm3_pywrap.c:
     18 client/src/pm3_luawrap.c:
      4 client/src/ui.c:                        --> printing before "log" 
      2 tools/fpga_compress/fpga_compress.c:    --> the tools are ignored.
      2 client/src/proxmark3.c:                 --> is not included in the "lib" idea
      1 common/crc.c:                           --> commented out
      1 client/deps/tinycbor/cborpretty.c:      --> commented out
      1 client/deps/jansson/strconv.c:          --> commented out

This leads me the clean list, where we have some new wrap files doing stuff.

     28 client/deps/cliparser/argtable3.c:
     19 client/src/pm3_pywrap.c:
     18 client/src/pm3_luawrap.c:
doegox commented 3 years ago

wrappers are generated by SWIG, I guess it is safe to ignore them for the moment. but at some point we'll have to look into all I/O-related and SWIG.