From be25db28048d06b58b9851d8915a69a24eeb8402 Mon Sep 17 00:00:00 2001 From: Akif Dinc Date: Tue, 16 Feb 2021 20:53:53 +0100 Subject: [PATCH 1/5] Adding Figurine Type ID and Figurine ID parameters for hf jooki --- client/src/cmdhfjooki.c | 39 +++++++++++++++++++++++++++++++++------ 1 file changed, 33 insertions(+), 6 deletions(-) diff --git a/client/src/cmdhfjooki.c b/client/src/cmdhfjooki.c index 82e3787e6..5144a90a7 100644 --- a/client/src/cmdhfjooki.c +++ b/client/src/cmdhfjooki.c @@ -278,7 +278,8 @@ static int CmdHF14AJookiEncode(const char *Cmd) { "Encode a Jooki token to base64 NDEF URI format", "hf jooki encode -t --> selftest\n" "hf jooki encode -r --dragon --> read uid from tag and use for encoding\n" - "hf jooki encode --uid 04010203040506 --dragon" + "hf jooki encode --uid 04010203040506 --dragon\n" + "hf jooki encode --uid 04010203040506 -y 1 -f 1" ); void *argtable[] = { @@ -300,6 +301,8 @@ static int CmdHF14AJookiEncode(const char *Cmd) { arg_lit0(NULL, "whitefox", "figurine type"), arg_lit0(NULL, "whiteknight", "figurine type"), arg_lit0(NULL, "whitewhale", "figurine type"), + arg_u64_0("y", "tid", "", "figurine type id"), + arg_u64_0("f", "fid", "", "figurine id"), arg_param_end }; CLIExecWithReturn(ctx, Cmd, argtable, false); @@ -328,18 +331,42 @@ static int CmdHF14AJookiEncode(const char *Cmd) { bool tb = arg_get_lit(ctx, 15); bool tc = arg_get_lit(ctx, 16); bool td = arg_get_lit(ctx, 17); + + bool figure_abbr = true; + + uint8_t ftid = arg_get_u32_def(ctx, 18, 0); + uint8_t ffid = arg_get_u32_def(ctx, 19, 0); //default 0 ist schlecht + CLIParserFree(ctx); if (selftest) { return jooki_selftest(); } - if ((t0 + t1 + t2 + t3 + t5 + t6 + t7 + t8 + t9 + ta + tb + tc + td) > 1) { - PrintAndLogEx(ERR, "Select one tag type"); + uint8_t tid, fid; + + if( ftid && ffid ) { + figure_abbr = true; + tid = 0x01; + fid = 0x00; + } + + if ( ftid > 0x04 || ffid > 0x20 ) { + PrintAndLogEx(ERR, "Use a valid Figure Type ID and Figure ID"); return PM3_EINVARG; - } - uint8_t tid = 0x01; - uint8_t fid = 0x00; + } else { + figure_abbr = false; + } + + if ((t0 + t1 + t2 + t3 + t5 + t6 + t7 + t8 + t9 + ta + tb + tc + td) > 1 && !figure_abbr) { + PrintAndLogEx(ERR, "Select one tag type or use figurine type id and figurine id"); + return PM3_EINVARG; + } else { + tid = ftid; + fid = ffid; + } + + PrintAndLogEx(INFO, "Figurine Type ID %u and Figurine ID %u ", ftid, ffid); if (t1) fid = 0x01; if (t2) From 5c385e8f2fc3ab389889d6d80dbff9021dc6dcff Mon Sep 17 00:00:00 2001 From: Akif Dinc Date: Tue, 16 Feb 2021 20:55:48 +0100 Subject: [PATCH 2/5] Changes to Jooki command codes --- client/src/cmdhfjooki.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/client/src/cmdhfjooki.c b/client/src/cmdhfjooki.c index 5144a90a7..d31218b08 100644 --- a/client/src/cmdhfjooki.c +++ b/client/src/cmdhfjooki.c @@ -67,7 +67,7 @@ jooki_figure_t jooks_figures[] = { {0x01, 0x0C, "White Knight", "Figurine"}, {0x01, 0x0D, "White Whale", "Figurine"}, - {0x02, 0x01, "Generic Flat", "Stone"}, + {0x02, 0x00, "Generic Flat", "Stone"}, {0x03, 0x00, "record", "Sys"}, {0x03, 0x01, "factory_mode_on", "Sys"}, @@ -77,9 +77,10 @@ jooki_figure_t jooks_figures[] = { {0x03, 0x05, "toy_safe_on", "Sys"}, {0x03, 0x06, "toy_safe_off", "Sys"}, {0x03, 0x07, "wifi_on", "Sys"}, - {0x03, 0x08, "bt_on", "Sys"}, - {0x03, 0x0a, "bt_off", "Sys"}, - {0x03, 0x0b, "production_finished", "Sys"}, + {0x03, 0x08, "wifi_off", "Sys"}, + {0x03, 0x09, "bt_on", "Sys"}, + {0x03, 0x0A, "bt_off", "Sys"}, + {0x03, 0x0B, "production_finished", "Sys"}, {0x04, 0x00, "test.0", "Test"}, {0x04, 0x01, "test.1", "Test"}, From 76b73b26d360330b03eccd9f032d399522d35f96 Mon Sep 17 00:00:00 2001 From: Akif Dinc Date: Tue, 16 Feb 2021 22:34:39 +0100 Subject: [PATCH 3/5] Fixing short commands for figurine names --- client/src/cmdhfjooki.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/client/src/cmdhfjooki.c b/client/src/cmdhfjooki.c index d31218b08..df7cba428 100644 --- a/client/src/cmdhfjooki.c +++ b/client/src/cmdhfjooki.c @@ -348,8 +348,6 @@ static int CmdHF14AJookiEncode(const char *Cmd) { if( ftid && ffid ) { figure_abbr = true; - tid = 0x01; - fid = 0x00; } if ( ftid > 0x04 || ffid > 0x20 ) { @@ -363,7 +361,7 @@ static int CmdHF14AJookiEncode(const char *Cmd) { PrintAndLogEx(ERR, "Select one tag type or use figurine type id and figurine id"); return PM3_EINVARG; } else { - tid = ftid; + tid = 0x01; fid = ffid; } From 23be1158c6dc8818b1343a02acb8dba69545e8c2 Mon Sep 17 00:00:00 2001 From: Akif Dinc Date: Tue, 16 Feb 2021 22:37:17 +0100 Subject: [PATCH 4/5] Remove useless comment --- client/src/cmdhfjooki.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/cmdhfjooki.c b/client/src/cmdhfjooki.c index df7cba428..c6b14914f 100644 --- a/client/src/cmdhfjooki.c +++ b/client/src/cmdhfjooki.c @@ -336,7 +336,7 @@ static int CmdHF14AJookiEncode(const char *Cmd) { bool figure_abbr = true; uint8_t ftid = arg_get_u32_def(ctx, 18, 0); - uint8_t ffid = arg_get_u32_def(ctx, 19, 0); //default 0 ist schlecht + uint8_t ffid = arg_get_u32_def(ctx, 19, 0); CLIParserFree(ctx); From f7359bcc656041db5da3e30167ce897678375a48 Mon Sep 17 00:00:00 2001 From: Akif Dinc Date: Tue, 16 Feb 2021 23:30:40 +0100 Subject: [PATCH 5/5] Fixing bug in tid selection --- client/src/cmdhfjooki.c | 40 ++++++++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/client/src/cmdhfjooki.c b/client/src/cmdhfjooki.c index c6b14914f..7c2d9aa08 100644 --- a/client/src/cmdhfjooki.c +++ b/client/src/cmdhfjooki.c @@ -280,7 +280,7 @@ static int CmdHF14AJookiEncode(const char *Cmd) { "hf jooki encode -t --> selftest\n" "hf jooki encode -r --dragon --> read uid from tag and use for encoding\n" "hf jooki encode --uid 04010203040506 --dragon\n" - "hf jooki encode --uid 04010203040506 -y 1 -f 1" + "hf jooki encode --uid 04010203040506 --tid 1 --fid 1" ); void *argtable[] = { @@ -302,8 +302,8 @@ static int CmdHF14AJookiEncode(const char *Cmd) { arg_lit0(NULL, "whitefox", "figurine type"), arg_lit0(NULL, "whiteknight", "figurine type"), arg_lit0(NULL, "whitewhale", "figurine type"), - arg_u64_0("y", "tid", "", "figurine type id"), - arg_u64_0("f", "fid", "", "figurine id"), + arg_u64_0(NULL, "tid", "", "figurine type id"), + arg_u64_0(NULL, "fid", "", "figurine id"), arg_param_end }; CLIExecWithReturn(ctx, Cmd, argtable, false); @@ -333,11 +333,11 @@ static int CmdHF14AJookiEncode(const char *Cmd) { bool tc = arg_get_lit(ctx, 16); bool td = arg_get_lit(ctx, 17); - bool figure_abbr = true; - uint8_t ftid = arg_get_u32_def(ctx, 18, 0); uint8_t ffid = arg_get_u32_def(ctx, 19, 0); + bool figure_abbr = true; + CLIParserFree(ctx); if (selftest) { @@ -346,26 +346,34 @@ static int CmdHF14AJookiEncode(const char *Cmd) { uint8_t tid, fid; - if( ftid && ffid ) { - figure_abbr = true; + if( ftid || ffid ) { + figure_abbr = false; } if ( ftid > 0x04 || ffid > 0x20 ) { PrintAndLogEx(ERR, "Use a valid Figure Type ID and Figure ID"); return PM3_EINVARG; - } else { - figure_abbr = false; - } + } + + uint8_t figure_abbr_val = t0 + t1 + t2 + t3 + t5 + t6 + t7 + t8 + t9 + ta + tb + tc + td; - if ((t0 + t1 + t2 + t3 + t5 + t6 + t7 + t8 + t9 + ta + tb + tc + td) > 1 && !figure_abbr) { + if (figure_abbr_val > 1) { PrintAndLogEx(ERR, "Select one tag type or use figurine type id and figurine id"); return PM3_EINVARG; - } else { - tid = 0x01; - fid = ffid; - } + } + + if (figure_abbr_val == 1 && !figure_abbr) { + PrintAndLogEx(ERR, "Use either --tid and --fid or one of the figurine types"); + return PM3_EINVARG; + } + + if (figure_abbr) { + tid = 0x01; + } else { + tid = ftid; + } + fid = ffid; - PrintAndLogEx(INFO, "Figurine Type ID %u and Figurine ID %u ", ftid, ffid); if (t1) fid = 0x01; if (t2)