style
This commit is contained in:
1 parent
df49565c04
commit
95d1631bed
13 files changed
+243
-252
No files matched your search
+25
-25
@@ -2888,16 +2888,16 @@ static int CmdDiff(const char *Cmd) {
|
||||
|
||||
CLIParserContext *ctx;
|
||||
CLIParserInit(&ctx, "data diff",
|
||||
"Diff takes a multitude of input data and makes a binary compare.\n"
|
||||
"It accepts filenames (filesystem or RDV4 flashmem SPIFFS), emulator memory, magic gen1",
|
||||
"data diff -w 4 -a hf-mfu-01020304.bin -b hf-mfu-04030201.bin\n"
|
||||
"data diff -a fileA -b fileB\n"
|
||||
"data diff -a fileA --eb\n"
|
||||
"Diff takes a multitude of input data and makes a binary compare.\n"
|
||||
"It accepts filenames (filesystem or RDV4 flashmem SPIFFS), emulator memory, magic gen1",
|
||||
"data diff -w 4 -a hf-mfu-01020304.bin -b hf-mfu-04030201.bin\n"
|
||||
"data diff -a fileA -b fileB\n"
|
||||
"data diff -a fileA --eb\n"
|
||||
// "data diff -a fileA --cb\n"
|
||||
"data diff --fa fileA -b fileB\n"
|
||||
"data diff --fa fileA --fb fileB\n"
|
||||
"data diff --ea --cb\n"
|
||||
);
|
||||
"data diff --fa fileA -b fileB\n"
|
||||
"data diff --fa fileA --fb fileB\n"
|
||||
"data diff --ea --cb\n"
|
||||
);
|
||||
|
||||
void *argtable[] = {
|
||||
arg_param_begin,
|
||||
@@ -2937,7 +2937,7 @@ static int CmdDiff(const char *Cmd) {
|
||||
CLIParserFree(ctx);
|
||||
|
||||
// sanity check
|
||||
if (IfPm3Rdv4Fw() == false && (splenA > 0 || splenB > 0) ) {
|
||||
if (IfPm3Rdv4Fw() == false && (splenA > 0 || splenB > 0)) {
|
||||
PrintAndLogEx(WARNING, "No RDV4 Flashmemory available");
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
@@ -2952,7 +2952,7 @@ static int CmdDiff(const char *Cmd) {
|
||||
}
|
||||
|
||||
//
|
||||
if (width > 16 || width < 1 ) {
|
||||
if (width > 16 || width < 1) {
|
||||
PrintAndLogEx(INFO, "Width out of range, using default 16 bytes width");
|
||||
width = 16;
|
||||
}
|
||||
@@ -3111,19 +3111,19 @@ static int CmdDiff(const char *Cmd) {
|
||||
|
||||
// print data diff loop
|
||||
int i;
|
||||
for (i = 0; i < n; i += width ) {
|
||||
for (i = 0; i < n; i += width) {
|
||||
|
||||
memset(line, 0, sizeof(line));
|
||||
|
||||
int diff = memcmp(inA + i, inB + i, width);
|
||||
int diff = memcmp(inA + i, inB + i, width);
|
||||
|
||||
// if ok, just print
|
||||
if (diff == 0) {
|
||||
hex_to_buffer((uint8_t*)line, inA + i, width, width, 0, 1, true);
|
||||
ascii_to_buffer((uint8_t*)(line + strlen(line)), inA + i, width, width, 0);
|
||||
hex_to_buffer((uint8_t *)line, inA + i, width, width, 0, 1, true);
|
||||
ascii_to_buffer((uint8_t *)(line + strlen(line)), inA + i, width, width, 0);
|
||||
strcat(line + strlen(line), " | ");
|
||||
hex_to_buffer((uint8_t*)(line + strlen(line)), inB + i, width, width, 0, 1, true);
|
||||
ascii_to_buffer((uint8_t*)(line + strlen(line)), inB + i, width, width, 0);
|
||||
hex_to_buffer((uint8_t *)(line + strlen(line)), inB + i, width, width, 0, 1, true);
|
||||
ascii_to_buffer((uint8_t *)(line + strlen(line)), inB + i, width, width, 0);
|
||||
} else {
|
||||
|
||||
char dlnA[240] = {0};
|
||||
@@ -3138,7 +3138,7 @@ static int CmdDiff(const char *Cmd) {
|
||||
|
||||
// if diff, time to find it
|
||||
for (int j = i; j < (i + width); j++) {
|
||||
|
||||
|
||||
char ca = inA[j];
|
||||
char cb = inB[j];
|
||||
|
||||
@@ -3166,8 +3166,8 @@ static int CmdDiff(const char *Cmd) {
|
||||
// mod
|
||||
|
||||
|
||||
// print different length
|
||||
bool tallestA = (datalenA > datalenB);
|
||||
// print different length
|
||||
bool tallestA = (datalenA > datalenB);
|
||||
if (tallestA) {
|
||||
n = datalenA;
|
||||
} else {
|
||||
@@ -3175,13 +3175,13 @@ static int CmdDiff(const char *Cmd) {
|
||||
}
|
||||
|
||||
// print data diff loop
|
||||
for (; i < n; i += width ) {
|
||||
for (; i < n; i += width) {
|
||||
|
||||
memset(line, 0, sizeof(line));
|
||||
|
||||
if (tallestA) {
|
||||
hex_to_buffer((uint8_t*)line, inA + i, width, width, 0, 1, true);
|
||||
ascii_to_buffer((uint8_t*)(line + strlen(line)), inA + i, width, width, 0);
|
||||
hex_to_buffer((uint8_t *)line, inA + i, width, width, 0, 1, true);
|
||||
ascii_to_buffer((uint8_t *)(line + strlen(line)), inA + i, width, width, 0);
|
||||
strcat(line + strlen(line), " | ");
|
||||
for (int j = 0; j < width; j++) {
|
||||
strcat(line + strlen(line), "-- ");
|
||||
@@ -3198,8 +3198,8 @@ static int CmdDiff(const char *Cmd) {
|
||||
strcat(line + strlen(line), ".");
|
||||
}
|
||||
strcat(line + strlen(line), " | ");
|
||||
hex_to_buffer((uint8_t*)(line + strlen(line)), inB + i, width, width, 0, 1, true);
|
||||
ascii_to_buffer((uint8_t*)(line + strlen(line)), inB + i, width, width, 0);
|
||||
hex_to_buffer((uint8_t *)(line + strlen(line)), inB + i, width, width, 0, 1, true);
|
||||
ascii_to_buffer((uint8_t *)(line + strlen(line)), inB + i, width, width, 0);
|
||||
}
|
||||
|
||||
PrintAndLogEx(INFO, "%03X | %s", i, line);
|
||||
|
||||
@@ -90,7 +90,7 @@ out:
|
||||
}
|
||||
|
||||
int flashmem_spiffs_download(char *fn, uint8_t fnlen, void **pdest, size_t *destlen) {
|
||||
// get size from spiffs itself !
|
||||
// get size from spiffs itself !
|
||||
clearCommandBuffer();
|
||||
SendCommandNG(CMD_SPIFFS_STAT, (uint8_t *)fn, fnlen);
|
||||
PacketResponseNG resp;
|
||||
@@ -542,7 +542,7 @@ static int CmdFlashMemSpiFFSView(const char *Cmd) {
|
||||
|
||||
int breaks = arg_get_int_def(ctx, 2, 32);
|
||||
CLIParserFree(ctx);
|
||||
|
||||
|
||||
uint8_t *dump = NULL;
|
||||
size_t dumplen = 0;
|
||||
int res = flashmem_spiffs_download(fn, fnlen, (void **)&dump, &dumplen);
|
||||
|
||||
@@ -261,7 +261,7 @@ static void mf_print_blocks(uint16_t n, uint8_t *d) {
|
||||
static int mf_print_keys(uint16_t n, uint8_t *d) {
|
||||
|
||||
uint8_t sectors = 0;
|
||||
switch(n) {
|
||||
switch (n) {
|
||||
case MIFARE_MINI_MAXBLOCK:
|
||||
sectors = MIFARE_MINI_MAXSECTOR;
|
||||
break;
|
||||
@@ -270,7 +270,7 @@ static int mf_print_keys(uint16_t n, uint8_t *d) {
|
||||
break;
|
||||
case MIFARE_4K_MAXBLOCK:
|
||||
sectors = MIFARE_4K_MAXSECTOR;
|
||||
break;
|
||||
break;
|
||||
case MIFARE_1K_MAXBLOCK:
|
||||
default:
|
||||
sectors = MIFARE_1K_MAXSECTOR;
|
||||
@@ -292,7 +292,7 @@ static int mf_print_keys(uint16_t n, uint8_t *d) {
|
||||
}
|
||||
printKeyTable(sectors, e_sector);
|
||||
free(e_sector);
|
||||
return PM3_SUCCESS;
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
static void mf_print_values(uint16_t n, uint8_t *d) {
|
||||
@@ -303,7 +303,7 @@ static void mf_print_values(uint16_t n, uint8_t *d) {
|
||||
uint8_t cnt = 0;
|
||||
uint32_t value = 0;
|
||||
for (uint16_t i = 0; i < n; i++) {
|
||||
|
||||
|
||||
if (mfc_value(d + (i * MFBLOCK_SIZE), &value)) {
|
||||
PrintAndLogEx(INFO, "%03d | " _YELLOW_("%" PRIu32) " " _YELLOW_("0x%" PRIX32), i, value, value);
|
||||
++cnt;
|
||||
@@ -311,7 +311,7 @@ static void mf_print_values(uint16_t n, uint8_t *d) {
|
||||
}
|
||||
|
||||
if (cnt) {
|
||||
PrintAndLogEx(INFO, "Found %u value blocks in file", cnt);
|
||||
PrintAndLogEx(INFO, "Found %u value blocks in file", cnt);
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
}
|
||||
}
|
||||
@@ -3634,7 +3634,7 @@ void printKeyTableEx(uint8_t sectorscnt, sector_t *e_sector, uint8_t start_secto
|
||||
snprintf(strB, sizeof(strB), "%012" PRIX64, e_sector[i].Key[1]);
|
||||
|
||||
if (e_sector[i].foundKey[0] > 1) {
|
||||
PrintAndLogEx(SUCCESS, " "_YELLOW_("%03d")" | %03d | " _GREEN_("%s")" | " _YELLOW_("%c")" | " _GREEN_("%s")" | " _YELLOW_("%c")
|
||||
PrintAndLogEx(SUCCESS, " "_YELLOW_("%03d")" | %03d | " _GREEN_("%s")" | " _YELLOW_("%c")" | " _GREEN_("%s")" | " _YELLOW_("%c")
|
||||
, i
|
||||
, mfSectorTrailerOfSector(i)
|
||||
, strA, e_sector[i].foundKey[0]
|
||||
@@ -3647,7 +3647,7 @@ void printKeyTableEx(uint8_t sectorscnt, sector_t *e_sector, uint8_t start_secto
|
||||
if (start_sector == 0)
|
||||
s = i;
|
||||
|
||||
PrintAndLogEx(SUCCESS, " "_YELLOW_("%03d")" | %03d | " _GREEN_("%s")" | " _YELLOW_("%d")" | " _GREEN_("%s")" | " _YELLOW_("%d")
|
||||
PrintAndLogEx(SUCCESS, " "_YELLOW_("%03d")" | %03d | " _GREEN_("%s")" | " _YELLOW_("%d")" | " _GREEN_("%s")" | " _YELLOW_("%d")
|
||||
, s
|
||||
, mfSectorTrailerOfSector(s)
|
||||
, strA, e_sector[i].foundKey[0]
|
||||
|
||||
@@ -101,6 +101,7 @@ const static vocabulory_t vocabulory[] = {
|
||||
{ 1, "data bin2hex" },
|
||||
{ 0, "data bitsamples" },
|
||||
{ 1, "data clear" },
|
||||
{ 1, "data diff" },
|
||||
{ 0, "data hexsamples" },
|
||||
{ 1, "data hex2bin" },
|
||||
{ 1, "data load" },
|
||||
|
||||
+1
-1
@@ -60,7 +60,7 @@ int FillBuffer(uint8_t *data, size_t maxDataLength, size_t *dataLength, ...);
|
||||
|
||||
bool CheckStringIsHEXValue(const char *value);
|
||||
void ascii_to_buffer(uint8_t *buf, const uint8_t *hex_data, const size_t hex_len,
|
||||
const size_t hex_max_len, const size_t min_str_len);
|
||||
const size_t hex_max_len, const size_t min_str_len);
|
||||
void hex_to_buffer(uint8_t *buf, const uint8_t *hex_data, const size_t hex_len,
|
||||
const size_t hex_max_len, const size_t min_str_len, const size_t spaces_between,
|
||||
bool uppercase);
|
||||
|
||||
Reference in new issue
Block a user