From 2152d563c95319e250841be43065c68f2123ff85 Mon Sep 17 00:00:00 2001 From: Gary Bell Date: Tue, 13 Aug 2024 20:09:05 -0400 Subject: [PATCH 1/7] Fixed hid clone script & new t55xx reset script --- CHANGELOG.md | 2 + client/luascripts/lf_hid_bulkclone_v2.lua | 3 +- client/luascripts/lf_t55xx_reset.lua | 89 +++++++++++++++++++++++ 3 files changed, 93 insertions(+), 1 deletion(-) create mode 100644 client/luascripts/lf_t55xx_reset.lua diff --git a/CHANGELOG.md b/CHANGELOG.md index df99d61b0..5cfba7c3f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,8 @@ 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] +- Fixed missing require of ansicolors in `lf_hid_bulkclone_v2.lua` script (@whiteneon) +- Added `lf_t55xx_reset.lua` - a script to aid in quickly resetting t55xx chips (@whiteneon) - Changed `hf mf chk/fchk`: added option `--no-default` to skip loading the usual ~61 hardcoded keys (@doegox) - Fixed `hf mf wipe` to detect properly write errors (@doegox) - Fixed `hf mf fchk` which was leaving the RF field on when interrupted by keyboard (@doegox) diff --git a/client/luascripts/lf_hid_bulkclone_v2.lua b/client/luascripts/lf_hid_bulkclone_v2.lua index b090d67ec..33d084dd8 100644 --- a/client/luascripts/lf_hid_bulkclone_v2.lua +++ b/client/luascripts/lf_hid_bulkclone_v2.lua @@ -1,9 +1,10 @@ local getopt = require('getopt') +local ansicolors = require('ansicolors') local cmds = require('commands') copyright = '' author = "TheChamop669" -version = 'v1.0.0' +version = 'v1.0.1' desc = [[ Perform bulk enrollment of 26 bit H10301 style RFID Tags For more info, check the comments in the code diff --git a/client/luascripts/lf_t55xx_reset.lua b/client/luascripts/lf_t55xx_reset.lua new file mode 100644 index 000000000..e63b07b66 --- /dev/null +++ b/client/luascripts/lf_t55xx_reset.lua @@ -0,0 +1,89 @@ +local getopt = require('getopt') +local ansicolors = require('ansicolors') +local utils = require('utils') + +copyright = '' +author = 'whiteneon' +version = 'v1.0.0' +desc = [[ +This script attempts to reset the password + - on a T55xx LF chip. + ]] +example = [[ + script run lf_t55xx_reset +]] +usage = [[ +script run lf_t55xx_reset -h +]] +arguments = [[ + -h : this help +]] + +local DEBUG = true +--- +-- A debug printout-function +local function dbg(args) + if not DEBUG then return end + if type(args) == 'table' then + local i = 1 + while args[i] do + dbg(args[i]) + i = i+1 + end + else + print('###', args) + end +end +--- +-- This is only meant to be used when errors occur +local function oops(err) + print('ERROR:', err) + core.clearCommandBuffer() + return nil, err +end +--- +-- Usage help +local function help() + print(copyright) + print(author) + print(version) + print(desc) + print(ansicolors.cyan..'Usage'..ansicolors.reset) + print(usage) + print(ansicolors.cyan..'Arguments'..ansicolors.reset) + print(arguments) + print(ansicolors.cyan..'Example usage'..ansicolors.reset) + print(example) +end +--- +-- The main entry point +function main(args) + local dash = string.rep('--', 20) + + print( dash ) + print( dash ) + print() + + -- Read the parameters + for o, a in getopt.getopt(args, 'h') do + if o == 'h' then return help() end + end + + print('Attempting T55xx chip reset') + print(dash) +-- core.console('lf t55 write -b 0 -d 000880E0 --r0 -t') +-- core.console('lf t55 write -b 0 -d 000880E0 --r1 -t') +-- core.console('lf t55 write -b 0 -d 000880E0 --r2 -t') +-- core.console('lf t55 write -b 0 -d 000880E0 --r3 -t') + core.console('lf t55 write -b 0 -d 000880E0 --r0') + core.console('lf t55 write -b 0 -d 000880E0 --r1') + core.console('lf t55 write -b 0 -d 000880E0 --r2') + core.console('lf t55 write -b 0 -d 000880E0 --r3') + core.console('lf t55 wipe') + core.console('lf t55 detect') + print(dash) + print('all done!') + +end + +main(args) From 20a0713441abc3ff9d5bc4c17cf2948308eec0ed Mon Sep 17 00:00:00 2001 From: mwalker33 <51802811+mwalker33@users.noreply.github.com> Date: Sat, 17 Aug 2024 13:41:16 +1000 Subject: [PATCH 2/7] Update cmdlfindala.c 25 But parity diz --- client/src/cmdlfindala.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/client/src/cmdlfindala.c b/client/src/cmdlfindala.c index 0b5c7bd0a..4571ffedf 100644 --- a/client/src/cmdlfindala.c +++ b/client/src/cmdlfindala.c @@ -1136,6 +1136,7 @@ int getIndalaBits(uint8_t fc, uint16_t cn, uint8_t *bits) { bits[51] = ((cn >> 8) & 1); // b9 - c bits[46] = ((cn >> 7) & 1); // b8 bits[33] = ((cn >> 6) & 1); // b7 - c + // bits[61] = ((cn >> 6) & 1); // b7 - c bits[37] = ((cn >> 5) & 1); // b6 - c bits[54] = ((cn >> 4) & 1); // b5 bits[56] = ((cn >> 3) & 1); // b4 @@ -1164,11 +1165,25 @@ int getIndalaBits(uint8_t fc, uint16_t cn, uint8_t *bits) { } // add parity - bits[34] = 1; // p1 64 - 30 = 34 - bits[38] = 1; // p2 68 - 30 = 38 + // bits[34] = 1; // p1 64 - 30 = 34 + // bits[38] = 1; // p2 68 - 30 = 38 // 92 = 62 // 93 = 63 + + bits[34] = 0; // parity for odd bits + bits[38] = 0; // parity for even bits + uint8_t p1 = 1; + uint8_t p2 = 1; + + for (int i=33; i < 64; i++) { + if (i%2) + p1 ^= bits[i]; + else + p2 ^= bits[i]; + } + bits[34] = p1; // parity for odd bits + bits[38] = p2; // parity for even bits return PM3_SUCCESS; } From 059b657156edade40d52b073070e7643f5190143 Mon Sep 17 00:00:00 2001 From: mwalker33 <51802811+mwalker33@users.noreply.github.com> Date: Sat, 17 Aug 2024 13:47:23 +1000 Subject: [PATCH 3/7] Update cmdlfindala.c --- client/src/cmdlfindala.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/cmdlfindala.c b/client/src/cmdlfindala.c index 4571ffedf..049c8c24f 100644 --- a/client/src/cmdlfindala.c +++ b/client/src/cmdlfindala.c @@ -1175,7 +1175,7 @@ int getIndalaBits(uint8_t fc, uint16_t cn, uint8_t *bits) { bits[38] = 0; // parity for even bits uint8_t p1 = 1; uint8_t p2 = 1; - + for (int i=33; i < 64; i++) { if (i%2) p1 ^= bits[i]; From e705c3424757b2e1bfb0ee228d254d9a9381e954 Mon Sep 17 00:00:00 2001 From: mwalker33 <51802811+mwalker33@users.noreply.github.com> Date: Sat, 17 Aug 2024 13:49:22 +1000 Subject: [PATCH 4/7] Update cmdlfindala.c cleanup --- client/src/cmdlfindala.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/cmdlfindala.c b/client/src/cmdlfindala.c index 049c8c24f..d0c9557d9 100644 --- a/client/src/cmdlfindala.c +++ b/client/src/cmdlfindala.c @@ -1136,7 +1136,6 @@ int getIndalaBits(uint8_t fc, uint16_t cn, uint8_t *bits) { bits[51] = ((cn >> 8) & 1); // b9 - c bits[46] = ((cn >> 7) & 1); // b8 bits[33] = ((cn >> 6) & 1); // b7 - c - // bits[61] = ((cn >> 6) & 1); // b7 - c bits[37] = ((cn >> 5) & 1); // b6 - c bits[54] = ((cn >> 4) & 1); // b5 bits[56] = ((cn >> 3) & 1); // b4 @@ -1182,6 +1181,7 @@ int getIndalaBits(uint8_t fc, uint16_t cn, uint8_t *bits) { else p2 ^= bits[i]; } + bits[34] = p1; // parity for odd bits bits[38] = p2; // parity for even bits From f1ceff852e3e98dde7a5d2aeb0cc704abda28f4c Mon Sep 17 00:00:00 2001 From: Philippe Teuwen Date: Sat, 17 Aug 2024 20:50:53 +0200 Subject: [PATCH 5/7] fm11rf08s_recovery: no need to turn ANSI off anymore with the native output grabber --- client/pyscripts/fm11rf08s_recovery.py | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/client/pyscripts/fm11rf08s_recovery.py b/client/pyscripts/fm11rf08s_recovery.py index 9e37e775f..d7108843f 100755 --- a/client/pyscripts/fm11rf08s_recovery.py +++ b/client/pyscripts/fm11rf08s_recovery.py @@ -62,22 +62,14 @@ args = parser.parse_args() start_time = time.time() p = pm3.pm3() -restore_color = False -p.console("prefs get color") -p.console("prefs set color --off") -for line in p.grabbed_output.split('\n'): - if "ansi" in line: - restore_color = True p.console("hf 14a read") uid = None -for line in p.grabbed_output.split('\n'): - if "UID:" in line: - uid = int(line[10:].replace(' ', ''), 16) +if p.grabbed_output is not None: + for line in p.grabbed_output.split('\n'): + if "UID:" in line: + uid = int(line[10:].replace(' ', ''), 16) if uid is None: print("Card not found") - if restore_color: - p.console("prefs set color --ansi") - _ = p.grabbed_output exit() print("UID: " + color(f"{uid:08X}", fg="green")) @@ -136,9 +128,6 @@ for sec in range(NUM_SECTORS): nt_enc[sec][key_type] == "" or par_err[sec][key_type] == ""): print("Error, could not collect nonces, abort") - if restore_color: - p.console("prefs set color --ansi") - _ = p.grabbed_output exit() print("Running staticnested_1nt & 2x1nt when doable...") @@ -330,9 +319,6 @@ for sec in range(NUM_SECTORS): print_key(sec, key_type_target, found_keys[sec][key_type_target]) if abort: break -if restore_color: - p.console("prefs set color --ansi") - _ = p.grabbed_output if abort: print("Brute-forcing phase aborted via keyboard!") From 67ebe71f589f47caa63f5a754777b3abaa36dc66 Mon Sep 17 00:00:00 2001 From: Philippe Teuwen Date: Sat, 17 Aug 2024 21:12:54 +0200 Subject: [PATCH 6/7] flash: logo even when ansi is off --- client/src/flash.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/client/src/flash.c b/client/src/flash.c index 067ad1c7f..3dda44069 100644 --- a/client/src/flash.c +++ b/client/src/flash.c @@ -647,7 +647,10 @@ int flash_write(flash_file_t *ctx) { PrintAndLogEx(SUCCESS, "Writing segments for file: %s", ctx->filename); - bool filter_ansi = !g_session.supports_colors; + char ice2[sizeof(ice)] = {0}; + char ice3[sizeof(ice)] = {0}; + memcpy_filter_ansi(ice2, ice, sizeof(ice), !g_session.supports_colors); + memcpy_filter_emoji(ice3, ice2, sizeof(ice2), g_session.emoji_mode); for (int i = 0; i < ctx->num_segs; i++) { flash_seg_t *seg = &ctx->segments[i]; @@ -676,12 +679,8 @@ int flash_write(flash_file_t *ctx) { baddr += block_size; length -= block_size; block++; - if (len < strlen(ice)) { - if (filter_ansi && !isalpha(ice[len])) { - len++; - } else { - fprintf(stdout, "%c", ice[len++]); - } + if (len < strlen(ice3)) { + fprintf(stdout, "%c", ice3[len++]); } else { fprintf(stdout, "."); } From 957db7cb536b42056d39b17ab32b043dcaed2a87 Mon Sep 17 00:00:00 2001 From: Philippe Teuwen Date: Sat, 17 Aug 2024 21:26:32 +0200 Subject: [PATCH 7/7] flash: fix & simplify post-logo filling --- client/src/flash.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/client/src/flash.c b/client/src/flash.c index 3dda44069..2395ffd40 100644 --- a/client/src/flash.c +++ b/client/src/flash.c @@ -635,11 +635,7 @@ static const char ice[] = "...................................................................\n @@@ @@@@@@@ @@@@@@@@ @@@@@@@@@@ @@@@@@ @@@ @@@\n" " @@! !@@ @@! @@! @@! @@! @@! @@@ @@!@!@@@\n !!@ !@! @!!!:! @!! !!@ @!@ @!@!@!@! @!@@!!@!\n" " !!: :!! !!: !!: !!: !!: !!! !!: !!!\n : :: :: : : :: ::: : : : : : :: : \n" - _RED_(" . .. .. . . .. ... . . . . . .. . ") - "\n...................................................................\n" - "...................................................................\n" - "...................................................................\n" - ; + _RED_(" . .. .. . . .. ... . . . . . .. . "); // Write a file's segments to Flash int flash_write(flash_file_t *ctx) { @@ -651,6 +647,7 @@ int flash_write(flash_file_t *ctx) { char ice3[sizeof(ice)] = {0}; memcpy_filter_ansi(ice2, ice, sizeof(ice), !g_session.supports_colors); memcpy_filter_emoji(ice3, ice2, sizeof(ice2), g_session.emoji_mode); + size_t ice3len = strlen(ice3); for (int i = 0; i < ctx->num_segs; i++) { flash_seg_t *seg = &ctx->segments[i]; @@ -679,10 +676,14 @@ int flash_write(flash_file_t *ctx) { baddr += block_size; length -= block_size; block++; - if (len < strlen(ice3)) { + if (len < ice3len) { fprintf(stdout, "%c", ice3[len++]); } else { + if ((len - ice3len) % 67 == 0) { + fprintf(stdout, "\n"); + } fprintf(stdout, "."); + len++; } fflush(stdout); }