From 266f2f0fc89799c7e1d6c5515a690c110562b60e Mon Sep 17 00:00:00 2001 From: Daniel Underhay <27876907+dunderhay@users.noreply.github.com> Date: Sat, 14 Mar 2020 01:09:25 +1100 Subject: [PATCH 1/5] Add colour to `lf hid` commands --- CHANGELOG.md | 1 + client/cmdlfhid.c | 36 ++++++++++++++++++------------------ 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index aa81e6baa..3f84700e6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ All notable changes to this project will be documented in this file. This project uses the changelog in accordance with [keepchangelog](http://keepachangelog.com/). Please use this to write notable changes, which is not the same as git commit log... ## [unreleased][unreleased] + - Add colour to `lf hid` commands in cmdlfhid.c - Change `script run hf_bruteforce -s start_id -e end_id -t timeout -x mifare_card_type` - The hf_bruteforce card script now requires Mifare type (mfc or mfu) (@dunderhay) - Updated `hf_bruteforce.lua` script - added support for brute forcing Mifare Ultralight EV1 cards (@dunderhay) - Added `hf mf personlize` - personalize the UID of a Mifare Classic EV1 card (@pwpiwi) diff --git a/client/cmdlfhid.c b/client/cmdlfhid.c index eb388faa6..c13882221 100644 --- a/client/cmdlfhid.c +++ b/client/cmdlfhid.c @@ -162,7 +162,7 @@ static int CmdHIDDemod(const char *Cmd) { uint8_t bits[GraphTraceLen]; size_t size = getFromGraphBuf(bits); if (size == 0) { - PrintAndLogEx(DEBUG, "DEBUG: Error - HID not enough samples"); + PrintAndLogEx(DEBUG, "DEBUG: Error - " _RED_("HID not enough samples")); return PM3_ESOFT; } //get binary from fsk wave @@ -171,17 +171,17 @@ static int CmdHIDDemod(const char *Cmd) { if (idx < 0) { if (idx == -1) - PrintAndLogEx(DEBUG, "DEBUG: Error - HID not enough samples"); + PrintAndLogEx(DEBUG, "DEBUG: Error - " _RED_("HID not enough samples")); else if (idx == -2) - PrintAndLogEx(DEBUG, "DEBUG: Error - HID just noise detected"); + PrintAndLogEx(DEBUG, "DEBUG: Error - " _RED_("HID just noise detected")); else if (idx == -3) - PrintAndLogEx(DEBUG, "DEBUG: Error - HID problem during FSK demod"); + PrintAndLogEx(DEBUG, "DEBUG: Error - " _RED_("HID problem during FSK demod")); else if (idx == -4) - PrintAndLogEx(DEBUG, "DEBUG: Error - HID preamble not found"); + PrintAndLogEx(DEBUG, "DEBUG: Error - " _RED_("HID preamble not found")); else if (idx == -5) - PrintAndLogEx(DEBUG, "DEBUG: Error - HID error in Manchester data, size %zu", size); + PrintAndLogEx(DEBUG, "DEBUG: Error - " _RED_("HID error in Manchester data, size %zu, size")); else - PrintAndLogEx(DEBUG, "DEBUG: Error - HID error demoding fsk %d", idx); + PrintAndLogEx(DEBUG, "DEBUG: Error - " _RED_("HID error demoding fsk %d, idx")); return PM3_ESOFT; } @@ -190,12 +190,12 @@ static int CmdHIDDemod(const char *Cmd) { setClockGrid(50, waveIdx + (idx * 50)); if (hi2 == 0 && hi == 0 && lo == 0) { - PrintAndLogEx(DEBUG, "DEBUG: Error - HID no values found"); + PrintAndLogEx(DEBUG, "DEBUG: Error - " _RED_("HID no values found")); return PM3_ESOFT; } if (hi2 != 0) { //extra large HID tags - PrintAndLogEx(SUCCESS, "HID Prox TAG ID: %x%08x%08x (%u)", hi2, hi, lo, (lo >> 1) & 0xFFFF); + PrintAndLogEx(SUCCESS, "HID Prox TAG ID: " _GREEN_("%x%08x%08x (%u)"), hi2, hi, lo, (lo >> 1) & 0xFFFF); } else { //standard HID tags <38 bits uint8_t fmtLen = 0; uint32_t cc = 0; @@ -241,14 +241,14 @@ static int CmdHIDDemod(const char *Cmd) { fc = ((hi & 0xF) << 12) | (lo >> 20); } if (fmtLen == 32 && (lo & 0x40000000)) { //if 32 bit and Kastle bit set - PrintAndLogEx(SUCCESS, "HID Prox TAG (Kastle format) ID: %x%08x (%u) - Format Len: 32bit - CC: %u - FC: %u - Card: %u", hi, lo, (lo >> 1) & 0xFFFF, cc, fc, cardnum); + PrintAndLogEx(SUCCESS, "HID Prox TAG (Kastle format) ID: " _GREEN_("%x%08x (%u)")"- Format Len: 32bit - CC: %u - FC: %u - Card: %u", hi, lo, (lo >> 1) & 0xFFFF, cc, fc, cardnum); } else { - PrintAndLogEx(SUCCESS, "HID Prox TAG ID: %x%08x (%u) - Format Len: %ubit - OEM: %03u - FC: %u - Card: %u", + PrintAndLogEx(SUCCESS, "HID Prox TAG ID: " _GREEN_("%x%08x (%u)")"- Format Len: %ubit - OEM: %03u - FC: %u - Card: %u", hi, lo, cardnum, fmtLen, oem, fc, cardnum); } } - PrintAndLogEx(DEBUG, "DEBUG: HID idx: %d, Len: %zu, Printing Demod Buffer:", idx, size); + PrintAndLogEx(DEBUG, "DEBUG: HID idx: " _GREEN_("%d, Len: %zu")", Printing Demod Buffer:", idx, size); if (g_debugMode) printDemodBuff(); @@ -288,14 +288,14 @@ static int CmdHIDSim(const char *Cmd) { lo = (lo << 4) | (n & 0xf); } - PrintAndLogEx(INFO, "Simulating HID tag with long ID %x%08x%08x", hi2, hi, lo); + PrintAndLogEx(INFO, "Simulating HID tag with long ID: " _GREEN_("%x%08x%08x"), hi2, hi, lo); payload.longFMT = 1; } else { while (sscanf(&Cmd[i++], "%1x", &n) == 1) { hi = (hi << 4) | (lo >> 28); lo = (lo << 4) | (n & 0xf); } - PrintAndLogEx(SUCCESS, "Simulating HID tag with ID %x%08x", hi, lo); + PrintAndLogEx(SUCCESS, "Simulating HID tag with ID: " _GREEN_("%x%08x"), hi, lo); hi2 = 0; } @@ -331,7 +331,7 @@ static int CmdHIDClone(const char *Cmd) { lo = (lo << 4) | (n & 0xf); } - PrintAndLogEx(INFO, "Preparing to clone HID tag with long ID %x%08x%08x", hi2, hi, lo); + PrintAndLogEx(INFO, "Preparing to clone HID tag with long ID: " _GREEN_("%x%08x%08x"), hi2, hi, lo); longid[0] = 1; } else { @@ -339,7 +339,7 @@ static int CmdHIDClone(const char *Cmd) { hi = (hi << 4) | (lo >> 28); lo = (lo << 4) | (n & 0xf); } - PrintAndLogEx(INFO, "Preparing to clone HID tag with ID %x%08x", hi, lo); + PrintAndLogEx(INFO, "Preparing to clone HID tag with ID: " _GREEN_("%x%08x"), hi, lo); hi2 = 0; } @@ -400,7 +400,7 @@ static int CmdHIDBrute(const char *Cmd) { param_getstr(Cmd, cmdp + 1, format, sizeof(format)); format_idx = HIDFindCardFormat(format); if (format_idx == -1) { - PrintAndLogEx(WARNING, "Unknown format: %s", format); + PrintAndLogEx(WARNING, _YELLOW_("Unknown format: %s"), format); errors = true; } cmdp += 2; @@ -431,7 +431,7 @@ static int CmdHIDBrute(const char *Cmd) { cmdp++; break; default: - PrintAndLogEx(WARNING, "Unknown parameter '%c'", param_getchar(Cmd, cmdp)); + PrintAndLogEx(WARNING, _YELLOW_("Unknown parameter '%c'"), param_getchar(Cmd, cmdp)); errors = true; break; } From e041e625c0f596feba915ee730f4edf7a5566e14 Mon Sep 17 00:00:00 2001 From: Daniel Underhay <27876907+dunderhay@users.noreply.github.com> Date: Sat, 14 Mar 2020 01:17:31 +1100 Subject: [PATCH 2/5] Colour fixes --- client/cmdlfhid.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/client/cmdlfhid.c b/client/cmdlfhid.c index c13882221..80d647437 100644 --- a/client/cmdlfhid.c +++ b/client/cmdlfhid.c @@ -248,7 +248,7 @@ static int CmdHIDDemod(const char *Cmd) { } } - PrintAndLogEx(DEBUG, "DEBUG: HID idx: " _GREEN_("%d, Len: %zu")", Printing Demod Buffer:", idx, size); + PrintAndLogEx(DEBUG, "DEBUG: HID idx: " _GREEN_("%d"), " Len: %zu", Printing Demod Buffer:", idx, size); if (g_debugMode) printDemodBuff(); @@ -400,7 +400,7 @@ static int CmdHIDBrute(const char *Cmd) { param_getstr(Cmd, cmdp + 1, format, sizeof(format)); format_idx = HIDFindCardFormat(format); if (format_idx == -1) { - PrintAndLogEx(WARNING, _YELLOW_("Unknown format: %s"), format); + PrintAndLogEx(WARNING, "Unknown format: " _YELLOW_("%s"), format); errors = true; } cmdp += 2; @@ -431,7 +431,7 @@ static int CmdHIDBrute(const char *Cmd) { cmdp++; break; default: - PrintAndLogEx(WARNING, _YELLOW_("Unknown parameter '%c'"), param_getchar(Cmd, cmdp)); + PrintAndLogEx(WARNING, "Unknown parameter: " _YELLOW_("%c"), param_getchar(Cmd, cmdp)); errors = true; break; } From 3e8c4b21731fb046f61f611e7ec425759e1c8b3f Mon Sep 17 00:00:00 2001 From: Daniel Underhay <27876907+dunderhay@users.noreply.github.com> Date: Sat, 14 Mar 2020 01:22:22 +1100 Subject: [PATCH 3/5] Typo --- client/cmdlfhid.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/cmdlfhid.c b/client/cmdlfhid.c index 80d647437..71517695d 100644 --- a/client/cmdlfhid.c +++ b/client/cmdlfhid.c @@ -431,7 +431,7 @@ static int CmdHIDBrute(const char *Cmd) { cmdp++; break; default: - PrintAndLogEx(WARNING, "Unknown parameter: " _YELLOW_("%c"), param_getchar(Cmd, cmdp)); + PrintAndLogEx(WARNING, "Unknown parameter: " _YELLOW_("'%c'"), param_getchar(Cmd, cmdp)); errors = true; break; } From 267063a05cf8156d7d564adc0c5fc6d4b7cd5588 Mon Sep 17 00:00:00 2001 From: Daniel Underhay <27876907+dunderhay@users.noreply.github.com> Date: Sat, 14 Mar 2020 01:52:25 +1100 Subject: [PATCH 4/5] Fix compile errors --- client/cmdlfhid.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/client/cmdlfhid.c b/client/cmdlfhid.c index 71517695d..fa3d4878d 100644 --- a/client/cmdlfhid.c +++ b/client/cmdlfhid.c @@ -179,9 +179,9 @@ static int CmdHIDDemod(const char *Cmd) { else if (idx == -4) PrintAndLogEx(DEBUG, "DEBUG: Error - " _RED_("HID preamble not found")); else if (idx == -5) - PrintAndLogEx(DEBUG, "DEBUG: Error - " _RED_("HID error in Manchester data, size %zu, size")); + PrintAndLogEx(DEBUG, "DEBUG: Error - " _RED_("HID error in Manchester data, size %zu"), size); else - PrintAndLogEx(DEBUG, "DEBUG: Error - " _RED_("HID error demoding fsk %d, idx")); + PrintAndLogEx(DEBUG, "DEBUG: Error - " _RED_("HID error demoding fsk %d"), idx); return PM3_ESOFT; } @@ -248,7 +248,7 @@ static int CmdHIDDemod(const char *Cmd) { } } - PrintAndLogEx(DEBUG, "DEBUG: HID idx: " _GREEN_("%d"), " Len: %zu", Printing Demod Buffer:", idx, size); + PrintAndLogEx(DEBUG, "DEBUG: HID idx: %d, Len: %zu, Printing Demod Buffer: ", idx, size); if (g_debugMode) printDemodBuff(); From 875aaee795d1e5ea6566b7b6d5c5ec6df79b5288 Mon Sep 17 00:00:00 2001 From: Daniel Underhay <27876907+dunderhay@users.noreply.github.com> Date: Sat, 14 Mar 2020 01:58:14 +1100 Subject: [PATCH 5/5] Last changes --- client/cmdlfhid.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/cmdlfhid.c b/client/cmdlfhid.c index fa3d4878d..ea76d3fd2 100644 --- a/client/cmdlfhid.c +++ b/client/cmdlfhid.c @@ -243,7 +243,7 @@ static int CmdHIDDemod(const char *Cmd) { if (fmtLen == 32 && (lo & 0x40000000)) { //if 32 bit and Kastle bit set PrintAndLogEx(SUCCESS, "HID Prox TAG (Kastle format) ID: " _GREEN_("%x%08x (%u)")"- Format Len: 32bit - CC: %u - FC: %u - Card: %u", hi, lo, (lo >> 1) & 0xFFFF, cc, fc, cardnum); } else { - PrintAndLogEx(SUCCESS, "HID Prox TAG ID: " _GREEN_("%x%08x (%u)")"- Format Len: %ubit - OEM: %03u - FC: %u - Card: %u", + PrintAndLogEx(SUCCESS, "HID Prox TAG ID: " _GREEN_("%x%08x (%u)")"- Format Len: " _GREEN_("%u bit")"- OEM: %03u - FC: " _GREEN_("%u")"- Card: " _GREEN_("%u"), hi, lo, cardnum, fmtLen, oem, fc, cardnum); } }