remove dump.c step2

This commit is contained in:
iceman1001 2020-11-12 18:43:03 +01:00
commit 243d509203
17 changed files with 21 additions and 105 deletions

View file

@ -188,7 +188,6 @@ set (TARGET_SOURCES
${PM3_ROOT}/client/src/emv/crypto.c ${PM3_ROOT}/client/src/emv/crypto.c
${PM3_ROOT}/client/src/emv/crypto_polarssl.c ${PM3_ROOT}/client/src/emv/crypto_polarssl.c
${PM3_ROOT}/client/src/emv/dol.c ${PM3_ROOT}/client/src/emv/dol.c
${PM3_ROOT}/client/src/emv/dump.c
${PM3_ROOT}/client/src/emv/emv_pk.c ${PM3_ROOT}/client/src/emv/emv_pk.c
${PM3_ROOT}/client/src/emv/emv_pki.c ${PM3_ROOT}/client/src/emv/emv_pki.c
${PM3_ROOT}/client/src/emv/emv_pki_priv.c ${PM3_ROOT}/client/src/emv/emv_pki_priv.c

View file

@ -506,7 +506,6 @@ SRCS = aiddesfire.c \
emv/crypto.c\ emv/crypto.c\
emv/crypto_polarssl.c\ emv/crypto_polarssl.c\
emv/dol.c \ emv/dol.c \
emv/dump.c \
emv/emv_pk.c\ emv/emv_pk.c\
emv/emv_pki.c\ emv/emv_pki.c\
emv/emv_pki_priv.c\ emv/emv_pki_priv.c\

View file

@ -29,7 +29,6 @@
#include "aidsearch.h" #include "aidsearch.h"
#include "cmdhf.h" // handle HF plot #include "cmdhf.h" // handle HF plot
#include "protocols.h" // MAGIC_GEN_1A #include "protocols.h" // MAGIC_GEN_1A
#include "emv/dump.h" // dump_buffer
bool APDUInFramingEnable = true; bool APDUInFramingEnable = true;

View file

@ -19,9 +19,7 @@
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
#include "cmdhffido.h" #include "cmdhffido.h"
#include <unistd.h> #include <unistd.h>
#include "cmdparser.h" // command_t #include "cmdparser.h" // command_t
#include "commonutil.h" #include "commonutil.h"
#include "comms.h" #include "comms.h"
@ -33,10 +31,10 @@
#include "crypto/libpcrypto.h" #include "crypto/libpcrypto.h"
#include "fido/cbortools.h" #include "fido/cbortools.h"
#include "fido/fidocore.h" #include "fido/fidocore.h"
#include "emv/dump.h"
#include "ui.h" #include "ui.h"
#include "cmdhf14a.h" #include "cmdhf14a.h"
#include "cmdtrace.h" #include "cmdtrace.h"
#include "util.h"
static int CmdHelp(const char *Cmd); static int CmdHelp(const char *Cmd);
@ -88,7 +86,7 @@ static int cmd_hf_fido_info(const char *cmd) {
} else { } else {
PrintAndLogEx(INFO, "FIDO authenticator detected (not standard U2F)."); PrintAndLogEx(INFO, "FIDO authenticator detected (not standard U2F).");
PrintAndLogEx(INFO, "Non U2F authenticator version:"); PrintAndLogEx(INFO, "Non U2F authenticator version:");
dump_buffer((const unsigned char *)buf, len, NULL, 0); print_buffer((const unsigned char *)buf, len, 1);
} }
} else { } else {
PrintAndLogEx(INFO, "FIDO U2F authenticator detected. Version: %.*s", (int)len, buf); PrintAndLogEx(INFO, "FIDO U2F authenticator detected. Version: %.*s", (int)len, buf);
@ -296,7 +294,7 @@ static int cmd_hf_fido_register(const char *cmd) {
if (verbose2) { if (verbose2) {
PrintAndLogEx(INFO, "------------ " _CYAN_("data") " ----------------------"); PrintAndLogEx(INFO, "------------ " _CYAN_("data") " ----------------------");
dump_buffer((const unsigned char *)buf, len, NULL, 0); print_buffer((const unsigned char *)buf, len, 1);
PrintAndLogEx(INFO, "-------------" _CYAN_("data") " ----------------------"); PrintAndLogEx(INFO, "-------------" _CYAN_("data") " ----------------------");
} }

View file

@ -16,7 +16,6 @@
#include "comms.h" // clearCommandBuffer #include "comms.h" // clearCommandBuffer
#include "fileutils.h" #include "fileutils.h"
#include "cmdtrace.h" #include "cmdtrace.h"
#include "emv/dump.h"
#include "mifare/mifaredefault.h" // mifare default key array #include "mifare/mifaredefault.h" // mifare default key array
#include "cliparser.h" // argtable #include "cliparser.h" // argtable
#include "hardnested_bf_core.h" // SetSIMDInstr #include "hardnested_bf_core.h" // SetSIMDInstr
@ -5095,7 +5094,7 @@ static int CmdHFMFNDEF(const char *Cmd) {
if (verbose2) { if (verbose2) {
PrintAndLogEx(NORMAL, ""); PrintAndLogEx(NORMAL, "");
PrintAndLogEx(INFO, "--- " _CYAN_("MFC NDEF raw") " ----------------"); PrintAndLogEx(INFO, "--- " _CYAN_("MFC NDEF raw") " ----------------");
dump_buffer(data, datalen, stdout, 1); print_buffer(data, datalen, 1);
} }
NDEFDecodeAndPrint(data, datalen, verbose); NDEFDecodeAndPrint(data, datalen, verbose);

View file

@ -35,6 +35,7 @@
#include "mifare/mad.h" #include "mifare/mad.h"
#include "generator.h" #include "generator.h"
#include "aiddesfire.h" #include "aiddesfire.h"
#include "util.h"
#define MAX_KEY_LEN 24 #define MAX_KEY_LEN 24
#define MAX_KEYS_LIST_LEN 1024 #define MAX_KEYS_LIST_LEN 1024
@ -4769,7 +4770,7 @@ static int CmdHF14aDesNDEF(const char *Cmd) {
if (verbose2) { if (verbose2) {
PrintAndLogEx(NORMAL, ""); PrintAndLogEx(NORMAL, "");
PrintAndLogEx(INFO, "--- " _CYAN_("DESFire NDEF raw") " ----------------"); PrintAndLogEx(INFO, "--- " _CYAN_("DESFire NDEF raw") " ----------------");
dump_buffer(data, datalen, stdout, 1); print_buffer(data, datalen, 1);
} }
PrintAndLogEx(HINT, "Try " _YELLOW_("`hf mfdes ndef -vv`") " for more details"); PrintAndLogEx(HINT, "Try " _YELLOW_("`hf mfdes ndef -vv`") " for more details");

View file

@ -15,12 +15,12 @@
#include "commonutil.h" // ARRAYLEN #include "commonutil.h" // ARRAYLEN
#include "comms.h" #include "comms.h"
#include "ui.h" #include "ui.h"
#include "util.h"
#include "cmdhf14a.h" #include "cmdhf14a.h"
#include "mifare/mifare4.h" #include "mifare/mifare4.h"
#include "mifare/mad.h" #include "mifare/mad.h"
#include "mifare/ndef.h" #include "mifare/ndef.h"
#include "cliparser.h" #include "cliparser.h"
#include "emv/dump.h"
#include "mifare/mifaredefault.h" #include "mifare/mifaredefault.h"
#include "util_posix.h" #include "util_posix.h"
#include "fileutils.h" #include "fileutils.h"
@ -1551,7 +1551,7 @@ static int CmdHFMFPNDEF(const char *Cmd) {
if (verbose2) { if (verbose2) {
PrintAndLogEx(NORMAL, ""); PrintAndLogEx(NORMAL, "");
PrintAndLogEx(INFO, "--- " _CYAN_("MF Plus NDEF raw") " ----------------"); PrintAndLogEx(INFO, "--- " _CYAN_("MF Plus NDEF raw") " ----------------");
dump_buffer(data, datalen, stdout, 1); print_buffer(data, datalen, 1);
} }
NDEFDecodeAndPrint(data, datalen, verbose); NDEFDecodeAndPrint(data, datalen, verbose);

View file

@ -18,8 +18,8 @@
#include "comms.h" // getfromdevice #include "comms.h" // getfromdevice
#include "emv/emvcore.h" // decodeTVL #include "emv/emvcore.h" // decodeTVL
#include "crypto/libpcrypto.h" // sha512hash #include "crypto/libpcrypto.h" // sha512hash
#include "emv/dump.h"
#include "ui.h" #include "ui.h"
#include "util.h"
#include "fileutils.h" #include "fileutils.h"
#include "crc16.h" // crc #include "crc16.h" // crc
@ -316,7 +316,7 @@ static void PrintATR(uint8_t *atr, size_t atrlen) {
if (K > 1) { if (K > 1) {
PrintAndLogEx(INFO, "\tHistorical bytes"); PrintAndLogEx(INFO, "\tHistorical bytes");
dump_buffer(&atr[2 + T1len + TD1len + TDilen], K, NULL, 1); print_buffer(&atr[2 + T1len + TD1len + TDilen], K, 1);
} }
} }

View file

@ -21,7 +21,6 @@
#include <mbedtls/asn1.h> #include <mbedtls/asn1.h>
#include <mbedtls/oid.h> #include <mbedtls/oid.h>
#include "emv/emv_tags.h" #include "emv/emv_tags.h"
#include "emv/dump.h"
#include "emv/emvjson.h" #include "emv/emvjson.h"
#include "util.h" #include "util.h"
#include "proxmark3.h" #include "proxmark3.h"

View file

@ -16,7 +16,6 @@
#include "ui.h" // Print... #include "ui.h" // Print...
#include "emv/tlv.h" #include "emv/tlv.h"
#include "emv/dump.h"
#include "asn1dump.h" #include "asn1dump.h"
#include "util.h" #include "util.h"
@ -68,7 +67,7 @@ static void print_cb(void *data, const struct tlv *tlv, int level, bool is_leaf)
bool candump = true; bool candump = true;
asn1_tag_dump(tlv, stdout, level, &candump); asn1_tag_dump(tlv, stdout, level, &candump);
if (is_leaf && candump) { if (is_leaf && candump) {
dump_buffer(tlv->value, tlv->len, stdout, level); print_buffer(tlv->value, tlv->len, level);
} }
} }

View file

@ -1,47 +0,0 @@
/*
* libopenemv - a library to work with EMV family of smart cards
* Copyright (C) 2015 Dmitry Eremin-Solenikov
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "dump.h"
#ifndef PRINT_INDENT
# define PRINT_INDENT(level) {for (int myi = 0; myi < (level); myi++) fprintf(f, " ");}
#endif
void dump_buffer(const unsigned char *ptr, size_t len, FILE *f, int level) {
int j;
if (!f)
f = stdout;
for (int i = 0; i < len; i += 16) {
PRINT_INDENT(level);
fprintf(f, "\t%02x:", i);
for (j = 0; j < 16; j++) {
if (i + j < len)
fprintf(f, " %02hhx", ptr[i + j]);
else
fprintf(f, " ");
}
fprintf(f, " |");
for (j = 0; j < 16 && i + j < len; j++) {
fprintf(f, "%c", (ptr[i + j] >= 0x20 && ptr[i + j] < 0x7f) ? ptr[i + j] : '.');
}
fprintf(f, "\n");
}
}

View file

@ -1,25 +0,0 @@
/*
* libopenemv - a library to work with EMV family of smart cards
* Copyright (C) 2015 Dmitry Eremin-Solenikov
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*/
#ifndef DUMP_H
#define DUMP_H
#include "common.h"
#include <stdio.h> // FILE
void dump_buffer(const unsigned char *ptr, size_t len, FILE *f, int level);
#endif

View file

@ -24,7 +24,6 @@
#include <stdarg.h> #include <stdarg.h>
#include "crypto.h" #include "crypto.h"
#include "dump.h"
#include "util.h" #include "util.h"
#include "ui.h" #include "ui.h"
@ -73,7 +72,7 @@ static unsigned char *emv_pki_decode_message(const struct emv_pk *enc_pk,
/* if (true){ /* if (true){
PrintAndLogEx(SUCCESS, "Recovered data:\n"); PrintAndLogEx(SUCCESS, "Recovered data:\n");
dump_buffer(data, data_len, stdout, 0); print_buffer(data, data_len, 1);
}*/ }*/
if (data[data_len - 1] != 0xbc || data[0] != 0x6a || data[1] != msgtype) { if (data[data_len - 1] != 0xbc || data[0] != 0x6a || data[1] != msgtype) {
@ -200,7 +199,7 @@ static struct emv_pk *emv_pki_decode_key_ex(const struct emv_pk *enc_pk,
if (showData) { if (showData) {
PrintAndLogEx(SUCCESS, "Recovered data:"); PrintAndLogEx(SUCCESS, "Recovered data:");
dump_buffer(data, data_len, stdout, 0); print_buffer(data, data_len, 1);
} }
/* Perform the rest of checks here */ /* Perform the rest of checks here */
@ -375,7 +374,7 @@ struct tlvdb *emv_pki_recover_dac_ex(const struct emv_pk *enc_pk, const struct t
if (showData) { if (showData) {
PrintAndLogEx(SUCCESS, "Recovered data:"); PrintAndLogEx(SUCCESS, "Recovered data:");
dump_buffer(data, data_len, stdout, 0); print_buffer(data, data_len, 1);
} }
struct tlvdb *dac_db = tlvdb_fixed(0x9f45, 2, data + 3); struct tlvdb *dac_db = tlvdb_fixed(0x9f45, 2, data + 3);
@ -409,7 +408,7 @@ struct tlvdb *emv_pki_recover_idn_ex(const struct emv_pk *enc_pk, const struct t
if (showData) { if (showData) {
PrintAndLogEx(SUCCESS, "Recovered data:"); PrintAndLogEx(SUCCESS, "Recovered data:");
dump_buffer(data, data_len, stdout, 0); print_buffer(data, data_len, 1);
} }
size_t idn_len = data[4]; size_t idn_len = data[4];
@ -445,7 +444,7 @@ struct tlvdb *emv_pki_recover_atc_ex(const struct emv_pk *enc_pk, const struct t
if (showData) { if (showData) {
PrintAndLogEx(SUCCESS, "Recovered data:"); PrintAndLogEx(SUCCESS, "Recovered data:");
dump_buffer(data, data_len, stdout, 0); print_buffer(data, data_len, 1);
} }
size_t idn_len = data[4]; size_t idn_len = data[4];
@ -511,7 +510,7 @@ struct tlvdb *emv_pki_perform_cda_ex(const struct emv_pk *enc_pk, const struct t
if (showData) { if (showData) {
PrintAndLogEx(SUCCESS, "Recovered data:"); PrintAndLogEx(SUCCESS, "Recovered data:");
dump_buffer(data, data_len, stdout, 0); print_buffer(data, data_len, 1);
} }
if (data[3] < 30 || data[3] > data_len - 4) { if (data[3] < 30 || data[3] > data_len - 4) {

View file

@ -19,7 +19,6 @@
#include "ui.h" #include "ui.h"
#include "cmdhf14a.h" #include "cmdhf14a.h"
#include "dol.h" #include "dol.h"
#include "dump.h"
#include "emv_tags.h" #include "emv_tags.h"
#include "emvjson.h" #include "emvjson.h"
#include "util_posix.h" #include "util_posix.h"
@ -160,7 +159,7 @@ enum CardPSVendor GetCardPSVendor(uint8_t *AID, size_t AIDlen) {
static void print_cb(void *data, const struct tlv *tlv, int level, bool is_leaf) { static void print_cb(void *data, const struct tlv *tlv, int level, bool is_leaf) {
emv_tag_dump(tlv, stdout, level); emv_tag_dump(tlv, stdout, level);
if (is_leaf) { if (is_leaf) {
dump_buffer(tlv->value, tlv->len, stdout, level); print_buffer(tlv->value, tlv->len, level);
} }
} }

View file

@ -24,7 +24,6 @@
#include "commonutil.h" // ARRAYLEN #include "commonutil.h" // ARRAYLEN
#include "../crypto.h" #include "../crypto.h"
#include "../dump.h"
#include "util_posix.h" #include "util_posix.h"
#include "ui.h" // printandlog #include "ui.h" // printandlog

View file

@ -22,7 +22,6 @@
#include "crypto/libpcrypto.h" #include "crypto/libpcrypto.h"
#include "additional_ca.h" #include "additional_ca.h"
#include "cose.h" #include "cose.h"
#include "emv/dump.h"
#include "ui.h" #include "ui.h"
#include "util.h" #include "util.h"

View file

@ -14,7 +14,6 @@
#include "ui.h" #include "ui.h"
#include "util.h" // sprint_hex... #include "util.h" // sprint_hex...
#include "emv/dump.h"
#include "crypto/asn1utils.h" #include "crypto/asn1utils.h"
#include "pm3_cmd.h" #include "pm3_cmd.h"
@ -375,15 +374,15 @@ static int ndefRecordDecodeAndPrint(uint8_t *ndefRecord, size_t ndefRecordLen) {
if (NDEFHeader.TypeLen) { if (NDEFHeader.TypeLen) {
PrintAndLogEx(INFO, "Type data:"); PrintAndLogEx(INFO, "Type data:");
dump_buffer(NDEFHeader.Type, NDEFHeader.TypeLen, stdout, 1); print_buffer(NDEFHeader.Type, NDEFHeader.TypeLen, 1);
} }
if (NDEFHeader.IDLen) { if (NDEFHeader.IDLen) {
PrintAndLogEx(INFO, "ID data:"); PrintAndLogEx(INFO, "ID data:");
dump_buffer(NDEFHeader.ID, NDEFHeader.IDLen, stdout, 1); print_buffer(NDEFHeader.ID, NDEFHeader.IDLen, 1);
} }
if (NDEFHeader.PayloadLen) { if (NDEFHeader.PayloadLen) {
PrintAndLogEx(INFO, "Payload data:"); PrintAndLogEx(INFO, "Payload data:");
dump_buffer(NDEFHeader.Payload, NDEFHeader.PayloadLen, stdout, 1); print_buffer(NDEFHeader.Payload, NDEFHeader.PayloadLen, 1);
if (NDEFHeader.TypeLen) if (NDEFHeader.TypeLen)
ndefDecodePayload(&NDEFHeader); ndefDecodePayload(&NDEFHeader);
} }