From 6953570c2ef8244c09ce120d9afb596cb739f657 Mon Sep 17 00:00:00 2001 From: mwalker33 Date: Thu, 1 Oct 2020 11:53:05 +1000 Subject: [PATCH 01/28] Create cliparser.md Draft cliparser notes/guide --- doc/cliparser.md | 114 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 doc/cliparser.md diff --git a/doc/cliparser.md b/doc/cliparser.md new file mode 100644 index 000000000..83002dda4 --- /dev/null +++ b/doc/cliparser.md @@ -0,0 +1,114 @@ +# cliparser - proxmark3-rrg + +## cliparser setup and use + +*** Draft notes - needs work *** + +Note: the parser will format and color and layout as needed. + +## common options +where possiable all options should be lowercase. +extended options preceeded with -- should be short +options provided directly (without an option identifier) should be avoided. +-vv for extra verbos should be avoided; use of debug level is prefered. +whith --options the equle is not needed (will work with and without) so dont use '=' +e.g. cmd --cn 12345 + + -h --help : help + --cn : card number + --fn : facility number + --q5 : target is lf q5 card + --raw : raw data + -k --key : key supplied + -n --keyno : key number to use + -v --verbose : flag when output should provide more information, not conidered debug. + -1 --buffer : use the sample buffer + +### setup the parser data structure +Header file to include + + #include "cliparser.h" + +In the command function, setup the context + + CLIParserContext *ctx; + + +### define the text +CLIParserInit (\, \, \); + +use -> to seperate example and example comment and \\n to seperate examples. +e.g. lf indala clone -r a0000000a0002021 -> this uses ..... + + CLIParserInit(&ctx, "lf indala clone", + "clone INDALA UID to T55x7 or Q5/T5555 tag", + "lf indala clone --heden 888\n" + "lf indala clone --fc 123 --cn 1337\n" + "lf indala clone -r a0000000a0002021\n" + "lf indala clone -l -r 80000001b23523a6c2e31eba3cbee4afb3c6ad1fcf649393928c14e5"); + +### define the options + + void *argtable[] = { + arg_param_begin, + arg_lit0("l", "long", "optional - long UID 224 bits"), + arg_int0("c", "heden", "", "Cardnumber for Heden 2L format"), + arg_strx0("r", "raw", "", "raw bytes"), + arg_lit0("q", "Q5", "optional - specify writing to Q5/T5555 tag"), + arg_int0(NULL, "fc", "", "Facility Code (26 bit format)"), + arg_int0(NULL, "cn", "", "Cardnumber (26 bit format)"), + arg_param_end + }; + +**Notes:** +booleen : arg_lit0 ("\", "\", \["\",\] \<"description"\>); +optional integer : arg_int0 ("\", "\", \["\",\] \<"description"\>); +required integer : arg_int1 ("\", "\", \["\",\] \<"description"\>); +optional string : arg_strx0 ("\", "\", \["\",\] \<"description"\>); +required string : arg_strx1 ("\", "\", \["\",\] \<"description"\>); + +** if an option does not have a short or long option, use NULL in its place. ** + +### show the menu +CLIExecWithReturn(\, \, \, \); + + CLIExecWithReturn(ctx, Cmd, argtable, false); + +### clean up +Once you have extracted the options, cleanup the context. + + CLIParserFree(ctx); + +### retreiving options +**bool option** +arg_get_lit(\, \); + + is_long_uid = arg_get_lit(ctx, 1); + +**int option** +arg_get_int_def(\, \, \); + + cardnumber = arg_get_int_def(ctx, 2, -1); + +**hex option** +CLIGetHexWithReturn(\, \, \, \); + ?? as an array of uint_8 ?? + + uint8_t aid[2] = {0}; + int aidlen; + CLIGetHexWithReturn(ctx, 2, aid, &aidlen); + +**hex option returning ???** + + uint8_t key[24] = {0}; + int keylen = 0; + int res_klen = CLIParamHexToBuf(arg_get_str(ctx, 3), key, 24, &keylen); + quick test : seems res_keylen == 0 when ok so not key len ??? + +**string option** +CLIGetStrWithReturn(\,\, \, \); + + uint8_t Buffer[100]; + int BufLen; + CLIGetStrWithReturn(ctx,7, Buffer, &BufLen); + From cda0e88be11959b9e02cd16ffe7db5195cc0a194 Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Thu, 1 Oct 2020 08:04:47 +0200 Subject: [PATCH 02/28] textual --- CHANGELOG.md | 1 + README.md | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 61f3e89b2..9cd0f8b2f 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 doc/cliparser.md (@mwalker33) - Add `hf 14b apdu` - send APDU over ISO14443B (@iceman1001) - Add `lf t55xx chk e option` - Checks calculated password based on the EM4100 id from some white cloners forumla by paleopterix (@mwalker33) - Add `lf t55xx sniff` to allow extracting commands and passwords used be cloners. (@mwalker33) diff --git a/README.md b/README.md index ac4ab1f6d..8fb77dc14 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ |[Notes on file formats used with Proxmark3](/doc/extensions_notes.md)|[Notes on MFU binary format](/doc/mfu_binary_format_notes.md)|[Notes on FPGA & ARM](/doc/fpga_arm_notes.md)| |[Developing standalone mode](/armsrc/Standalone/readme.md)|[Wiki about standalone mode](https://github.com/RfidResearchGroup/proxmark3/wiki/Standalone-mode)|[Notes on Magic cards](/doc/magic_cards_notes.md)| |[Notes on Color usage](/doc/colors_notes.md)|[Makefile vs CMake](/doc/md/Development/Makefile-vs-CMake.md)|[Notes on Cloner guns](/doc/cloner_notes.md)| - +|[Notes on cliparser usage](/doc/cliparser.md)||| ## Build for non-RDV4 Proxmark3 platforms From f56cbc82f53cb46e52fddeaf0be7ede078e93697 Mon Sep 17 00:00:00 2001 From: Philippe Teuwen Date: Thu, 1 Oct 2020 02:14:49 +0200 Subject: [PATCH 03/28] Add support for 14b' aka Innovatron in armsrc/iso14443b.c --- CHANGELOG.md | 1 + armsrc/iso14443b.c | 123 +++++++++++++++++++++++++-------------------- 2 files changed, 69 insertions(+), 55 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9cd0f8b2f..7e5f00a78 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 low level support for 14b' aka Innovatron (@doegox) - Add doc/cliparser.md (@mwalker33) - Add `hf 14b apdu` - send APDU over ISO14443B (@iceman1001) - Add `lf t55xx chk e option` - Checks calculated password based on the EM4100 id from some white cloners forumla by paleopterix (@mwalker33) diff --git a/armsrc/iso14443b.c b/armsrc/iso14443b.c index 57699af62..c3e1a58d5 100644 --- a/armsrc/iso14443b.c +++ b/armsrc/iso14443b.c @@ -274,8 +274,7 @@ static struct { enum { DEMOD_UNSYNCD, DEMOD_PHASE_REF_TRAINING, - DEMOD_AWAITING_FALLING_EDGE_OF_SOF, - DEMOD_GOT_FALLING_EDGE_OF_SOF, + WAIT_FOR_RISING_EDGE_OF_SOF, DEMOD_AWAITING_START_BIT, DEMOD_RECEIVING_DATA } state; @@ -724,6 +723,13 @@ void SimulateIso14443bTag(uint32_t pupi) { // tag's response, which we leave in the buffer to be demodulated on the // PC side. //============================================================================= +// We support both 14b framing and 14b' framing. +// 14b framing looks like: +// xxxxxxxx1111111111111111-000000000011-0........1-0........1-0........1-1-0........1-0........1-1000000000011xxxxxx +// TR1 SOF 10*0+2*1 start-stop ^^^^^^^^byte ^ occasional stuff bit EOF 10*0+N*1 +// 14b' framing looks like: +// xxxxxxxxxxxxxxxx111111111111111111111-0........1-0........1-0........1-1-0........1-0........1-000000000000xxxxxxx +// SOF? start-stop ^^^^^^^^byte ^ occasional stuff bit EOF /* * Handles reception of a bit from the tag @@ -774,57 +780,33 @@ static RAMFUNC int Handle14443bSamplesFromTag(int ci, int cq) { break; } case DEMOD_PHASE_REF_TRAINING: { - if (Demod.posCount < 8) { - if (AMPLITUDE(ci, cq) > SUBCARRIER_DETECT_THRESHOLD) { - // set the reference phase (will code a logic '1') by averaging over 32 1/fs. - // note: synchronization time > 80 1/fs - Demod.sumI += ci; - Demod.sumQ += cq; - Demod.posCount++; + // While we get a constant signal + if (AMPLITUDE(ci, cq) > SUBCARRIER_DETECT_THRESHOLD) { + if (((ABS(Demod.sumI) > ABS(Demod.sumQ)) && (((ci > 0) && (Demod.sumI > 0)) || ((ci < 0) && (Demod.sumI < 0)))) || // signal closer to horizontal, polarity check based on on I + ((ABS(Demod.sumI) <= ABS(Demod.sumQ)) && (((cq > 0) && (Demod.sumQ > 0)) || ((cq < 0) && (Demod.sumQ < 0))))) { // signal closer to vertical, polarity check based on on Q + if (Demod.posCount < 10) { // refine signal approximation during first 10 samples + Demod.sumI += ci; + Demod.sumQ += cq; + } + Demod.posCount += 1; } else { - // subcarrier lost - Demod.state = DEMOD_UNSYNCD; + // transition + if (Demod.posCount < 10) { + // subcarrier lost + Demod.state = DEMOD_UNSYNCD; + break; + } else { + // at this point it can be start of 14b' data or start of 14b SOF + MAKE_SOFT_DECISION(); + Demod.posCount = 1; // this was the first half + Demod.thisBit = v; + Demod.shiftReg = 0; + Demod.state = DEMOD_RECEIVING_DATA; + } } } else { - Demod.state = DEMOD_AWAITING_FALLING_EDGE_OF_SOF; - } - break; - } - case DEMOD_AWAITING_FALLING_EDGE_OF_SOF: { - - MAKE_SOFT_DECISION(); - - if (v < 0) { // logic '0' detected - Demod.state = DEMOD_GOT_FALLING_EDGE_OF_SOF; - Demod.posCount = 0; // start of SOF sequence - } else { - if (Demod.posCount > 200/4) { // maximum length of TR1 = 200 1/fs - Demod.state = DEMOD_UNSYNCD; - } - } - Demod.posCount++; - break; - } - case DEMOD_GOT_FALLING_EDGE_OF_SOF: { - - Demod.posCount++; - MAKE_SOFT_DECISION(); - - if (v > 0) { - if (Demod.posCount < 9 * 2) { // low phase of SOF too short (< 9 etu). Note: spec is >= 10, but FPGA tends to "smear" edges - Demod.state = DEMOD_UNSYNCD; - } else { - LED_C_ON(); // Got SOF - Demod.posCount = 0; - Demod.bitCount = 0; - Demod.len = 0; - Demod.state = DEMOD_AWAITING_START_BIT; - } - } else { - if (Demod.posCount > 12 * 2) { // low phase of SOF too long (> 12 etu) - Demod.state = DEMOD_UNSYNCD; - LED_C_OFF(); - } + // subcarrier lost + Demod.state = DEMOD_UNSYNCD; } break; } @@ -848,6 +830,28 @@ static RAMFUNC int Handle14443bSamplesFromTag(int ci, int cq) { } break; } + case WAIT_FOR_RISING_EDGE_OF_SOF: { + + Demod.posCount++; + MAKE_SOFT_DECISION(); + if (v > 0) { + if (Demod.posCount < 9 * 2) { // low phase of SOF too short (< 9 etu). Note: spec is >= 10, but FPGA tends to "smear" edges + Demod.state = DEMOD_UNSYNCD; + } else { + LED_C_ON(); // Got SOF + Demod.posCount = 0; + Demod.bitCount = 0; + Demod.len = 0; + Demod.state = DEMOD_AWAITING_START_BIT; + } + } else { + if (Demod.posCount > 12 * 2) { // low phase of SOF too long (> 12 etu) + Demod.state = DEMOD_UNSYNCD; + LED_C_OFF(); + } + } + break; + } case DEMOD_RECEIVING_DATA: { MAKE_SOFT_DECISION(); @@ -874,11 +878,20 @@ static RAMFUNC int Handle14443bSamplesFromTag(int ci, int cq) { Demod.bitCount = 0; Demod.state = DEMOD_AWAITING_START_BIT; } else { - Demod.state = DEMOD_AWAITING_FALLING_EDGE_OF_SOF; - LED_C_OFF(); if (s == 0x000) { - // This is EOF (start, stop and all data bits == '0' - return true; + if (Demod.len > 0) { + LED_C_OFF(); + // This is EOF (start, stop and all data bits == '0' + return true; + } else { + // Zeroes but no data acquired yet? + // => Still in SOF of 14b, wait for raising edge + Demod.posCount = 10 * 2; + Demod.bitCount = 0; + Demod.len = 0; + Demod.state = WAIT_FOR_RISING_EDGE_OF_SOF; + break; + } } } } @@ -1692,7 +1705,7 @@ void SniffIso14443b(void) { expect_tag_answer = false; tag_is_active = false; } else { - tag_is_active = (Demod.state > DEMOD_GOT_FALLING_EDGE_OF_SOF); + tag_is_active = (Demod.state > WAIT_FOR_RISING_EDGE_OF_SOF); } } } From a2abfb44ae8520a95dba7be9beba0d4f677a4895 Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Thu, 1 Oct 2020 23:48:32 +0200 Subject: [PATCH 04/28] correction of text --- fpga/fpga_lf.v | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fpga/fpga_lf.v b/fpga/fpga_lf.v index aa79da234..3b37e44f0 100644 --- a/fpga/fpga_lf.v +++ b/fpga/fpga_lf.v @@ -100,7 +100,7 @@ module fpga_lf( lf_ed_threshold = 8bits threshold value. conf_word 12bits - conf_word[7:5] = 3bit major mode. + conf_word[8:6] = 3bit major mode. conf_word[0] = 1bit lf_field conf_word[1] = 1bit lf_ed_toggle_mode conf_word[7:0] = 8bit divisor @@ -110,7 +110,7 @@ module fpga_lf( bit | 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 -----+------------------------------------------- cmd | x x x x -major| x x x +major| x x x opt | x x divi | x x x x x x x x thres| x x x x x x x x From cf3b18605f3430757194141dcd6086f964ad166b Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Thu, 1 Oct 2020 23:49:01 +0200 Subject: [PATCH 05/28] correction of text --- fpga/fpga_hf.v | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/fpga/fpga_hf.v b/fpga/fpga_hf.v index df3780fc6..add927514 100644 --- a/fpga/fpga_hf.v +++ b/fpga/fpga_hf.v @@ -92,7 +92,8 @@ module fpga_hf( //----------------------------------------------------------------------------- /* - Attempt to write up how its hooked up. Iceman 2020. + Attempt to write up how its hooked up. + / Iceman, 2020 Communication between ARM / FPGA is done inside armsrc/fpgaloader.c see: function FpgaSendCommand() Send 16 bit command / data pair to FPGA @@ -108,8 +109,9 @@ module fpga_hf( bit | 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 -----+------------------------------------------- cmd | x x x x -major| x x x -opt | x x x +major| x x x +opt | x x x x +sub | x x divi | x x x x x x x x thres| x x x x x x x x -----+------------------------------------------- From b1c1433e4573b5d7d196acda00650bf9a5fa9f40 Mon Sep 17 00:00:00 2001 From: Philippe Teuwen Date: Fri, 2 Oct 2020 00:58:41 +0200 Subject: [PATCH 06/28] 14b: safer handling of corrupted signals --- armsrc/iso14443b.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/armsrc/iso14443b.c b/armsrc/iso14443b.c index c3e1a58d5..be8b820e0 100644 --- a/armsrc/iso14443b.c +++ b/armsrc/iso14443b.c @@ -893,6 +893,16 @@ static RAMFUNC int Handle14443bSamplesFromTag(int ci, int cq) { break; } } + if (AMPLITUDE(ci, cq) < SUBCARRIER_DETECT_THRESHOLD) { + LED_C_OFF(); + // subcarrier lost + Demod.state = DEMOD_UNSYNCD; + if (Demod.len > 0) { // no EOF but no signal anymore and we got data, e.g. ASK CTx + return true; + } + } + // we have still signal but no proper byte or EOF? this shouldn't happen + Demod.state = WAIT_FOR_RISING_EDGE_OF_SOF; } } Demod.posCount = 0; From b3a3828c3ff07ccfe28088c0490c286ce7b2e929 Mon Sep 17 00:00:00 2001 From: Philippe Teuwen Date: Fri, 2 Oct 2020 01:18:49 +0200 Subject: [PATCH 07/28] add 14b* traces --- traces/README.md | 5 +- traces/hf_14b_raw_010fxxxxxxxx_innovatron.pm3 | 3072 +++++++++++++++++ traces/hf_14b_raw_0600_st_sri512.pm3 | 3072 +++++++++++++++++ traces/hf_14b_raw_10_ask_ctx.pm3 | 3072 +++++++++++++++++ 4 files changed, 9220 insertions(+), 1 deletion(-) create mode 100644 traces/hf_14b_raw_010fxxxxxxxx_innovatron.pm3 create mode 100644 traces/hf_14b_raw_0600_st_sri512.pm3 create mode 100644 traces/hf_14b_raw_10_ask_ctx.pm3 diff --git a/traces/README.md b/traces/README.md index 78675df95..9d0271cc9 100644 --- a/traces/README.md +++ b/traces/README.md @@ -64,7 +64,10 @@ |filename|description| |--------|-----------| -|hf_14b_raw_050008_resp.pm3 |Response to `hf 14b raw -c 050008`| +|hf_14b_raw_050008_resp.pm3 |Response of 14b card to `hf 14b raw -c 050008`| +|hf_14b_raw_0600_st_sri512.pm3 |Response of ST SRI512 to `hf 14b raw -c 0600`| +|hf_14b_raw_10_ask_ctx.pm3 |Response of ASK CTx to `hf 14b raw -c 10`| +|hf_14b_raw_010fxxxxxxxx_innovatron.pm3 |Response of 14b' card to `hf 14b raw -c -k 010fxxxxxxxx`| ## HF sniffed traces diff --git a/traces/hf_14b_raw_010fxxxxxxxx_innovatron.pm3 b/traces/hf_14b_raw_010fxxxxxxxx_innovatron.pm3 new file mode 100644 index 000000000..bd23d1760 --- /dev/null +++ b/traces/hf_14b_raw_010fxxxxxxxx_innovatron.pm3 @@ -0,0 +1,3072 @@ +-113 +-2 +-4 +-5 +-5 +-3 +-4 +-4 +-6 +-5 +-2 +-3 +-4 +-4 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-97 +-71 +-51 +-36 +-26 +-20 +-15 +-11 +-9 +-7 +-6 +-4 +-4 +-3 +-4 +-4 +-3 +-3 +-4 +-3 +-3 +-2 +-3 +-3 +-4 +-4 +-4 +-4 +-4 +-3 +-3 +-3 +-3 +-2 +-2 +-3 +-3 +-4 +-4 +-3 +-3 +-3 +-3 +-3 +-2 +-3 +-3 +-4 +-4 +-4 +-3 +-2 +-3 +-3 +-3 +-3 +-4 +-4 +-4 +-3 +-3 +-2 +-2 +-3 +-3 +-4 +-3 +-3 +-4 +-3 +-4 +-3 +-3 +-3 +-3 +-3 +-4 +-3 +-3 +-4 +-4 +-2 +-2 +-3 +-3 +-3 +-4 +-3 +-4 +-4 +-3 +-2 +-2 +-3 +-3 +-3 +43 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +94 +63 +14 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-45 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +92 +63 +41 +27 +18 +14 +11 +10 +8 +8 +5 +1 +-2 +-4 +-7 +-9 +-7 +-5 +-5 +-4 +-3 +-2 +0 +-3 +-3 +-4 +-5 +-6 +-7 +-6 +-6 +-6 +-3 +-3 +-2 +-2 +-4 +-3 +-4 +-6 +-7 +-6 +-4 +-4 +-4 +-3 +-3 +-4 +-4 +-4 +-65 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-100 +-73 +-52 +-38 +-27 +-19 +-14 +-11 +-9 +-7 +-7 +-5 +-5 +-4 +-3 +-3 +-3 +-2 +-3 +-3 +-3 +-4 +-3 +-3 +-2 +-2 +-3 +-3 +-4 +-4 +-3 +-3 +-3 +-2 +-2 +-2 +-4 +-3 +-3 +-4 +-3 +-3 +-4 +-3 +-2 +-3 +-3 +-3 +25 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +94 +63 +24 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-58 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +93 +63 +21 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-48 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +91 +62 +11 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-94 +-69 +-51 +-36 +-26 +-19 +-14 +-11 +-9 +-7 +-6 +-4 +-4 +-4 +-4 +-3 +57 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +91 +60 +-12 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-97 +-71 +-51 +-37 +-26 +-18 +-14 +-10 +-8 +-7 +-6 +-5 +-5 +-4 +-3 +-3 +62 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +90 +59 +-23 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-31 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +90 +62 +25 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-65 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +93 +63 +41 +28 +19 +13 +11 +10 +10 +8 +5 +2 +-3 +-7 +-8 +-8 +-7 +-4 +-4 +-4 +-2 +0 +0 +-3 +-4 +-5 +-7 +-6 +-7 +-7 +-6 +-4 +-2 +-2 +-3 +-4 +-5 +-4 +-4 +-5 +-5 +-6 +-6 +-4 +-5 +-6 +-4 +-4 +-4 +-3 +-35 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-98 +-72 +-52 +-37 +-27 +-20 +-14 +-10 +-8 +-6 +-6 +-5 +-5 +-4 +-4 +-4 +55 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +88 +60 +-9 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-35 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +91 +62 +-17 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-33 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +90 +60 +42 +29 +18 +13 +11 +11 +9 +6 +5 +1 +-4 +-5 +-7 +-7 +-6 +-6 +-22 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-70 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +94 +63 +23 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-52 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +92 +62 +45 +28 +17 +17 +13 +10 +8 +6 +3 +0 +0 +-4 +-7 +-9 +-8 +-4 +-35 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-46 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +90 +61 +-7 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-38 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +89 +62 +-13 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-35 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +90 +60 +-21 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-32 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +90 +61 +-23 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-64 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +95 +64 +25 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-95 +-70 +-50 +-37 +-27 +-19 +-15 +-11 +-8 +-6 +-5 +-4 +-5 +-4 +-5 +-4 +45 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +91 +62 +11 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-96 +-71 +-51 +-36 +-25 +-18 +-14 +-10 +-8 +-6 +-6 +-5 +-5 +-4 +-4 +-3 +-2 +-1 +-3 +-3 +-3 +-2 +-3 +-3 +-4 +-3 +-2 +-2 +-3 +-3 +-3 +-3 +58 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +90 +60 +-15 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-97 +-71 +-49 +-36 +-26 +-19 +-14 +-11 +-8 +-6 +-7 +-5 +-4 +-3 +-4 +-3 +63 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +91 +60 +-24 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-32 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +91 +61 +41 +26 +18 +12 +11 +9 +9 +8 +5 +0 +-2 +-5 +-8 +-7 +-6 +-6 +-21 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-58 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +92 +63 +43 +25 +15 +11 +11 +12 +10 +9 +7 +2 +0 +-5 +-9 +-10 +-9 +-6 +-33 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-98 +-71 +-51 +-37 +-27 +-19 +-14 +-11 +-8 +-7 +-5 +-4 +-4 +-4 +-4 +-4 +-3 +-3 +-3 +-3 +-2 +-2 +-3 +-2 +-3 +-4 +-3 +-3 +-4 +-3 +-2 +-2 +58 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +90 +60 +-12 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-114 +-96 +-71 +-51 +-37 +-27 +-19 +-13 +-9 +-8 +-6 +-6 +-5 +-4 +-4 +-4 +-4 +-3 +-3 +-2 +-2 +-3 +-2 +-3 +-3 +-4 +-3 +-3 +-3 +-3 +-2 +-3 +-3 +-3 +-4 +-2 +-3 +-3 +-2 +-2 +-3 +-3 +-3 +-4 +-4 +-3 +-3 +-2 +-2 +-2 +-2 +-2 +-3 +-4 +-4 +-3 +-3 +-3 +-2 +-2 +-3 +-3 +-3 +-3 +-3 +-3 +-4 +-3 +-2 +-2 +-3 +-3 +-3 +-4 +-3 +-3 +-4 +-3 +-3 +-2 +-2 +-3 +-4 +-4 +-3 +-3 +-3 +-3 +-2 +-3 +-2 +-3 +-4 +-3 +-4 +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 +-5 +-5 +-5 +-5 +-4 +-9 +-4 +-3 +-4 +-4 +2 +-3 +-5 +-5 +-4 +-4 +-6 +-5 +-2 +-4 +-5 +58 +127 +10 +127 +-37 +127 +-65 +118 +-79 +110 +-86 +100 +-94 +95 +-95 +95 +-98 +92 +-98 +96 +-96 +94 +-97 +94 +-96 +94 +-99 +90 +-100 +94 +-97 +93 +-98 +94 +-96 +94 +-99 +91 +-99 +94 +-98 +92 +-99 +93 +-96 +94 +-98 +92 +-98 +95 +-98 +92 +-99 +93 +-97 +94 +-98 +92 +-98 +95 +-97 +92 +-99 +93 +-98 +93 +-99 +92 +-98 +95 +-97 +93 +-99 +93 +-97 +93 +-99 +92 +-98 +94 +-97 +93 +-99 +92 +-97 +94 +-98 +92 +-98 +95 +-97 +93 +-99 +92 +-97 +94 +-98 +92 +-98 +95 +-97 +92 +-99 +92 +-98 +93 +-99 +92 +-98 +95 +-96 +93 +-99 +92 +-98 +94 +-98 +92 +-98 +95 +-97 +93 +-99 +92 +-97 +94 +-98 +92 +-98 +95 +-97 +93 +-99 +92 +-97 +94 +-98 +92 +-98 +95 +-97 +92 +-99 +93 +-97 +94 +-98 +92 +-98 +95 +-97 +92 +-100 +92 +-97 +94 +-98 +92 +-98 +95 +-97 +92 +-100 +92 +-97 +94 +-98 +92 +-98 +95 +-98 +92 +-99 +92 +-97 +94 +-98 +92 +-98 +94 +-98 +92 +-99 +93 +-97 +94 +-98 +92 +-98 +94 +-97 +92 +-100 +93 +-97 +94 +-98 +92 +-98 +94 +-98 +92 +-99 +93 +-97 +94 +-98 +92 +-98 +94 +-98 +92 +-99 +93 +-97 +94 +-98 +91 +-98 +94 +-98 +92 +-99 +93 +-97 +94 +-98 +91 +-99 +94 +-97 +93 +-99 +93 +-97 +94 +-98 +92 +-99 +94 +-97 +93 +-99 +93 +-96 +94 +-99 +91 +-99 +94 +-98 +93 +-99 +93 +-96 +94 +-99 +91 +-98 +95 +-97 +93 +-99 +93 +-96 +94 +-99 +91 +-99 +95 +-97 +93 +-99 +93 +-97 +93 +-99 +91 +-98 +95 +-97 +93 +-99 +93 +-97 +94 +-98 +92 +-98 +94 +-97 +93 +-98 +93 +-97 +94 +-98 +91 +-98 +95 +-97 +93 +-99 +93 +-98 +94 +-98 +91 +-98 +95 +-97 +93 +-99 +92 +-97 +94 +-98 +92 +-98 +95 +-97 +93 +-100 +92 +-98 +95 +-98 +92 +-97 +127 +82 +-114 +67 +-114 +78 +-107 +85 +-103 +89 +-102 +89 +-99 +91 +-100 +92 +-114 +-86 +122 +-68 +116 +-83 +103 +-90 +100 +-94 +95 +-95 +99 +-94 +94 +-98 +127 +78 +-114 +67 +-114 +78 +-107 +87 +-102 +89 +-102 +90 +-99 +92 +-100 +92 +-99 +93 +-98 +94 +-97 +92 +-98 +94 +-96 +93 +-100 +91 +-97 +93 +-98 +94 +-97 +94 +-98 +94 +-98 +91 +-99 +94 +-96 +93 +-99 +93 +-96 +93 +-98 +93 +-99 +93 +-98 +94 +-97 +92 +-98 +94 +-97 +93 +-99 +92 +-96 +94 +-98 +93 +-99 +92 +-99 +93 +-98 +92 +-98 +94 +-96 +93 +-99 +92 +-97 +93 +-98 +93 +-98 +93 +-98 +94 +-98 +91 +-98 +94 +-96 +93 +-99 +93 +-96 +93 +-99 +93 +-99 +93 +-98 +94 +-97 +92 +-99 +93 +-98 +93 +-97 +92 +-96 +93 +-98 +92 +-114 +-86 +123 +-68 +114 +-83 +105 +-88 +100 +-94 +96 +-95 +98 +-95 +94 +-97 +127 +82 +-114 +66 +-114 +78 +-107 +85 +-102 +90 +-101 +90 +-99 +91 +-100 +91 +-114 +-86 +122 +-68 +116 +-83 +103 +-90 +100 +-94 +95 +-95 +99 +-94 +95 +-97 +127 +78 +-114 +67 +-114 +77 +-107 +88 +-101 +89 +-102 +90 +-99 +92 +-100 +92 +-99 +93 +-98 +94 +-98 +92 +-98 +94 +-97 +93 +-99 +92 +-97 +93 +-99 +93 +-98 +93 +-98 +94 +-97 +92 +-99 +94 +-97 +93 +-99 +93 +-96 +94 +-98 +93 +-99 +92 +-99 +93 +-98 +92 +-98 +94 +-97 +93 +-99 +92 +-97 +94 +-98 +93 +-98 +93 +-98 +93 +-98 +92 +-98 +94 +-96 +93 +-99 +92 +-97 +93 +-99 +93 +-98 +93 +-98 +94 +-98 +91 +-99 +94 +-97 +93 +-98 +93 +-96 +94 +-98 +92 +-99 +93 +-98 +94 +-97 +92 +-98 +94 +-98 +92 +-98 +91 +-97 +93 +-98 +93 +-114 +-85 +123 +-68 +114 +-83 +105 +-88 +100 +-94 +96 +-95 +97 +-96 +93 +-97 +127 +81 +-114 +67 +-114 +78 +-107 +85 +-102 +90 +-101 +90 +-99 +92 +-100 +91 +-99 +93 +-98 +94 +-97 +92 +-99 +93 +-98 +92 +-99 +92 +-96 +94 +-98 +93 +-114 +-87 +121 +-68 +115 +-84 +104 +-89 +101 +-94 +95 +-95 +98 +-95 +94 +-97 +93 +-98 +92 +-98 +92 +-99 +93 +-97 +96 +-97 +92 +-98 +95 +-98 +91 +-99 +127 +79 +-114 +68 +-114 +78 +-108 +87 +-102 +88 +-103 +89 +-99 +92 +-99 +92 +-114 +-86 +122 +-68 +116 +-83 +104 +-90 +100 +-94 +95 +-95 +98 +-94 +95 +-97 +127 +79 +-114 +66 +-114 +77 +-108 +87 +-101 +90 +-101 +90 +-99 +91 +-100 +91 +-99 +93 +-98 +94 +-97 +92 +-99 +93 +-98 +92 +-99 +92 +-96 +94 +-98 +93 +-99 +93 +-98 +94 +-98 +92 +-98 +94 +-97 +93 +-97 +92 +-96 +93 +-98 +93 +-114 +-85 +123 +-69 +113 +-83 +105 +-89 +100 +-94 +97 +-94 +98 +-96 +93 +-98 +127 +81 +-114 +67 +-114 +79 +-107 +85 +-102 +89 +-102 +90 +-99 +92 +-100 +91 +-114 +-87 +122 +-68 +116 +-83 +104 +-89 +101 +-94 +94 +-96 +98 +-95 +94 +-97 +93 +-98 +92 +-98 +92 +-99 +93 +-97 +95 +-98 +92 +-98 +95 +-98 +92 +-99 +92 +-98 +93 +-97 +94 +-98 +92 +-98 +94 +-98 +91 +-98 +96 +-97 +93 +-98 +127 +78 +-114 +68 +-114 +78 +-107 +87 +-102 +88 +-103 +89 +-99 +92 +-99 +93 +-98 +93 +-98 +93 +-98 +91 +-98 +93 +-97 +93 +-99 +92 +-97 +93 +-98 +93 +-98 +93 +-98 +93 +-98 +91 +-99 +94 +-96 +93 +-99 +93 +-96 +93 +-99 +92 +-99 +92 +-98 +94 +-97 +92 +-98 +94 +-97 +92 +-99 +92 +-96 +94 +-98 +93 +-99 +92 +-98 +93 +-98 +92 +-98 +94 +-97 +93 +-98 +91 +-97 +93 +-99 +93 +-114 +-85 +123 +-68 +113 +-83 +105 +-89 +100 +-94 +96 +-94 +98 +-96 +93 +-98 +127 +78 +-114 +65 +-114 +81 +-107 +86 +-104 +89 +-100 +91 +-100 +90 +-100 +94 +-98 +92 +-99 +92 +-96 +94 +-98 +92 +-98 +94 +-99 +92 +-99 +92 +-96 +94 +-97 +92 +-98 +94 +-98 +92 +-99 +92 +-97 +93 +-98 +92 +-98 +94 +-98 +92 +-99 +92 +-96 +93 +-98 +92 +-99 +94 +-98 +92 +-99 +92 +-96 +94 +-98 +91 +-99 +94 +-98 +93 +-99 +93 +-96 +94 +-98 +91 +-99 +95 +-98 +93 +-99 +93 +-96 +93 +-99 +91 +-98 +95 +-97 +93 +-99 +93 +-96 +93 +-99 +91 +-98 +94 +-97 +93 +-99 +92 +-97 +93 +-99 +91 +-98 +95 +-98 +93 +-98 +92 +-97 +93 +-99 +91 +-98 +95 +-97 +93 +-98 +93 +-97 +93 +-98 +91 +-98 +95 +-97 +93 +-99 +92 +-97 +93 +-98 +92 +-98 +95 +-97 +93 +-99 +92 +-97 +93 +-99 +92 +-98 +95 +-98 +93 +-99 +92 +-97 +93 +-98 +92 +-98 +95 +-97 +93 +-99 +92 +-97 +93 +-98 +92 +-98 +95 +-97 +92 +-100 +92 +-97 +93 +-98 +92 +-98 +95 +-98 +92 +-99 +92 +-96 +94 +-98 +92 +-98 +95 +-99 +92 +-98 +95 +-97 +92 +-114 +-114 +-114 +-85 +-65 +-47 +-37 +-30 diff --git a/traces/hf_14b_raw_0600_st_sri512.pm3 b/traces/hf_14b_raw_0600_st_sri512.pm3 new file mode 100644 index 000000000..f3bf5b3c4 --- /dev/null +++ b/traces/hf_14b_raw_0600_st_sri512.pm3 @@ -0,0 +1,3072 @@ +127 +-8 +-7 +-8 +-8 +-8 +-7 +-8 +-8 +-8 +-7 +-8 +-8 +-8 +-8 +-9 +-8 +-8 +-8 +-8 +-7 +-8 +-8 +-8 +-8 +-8 +-8 +-8 +-8 +-8 +-7 +-8 +-7 +-8 +-8 +-8 +-8 +-8 +-8 +-7 +-8 +-8 +-7 +-8 +-8 +-8 +-7 +-8 +-8 +-8 +-8 +-8 +-8 +-8 +-8 +-8 +-8 +-8 +-8 +-8 +-7 +-7 +-7 +-8 +-8 +-8 +-8 +-8 +-8 +-8 +-8 +-8 +-7 +-8 +-8 +-8 +-8 +-8 +-7 +-7 +-7 +-8 +-8 +-8 +-8 +-8 +-7 +-8 +-8 +-8 +-8 +-8 +-8 +-8 +-8 +-9 +-8 +-8 +-7 +-7 +-7 +-7 +-8 +-8 +-8 +-8 +-8 +-8 +-8 +-8 +-7 +-7 +-7 +-8 +-8 +-8 +-7 +-8 +-8 +-8 +-7 +-8 +-8 +-8 +-8 +-8 +-7 +-8 +-8 +-8 +-7 +-7 +-8 +-8 +-8 +-8 +-8 +-8 +-8 +-8 +-7 +-7 +-7 +-8 +-8 +-8 +-8 +-8 +-7 +-8 +-7 +-7 +-8 +-8 +-8 +-8 +-7 +-8 +-8 +-8 +-7 +-8 +-7 +-8 +-8 +-8 +-8 +-8 +-8 +-8 +-7 +-8 +-7 +-7 +-7 +-9 +-8 +-8 +-7 +-8 +-7 +-8 +-8 +-8 +-8 +-8 +-8 +-8 +-8 +-7 +-7 +-8 +-7 +-8 +-8 +-8 +-8 +-8 +-8 +-7 +-7 +-7 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+-8 +-8 +-7 +-7 +-7 +-7 +-8 +-8 +-8 +-8 +-8 +-8 +-7 +-8 +-7 +-7 +-8 +-7 +-8 +-8 +-8 +-8 +-7 +-7 +-7 +-7 +-8 +-8 +-8 +-8 +-8 +-8 +-7 +-7 +-7 +-7 +-8 +-8 +-8 +-8 +-8 +-8 +-7 +-7 +-7 +-7 +-8 +-8 +-8 +-8 +-8 +-8 +-7 +-8 +-8 +-7 +-8 +-8 +-8 +-8 +-8 +-8 +-7 +-7 +-7 +-8 +-8 +-8 +-8 +-8 +-8 +-8 +-8 +-7 +-7 +-8 +-8 +-7 +-8 +-8 +-8 +-8 +-7 +-7 +-7 +-7 +-8 +-7 +-8 +-8 +-8 +-8 +-7 +-8 +-8 +-7 +-8 +-8 +-8 +-8 +-8 +-7 +-8 +-7 +-8 +-8 +-7 +-8 +-8 +-8 +-8 +-8 +-7 +-7 +-8 +-8 +-8 +-8 +-8 +-8 +-8 +-7 +-7 +-7 +-8 +-7 +-8 +-8 +-8 +-8 +60 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +115 +78 +52 +34 +21 +14 +9 +6 +4 +2 +-1 +-3 +-5 +-8 +-9 +-10 +-9 +-9 +-9 +-27 +-119 +-119 +-119 +-119 +-119 +-119 +-119 +-119 +-119 +-119 +-119 +-119 +-119 +-119 +-119 +-90 +-67 +-49 +-36 +-27 +-21 +-17 +-14 +-12 +-11 +-10 +-9 +-10 +-8 +-7 +-8 +30 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +120 +80 +53 +34 +21 +13 +9 +6 +5 +3 +1 +-2 +-5 +-7 +-9 +-11 +-12 +-10 +-9 +-28 +-119 +-119 +-119 +-119 +-119 +-119 +-119 +-119 +-119 +-119 +-119 +-119 +-119 +-119 +-118 +-85 +-63 +-46 +-35 +-27 +-21 +-17 +-15 +-13 +-11 +-9 +-8 +-8 +-8 +-8 +-8 +-8 +-8 +-8 +-8 +-7 +-7 +-7 +-7 +-8 +-8 +-8 +-8 +-8 +-8 +-7 +-7 +-7 +-8 +-8 +-7 +-8 +-8 +-8 +-8 +-7 +-7 +-7 +-7 +-8 +-8 +-8 +-8 +-8 +-8 +-7 +-8 +-8 +-7 +-8 +-8 +-8 +-8 +-8 +-8 +-7 +-8 +-7 +-8 +56 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +117 +79 +52 +-22 +-119 +-119 +-119 +-119 +-119 +-119 +-119 +-119 +-119 +-119 +-119 +-119 +-119 +-119 +-116 +-85 +-63 +-47 +-35 +-26 +-20 +-16 +-14 +-12 +-11 +-10 +-9 +-10 +-9 +-8 +-7 +-7 +-8 +-8 +-7 +-8 +-8 +-8 +-8 +-7 +-7 +-7 +-8 +-8 +-8 +-8 +-8 +-8 +-8 +-8 +-7 +-8 +-7 +-8 +-8 +-8 +-8 +-8 +-8 +-7 +-7 +-7 +-8 +-8 +-8 +-8 +-8 +-8 +-8 +-7 +-7 +-7 +-8 +-8 +-8 +-8 +-8 +-8 +-8 +-7 +-7 +-8 +-8 +-8 +-7 +-8 +-8 +-8 +-8 +-7 +-7 +-7 +-8 +-8 +-8 +-8 +-8 +-8 +-7 +-7 +-7 +-7 +-8 +-8 +-8 +-8 +-8 +-8 +-8 +-7 +-7 +-7 +-8 +-8 +-7 +-8 +-8 +-8 +-7 +-7 +-7 +-7 +-8 +-8 +-8 +-8 +-8 +-8 +-8 +-7 +-7 +-8 +-8 +-7 +-8 +-8 +-8 +-8 +-8 +-7 +-7 +-8 +-8 +47 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +119 +81 +53 +1 +-119 +-119 +-119 +-119 +-119 +-119 +-119 +-119 +-119 +-119 +-119 +-119 +-119 +-119 +-115 +-26 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +116 +79 +52 +33 +20 +11 +7 +3 +3 +2 +1 +-1 +-4 +-6 +-8 +-9 +-10 +-10 +-9 +-8 +-7 +-6 +-6 +-6 +-6 +-7 +-7 +-8 +-9 +-9 +-9 +-9 +-9 +-8 +-7 +-68 +-119 +-119 +-119 +-119 +-119 +-119 +-119 +-119 +-119 +-119 +-119 +-119 +-119 +-119 +-119 +-20 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +114 +77 +51 +13 +-119 +-119 +-119 +-119 +-119 +-119 +-119 +-119 +-119 +-119 +-119 +-119 +-119 +-119 +-119 +-87 +-64 +-48 +-36 +-28 +-22 +-18 +-15 +-12 +-10 +-10 +-8 +-9 +-8 +-8 +-8 +26 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +121 +81 +52 +33 +20 +13 +9 +7 +5 +4 +2 +-2 +-5 +-8 +-9 +-11 +-11 +-10 +-9 +-28 +-119 +-119 +-119 +-119 +-119 +-119 +-119 +-119 +-119 +-119 +-119 +-119 +-119 +-119 +-118 +-39 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +118 +81 +53 +33 +19 +10 +5 +3 +2 +2 +1 +0 +-2 +-5 +-8 +-10 +-11 +-11 +-11 +-40 +-119 +-119 +-119 +-119 +-119 +-119 +-119 +-119 +-119 +-119 +-119 +-119 +-119 +-119 +-118 +-27 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +117 +79 +51 +32 +20 +11 +6 +4 +2 +1 +1 +0 +-3 +-5 +-7 +-9 +-11 +-11 +-11 +-64 +-119 +-119 +-119 +-119 +-119 +-119 +-119 +-119 +-119 +-119 +-119 +-119 +-119 +-119 +-119 +-23 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +115 +78 +50 +-32 +-119 +-119 +-119 +-119 +-119 +-119 +-119 +-119 +-119 +-119 +-119 +-119 +-119 +-119 +-117 +-66 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +119 +81 +53 +15 +-119 +-119 +-119 +-119 +-119 +-119 +-119 +-119 +-119 +-119 +-119 +-119 +-119 +-119 +-119 +-88 +-64 +-47 +-35 +-27 +-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7 +-8 +-8 +-8 +-9 +-8 +-8 +-7 +-8 +-7 +-8 +-8 +-8 +-8 +-8 +-8 +-8 +-7 +-8 +-7 +-7 +-7 +-8 +-8 +-8 +-8 +-8 +-8 +-7 +-7 +-8 +-8 +-8 +-8 +-8 +-7 +-7 +-7 +-7 +-7 +-7 +-8 +-8 +-8 +-8 +-8 +-7 +-7 +-7 +-7 +-8 +-8 +-8 +-8 +-8 +-8 +-8 +-7 +-7 +-7 +-7 +-7 +-8 +-8 +-8 +-7 +-7 +-7 +-8 +-7 +-8 +-8 +-8 +-8 +-8 +-7 +-8 +-7 +-8 +-7 +-8 +-8 +-8 +-7 +-8 +-8 +-8 +-8 +-8 +-8 +-8 +-8 +-8 +-7 +-8 +-8 +-8 +-8 +-8 +-8 +-8 +-8 +-9 +-8 +-7 +-8 +-8 +-8 +-8 +-8 +-8 +-7 +-8 +-8 +-8 +-7 +-7 +-7 +-8 +-8 +-8 +-8 +-8 +-7 +-8 +-8 +-7 +-8 +-8 +-8 +-7 +-7 +-8 +-8 +-8 +-8 +-8 +-8 +-9 +-8 +-8 +-8 +-8 +-8 +-8 +-7 +-8 +-8 +127 +127 +41 +127 +-69 +127 +-111 +127 +-114 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +87 +-119 +47 +-119 +122 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +58 +127 +-67 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +87 +-119 +47 +-119 +122 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +72 +127 +-66 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +84 +-119 +44 +-119 +121 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +69 +127 +-65 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +83 +-119 +45 +-119 +121 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +72 +127 +-66 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +85 +-119 +47 +-119 +122 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +77 +127 +-65 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +86 +-119 +47 +-119 +122 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +68 +127 +-69 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +87 +-119 +46 +-119 +122 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +69 +127 +-66 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +85 +-119 +45 +-119 +121 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +66 +127 +-65 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +85 +-119 +45 +-119 +121 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +62 +127 +-68 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +84 +-119 +45 +-119 +122 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +62 +127 +-68 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +84 +-119 +45 +-119 +122 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +59 +127 +-67 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +84 +-119 +46 +-119 +122 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +57 +127 +-67 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 +127 +-119 diff --git a/traces/hf_14b_raw_10_ask_ctx.pm3 b/traces/hf_14b_raw_10_ask_ctx.pm3 new file mode 100644 index 000000000..8412b471e --- /dev/null +++ b/traces/hf_14b_raw_10_ask_ctx.pm3 @@ -0,0 +1,3072 @@ +-6 +-6 +-6 +-5 +-5 +-5 +-5 +-5 +-6 +-6 +-6 +-5 +-5 +-5 +-5 +-5 +-5 +-6 +-6 +-6 +-6 +-5 +-5 +-5 +-5 +-5 +-6 +-6 +-6 +-6 +-6 +-5 +-5 +-5 +-5 +-5 +-5 +-6 +-6 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-6 +-6 +-6 +-6 +-6 +-5 +-5 +-5 +-5 +-5 +-6 +-6 +-6 +-6 +-6 +-6 +-5 +-5 +-5 +-6 +-6 +-6 +-6 +-6 +-6 +-5 +-5 +-5 +-5 +-6 +-6 +-6 +-6 +-6 +-6 +-5 +-5 +-5 +-6 +-6 +-6 +-6 +-6 +-5 +-5 +-5 +-5 +-5 +-6 +-6 +-6 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-6 +-6 +-6 +-6 +-5 +-6 +-5 +-5 +-5 +-6 +-6 +-6 +-6 +-6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+-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-4 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +56 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +94 +69 +50 +35 +25 +16 +9 +5 +1 +-1 +-3 +-3 +-3 +-3 +-3 +-3 +-4 +-5 +-6 +-6 +-69 +-116 +-116 +-116 +-116 +-116 +-116 +-116 +-116 +-116 +-116 +-116 +-116 +-99 +-72 +-52 +-38 +-28 +-21 +-16 +-12 +-10 +-9 +-8 +-7 +-6 +-6 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-4 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +35 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +96 +70 +51 +36 +3 +-116 +-116 +-116 +-116 +-116 +-116 +-116 +-116 +-116 +-116 +-116 +-116 +-96 +-69 +-50 +-37 +-28 +-21 +-16 +-13 +-10 +-8 +-7 +-7 +-6 +-6 +-6 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +51 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +95 +69 +50 +36 +-25 +-116 +-116 +-116 +-116 +-116 +-116 +-116 +-116 +-116 +-116 +-116 +-116 +-96 +-70 +-51 +22 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +125 +91 +66 +48 +34 +-35 +-116 +-116 +-116 +-116 +-116 +-116 +-116 +-116 +-116 +-116 +-116 +-116 +-96 +-69 +-50 +-37 +-27 +-21 +-16 +-13 +-10 +-9 +-8 +-7 +-6 +-5 +-5 +-5 +-5 +-5 +-5 +61 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +93 +68 +49 +35 +24 +16 +10 +5 +1 +-1 +-2 +-3 +-3 +-4 +-3 +-4 +-4 +-4 +-5 +-5 +-6 +-7 +-7 +-6 +-6 +-6 +-5 +-4 +-5 +-5 +-5 +-6 +-6 +-6 +-6 +-6 +-6 +-5 +-5 +-5 +-5 +-5 +-6 +-6 +-6 +-6 +-6 +-6 +-6 +-6 +-6 +-6 +-6 +-5 +-5 +-5 +-6 +-5 +-5 +-6 +-6 +-7 +-6 +-6 +-6 +-5 +-5 +-5 +-5 +-5 +-5 +-6 +-6 +-6 +-6 +-6 +-5 +-5 +-5 +-5 +-5 +-5 +-6 +-5 +-34 +-116 +-116 +-116 +-116 +-116 +-116 +-116 +-116 +-116 +-116 +-116 +-116 +-99 +-72 +-52 +-38 +-28 +-21 +-16 +-13 +-10 +-9 +-8 +-7 +-6 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-4 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5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-6 +-6 +-5 +-5 +-5 +-6 +-5 +-5 +-5 +-6 +-6 +-6 +-6 +-5 +-6 +-6 +-5 +-5 +-6 +-7 +127 +127 +-38 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +10 +-116 +101 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +-2 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +10 +-116 +100 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +-1 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +11 +-116 +100 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +-1 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +10 +-116 +101 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +-2 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +10 +-116 +100 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +-2 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +10 +-116 +101 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +-1 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +11 +-116 +100 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +-1 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +10 +-116 +100 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +-1 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +10 +-116 +101 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +-1 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +127 +-116 +-116 +-116 +-84 +-61 +-45 +-35 +-28 +-23 +-19 +-15 +-12 +-9 +-7 +-6 +-5 +-6 +-6 +-7 +-7 +-7 +-7 +-6 +-6 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-6 +-5 +-6 +-7 +-6 +-6 +-6 +-6 +-5 +-5 +-4 +-5 +-5 +-5 +-6 +-6 +-6 +-6 +-6 +-6 +-5 +-5 +-5 +-5 +-5 +-5 +-6 +-6 +-6 +-6 +-6 +-6 +-6 +-5 +-5 +-5 +-6 +-6 +-6 +-6 +-6 +-6 +-6 +-5 +-5 +-6 +-6 +-6 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-6 +-6 +-5 +-5 +-5 +-5 +-5 +-5 +-5 +-6 +-6 +-6 +-6 +-5 +-4 +-5 +-5 +-5 +-5 +-6 +-6 +-6 +-6 +-5 +-5 +-5 +-5 +-5 +-6 +-6 +-6 +-6 +-5 +-5 +-5 +-5 +-5 +-6 +-6 +-6 +-6 +-6 +-5 +-5 +-5 +-5 +-5 +-6 +-6 +-6 +-5 +-6 +-5 +-5 +-5 +-5 +-6 +-5 +-6 +-6 +-6 +-6 +-6 +-5 +-5 +-5 +-6 +-5 +-6 +-5 +-5 +-6 +-5 +-5 +-5 +-5 +-6 +-6 +-6 +-6 +-6 +-5 +-5 +-5 +-5 +-6 +-6 +-6 +-6 +-6 +-6 +-5 +-5 +-5 +-5 +-6 +-6 +-6 +-5 +-5 +-6 +-5 +-5 +-5 +-5 +-6 +-6 +-6 +-6 +-6 +-6 +-5 +-5 +-5 +-5 +-6 +-6 +-6 +-5 +-6 +-5 +-5 +-5 +-5 +-5 From affd92f79acbe662b5280ce2271abe828180b1fe Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Fri, 2 Oct 2020 01:29:21 +0200 Subject: [PATCH 08/28] hf 14b reader - added simple ask ct detection --- client/src/cmdhf14b.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/client/src/cmdhf14b.c b/client/src/cmdhf14b.c index ebb865d06..59d53b221 100644 --- a/client/src/cmdhf14b.c +++ b/client/src/cmdhf14b.c @@ -810,6 +810,39 @@ static bool HF14B_Std_Reader(bool verbose) { return is_success; } +static bool HF14B_ask_ct_Reader(bool verbose) { + uint8_t cmd[] = {0x10}; + uint8_t datalen = 1; + + // 14b get and print UID only (general info) + uint32_t flags = ISO14B_CONNECT | ISO14B_RAW | ISO14B_APPEND_CRC; + + clearCommandBuffer(); + PacketResponseNG resp; + SendCommandMIX(CMD_HF_ISO14443B_COMMAND, flags, datalen, 0, cmd, sizeof(cmd)); + + if (!WaitForResponseTimeout(CMD_HF_ISO14443B_COMMAND, &resp, TIMEOUT)) { + if (verbose) PrintAndLogEx(WARNING, "command execution timeout"); + switch_off_field_14b(); + return false; + } + + int status = resp.oldarg[0]; + PrintAndLogEx(DEBUG, "status %d", status); + bool retval = false; + if (status == 0) { + PrintAndLogEx(SUCCESS, "\nASK CT - 14443-3b tag found:"); + retval = true; + } else if (status > 0) { + PrintAndLogEx(SUCCESS, "\nASK CT - 14443-3b tag found:"); + PrintAndLogEx(SUCCESS, "%s", sprint_hex(resp.data.asBytes, status)); + retval = true; + } + + switch_off_field_14b(); + return retval; +} + // test for other 14b type tags (mimic another reader - don't have tags to identify) static bool HF14B_Other_Reader(bool verbose) { @@ -1749,6 +1782,9 @@ int readHF14B(bool verbose) { if (HF14B_Other_Reader(verbose)) return 1; + if (HF14B_ask_ct_Reader(verbose)) + return 1; + if (verbose) PrintAndLogEx(FAILED, "no 14443-B tag found"); return 0; } From fc6492288ca3f46e4c1b2aa6751845278769fe7c Mon Sep 17 00:00:00 2001 From: Philippe Teuwen Date: Fri, 2 Oct 2020 02:20:35 +0200 Subject: [PATCH 09/28] add trace --- traces/README.md | 1 + .../hf_14b_raw_0600_st_sri512_collision.pm3 | 3072 +++++++++++++++++ 2 files changed, 3073 insertions(+) create mode 100644 traces/hf_14b_raw_0600_st_sri512_collision.pm3 diff --git a/traces/README.md b/traces/README.md index 9d0271cc9..2c28d2e8e 100644 --- a/traces/README.md +++ b/traces/README.md @@ -66,6 +66,7 @@ |--------|-----------| |hf_14b_raw_050008_resp.pm3 |Response of 14b card to `hf 14b raw -c 050008`| |hf_14b_raw_0600_st_sri512.pm3 |Response of ST SRI512 to `hf 14b raw -c 0600`| +|hf_14b_raw_0600_st_sri512_collision.pm3 |Same but with two cards, showing the collisions in answers| |hf_14b_raw_10_ask_ctx.pm3 |Response of ASK CTx to `hf 14b raw -c 10`| |hf_14b_raw_010fxxxxxxxx_innovatron.pm3 |Response of 14b' card to `hf 14b raw -c -k 010fxxxxxxxx`| diff --git a/traces/hf_14b_raw_0600_st_sri512_collision.pm3 b/traces/hf_14b_raw_0600_st_sri512_collision.pm3 new file mode 100644 index 000000000..a7782819a --- /dev/null +++ b/traces/hf_14b_raw_0600_st_sri512_collision.pm3 @@ -0,0 +1,3072 @@ +22 +7 +8 +8 +8 +7 +9 +8 +8 +7 +8 +7 +7 +7 +8 +8 +7 +8 +8 +6 +8 +8 +8 +7 +8 +8 +8 +7 +8 +8 +7 +8 +9 +7 +8 +8 +8 +7 +8 +8 +7 +8 +7 +9 +9 +8 +8 +8 +8 +6 +7 +7 +8 +8 +9 +9 +8 +8 +8 +7 +7 +8 +8 +8 +7 +8 +7 +8 +8 +7 +8 +7 +9 +7 +7 +8 +8 +7 +7 +9 +8 +8 +8 +8 +9 +8 +8 +8 +7 +7 +7 +8 +8 +8 +8 +8 +9 +7 +7 +7 +7 +8 +8 +7 +8 +9 +8 +8 +8 +8 +7 +7 +8 +7 +8 +8 +8 +8 +8 +9 +8 +7 +8 +8 +9 +7 +7 +7 +7 +6 +8 +8 +8 +8 +9 +8 +8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 +7 +7 +6 +7 +7 +7 +7 +7 +8 +8 +8 +7 +6 +7 +7 +6 +6 +8 +8 +9 +8 +7 +6 +7 +6 +6 +6 +8 +8 +8 +8 +8 +58 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +120 +86 +65 +51 +41 +34 +27 +21 +16 +9 +6 +4 +3 +4 +7 +7 +11 +13 +13 +11 +-14 +-104 +-104 +-104 +-104 +-104 +-104 +-104 +-104 +-104 +-104 +-104 +-104 +-104 +-104 +-77 +-54 +-36 +-24 +-16 +-10 +-6 +-3 +1 +4 +6 +6 +7 +7 +7 +7 +7 +70 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +117 +84 +65 +52 +44 +35 +27 +22 +15 +9 +4 +2 +2 +3 +6 +10 +12 +13 +14 +12 +-16 +-104 +-104 +-104 +-104 +-104 +-104 +-104 +-104 +-104 +-104 +-104 +-104 +-104 +-104 +-76 +-52 +-35 +-23 +-14 +-7 +-4 +-1 +1 +2 +4 +5 +6 +6 +8 +8 +8 +8 +7 +6 +6 +5 +6 +6 +7 +8 +9 +8 +8 +7 +7 +6 +6 +6 +7 +7 +8 +7 +7 +6 +7 +7 +6 +6 +8 +8 +9 +7 +7 +6 +7 +7 +6 +6 +8 +8 +9 +8 +6 +6 +7 +7 +6 +6 +8 +48 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +119 +87 +65 +51 +17 +-104 +-104 +-104 +-104 +-104 +-104 +-104 +-104 +-104 +-104 +-104 +-104 +-104 +-104 +-78 +-55 +-37 +-24 +-16 +-9 +-5 +-2 +1 +4 +6 +5 +6 +7 +7 +7 +6 +6 +7 +8 +8 +8 +7 +6 +7 +6 +7 +6 +7 +8 +9 +7 +6 +7 +6 +6 +7 +6 +7 +7 +8 +8 +8 +6 +6 +6 +6 +6 +7 +7 +8 +7 +6 +7 +7 +7 +7 +6 +7 +8 +8 +8 +8 +7 +7 +6 +6 +6 +7 +8 +8 +8 +7 +7 +6 +6 +7 +5 +6 +7 +8 +8 +8 +8 +6 +7 +7 +6 +7 +8 +8 +8 +8 +6 +7 +6 +6 +7 +7 +7 +9 +8 +8 +7 +7 +6 +6 +6 +7 +8 +8 +8 +8 +7 +7 +6 +6 +5 +6 +7 +8 +8 +8 +7 +7 +7 +6 +6 +6 +77 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +117 +85 +64 +51 +4 +-104 +-104 +-104 +-104 +-104 +-104 +-104 +-104 +-104 +-104 +-104 +-104 +-104 +-104 +-74 +19 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +113 +80 +61 +48 +39 +35 +28 +22 +16 +12 +7 +3 +3 +3 +4 +6 +10 +11 +12 +13 +11 +10 +7 +6 +5 +4 +4 +5 +7 +8 +9 +11 +11 +10 +8 +8 +-19 +-104 +-104 +-104 +-104 +-104 +-104 +-104 +-104 +-104 +-104 +-104 +-104 +-104 +-104 +-78 +-3 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +112 +81 +61 +49 +17 +-104 +-104 +-104 +-104 +-104 +-104 +-104 +-104 +-104 +-104 +-104 +-104 +-104 +-104 +-79 +-55 +-38 +-24 +-14 +-7 +-3 +0 +1 +2 +3 +3 +5 +6 +8 +8 +9 +70 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +118 +84 +65 +51 +42 +33 +28 +21 +14 +10 +5 +5 +3 +3 +7 +8 +9 +11 +13 +13 +-17 +-104 +-104 +-104 +-104 +-104 +-104 +-104 +-104 +-104 +-104 +-104 +-104 +-104 +-104 +-75 +14 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +110 +78 +59 +48 +40 +36 +31 +24 +19 +12 +6 +3 +1 +2 +3 +6 +10 +12 +13 +13 +-22 +-104 +-104 +-104 +-104 +-104 +-104 +-104 +-104 +-104 +-104 +-104 +-104 +-104 +-104 +-76 +17 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +111 +78 +59 +47 +40 +35 +30 +25 +19 +13 +7 +3 +1 +1 +2 +6 +9 +12 +13 +13 +-11 +-104 +-104 +-104 +-104 +-104 +-104 +-104 +-104 +-104 +-104 +-104 +-104 +-104 +-104 +-79 +-9 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +113 +81 +61 +48 +15 +-104 +-104 +-104 +-104 +-104 +-104 +-104 +-104 +-104 +-104 +-104 +-104 +-104 +-104 +-79 +-1 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +115 +83 +63 +50 +15 +-104 +-104 +-104 +-104 +-104 +-104 +-104 +-104 +-104 +-104 +-104 +-104 +-104 +-104 +-79 +-55 +-37 +-24 +-14 +-7 +-4 +-1 +1 +2 +4 +5 +6 +5 +8 +8 +8 +8 +7 +6 +6 +6 +6 +6 +8 +8 +8 +8 +7 +6 +7 +6 +6 +5 +7 +7 +8 +8 +8 +6 +7 +7 +6 +6 +7 +8 +8 +8 +8 +6 +7 +7 +6 +6 +7 +7 +8 +8 +8 +6 +7 +6 +7 +6 +7 +8 +8 +7 +8 +6 +7 +7 +6 +6 +7 +7 +8 +8 +8 +7 +7 +7 +6 +6 +6 +8 +8 +8 +8 +7 +6 +6 +6 +6 +7 +8 +8 +8 +7 +7 +6 +6 +6 +6 +6 +8 +9 +8 +8 +7 +6 +6 +7 +6 +6 +7 +8 +8 +8 +7 +7 +7 +6 +6 +5 +7 +9 +8 +9 +7 +6 +7 +6 +6 +7 +7 +8 +8 +8 +7 +7 +6 +6 +6 +6 +55 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +127 +120 +87 +65 +52 +42 +35 +28 +22 +14 +10 +5 +4 +2 +5 +6 +8 +11 +11 +11 +12 +10 +8 +7 +5 +4 +4 +5 +8 +8 +9 +10 +9 +10 +10 +8 +7 +6 +6 +6 +5 +8 +7 +9 +8 +10 +8 +9 +8 +7 +9 +6 +6 +6 +8 +8 +9 +10 +8 +8 +9 +8 +7 +8 +7 +8 +7 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 +9 +8 +8 +7 +7 +7 +7 +9 +8 +8 +9 +8 +9 +8 +7 +8 +7 +7 +8 +8 +8 +8 +9 +8 +8 +7 +8 +7 +8 +8 +8 +8 +8 +8 +8 +8 +9 +8 +8 +8 +7 +9 +8 +8 +8 +7 +8 +8 +9 +8 +8 +8 +8 +8 +7 +8 +8 +7 +7 +9 +9 +8 +8 +8 +8 +8 +8 +8 +8 +8 +9 +8 +9 +8 +7 +7 +7 +8 +8 +8 +8 +8 +8 +7 +9 +7 +7 +7 +7 +8 +7 +9 +7 +8 +8 +9 +8 +8 +7 +8 +8 +8 +8 +8 +9 +8 +9 +8 +8 +7 +10 +8 +7 +8 +8 +7 +8 +8 +8 +8 +8 +8 +8 +7 +8 +8 +7 +8 +8 +8 +8 +9 +8 +7 +7 +8 +8 +8 +8 +8 +8 +8 +7 +8 +8 +8 +9 +8 +9 +7 +8 +8 +8 +8 +8 +8 +8 +8 +9 +8 +9 +7 +7 +7 +8 +8 +8 +8 +9 +8 +9 +8 +8 +6 +7 +23 +55 +1 +34 +-9 +29 +-13 +28 +-15 +26 +-17 +23 +-20 +20 +-22 +20 +-21 +20 +-18 +23 +-18 +23 +-17 +22 +-19 +21 +-20 +19 +-21 +21 +-19 +22 +-18 +23 +-18 +21 +-19 +21 +-20 +21 +-19 +21 +-19 +22 +-18 +22 +-19 +22 +-19 +21 +-19 +21 +-19 +21 +-20 +21 +-20 +21 +-18 +23 +-19 +21 +-19 +21 +-19 +21 +-19 +21 +-19 +22 +-18 +22 +-19 +23 +-19 +20 +-20 +21 +-19 +21 +-19 +22 +-19 +21 +-19 +21 +-20 +21 +-18 +21 +-18 +22 +-18 +21 +-19 +22 +-19 +22 +-18 +22 +-19 +21 +-18 +21 +-19 +22 +-18 +22 +-19 +22 +-19 +21 +-19 +21 +-19 +21 +-19 +22 +-19 +21 +-19 +21 +-19 +21 +-19 +21 +-20 +22 +-18 +21 +-19 +22 +-19 +22 +-20 +21 +-19 +21 +-18 +22 +-19 +21 +-19 +21 +-19 +21 +-18 +21 +-19 +21 +-18 +21 +-19 +22 +-19 +21 +-19 +22 +-19 +21 +-19 +21 +-20 +21 +-19 +21 +-19 +22 +-18 +21 +-18 +21 +-20 +21 +-20 +22 +-18 +21 +-18 +22 +-19 +21 +-19 +22 +-20 +23 +-18 +21 +-19 +21 +-19 +21 +-20 +22 +-18 +21 +-19 +22 +-19 +21 +-20 +21 +-19 +21 +-19 +22 +-18 +22 +-19 +22 +-20 +21 +-19 +21 +-18 +22 +-19 +22 +-18 +23 +-21 +22 +-18 +22 +-19 +22 +-18 +21 +-20 +21 +-19 +21 +-19 +22 +-18 +21 +-19 +22 +-20 +21 +-19 +21 +-19 +21 +-19 +22 +-18 +22 +-19 +21 +-20 +22 +-20 +21 +-19 +22 +-18 +21 +-19 +111 +-1 +-46 +3 +-31 +14 +-23 +19 +-22 +18 +-21 +19 +-20 +20 +-19 +22 +-18 +21 +-18 +21 +-19 +21 +-19 +21 +-19 +21 +-18 +20 +-20 +21 +-19 +21 +-18 +21 +-19 +21 +-18 +21 +-20 +21 +-18 +21 +-19 +22 +-18 +21 +-19 +21 +-19 +20 +-19 +21 +-19 +21 +-18 +22 +-19 +21 +-18 +21 +-19 +21 +-18 +21 +-18 +21 +-19 +20 +-19 +21 +-19 +21 +-18 +22 +-18 +21 +-19 +20 +-20 +21 +-19 +21 +-19 +22 +-17 +21 +-20 +22 +-18 +21 +-19 +21 +-19 +21 +-19 +21 +-20 +21 +-18 +21 +-18 +21 +-18 +21 +-19 +21 +-19 +20 +-18 +22 +-18 +21 +-18 +22 +-19 +20 +-19 +21 +-20 +21 +-19 +21 +-19 +22 +-19 +20 +-19 +22 +-19 +21 +-19 +21 +-18 +21 +-19 +21 +-19 +21 +-18 +21 +-19 +21 +-19 +21 +-20 +21 +-19 +21 +-18 +22 +-18 +22 +-19 +21 +-20 +20 +-19 +21 +-18 +22 +-31 +-9 +33 +-13 +24 +-18 +22 +-18 +22 +-18 +23 +-16 +23 +-18 +22 +-19 +20 +-20 +21 +-20 +21 +-19 +22 +-19 +22 +-17 +23 +-18 +22 +-19 +21 +-20 +111 +-1 +-47 +3 +-30 +15 +-22 +19 +-20 +19 +-23 +18 +-21 +19 +-20 +22 +-18 +23 +-17 +22 +-19 +20 +-19 +21 +-20 +20 +-19 +21 +-19 +21 +-17 +21 +-18 +-3 +95 +-9 +77 +-19 +70 +-23 +68 +-23 +67 +-25 +68 +-25 +67 +-27 +65 +-2 +-48 +0 +-32 +13 +-24 +19 +-20 +20 +-21 +21 +-21 +19 +-20 +21 +-33 +94 +-8 +78 +-18 +70 +-22 +68 +-24 +67 +-25 +66 +-26 +66 +-26 +65 +-19 +-6 +-38 +10 +-26 +16 +-22 +18 +-20 +19 +-20 +20 +-19 +20 +-19 +21 +-18 +-3 +95 +-8 +79 +-18 +71 +-22 +68 +-24 +67 +-26 +67 +-26 +67 +-26 +-20 +-21 +19 +-23 +17 +-21 +20 +-19 +21 +-17 +23 +-17 +23 +-19 +20 +-20 +110 +-1 +-47 +3 +-30 +15 +-23 +19 +-20 +19 +-22 +19 +-22 +19 +-20 +22 +-32 +-9 +35 +-11 +26 +-18 +22 +-19 +21 +-19 +21 +-19 +22 +-17 +23 +-17 +112 +-1 +-47 +1 +-32 +13 +-24 +18 +-20 +20 +-20 +20 +-20 +20 +-20 +21 +-19 +21 +-19 +22 +-18 +21 +-19 +21 +-19 +21 +-19 +21 +-19 +21 +-18 +21 +-19 +21 +-18 +21 +-19 +21 +-18 +22 +-18 +22 +-19 +20 +-19 +21 +-19 +21 +-31 +-9 +34 +-13 +24 +-19 +22 +-19 +22 +-18 +23 +-16 +24 +-18 +22 +-19 +110 +-28 +65 +-25 +67 +-24 +67 +-24 +67 +-26 +66 +-27 +64 +-27 +65 +-27 +-21 +86 +-24 +67 +-24 +67 +-25 +66 +-25 +66 +-27 +65 +-27 +65 +-27 +66 +-26 +-35 +16 +-24 +17 +-23 +19 +-21 +19 +-20 +22 +-18 +22 +-18 +22 +-19 +112 +-27 +66 +-25 +66 +-23 +66 +-26 +66 +-26 +65 +-27 +66 +-27 +66 +-26 +66 +-1 +-48 +2 +-31 +13 +-24 +18 +-22 +19 +-21 +20 +-21 +20 +-19 +21 +-32 +-9 +34 +-11 +24 +-18 +22 +-19 +22 +-19 +23 +-18 +23 +-18 +22 +-19 +110 +0 +-47 +2 +-31 +14 +-22 +20 +-21 +19 +-21 +19 +-20 +19 +-20 +21 +-18 +22 +-18 +22 +-18 +21 +-18 +21 +-19 +20 +-20 +21 +-19 +20 +-18 +23 +-32 +95 +-8 +77 +-19 +71 +-24 +67 +-25 +68 +-25 +67 +-25 +67 +-27 +65 +-27 +65 +-27 +65 +-26 +66 +-24 +67 +-26 +66 +-26 +66 +-26 +65 +-27 +65 +-27 +65 +-26 +65 +-26 +65 +-26 +65 +-27 +66 +-27 +65 +-26 +66 +-25 +66 +-25 +-34 +17 +-25 +18 +-23 +17 +-21 +20 +-19 +21 +-18 +23 +-18 +22 +-19 +21 +-20 +20 +-20 +21 +-19 +23 +-17 +21 +-19 +22 +-19 +21 +-19 +21 +-18 +111 +0 +-46 +3 +-31 +14 +-22 +19 +-21 +19 +-21 +18 +-21 +19 +-20 +21 +-17 +-1 +96 +-8 +79 +-19 +70 +-23 +68 +-26 +67 +-25 +68 +-25 +67 +-26 +-20 +-22 +19 +-22 +19 +-22 +21 +-19 +21 +-19 +23 +-18 +22 +-18 +22 +-19 +110 +-1 +-48 +1 +-30 +15 +-22 +19 +-20 +20 +-21 +18 +-21 +18 +-21 +20 +-18 +22 +-17 +23 +-18 +21 +-19 +21 +-20 +20 +-20 +21 +-18 +21 +-18 +22 +-18 +22 +-18 +21 +-19 +20 +-19 +21 +-19 +21 +-18 +21 +-18 +21 +-18 +21 +-18 +21 +-19 +21 +-18 +22 +-19 +22 +-18 +22 +-18 +21 +-19 +20 +-20 +21 +-19 +21 +-19 +22 +-19 +20 +-18 +21 +-19 +21 +-18 +21 +-18 +21 +-18 +21 +-19 +21 +-19 +21 +-19 +22 +-19 +21 +-19 +21 +-19 +21 +-18 +22 +-19 +22 +-18 +21 +-19 +21 +-19 +21 +-19 +22 +-18 +22 +-18 +22 +-19 +20 +-19 +21 +-19 +21 +-18 +22 +-18 +21 +-18 +21 +-19 +21 +-18 +20 +-19 +21 +-19 +20 +-19 +21 +-18 +21 +-19 +21 +-20 +21 +-19 +21 +-20 +21 +-18 +21 +-19 +22 +-18 +22 +-20 +21 +-19 +21 +-18 +22 +-18 +21 +-18 +21 +-19 +20 +-19 +21 +-33 +-9 +34 +-12 +25 +-17 +22 +-19 +22 +-18 +23 +-17 +23 +-17 +22 +-19 +21 +-20 +20 +-21 +22 +-20 +22 +-17 +22 +-19 +21 +-19 +21 +-19 +21 +-18 +21 +-19 From 67c175fe7a760ca0cd956c2e767107e5c0980fba Mon Sep 17 00:00:00 2001 From: Philippe Teuwen Date: Fri, 2 Oct 2020 02:56:29 +0200 Subject: [PATCH 10/28] hf 14b reader: show actual ASK CTx UID --- client/src/cmdhf14b.c | 70 ++++++++++++++++++++++++++++++++----------- 1 file changed, 53 insertions(+), 17 deletions(-) diff --git a/client/src/cmdhf14b.c b/client/src/cmdhf14b.c index 59d53b221..9bdeb8c91 100644 --- a/client/src/cmdhf14b.c +++ b/client/src/cmdhf14b.c @@ -811,15 +811,19 @@ static bool HF14B_Std_Reader(bool verbose) { } static bool HF14B_ask_ct_Reader(bool verbose) { - uint8_t cmd[] = {0x10}; - uint8_t datalen = 1; + uint8_t cmd1[] = {0x10}; + uint8_t cmd2[] = {0x9F, 0xFF, 0xFF}; + uint8_t cmd3[] = {0xC4}; + uint8_t uid[4]; + uint8_t pc, fc; // 14b get and print UID only (general info) uint32_t flags = ISO14B_CONNECT | ISO14B_RAW | ISO14B_APPEND_CRC; + PacketResponseNG resp; + int status; clearCommandBuffer(); - PacketResponseNG resp; - SendCommandMIX(CMD_HF_ISO14443B_COMMAND, flags, datalen, 0, cmd, sizeof(cmd)); + SendCommandMIX(CMD_HF_ISO14443B_COMMAND, flags, sizeof(cmd1), 0, cmd1, sizeof(cmd1)); if (!WaitForResponseTimeout(CMD_HF_ISO14443B_COMMAND, &resp, TIMEOUT)) { if (verbose) PrintAndLogEx(WARNING, "command execution timeout"); @@ -827,20 +831,52 @@ static bool HF14B_ask_ct_Reader(bool verbose) { return false; } - int status = resp.oldarg[0]; - PrintAndLogEx(DEBUG, "status %d", status); - bool retval = false; - if (status == 0) { - PrintAndLogEx(SUCCESS, "\nASK CT - 14443-3b tag found:"); - retval = true; - } else if (status > 0) { - PrintAndLogEx(SUCCESS, "\nASK CT - 14443-3b tag found:"); - PrintAndLogEx(SUCCESS, "%s", sprint_hex(resp.data.asBytes, status)); - retval = true; + status = resp.oldarg[0]; + PrintAndLogEx(DEBUG, "status cmd1 %d", status); + if (status == 4) { + pc = resp.data.asBytes[0]; + fc = resp.data.asBytes[1]; + } else { + switch_off_field_14b(); + return false; + } + clearCommandBuffer(); + SendCommandMIX(CMD_HF_ISO14443B_COMMAND, flags, sizeof(cmd2), 0, cmd2, sizeof(cmd2)); + if (!WaitForResponseTimeout(CMD_HF_ISO14443B_COMMAND, &resp, TIMEOUT)) { + if (verbose) PrintAndLogEx(WARNING, "command execution timeout"); + switch_off_field_14b(); + return false; + } + status = resp.oldarg[0]; + PrintAndLogEx(DEBUG, "status cmd2 %d", status); + if (status == 4) { + uid[0] = resp.data.asBytes[0]; + uid[1] = resp.data.asBytes[1]; + } else { + switch_off_field_14b(); + return false; + } + clearCommandBuffer(); + SendCommandMIX(CMD_HF_ISO14443B_COMMAND, flags, sizeof(cmd3), 0, cmd3, sizeof(cmd3)); + if (!WaitForResponseTimeout(CMD_HF_ISO14443B_COMMAND, &resp, TIMEOUT)) { + if (verbose) PrintAndLogEx(WARNING, "command execution timeout"); + switch_off_field_14b(); + return false; + } + status = resp.oldarg[0]; + PrintAndLogEx(DEBUG, "status cmd3 %d", status); + if (status == 4) { + uid[2] = resp.data.asBytes[0]; + uid[3] = resp.data.asBytes[1]; + uint32_t uid32 = uid[0] + (uid[1] << 8) + (uid[2] << 16) + (uid[3] << 24); + PrintAndLogEx(SUCCESS, "\nASK CT - 14443-3b tag found:"); + PrintAndLogEx(SUCCESS, "UID: %02X%02X%02X%02X (%u) Product code: %02X Fab code: %02X", uid[0], uid[1], uid[2], uid[3], uid32, pc, fc); + switch_off_field_14b(); + return true; + } else { + switch_off_field_14b(); + return false; } - - switch_off_field_14b(); - return retval; } // test for other 14b type tags (mimic another reader - don't have tags to identify) From 5202eb8587e868bc0de777c8b5bbafb84cf21135 Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Fri, 2 Oct 2020 14:30:15 +0200 Subject: [PATCH 11/28] broke out type prototyping from mifare.h --- include/iso14b.h | 43 +++++++++++++++++ include/iso15.h | 33 +++++++++++++ include/iso18.h | 119 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 195 insertions(+) create mode 100644 include/iso14b.h create mode 100644 include/iso15.h create mode 100644 include/iso18.h diff --git a/include/iso14b.h b/include/iso14b.h new file mode 100644 index 000000000..e1baf231a --- /dev/null +++ b/include/iso14b.h @@ -0,0 +1,43 @@ +//----------------------------------------------------------------------------- +// (c) 2020 Iceman +// +// This code is licensed to you under the terms of the GNU GPL, version 2 or, +// at your option, any later version. See the LICENSE.txt file for the text of +// the license. +//----------------------------------------------------------------------------- +// ISO 14443B type prototyping +//----------------------------------------------------------------------------- + +#ifndef _ISO14B_H_ +#define _ISO14B_H_ + +#include "common.h" +typedef struct { + uint8_t uid[10]; + uint8_t uidlen; + uint8_t atqb[7]; + uint8_t chipid; + uint8_t cid; +} PACKED iso14b_card_select_t; + +typedef struct { + uint8_t uid[4]; + uint8_t pc; + uint8_t fc; +} PACKED iso14b_cts_card_select_t; + +typedef enum ISO14B_COMMAND { + ISO14B_CONNECT = (1 << 0), + ISO14B_DISCONNECT = (1 << 1), + ISO14B_APDU = (1 << 2), + ISO14B_RAW = (1 << 3), + ISO14B_REQUEST_TRIGGER = (1 << 4), + ISO14B_APPEND_CRC = (1 << 5), + ISO14B_SELECT_STD = (1 << 6), + ISO14B_SELECT_SR = (1 << 7), + ISO14B_SET_TIMEOUT = (1 << 8), + ISO14B_SEND_CHAINING = (1 << 9), + ISO14B_SELECT_CTS = (1 << 10), +} iso14b_command_t; + +#endif // _ISO14B_H_ \ No newline at end of file diff --git a/include/iso15.h b/include/iso15.h new file mode 100644 index 000000000..228669cda --- /dev/null +++ b/include/iso15.h @@ -0,0 +1,33 @@ +//----------------------------------------------------------------------------- +// (c) 2020 Iceman +// +// This code is licensed to you under the terms of the GNU GPL, version 2 or, +// at your option, any later version. See the LICENSE.txt file for the text of +// the license. +//----------------------------------------------------------------------------- +// ISO 15693 type prototyping +//----------------------------------------------------------------------------- + +#ifndef _ISO15_H_ +#define _ISO15_H_ + +#include "common.h" +typedef struct { + uint8_t uid[10]; + uint8_t uidlen; + uint8_t atqb[7]; + uint8_t chipid; + uint8_t cid; +} PACKED iso14b_card_select_t; + +typedef enum ISO15_COMMAND { + ISO15_CONNECT = (1 << 0), + ISO15_NO_DISCONNECT = (1 << 1), + ISO15_RAW = (1 << 2), + ISO15_APPEND_CRC = (1 << 3), + ISO15_HIGH_SPEED = (1 << 4), + ISO15_READ_RESPONSE = (1 << 5) +} iso15_command_t; + + +#endif // _ISO15_H_ \ No newline at end of file diff --git a/include/iso18.h b/include/iso18.h new file mode 100644 index 000000000..711bba495 --- /dev/null +++ b/include/iso18.h @@ -0,0 +1,119 @@ +//----------------------------------------------------------------------------- +// (c) 2020 Iceman +// +// This code is licensed to you under the terms of the GNU GPL, version 2 or, +// at your option, any later version. See the LICENSE.txt file for the text of +// the license. +//----------------------------------------------------------------------------- +// ISO 18002 / FeliCa type prototyping +//----------------------------------------------------------------------------- +#ifndef _ISO18_H_ +#define _ISO18_H_ + +#include "common.h" + +typedef enum FELICA_COMMAND { + FELICA_CONNECT = (1 << 0), + FELICA_NO_DISCONNECT = (1 << 1), + FELICA_RAW = (1 << 3), + FELICA_APPEND_CRC = (1 << 5), + FELICA_NO_SELECT = (1 << 6), +} felica_command_t; + +//----------------------------------------------------------------------------- +// FeliCa +//----------------------------------------------------------------------------- +// IDm = ID manufacturer +// mc = manufactureCode +// mc1 mc2 u1 u2 u3 u4 u5 u6 +// PMm = Product manufacturer +// icCode = +// ic1 = ROM +// ic2 = IC +// maximum response time = +// B3(request service) +// B4(request response) +// B5(authenticate) +// B6(read) +// B7(write) +// B8() + +// ServiceCode 2bytes (access-rights) +// FileSystem = 1 Block = 16 bytes + + +typedef struct { + uint8_t IDm[8]; + uint8_t code[2]; + uint8_t uid[6]; + uint8_t PMm[8]; + uint8_t iccode[2]; + uint8_t mrt[6]; + uint8_t servicecode[2]; +} PACKED felica_card_select_t; + +typedef struct { + uint8_t sync[2]; + uint8_t length[1]; + uint8_t cmd_code[1]; + uint8_t IDm[8]; +} PACKED felica_frame_response_t; + +typedef struct { + uint8_t status_flag1[1]; + uint8_t status_flag2[1]; +} PACKED felica_status_flags_t; + +typedef struct { + felica_frame_response_t frame_response; + uint8_t node_number[1]; + uint8_t node_key_versions[2]; +} PACKED felica_request_service_response_t; + +typedef struct { + felica_frame_response_t frame_response; + uint8_t mode[1]; +} PACKED felica_request_request_response_t; + +typedef struct { + felica_frame_response_t frame_response; + felica_status_flags_t status_flags; + uint8_t number_of_block[1]; + uint8_t block_data[16]; + uint8_t block_element_number[1]; +} PACKED felica_read_without_encryption_response_t; + +typedef struct { + felica_frame_response_t frame_response; + felica_status_flags_t status_flags; +} PACKED felica_status_response_t; + +typedef struct { + felica_frame_response_t frame_response; + uint8_t number_of_systems[1]; + uint8_t system_code_list[32]; +} PACKED felica_syscode_response_t; + +typedef struct { + felica_frame_response_t frame_response; + felica_status_flags_t status_flags; + uint8_t format_version[1]; + uint8_t basic_version[2]; + uint8_t number_of_option[1]; + uint8_t option_version_list[4]; +} PACKED felica_request_spec_response_t; + +typedef struct { + felica_frame_response_t frame_response; + uint8_t m2c[8]; + uint8_t m3c[8]; +} PACKED felica_auth1_response_t; + +typedef struct { + uint8_t code[1]; + uint8_t IDtc[8]; + uint8_t IDi[8]; + uint8_t PMi[8]; +} PACKED felica_auth2_response_t; + +#endif // _ISO18_H_ \ No newline at end of file From 108424d3265ea89cd09ca76c252b7426f878ffc8 Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Fri, 2 Oct 2020 14:30:37 +0200 Subject: [PATCH 12/28] add ASK C-ticket commands --- include/protocols.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/include/protocols.h b/include/protocols.h index 7cd547fef..d2af15647 100644 --- a/include/protocols.h +++ b/include/protocols.h @@ -247,6 +247,16 @@ ISO 7816-4 Basic interindustry commands. For command APDU's. #define ISO14443B_PING 0xBA #define ISO14443B_PONG 0xAB +// ASK C-ticket +#define ASK_REQT 0x10 +#define ASK_IDENTIFY 0x0F +#define ASK_SELECT 0x9F +#define ASK_MULTREAD (0x1 << 4) // High nibble +#define ASK_UPDATE (0x3 << 4) // High nibble +#define ASK_WRITE (0x5 << 4) // High nibble +#define ASK_READ (0x6 << 4) // High nibble +#define ASK_DESACTIVATE 0xF0 + // defined crypto RF commands // only interpreting channel 1 communication From b2e58df80746e9ad4acf2d0486205898888e0127 Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Fri, 2 Oct 2020 14:31:03 +0200 Subject: [PATCH 13/28] new ref to inclue --- client/src/cmdhffelica.c | 2 +- client/src/cmdhffelica.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/client/src/cmdhffelica.c b/client/src/cmdhffelica.c index fde071419..092677b42 100644 --- a/client/src/cmdhffelica.c +++ b/client/src/cmdhffelica.c @@ -21,7 +21,7 @@ #include "crc16.h" #include "util.h" #include "ui.h" -#include "mifare.h" // felica_card_select_t struct +#include "iso18.h" // felica_card_select_t struct #include "des.h" #define AddCrc(data, len) compute_crc(CRC_FELICA, (data), (len), (data)+(len)+1, (data)+(len)) diff --git a/client/src/cmdhffelica.h b/client/src/cmdhffelica.h index 8d8156006..e7be7ede1 100644 --- a/client/src/cmdhffelica.h +++ b/client/src/cmdhffelica.h @@ -12,7 +12,7 @@ #define CMDHFFELICA_H__ #include "common.h" -#include "mifare.h" +#include "iso18.h" int CmdHFFelica(const char *Cmd); int readFelicaUid(bool verbose); From 9956c5af312eda970e02c814efdd86240b27f284 Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Fri, 2 Oct 2020 14:31:11 +0200 Subject: [PATCH 14/28] new ref to inclue --- client/src/cmdhfcryptorf.c | 1 + 1 file changed, 1 insertion(+) diff --git a/client/src/cmdhfcryptorf.c b/client/src/cmdhfcryptorf.c index 98eada2ba..b473b2fa2 100644 --- a/client/src/cmdhfcryptorf.c +++ b/client/src/cmdhfcryptorf.c @@ -19,6 +19,7 @@ #include "crc16.h" #include "cmdhf14a.h" #include "protocols.h" // definitions of ISO14B protocol +#include "iso14b.h" #define TIMEOUT 2000 static int CmdHelp(const char *Cmd); From 31f5502171d2a5b59861d3d46d5c009a8d8e9790 Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Fri, 2 Oct 2020 14:31:52 +0200 Subject: [PATCH 15/28] remade ASK C-ticket select to deviceside --- armsrc/felica.c | 2 +- armsrc/iso14443b.c | 93 +++++++++++++++++++++++++++-- armsrc/iso14443b.h | 2 +- client/src/cmdhf14b.c | 134 +++++++++++++++++++----------------------- 4 files changed, 149 insertions(+), 82 deletions(-) diff --git a/armsrc/felica.c b/armsrc/felica.c index 53f78d17b..aafdae5d8 100644 --- a/armsrc/felica.c +++ b/armsrc/felica.c @@ -9,7 +9,7 @@ #include "commonutil.h" #include "dbprint.h" #include "ticks.h" -#include "mifare.h" +#include "iso18.h" // FeliCa timings // minimum time between the start bits of consecutive transfers from reader to tag: 6800 carrier (13.56MHz) cycles diff --git a/armsrc/iso14443b.c b/armsrc/iso14443b.c index be8b820e0..e4fe67a64 100644 --- a/armsrc/iso14443b.c +++ b/armsrc/iso14443b.c @@ -902,7 +902,11 @@ static RAMFUNC int Handle14443bSamplesFromTag(int ci, int cq) { } } // we have still signal but no proper byte or EOF? this shouldn't happen + //Demod.posCount = 10 * 2; + Demod.bitCount = 0; + Demod.len = 0; Demod.state = WAIT_FOR_RISING_EDGE_OF_SOF; + break; } } Demod.posCount = 0; @@ -1253,6 +1257,79 @@ int iso14443b_apdu(uint8_t const *msg, size_t msg_len, bool send_chaining, uint8 return len; } +/** +* ASK CTS initialise. +*/ +static int iso14443b_select_cts_card(iso14b_cts_card_select_t *card) { + // INITIATE command: wake up the tag using the INITIATE + uint8_t cmdINIT[] = {ASK_REQT, 0xF9, 0xE0}; + uint8_t cmdMSBUID[] = {ASK_SELECT, 0xFF, 0xFF, 0x00, 0x00}; + uint8_t cmdLSBUID[] = {0xC4, 0x00, 0x00}; + + AddCrc14B(cmdMSBUID, 3); + AddCrc14B(cmdLSBUID, 1); + + uint8_t r[8]; + + uint32_t start_time = 0; + uint32_t eof_time = 0; + CodeAndTransmit14443bAsReader(cmdINIT, sizeof(cmdINIT), &start_time, &eof_time); + + eof_time += DELAY_ISO14443B_VCD_TO_VICC_READER; + int retlen = Get14443bAnswerFromTag(r, sizeof(r), ISO14443B_READER_TIMEOUT, &eof_time); + FpgaDisableTracing(); + + if (retlen != 4) { + return -1; + } + if (check_crc(CRC_14443_B, r, retlen) == false) { + return -2; + } + + if (card) { + // pc. fc Product code, Facility code + card->pc = r[0]; + card->fc = r[1]; + } + + start_time = eof_time + DELAY_ISO14443B_VICC_TO_VCD_READER; + CodeAndTransmit14443bAsReader(cmdMSBUID, sizeof(cmdMSBUID), &start_time, &eof_time); + + eof_time += DELAY_ISO14443B_VCD_TO_VICC_READER; + retlen = Get14443bAnswerFromTag(r, sizeof(r), ISO14443B_READER_TIMEOUT, &eof_time); + FpgaDisableTracing(); + + if (retlen != 4) { + return -1; + } + if (check_crc(CRC_14443_B, r, retlen) == false) { + return -2; + } + + if (card) { + memcpy(card->uid, r, 2); + } + + start_time = eof_time + DELAY_ISO14443B_VICC_TO_VCD_READER; + CodeAndTransmit14443bAsReader(cmdLSBUID, sizeof(cmdLSBUID), &start_time, &eof_time); + + eof_time += DELAY_ISO14443B_VCD_TO_VICC_READER; + retlen = Get14443bAnswerFromTag(r, sizeof(r), ISO14443B_READER_TIMEOUT, &eof_time); + FpgaDisableTracing(); + + if (retlen != 4) { + return -1; + } + if (check_crc(CRC_14443_B, r, retlen) == false) { + return -2; + } + + if (card) { + memcpy(card->uid + 2, r, 2); + } + + return 0; +} /** * SRx Initialise. */ @@ -1271,8 +1348,9 @@ static int iso14443b_select_srx_card(iso14b_card_select_t *card) { int retlen = Get14443bAnswerFromTag(r_init, sizeof(r_init), ISO14443B_READER_TIMEOUT, &eof_time); FpgaDisableTracing(); - if (retlen <= 0) + if (retlen <= 0) { return -1; + } // Randomly generated Chip ID if (card) { @@ -1295,8 +1373,6 @@ static int iso14443b_select_srx_card(iso14b_card_select_t *card) { if (retlen != 3) { return -1; } - - // Check the CRC of the answer: if (!check_crc(CRC_14443_B, r_select, retlen)) { return -2; } @@ -1321,8 +1397,6 @@ static int iso14443b_select_srx_card(iso14b_card_select_t *card) { if (retlen != 10) { return -1; } - - // The check the CRC of the answer if (!check_crc(CRC_14443_B, r_papid, retlen)) { return -2; } @@ -1793,6 +1867,15 @@ void SendRawCommand14443B_Ex(PacketCommandNG *c) { if (status > 0) goto out; } + if ((param & ISO14B_SELECT_CTS) == ISO14B_SELECT_CTS) { + iso14b_cts_card_select_t cts; + sendlen = sizeof(iso14b_cts_card_select_t); + status = iso14443b_select_cts_card(&cts); + reply_mix(CMD_HF_ISO14443B_COMMAND, status, sendlen, 0, (uint8_t *)&cts, sendlen); + // 0: OK 2: demod fail, 3:crc fail, + if (status > 0) goto out; + } + if ((param & ISO14B_APDU) == ISO14B_APDU) { status = iso14443b_apdu(cmd, len, (param & ISO14B_SEND_CHAINING), buf, sizeof(buf)); sendlen = MIN(Demod.len, PM3_CMD_DATA_SIZE); diff --git a/armsrc/iso14443b.h b/armsrc/iso14443b.h index 84c264c92..3fde4ffe0 100644 --- a/armsrc/iso14443b.h +++ b/armsrc/iso14443b.h @@ -15,7 +15,7 @@ #include "common.h" -#include "mifare.h" +#include "iso14b.h" #include "pm3_cmd.h" #ifndef AddCrc14A diff --git a/client/src/cmdhf14b.c b/client/src/cmdhf14b.c index 9bdeb8c91..fe496919e 100644 --- a/client/src/cmdhf14b.c +++ b/client/src/cmdhf14b.c @@ -11,6 +11,7 @@ #include "cmdhf14b.h" #include +#include "iso14b.h" #include "fileutils.h" #include "cmdparser.h" // command_t #include "commonutil.h" // ARRAYLEN @@ -43,10 +44,10 @@ static int usage_hf_14b_info(void) { return PM3_SUCCESS; } static int usage_hf_14b_reader(void) { - PrintAndLogEx(NORMAL, "Usage: hf 14b reader [h] [s]"); + PrintAndLogEx(NORMAL, "Usage: hf 14b reader [h] [v]"); PrintAndLogEx(NORMAL, "Options:"); PrintAndLogEx(NORMAL, " h this help"); - PrintAndLogEx(NORMAL, " s silently"); + PrintAndLogEx(NORMAL, " v verbose"); PrintAndLogEx(NORMAL, "Example:"); PrintAndLogEx(NORMAL, _YELLOW_(" hf 14b reader")); return PM3_SUCCESS; @@ -632,6 +633,20 @@ static void print_st_general_info(uint8_t *data, uint8_t len) { PrintAndLogEx(SUCCESS, "Chip: %02X, " _YELLOW_("%s"), chipid, get_ST_Chip_Model(chipid)); } +// print UID info from ASK CT chips +static void print_ct_general_info(void *vcard) { + iso14b_cts_card_select_t card; + memcpy(&card, (iso14b_cts_card_select_t *)vcard, sizeof(iso14b_cts_card_select_t)); + + uint32_t uid32 = (card.uid[0] |card.uid[1] << 8 |card.uid[2] << 16 | card.uid[3] << 24); + PrintAndLogEx(SUCCESS, "ASK C-Ticket"); + PrintAndLogEx(SUCCESS, " UID: " _GREEN_("%s") " ( " _YELLOW_("%u") " )", sprint_hex(card.uid, sizeof(card.uid)), uid32); + PrintAndLogEx(SUCCESS, " Product Code: %02X", card.pc); + PrintAndLogEx(SUCCESS, " Facility Code: %02X", card.fc); + PrintAndLogEx(NORMAL, ""); + +} + // iceman, some 14B APDU break down // 05 00 00 = find one tag in field // 1d xx xx xx xx 00 08 01 00 = attrib xx=UID (resp 10 [f9 e0]) @@ -726,7 +741,7 @@ static int CmdHF14Binfo(const char *Cmd) { return infoHF14B(verbose); } -static bool HF14B_ST_Reader(bool verbose) { +static bool HF14B_st_reader(bool verbose) { bool is_success = false; @@ -751,22 +766,22 @@ static bool HF14B_ST_Reader(bool verbose) { is_success = true; break; case -1: - if (verbose) PrintAndLogEx(FAILED, "ISO 14443-3 ATTRIB fail"); + if (verbose) PrintAndLogEx(FAILED, "ISO 14443-3 ST ATTRIB fail"); break; case -2: - if (verbose) PrintAndLogEx(FAILED, "ISO 14443-3 CRC fail"); + if (verbose) PrintAndLogEx(FAILED, "ISO 14443-3 ST CRC fail"); break; case -3: - if (verbose) PrintAndLogEx(FAILED, "ISO 14443-3 random chip id fail"); + if (verbose) PrintAndLogEx(FAILED, "ISO 14443-3 ST random chip id fail"); break; default: - if (verbose) PrintAndLogEx(FAILED, "ISO 14443-b card select SRx failed"); + if (verbose) PrintAndLogEx(FAILED, "ISO 14443-b ST card select SRx failed"); break; } return is_success; } -static bool HF14B_Std_Reader(bool verbose) { +static bool HF14B_std_reader(bool verbose) { bool is_success = false; @@ -810,77 +825,45 @@ static bool HF14B_Std_Reader(bool verbose) { return is_success; } -static bool HF14B_ask_ct_Reader(bool verbose) { - uint8_t cmd1[] = {0x10}; - uint8_t cmd2[] = {0x9F, 0xFF, 0xFF}; - uint8_t cmd3[] = {0xC4}; - uint8_t uid[4]; - uint8_t pc, fc; +static bool HF14B_ask_ct_reader(bool verbose) { + + bool is_success = false; // 14b get and print UID only (general info) - uint32_t flags = ISO14B_CONNECT | ISO14B_RAW | ISO14B_APPEND_CRC; + clearCommandBuffer(); PacketResponseNG resp; - int status; - - clearCommandBuffer(); - SendCommandMIX(CMD_HF_ISO14443B_COMMAND, flags, sizeof(cmd1), 0, cmd1, sizeof(cmd1)); - - if (!WaitForResponseTimeout(CMD_HF_ISO14443B_COMMAND, &resp, TIMEOUT)) { + SendCommandMIX(CMD_HF_ISO14443B_COMMAND, ISO14B_CONNECT | ISO14B_SELECT_CTS | ISO14B_DISCONNECT, 0, 0, NULL, 0); + if (WaitForResponseTimeout(CMD_HF_ISO14443B_COMMAND, &resp, TIMEOUT) == false) { if (verbose) PrintAndLogEx(WARNING, "command execution timeout"); - switch_off_field_14b(); return false; } - status = resp.oldarg[0]; - PrintAndLogEx(DEBUG, "status cmd1 %d", status); - if (status == 4) { - pc = resp.data.asBytes[0]; - fc = resp.data.asBytes[1]; - } else { - switch_off_field_14b(); - return false; - } - clearCommandBuffer(); - SendCommandMIX(CMD_HF_ISO14443B_COMMAND, flags, sizeof(cmd2), 0, cmd2, sizeof(cmd2)); - if (!WaitForResponseTimeout(CMD_HF_ISO14443B_COMMAND, &resp, TIMEOUT)) { - if (verbose) PrintAndLogEx(WARNING, "command execution timeout"); - switch_off_field_14b(); - return false; - } - status = resp.oldarg[0]; - PrintAndLogEx(DEBUG, "status cmd2 %d", status); - if (status == 4) { - uid[0] = resp.data.asBytes[0]; - uid[1] = resp.data.asBytes[1]; - } else { - switch_off_field_14b(); - return false; - } - clearCommandBuffer(); - SendCommandMIX(CMD_HF_ISO14443B_COMMAND, flags, sizeof(cmd3), 0, cmd3, sizeof(cmd3)); - if (!WaitForResponseTimeout(CMD_HF_ISO14443B_COMMAND, &resp, TIMEOUT)) { - if (verbose) PrintAndLogEx(WARNING, "command execution timeout"); - switch_off_field_14b(); - return false; - } - status = resp.oldarg[0]; - PrintAndLogEx(DEBUG, "status cmd3 %d", status); - if (status == 4) { - uid[2] = resp.data.asBytes[0]; - uid[3] = resp.data.asBytes[1]; - uint32_t uid32 = uid[0] + (uid[1] << 8) + (uid[2] << 16) + (uid[3] << 24); - PrintAndLogEx(SUCCESS, "\nASK CT - 14443-3b tag found:"); - PrintAndLogEx(SUCCESS, "UID: %02X%02X%02X%02X (%u) Product code: %02X Fab code: %02X", uid[0], uid[1], uid[2], uid[3], uid32, pc, fc); - switch_off_field_14b(); - return true; - } else { - switch_off_field_14b(); - return false; + int status = resp.oldarg[0]; + + switch (status) { + case 0: { + print_ct_general_info(resp.data.asBytes); + is_success = true; + break; + } + case -1: { + if (verbose) PrintAndLogEx(FAILED, "ISO 14443-3 CTS wrong length"); + break; + } + case -2: { + if (verbose) PrintAndLogEx(FAILED, "ISO 14443-3 CTS CRC fail"); + break; + } + default: { + if (verbose) PrintAndLogEx(FAILED, "ISO 14443-b CTS card select failed"); + break; + } } + return is_success; } // test for other 14b type tags (mimic another reader - don't have tags to identify) -static bool HF14B_Other_Reader(bool verbose) { +static bool HF14B_other_reader(bool verbose) { uint8_t data[] = {0x00, 0x0b, 0x3f, 0x80}; uint8_t datalen = 4; @@ -969,7 +952,7 @@ static bool HF14B_Other_Reader(bool verbose) { static int CmdHF14BReader(const char *Cmd) { char cmdp = tolower(param_getchar(Cmd, 0)); if (cmdp == 'h') return usage_hf_14b_reader(); - bool verbose = !(cmdp == 's'); + bool verbose = (cmdp == 'v'); return readHF14B(verbose); } @@ -1806,19 +1789,20 @@ int infoHF14B(bool verbose) { int readHF14B(bool verbose) { // try std 14b (atqb) - if (HF14B_Std_Reader(verbose)) + if (HF14B_std_reader(verbose)) return 1; // try ST Microelectronics 14b - if (HF14B_ST_Reader(verbose)) + if (HF14B_st_reader(verbose)) + return 1; + + // try ASK CT 14b + if (HF14B_ask_ct_reader(verbose)) return 1; // try unknown 14b read commands (to be identified later) // could be read of calypso, CEPAS, moneo, or pico pass. - if (HF14B_Other_Reader(verbose)) - return 1; - - if (HF14B_ask_ct_Reader(verbose)) + if (HF14B_other_reader(verbose)) return 1; if (verbose) PrintAndLogEx(FAILED, "no 14443-B tag found"); From 235cca276d17a6ec9db66605f22a0a64f3a9e61f Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Fri, 2 Oct 2020 14:32:16 +0200 Subject: [PATCH 16/28] moved old type --- include/mifare.h | 150 +++-------------------------------------------- 1 file changed, 7 insertions(+), 143 deletions(-) diff --git a/include/mifare.h b/include/mifare.h index f8cdf72af..2fe6b84e4 100644 --- a/include/mifare.h +++ b/include/mifare.h @@ -94,40 +94,6 @@ typedef enum { MFDES_ALGO_AES = 4 } mifare_des_authalgo_t; - -//----------------------------------------------------------------------------- -// ISO 14443B -//----------------------------------------------------------------------------- -typedef struct { - uint8_t uid[10]; - uint8_t uidlen; - uint8_t atqb[7]; - uint8_t chipid; - uint8_t cid; -} PACKED iso14b_card_select_t; - -typedef enum ISO14B_COMMAND { - ISO14B_CONNECT = (1 << 0), - ISO14B_DISCONNECT = (1 << 1), - ISO14B_APDU = (1 << 2), - ISO14B_RAW = (1 << 3), - ISO14B_REQUEST_TRIGGER = (1 << 4), - ISO14B_APPEND_CRC = (1 << 5), - ISO14B_SELECT_STD = (1 << 6), - ISO14B_SELECT_SR = (1 << 7), - ISO14B_SET_TIMEOUT = (1 << 8), - ISO14B_SEND_CHAINING = (1 << 9), -} iso14b_command_t; - -typedef enum ISO15_COMMAND { - ISO15_CONNECT = (1 << 0), - ISO15_NO_DISCONNECT = (1 << 1), - ISO15_RAW = (1 << 2), - ISO15_APPEND_CRC = (1 << 3), - ISO15_HIGH_SPEED = (1 << 4), - ISO15_READ_RESPONSE = (1 << 5) -} iso15_command_t; - //----------------------------------------------------------------------------- // "hf 14a sim x", "hf mf sim x" attacks //----------------------------------------------------------------------------- @@ -158,116 +124,14 @@ typedef struct { } PACKED smart_card_atr_t; typedef enum SMARTCARD_COMMAND { - SC_CONNECT = (1 << 0), - SC_NO_DISCONNECT = (1 << 1), - SC_RAW = (1 << 2), - SC_SELECT = (1 << 3), - SC_RAW_T0 = (1 << 4), - SC_CLEARLOG = (1 << 5), - SC_LOG = (1 << 6), + SC_CONNECT = (1 << 0), + SC_NO_DISCONNECT = (1 << 1), + SC_RAW = (1 << 2), + SC_SELECT = (1 << 3), + SC_RAW_T0 = (1 << 4), + SC_CLEARLOG = (1 << 5), + SC_LOG = (1 << 6), } smartcard_command_t; -//----------------------------------------------------------------------------- -// FeliCa -//----------------------------------------------------------------------------- -// IDm = ID manufacturer -// mc = manufactureCode -// mc1 mc2 u1 u2 u3 u4 u5 u6 -// PMm = Product manufacturer -// icCode = -// ic1 = ROM -// ic2 = IC -// maximum response time = -// B3(request service) -// B4(request response) -// B5(authenticate) -// B6(read) -// B7(write) -// B8() - -// ServiceCode 2bytes (access-rights) -// FileSystem = 1 Block = 16 bytes -typedef struct { - uint8_t IDm[8]; - uint8_t code[2]; - uint8_t uid[6]; - uint8_t PMm[8]; - uint8_t iccode[2]; - uint8_t mrt[6]; - uint8_t servicecode[2]; -} PACKED felica_card_select_t; - -typedef struct { - uint8_t sync[2]; - uint8_t length[1]; - uint8_t cmd_code[1]; - uint8_t IDm[8]; -} PACKED felica_frame_response_t; - -typedef struct { - uint8_t status_flag1[1]; - uint8_t status_flag2[1]; -} PACKED felica_status_flags_t; - -typedef struct { - felica_frame_response_t frame_response; - uint8_t node_number[1]; - uint8_t node_key_versions[2]; -} PACKED felica_request_service_response_t; - -typedef struct { - felica_frame_response_t frame_response; - uint8_t mode[1]; -} PACKED felica_request_request_response_t; - -typedef struct { - felica_frame_response_t frame_response; - felica_status_flags_t status_flags; - uint8_t number_of_block[1]; - uint8_t block_data[16]; - uint8_t block_element_number[1]; -} PACKED felica_read_without_encryption_response_t; - -typedef struct { - felica_frame_response_t frame_response; - felica_status_flags_t status_flags; -} PACKED felica_status_response_t; - -typedef struct { - felica_frame_response_t frame_response; - uint8_t number_of_systems[1]; - uint8_t system_code_list[32]; -} PACKED felica_syscode_response_t; - -typedef struct { - felica_frame_response_t frame_response; - felica_status_flags_t status_flags; - uint8_t format_version[1]; - uint8_t basic_version[2]; - uint8_t number_of_option[1]; - uint8_t option_version_list[4]; -} PACKED felica_request_spec_response_t; - -typedef struct { - felica_frame_response_t frame_response; - uint8_t m2c[8]; - uint8_t m3c[8]; -} PACKED felica_auth1_response_t; - -typedef struct { - uint8_t code[1]; - uint8_t IDtc[8]; - uint8_t IDi[8]; - uint8_t PMi[8]; -} PACKED felica_auth2_response_t; - - -typedef enum FELICA_COMMAND { - FELICA_CONNECT = (1 << 0), - FELICA_NO_DISCONNECT = (1 << 1), - FELICA_RAW = (1 << 3), - FELICA_APPEND_CRC = (1 << 5), - FELICA_NO_SELECT = (1 << 6), -} felica_command_t; #endif // _MIFARE_H_ From c3872e626b0c99bc06a0e48284f6fbfad6ec87b4 Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Fri, 2 Oct 2020 15:26:10 +0200 Subject: [PATCH 17/28] hf 14b raw -> now using cliparser. -s now has number to denote which select to use. 0,1,2 --- client/src/cmdhf14b.c | 145 ++++++++++++++++++------------------------ 1 file changed, 62 insertions(+), 83 deletions(-) diff --git a/client/src/cmdhf14b.c b/client/src/cmdhf14b.c index fe496919e..cc8067f7c 100644 --- a/client/src/cmdhf14b.c +++ b/client/src/cmdhf14b.c @@ -52,20 +52,6 @@ static int usage_hf_14b_reader(void) { PrintAndLogEx(NORMAL, _YELLOW_(" hf 14b reader")); return PM3_SUCCESS; } -static int usage_hf_14b_raw(void) { - PrintAndLogEx(NORMAL, "Usage: hf 14b raw [-h] [-r] [-c] [-k] [-s / -ss] [-t] <0A 0B 0C ... hex>"); - PrintAndLogEx(NORMAL, "Options:"); - PrintAndLogEx(NORMAL, " -h this help"); - PrintAndLogEx(NORMAL, " -r do not read response"); - PrintAndLogEx(NORMAL, " -c calculate and append CRC"); - PrintAndLogEx(NORMAL, " -k keep signal field ON after receive"); - PrintAndLogEx(NORMAL, " -s active signal field ON with select"); - PrintAndLogEx(NORMAL, " -ss active signal field ON with select for SRx ST Microelectronics tags"); - PrintAndLogEx(NORMAL, " -t timeout in ms"); - PrintAndLogEx(NORMAL, "Example:"); - PrintAndLogEx(NORMAL, _YELLOW_(" hf 14b raw -s -c -k 0200a40400")); - return PM3_SUCCESS; -} static int usage_hf_14b_sniff(void) { PrintAndLogEx(NORMAL, "It get data from the field and saves it into command buffer."); PrintAndLogEx(NORMAL, "Buffer accessible from command 'hf list 14b'"); @@ -162,6 +148,8 @@ static bool waitCmd14b(bool verbose) { (crc) ? _GREEN_("ok") : _RED_("fail") ); } else if (len == 0) { + if (verbose) + PrintAndLogEx(INFO, "no response from tag"); } else { PrintAndLogEx(SUCCESS, "len %u | %s", len, sprint_hex(data, len)); } @@ -204,76 +192,67 @@ static int CmdHF14BSniff(const char *Cmd) { } static int CmdHF14BCmdRaw(const char *Cmd) { - bool reply = true, keep_field_on = false, select = false, hasTimeout = false; - char buf[5] = ""; - int i = 0; - uint8_t data[PM3_CMD_DATA_SIZE] = {0x00}; - uint16_t datalen = 0; + + CLIParserContext *ctx; + CLIParserInit(&ctx, "hf 14b raw", + "Sends raw bytes to card ", + "hf 14b raw -s 0 -c -k 0200a40400" + ); + + void *argtable[] = { + arg_param_begin, + arg_lit0("k", "keep", "leave the signal field ON after receive response"), + arg_int0("s", "select", "decimal", "activate field and select card (0 = std, 1 = SRx ST, 2 = ASK C-ticket"), + arg_lit0("c", "crc", "calculate and append CRC"), + arg_lit0("r", "noresponse", "do not read response"), + arg_int0("t", "timeout", "decimal", "timeout in ms"), + arg_lit0("v", "verbose", "verbose"), + arg_strx0(NULL, NULL, "", "bytes to send"), + arg_param_end + }; + CLIExecWithReturn(ctx, Cmd, argtable, false); + + bool select = false; + bool keep_field_on = arg_get_lit(ctx, 1); + int select_type = arg_get_int_def(ctx, 2, -1); + bool add_crc = arg_get_lit(ctx, 3); + bool read_reply = arg_get_lit(ctx, 4); + int user_timeout = arg_get_int_def(ctx, 5, -1); + bool verbose = arg_get_lit(ctx, 6); + uint32_t flags = ISO14B_CONNECT; - uint32_t temp = 0, user_timeout = 0, time_wait = 0; - - if (strlen(Cmd) < 2) return usage_hf_14b_raw(); - - // strip - while (*Cmd == ' ' || *Cmd == '\t') ++Cmd; - - while (Cmd[i] != '\0') { - if (Cmd[i] == ' ' || Cmd[i] == '\t') { ++i; continue; } - if (Cmd[i] == '-') { - switch (tolower(Cmd[i + 1])) { - case 'h': - return usage_hf_14b_raw(); - case 'r': - reply = false; - break; - case 'c': - flags |= ISO14B_APPEND_CRC; - break; - case 'k': - keep_field_on = true; - break; - case 's': - select = true; - if (tolower(Cmd[i + 2]) == 's') { - flags |= ISO14B_SELECT_SR; - ++i; - } else { - flags |= ISO14B_SELECT_STD; - } - break; - case 't': - hasTimeout = true; - sscanf(Cmd + i + 2, "%d", &user_timeout); - i += 3; - while (Cmd[i] != ' ' && Cmd[i] != '\0') { i++; } - i -= 2; - break; - default: - return usage_hf_14b_raw(); - } - i += 2; - continue; - } - if ((Cmd[i] >= '0' && Cmd[i] <= '9') || - (Cmd[i] >= 'a' && Cmd[i] <= 'f') || - (Cmd[i] >= 'A' && Cmd[i] <= 'F')) { - buf[strlen(buf) + 1] = 0; - buf[strlen(buf)] = Cmd[i]; - i++; - - if (strlen(buf) >= 2) { - sscanf(buf, "%x", &temp); - data[datalen++] = (uint8_t)(temp & 0xff); - *buf = 0; - memset(buf, 0x00, sizeof(buf)); - } - continue; - } - PrintAndLogEx(WARNING, "unknown parameter '%c'\n", param_getchar(Cmd, i)); - return PM3_EINVARG; + if (add_crc) { + flags |= ISO14B_APPEND_CRC; } - if (hasTimeout) { + switch(select_type) { + case 0: + select = true; + flags |= ISO14B_SELECT_STD; + if (verbose) + PrintAndLogEx(INFO, "using standard select"); + break; + case 1: + select = true; + flags |= ISO14B_SELECT_SR; + if (verbose) + PrintAndLogEx(INFO, "using SRx ST select"); + break; + case 2: + select = true; + flags |= ISO14B_SELECT_CTS; + if (verbose) + PrintAndLogEx(INFO, "using ASK C-ticket select"); + break; + } + + uint8_t data[PM3_CMD_DATA_SIZE] = {0x00}; + int datalen = 0; + CLIParamHexToBuf(arg_get_str(ctx, 7), data, sizeof(data), &datalen); + CLIParserFree(ctx); + + uint32_t time_wait = 0; + if (user_timeout > 0) { #define MAX_14B_TIMEOUT 40542464 // = (2^32-1) * (8*16) / 13560000Hz * 1000ms/s flags |= ISO14B_SET_TIMEOUT; @@ -296,14 +275,14 @@ static int CmdHF14BCmdRaw(const char *Cmd) { clearCommandBuffer(); SendCommandMIX(CMD_HF_ISO14443B_COMMAND, flags, datalen, time_wait, data, datalen); - if (reply == false) { + if (read_reply == false) { return PM3_SUCCESS; } bool success = true; // get back iso14b_card_select_t, don't print it. if (select) { - success = waitCmd14b(false); + success = waitCmd14b(verbose); } // get back response from the raw bytes you sent. From 206b699af44d4b2d5c1e27b92b7341c328ebb23d Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Fri, 2 Oct 2020 16:53:03 +0200 Subject: [PATCH 18/28] hf 14b raw - adapt params --- client/src/cmdhf14b.c | 81 ++++++++++++++++++++++++------------------- 1 file changed, 45 insertions(+), 36 deletions(-) diff --git a/client/src/cmdhf14b.c b/client/src/cmdhf14b.c index cc8067f7c..46969145f 100644 --- a/client/src/cmdhf14b.c +++ b/client/src/cmdhf14b.c @@ -127,7 +127,7 @@ static uint16_t get_sw(uint8_t *d, uint8_t n) { return d[n] * 0x0100 + d[n + 1]; } -static bool waitCmd14b(bool verbose) { +static bool wait_cmd_14b(bool verbose) { PacketResponseNG resp; if (WaitForResponseTimeout(CMD_HF_ISO14443B_COMMAND, &resp, TIMEOUT)) { @@ -196,13 +196,17 @@ static int CmdHF14BCmdRaw(const char *Cmd) { CLIParserContext *ctx; CLIParserInit(&ctx, "hf 14b raw", "Sends raw bytes to card ", - "hf 14b raw -s 0 -c -k 0200a40400" + "hf 14b raw -s -c -k 0200a40400\n" + "hf 14b raw --sr -c -k 0200a40400\n" + "hf 14b raw --cts -c -k 0200a40400\n" ); void *argtable[] = { arg_param_begin, arg_lit0("k", "keep", "leave the signal field ON after receive response"), - arg_int0("s", "select", "decimal", "activate field and select card (0 = std, 1 = SRx ST, 2 = ASK C-ticket"), + arg_lit0("s", "std", "activate field and select standard card"), + arg_lit0(NULL, "sr", "activate field and select SRx ST"), + arg_lit0(NULL, "cts", "activate field and select ASK C-ticket"), arg_lit0("c", "crc", "calculate and append CRC"), arg_lit0("r", "noresponse", "do not read response"), arg_int0("t", "timeout", "decimal", "timeout in ms"), @@ -214,41 +218,39 @@ static int CmdHF14BCmdRaw(const char *Cmd) { bool select = false; bool keep_field_on = arg_get_lit(ctx, 1); - int select_type = arg_get_int_def(ctx, 2, -1); - bool add_crc = arg_get_lit(ctx, 3); - bool read_reply = arg_get_lit(ctx, 4); - int user_timeout = arg_get_int_def(ctx, 5, -1); - bool verbose = arg_get_lit(ctx, 6); + bool select_std = arg_get_lit(ctx, 2); + bool select_sr = arg_get_lit(ctx, 3); + bool select_cts = arg_get_lit(ctx, 4); + bool add_crc = arg_get_lit(ctx, 5); + bool read_reply = !arg_get_lit(ctx, 6); + int user_timeout = arg_get_int_def(ctx, 7, -1); + bool verbose = arg_get_lit(ctx, 8); uint32_t flags = ISO14B_CONNECT; if (add_crc) { flags |= ISO14B_APPEND_CRC; } - switch(select_type) { - case 0: - select = true; - flags |= ISO14B_SELECT_STD; - if (verbose) - PrintAndLogEx(INFO, "using standard select"); - break; - case 1: - select = true; - flags |= ISO14B_SELECT_SR; - if (verbose) - PrintAndLogEx(INFO, "using SRx ST select"); - break; - case 2: - select = true; - flags |= ISO14B_SELECT_CTS; - if (verbose) - PrintAndLogEx(INFO, "using ASK C-ticket select"); - break; + if (select_std) { + select = true; + flags |= ISO14B_SELECT_STD; + if (verbose) + PrintAndLogEx(INFO, "using standard select"); + } else if (select_sr) { + select = true; + flags |= ISO14B_SELECT_SR; + if (verbose) + PrintAndLogEx(INFO, "using SRx ST select"); + } else if (select_cts) { + select = true; + flags |= ISO14B_SELECT_CTS; + if (verbose) + PrintAndLogEx(INFO, "using ASK C-ticket select"); } uint8_t data[PM3_CMD_DATA_SIZE] = {0x00}; int datalen = 0; - CLIParamHexToBuf(arg_get_str(ctx, 7), data, sizeof(data), &datalen); + CLIParamHexToBuf(arg_get_str(ctx, 9), data, sizeof(data), &datalen); CLIParserFree(ctx); uint32_t time_wait = 0; @@ -258,9 +260,11 @@ static int CmdHF14BCmdRaw(const char *Cmd) { flags |= ISO14B_SET_TIMEOUT; if (user_timeout > MAX_14B_TIMEOUT) { user_timeout = MAX_14B_TIMEOUT; - PrintAndLogEx(INFO, "Set timeout to 40542 seconds (11.26 hours). The max we can wait for response"); + PrintAndLogEx(INFO, "set timeout to 40542 seconds (11.26 hours). The max we can wait for response"); } time_wait = 13560000 / 1000 / (8 * 16) * user_timeout; // timeout in ETUs (time to transfer 1 bit, approx. 9.4 us) + if (verbose) + PrintAndLogEx(INFO, "using timeout %u", user_timeout); } if (keep_field_on == 0) @@ -274,7 +278,6 @@ static int CmdHF14BCmdRaw(const char *Cmd) { clearCommandBuffer(); SendCommandMIX(CMD_HF_ISO14443B_COMMAND, flags, datalen, time_wait, data, datalen); - if (read_reply == false) { return PM3_SUCCESS; } @@ -282,12 +285,12 @@ static int CmdHF14BCmdRaw(const char *Cmd) { bool success = true; // get back iso14b_card_select_t, don't print it. if (select) { - success = waitCmd14b(verbose); + success = wait_cmd_14b(verbose); } // get back response from the raw bytes you sent. if (success && datalen > 0) { - waitCmd14b(true); + wait_cmd_14b(true); } return PM3_SUCCESS; @@ -1309,14 +1312,20 @@ static int select_card_14443b_4(bool disconnect, iso14b_card_select_t *card) { // Anticollision + SELECT STD card SendCommandMIX(CMD_HF_ISO14443B_COMMAND, ISO14B_CONNECT | ISO14B_SELECT_STD, 0, 0, NULL, 0); if (WaitForResponseTimeout(CMD_HF_ISO14443B_COMMAND, &resp, TIMEOUT) == false) { - PrintAndLogEx(INFO, "Trying 14B Select SR"); + PrintAndLogEx(INFO, "Trying 14B Select SRx"); // Anticollision + SELECT SR card SendCommandMIX(CMD_HF_ISO14443B_COMMAND, ISO14B_CONNECT | ISO14B_SELECT_SR, 0, 0, NULL, 0); if (WaitForResponseTimeout(CMD_HF_ISO14443B_COMMAND, &resp, TIMEOUT) == false) { - PrintAndLogEx(ERR, "connection timeout"); - switch_off_field_14b(); - return PM3_ESOFT; + PrintAndLogEx(INFO, "Trying 14B Select CTS"); + + // Anticollision + SELECT ASK C-Ticket card + SendCommandMIX(CMD_HF_ISO14443B_COMMAND, ISO14B_CONNECT | ISO14B_SELECT_CTS, 0, 0, NULL, 0); + if (WaitForResponseTimeout(CMD_HF_ISO14443B_COMMAND, &resp, TIMEOUT) == false) { + PrintAndLogEx(ERR, "connection timeout"); + switch_off_field_14b(); + return PM3_ESOFT; + } } } From 67a672e6dc5c04ea6bc02362d54d28fef6f51f3b Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Fri, 2 Oct 2020 17:06:42 +0200 Subject: [PATCH 19/28] hf 14b sniff - wait for button press --- client/src/cmdhf14b.c | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/client/src/cmdhf14b.c b/client/src/cmdhf14b.c index 46969145f..a1be64ffd 100644 --- a/client/src/cmdhf14b.c +++ b/client/src/cmdhf14b.c @@ -52,16 +52,6 @@ static int usage_hf_14b_reader(void) { PrintAndLogEx(NORMAL, _YELLOW_(" hf 14b reader")); return PM3_SUCCESS; } -static int usage_hf_14b_sniff(void) { - PrintAndLogEx(NORMAL, "It get data from the field and saves it into command buffer."); - PrintAndLogEx(NORMAL, "Buffer accessible from command 'hf list 14b'"); - PrintAndLogEx(NORMAL, "Usage: hf 14b sniff [h]"); - PrintAndLogEx(NORMAL, "Options:"); - PrintAndLogEx(NORMAL, " h this help"); - PrintAndLogEx(NORMAL, "Example:"); - PrintAndLogEx(NORMAL, _YELLOW_(" hf 14b sniff")); - return PM3_SUCCESS; -} static int usage_hf_14b_sim(void) { PrintAndLogEx(NORMAL, "Emulating ISO/IEC 14443 type B tag with 4 UID / PUPI"); PrintAndLogEx(NORMAL, "Usage: hf 14b sim [h] u "); @@ -183,11 +173,27 @@ static int CmdHF14BSim(const char *Cmd) { static int CmdHF14BSniff(const char *Cmd) { - char cmdp = tolower(param_getchar(Cmd, 0)); - if (cmdp == 'h') return usage_hf_14b_sniff(); - + CLIParserContext *ctx; + CLIParserInit(&ctx, "hf 14b sniff", + "Sniff the communication reader and tag", + "hf 14b sniff" + ); + + void *argtable[] = { + arg_param_begin, + arg_param_end + }; + CLIExecWithReturn(ctx, Cmd, argtable, true); + CLIParserFree(ctx); + + PacketResponseNG resp; clearCommandBuffer(); SendCommandNG(CMD_HF_ISO14443B_SNIFF, NULL, 0); + + WaitForResponse(CMD_HF_ISO14443B_SNIFF, &resp); + + PrintAndLogEx(HINT, "Try `" _YELLOW_("hf 14b list") "` to view captured tracelog"); + PrintAndLogEx(HINT, "Try `" _YELLOW_("trace save h") "` to save tracelog for later analysing"); return PM3_SUCCESS; } From 19a458e31efc35d6fda9e66969cb24eed59e25cc Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Fri, 2 Oct 2020 17:07:03 +0200 Subject: [PATCH 20/28] textual --- client/src/cmdhf14a.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/src/cmdhf14a.c b/client/src/cmdhf14a.c index 4044273a7..49cdf2e90 100644 --- a/client/src/cmdhf14a.c +++ b/client/src/cmdhf14a.c @@ -236,8 +236,8 @@ static int usage_hf_14a_sim(void) { return PM3_SUCCESS; } static int usage_hf_14a_sniff(void) { - PrintAndLogEx(NORMAL, "It get data from the field and saves it into command buffer."); - PrintAndLogEx(NORMAL, "Buffer accessible from command 'hf list 14a'"); + PrintAndLogEx(NORMAL, "Collect data from the field and save into command buffer."); + PrintAndLogEx(NORMAL, "Buffer accessible from command 'hf 14a list'"); PrintAndLogEx(NORMAL, "Usage: hf 14a sniff [c][r]"); PrintAndLogEx(NORMAL, "c - triggered by first data from card"); PrintAndLogEx(NORMAL, "r - triggered by first 7-bit request from reader (REQ,WUP,...)"); From 01af87e6d7bbb6342c7983c0f67585b30be9487f Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Fri, 2 Oct 2020 18:06:21 +0200 Subject: [PATCH 21/28] hf 14b sniff, sim, info, - now uses cliparser --- armsrc/appmain.c | 3 +- armsrc/iso14443b.c | 12 +++--- armsrc/iso14443b.h | 2 +- client/src/cmdhf14b.c | 91 +++++++++++++++++++++++-------------------- 4 files changed, 56 insertions(+), 52 deletions(-) diff --git a/armsrc/appmain.c b/armsrc/appmain.c index 42161d738..2c6ace8ee 100644 --- a/armsrc/appmain.c +++ b/armsrc/appmain.c @@ -1126,11 +1126,10 @@ static void PacketReceived(PacketCommandNG *packet) { break; } case CMD_HF_ISO14443B_SIMULATE: { - SimulateIso14443bTag(packet->oldarg[0]); + SimulateIso14443bTag(packet->data.asBytes); break; } case CMD_HF_ISO14443B_COMMAND: { - //SendRawCommand14443B(packet->oldarg[0],packet->oldarg[1],packet->oldarg[2],packet->data.asBytes); SendRawCommand14443B_Ex(packet); break; } diff --git a/armsrc/iso14443b.c b/armsrc/iso14443b.c index e4fe67a64..ccbe06e5c 100644 --- a/armsrc/iso14443b.c +++ b/armsrc/iso14443b.c @@ -530,7 +530,7 @@ static void TransmitFor14443b_AsTag(uint8_t *response, uint16_t len) { // Main loop of simulated tag: receive commands from reader, decide what // response to send, and send it. //----------------------------------------------------------------------------- -void SimulateIso14443bTag(uint32_t pupi) { +void SimulateIso14443bTag(uint8_t *pupi) { LED_A_ON(); // the only commands we understand is WUPB, AFI=0, Select All, N=1: @@ -553,15 +553,15 @@ void SimulateIso14443bTag(uint32_t pupi) { 0x5e, 0xd7 }; - // response to HLTB and ATTRIB - static const uint8_t respOK[] = {0x00, 0x78, 0xF0}; - // ...PUPI/UID supplied from user. Adjust ATQB response accordingly - if (pupi > 0) { - num_to_bytes(pupi, 4, respATQB + 1); + if (memcmp("\x00\x00\x00\x00", pupi, 4) != 0) { + memcpy(respATQB + 1, pupi, 4); AddCrc14B(respATQB, 12); } + // response to HLTB and ATTRIB + static const uint8_t respOK[] = {0x00, 0x78, 0xF0}; + // setup device. FpgaDownloadAndGo(FPGA_BITSTREAM_HF); diff --git a/armsrc/iso14443b.h b/armsrc/iso14443b.h index 3fde4ffe0..7e5023e1b 100644 --- a/armsrc/iso14443b.h +++ b/armsrc/iso14443b.h @@ -32,7 +32,7 @@ int iso14443b_apdu(uint8_t const *msg, size_t msg_len, bool send_chaining, uint8 int iso14443b_select_card(iso14b_card_select_t *card); int iso14443b_select_card_srx(iso14b_card_select_t *card); -void SimulateIso14443bTag(uint32_t pupi); +void SimulateIso14443bTag(uint8_t *pupi); void AcquireRawAdcSamplesIso14443b(uint32_t parameter); void ReadSTMemoryIso14443b(uint16_t numofblocks); void SniffIso14443b(void); diff --git a/client/src/cmdhf14b.c b/client/src/cmdhf14b.c index a1be64ffd..dd90a4e39 100644 --- a/client/src/cmdhf14b.c +++ b/client/src/cmdhf14b.c @@ -34,35 +34,6 @@ bool apdu_in_framing_enable = true; static int CmdHelp(const char *Cmd); -static int usage_hf_14b_info(void) { - PrintAndLogEx(NORMAL, "Usage: hf 14b info [h] [s]"); - PrintAndLogEx(NORMAL, "Options:"); - PrintAndLogEx(NORMAL, " h this help"); - PrintAndLogEx(NORMAL, " s silently"); - PrintAndLogEx(NORMAL, "Example:"); - PrintAndLogEx(NORMAL, _YELLOW_(" hf 14b info")); - return PM3_SUCCESS; -} -static int usage_hf_14b_reader(void) { - PrintAndLogEx(NORMAL, "Usage: hf 14b reader [h] [v]"); - PrintAndLogEx(NORMAL, "Options:"); - PrintAndLogEx(NORMAL, " h this help"); - PrintAndLogEx(NORMAL, " v verbose"); - PrintAndLogEx(NORMAL, "Example:"); - PrintAndLogEx(NORMAL, _YELLOW_(" hf 14b reader")); - return PM3_SUCCESS; -} -static int usage_hf_14b_sim(void) { - PrintAndLogEx(NORMAL, "Emulating ISO/IEC 14443 type B tag with 4 UID / PUPI"); - PrintAndLogEx(NORMAL, "Usage: hf 14b sim [h] u "); - PrintAndLogEx(NORMAL, "Options:"); - PrintAndLogEx(NORMAL, " h this help"); - PrintAndLogEx(NORMAL, " u 4byte UID/PUPI"); - PrintAndLogEx(NORMAL, "Example:"); - PrintAndLogEx(NORMAL, _YELLOW_(" hf 14b sim")); - PrintAndLogEx(NORMAL, _YELLOW_(" hf 14b sim u 11223344")); - return PM3_SUCCESS; -} static int usage_hf_14b_read_srx(void) { PrintAndLogEx(NORMAL, "Usage: hf 14b sriread [h] <1|2>"); PrintAndLogEx(NORMAL, "Options:"); @@ -158,16 +129,29 @@ static int CmdHF14BList(const char *Cmd) { } static int CmdHF14BSim(const char *Cmd) { - char cmdp = tolower(param_getchar(Cmd, 0)); - if (cmdp == 'h') return usage_hf_14b_sim(); - - uint32_t pupi = 0; - if (cmdp == 'u') { - pupi = param_get32ex(Cmd, 1, 0, 16); - } + + CLIParserContext *ctx; + CLIParserInit(&ctx, "hf 14b sim", + "Simulate a ISO/IEC 14443 type B tag with 4 byte UID / PUPI", + "hf 14b sim\n" + "hf 14b sim -u 11AA33BB" + ); + + void *argtable[] = { + arg_param_begin, + arg_strx0("u", "uid", "hex", "4byte UID/PUPI"), + arg_param_end + }; + CLIExecWithReturn(ctx, Cmd, argtable, true); + + uint8_t pupi[4]; + int n = 0; + CLIParamHexToBuf(arg_get_str(ctx, 1), pupi, sizeof(pupi), &n); + CLIParserFree(ctx); clearCommandBuffer(); - SendCommandMIX(CMD_HF_ISO14443B_SIMULATE, pupi, 0, 0, NULL, 0); + SendCommandNG(CMD_HF_ISO14443B_SIMULATE, pupi, sizeof(pupi)); + return PM3_SUCCESS; } @@ -722,10 +706,20 @@ static bool HF14B_ST_Info(bool verbose) { // menu command to get and print all info known about any known 14b tag static int CmdHF14Binfo(const char *Cmd) { - char cmdp = tolower(param_getchar(Cmd, 0)); - if (cmdp == 'h') return usage_hf_14b_info(); + CLIParserContext *ctx; + CLIParserInit(&ctx, "hf 14b info", + "Tag information for ISO/IEC 14443 type B based tags", + "hf 14b info\n" + ); - bool verbose = !(cmdp == 's'); + void *argtable[] = { + arg_param_begin, + arg_lit0("v", "verbose", "verbose"), + arg_param_end + }; + CLIExecWithReturn(ctx, Cmd, argtable, true); + bool verbose = arg_get_lit(ctx, 1); + CLIParserFree(ctx); return infoHF14B(verbose); } @@ -938,9 +932,20 @@ static bool HF14B_other_reader(bool verbose) { // menu command to get and print general info about all known 14b chips static int CmdHF14BReader(const char *Cmd) { - char cmdp = tolower(param_getchar(Cmd, 0)); - if (cmdp == 'h') return usage_hf_14b_reader(); - bool verbose = (cmdp == 'v'); + CLIParserContext *ctx; + CLIParserInit(&ctx, "hf 14b reader", + "Act as a 14443B reader to identify a tag", + "hf 14b reader\n" + ); + + void *argtable[] = { + arg_param_begin, + arg_lit0("v", "verbose", "verbose"), + arg_param_end + }; + CLIExecWithReturn(ctx, Cmd, argtable, true); + bool verbose = arg_get_lit(ctx, 1); + CLIParserFree(ctx); return readHF14B(verbose); } From 2b4124d66566a9d18701642b582ec043302d99fd Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Fri, 2 Oct 2020 19:40:01 +0200 Subject: [PATCH 22/28] hf 14b dump - now uses cliparser, and only work on ST SRx tags --- client/src/cmdhf14b.c | 90 +++++++++++++++++-------------------------- 1 file changed, 35 insertions(+), 55 deletions(-) diff --git a/client/src/cmdhf14b.c b/client/src/cmdhf14b.c index dd90a4e39..d4c31237d 100644 --- a/client/src/cmdhf14b.c +++ b/client/src/cmdhf14b.c @@ -58,21 +58,6 @@ static int usage_hf_14b_write_srx(void) { PrintAndLogEx(NORMAL, _YELLOW_(" hf 14b sriwrite 2 FF 11223344")); return PM3_SUCCESS; } -static int usage_hf_14b_dump(void) { - PrintAndLogEx(NORMAL, "This command dumps the contents of a ISO-14443-B tag and save it to file\n" - "If memory size defaults to SRI4K if auto detect fails.\n" - "\n" - "Usage: hf 14b dump [h] \n" - "Options:\n" - "\th this help\n" - "\tf (optional) filename, if no UID will be used as filename\n" - "\n" - "Example:\n" - _YELLOW_("\thf 14b dump\n") - _YELLOW_("\thf 14b dump f mydump") - ); - return PM3_SUCCESS; -} static int switch_off_field_14b(void) { clearCommandBuffer(); @@ -373,7 +358,7 @@ static int print_atqb_resp(uint8_t *data, uint8_t cid) { } // get SRx chip model (from UID) // from ST Microelectronics -static char *get_ST_Chip_Model(uint8_t data) { +static char *get_st_chip_model(uint8_t data) { static char model[20]; char *retStr = model; memset(model, 0, sizeof(model)); @@ -602,7 +587,7 @@ static void print_st_general_info(uint8_t *data, uint8_t len) { PrintAndLogEx(NORMAL, ""); PrintAndLogEx(SUCCESS, " UID: " _GREEN_("%s"), sprint_hex(SwapEndian64(data, 8, 8), len)); PrintAndLogEx(SUCCESS, " MFG: %02X, " _YELLOW_("%s"), mfgid, getTagInfo(mfgid)); - PrintAndLogEx(SUCCESS, "Chip: %02X, " _YELLOW_("%s"), chipid, get_ST_Chip_Model(chipid)); + PrintAndLogEx(SUCCESS, "Chip: %02X, " _YELLOW_("%s"), chipid, get_st_chip_model(chipid)); } // print UID info from ASK CT chips @@ -619,12 +604,9 @@ static void print_ct_general_info(void *vcard) { } -// iceman, some 14B APDU break down +// iceman, calypso? // 05 00 00 = find one tag in field // 1d xx xx xx xx 00 08 01 00 = attrib xx=UID (resp 10 [f9 e0]) -// a3 = ? (resp 03 [e2 c2]) -// 02 = ? (resp 02 [6a d3]) -// 022b (resp 02 67 00 [29 5b]) // 0200a40400 (resp 02 67 00 [29 5b]) // 0200a4040c07a0000002480300 (resp 02 67 00 [29 5b]) // 0200a4040c07a0000002480200 (resp 02 67 00 [29 5b]) @@ -633,10 +615,6 @@ static void print_ct_general_info(void *vcard) { // 0200a404000cd2760001354b414e4d30310000 (resp 02 6a 82 [4b 4c]) // 0200a404000ca000000063504b43532d313500 (resp 02 6a 82 [4b 4c]) // 0200a4040010a000000018300301000000000000000000 (resp 02 6a 82 [4b 4c]) -// 03 = ? (resp 03 [e3 c2]) -// c2 = ? (resp c2 [66 15]) -// b2 = ? (resp a3 [e9 67]) -// a2 = ? (resp 02 [6a d3]) // 14b get and print Full Info (as much as we know) static bool HF14B_Std_Info(bool verbose) { @@ -1036,43 +1014,45 @@ static int CmdHF14BWriteSri(const char *Cmd) { // need to write to file static int CmdHF14BDump(const char *Cmd) { - uint8_t fileNameLen = 0; + CLIParserContext *ctx; + CLIParserInit(&ctx, "hf 14b dump", + "This command dumps the contents of a ISO-14443-B tag and save it to file\n" + "Tries to autodetect cardtype, memory size defaults to SRI4K", + "hf 14b dump\n" + "hf 14b dump -f myfilename\n" + ); + + void *argtable[] = { + arg_param_begin, + arg_strx0("f", "file", "", "(optional) filename, if no UID will be used as filename"), + arg_param_end + }; + CLIExecWithReturn(ctx, Cmd, argtable, true); + + int fnlen = 0; char filename[FILE_PATH_SIZE] = {0}; char *fptr = filename; - bool errors = false; - uint8_t cmdp = 0, cardtype = 1; - uint16_t cardsize = 0; - - while (param_getchar(Cmd, cmdp) != 0x00 && !errors) { - switch (tolower(param_getchar(Cmd, cmdp))) { - case 'h': - return usage_hf_14b_dump(); - case 'f': - fileNameLen = param_getstr(Cmd, cmdp + 1, filename, FILE_PATH_SIZE); - cmdp += 2; - break; - default: - PrintAndLogEx(WARNING, "Unknown parameter '%c'\n", param_getchar(Cmd, cmdp)); - errors = true; - break; - } - } - - //Validations - if (errors) return usage_hf_14b_dump(); + CLIParamStrToBuf(arg_get_str(ctx, 1), (uint8_t*)filename, FILE_PATH_SIZE, &fnlen); + CLIParserFree(ctx); iso14b_card_select_t card; if (get_14b_UID(&card) == false) { - PrintAndLogEx(WARNING, "No tag found."); + PrintAndLogEx(WARNING, "no tag found"); + return PM3_SUCCESS; + } + + if (card.uidlen != 8) { + PrintAndLogEx(FAILED, "current dump command only work with SRI4K / SRI512 tags"); return PM3_SUCCESS; } // detect cardsize // 1 = 4096 // 2 = 512 - cardtype = get_st_cardsize(card.uid); - + uint8_t cardtype = get_st_cardsize(card.uid); uint8_t blocks = 0; + uint16_t cardsize = 0; + switch (cardtype) { case 2: cardsize = (512 / 8) + 4; @@ -1085,17 +1065,17 @@ static int CmdHF14BDump(const char *Cmd) { break; } - if (fileNameLen < 1) { - PrintAndLogEx(INFO, "Using UID as filename"); + if (fnlen < 1) { + PrintAndLogEx(INFO, "using UID as filename"); fptr += sprintf(fptr, "hf-14b-"); FillFileNameByUID(fptr, SwapEndian64(card.uid, card.uidlen, 8), "-dump", card.uidlen); } uint8_t chipid = get_st_chipid(card.uid); - PrintAndLogEx(SUCCESS, "Found a " _GREEN_("%s") " tag", get_ST_Chip_Model(chipid)); + PrintAndLogEx(SUCCESS, "found a " _GREEN_("%s") " tag", get_st_chip_model(chipid)); // detect blocksize from card :) - PrintAndLogEx(INFO, "Reading memory from tag UID " _GREEN_("%s"), sprint_hex_inrow(SwapEndian64(card.uid, card.uidlen, 8), card.uidlen)); + PrintAndLogEx(INFO, "reading tag memory from UID " _GREEN_("%s"), sprint_hex_inrow(SwapEndian64(card.uid, card.uidlen, 8), card.uidlen)); uint8_t data[cardsize]; memset(data, 0, sizeof(data)); @@ -1163,7 +1143,7 @@ static int CmdHF14BDump(const char *Cmd) { PrintAndLogEx(NORMAL, ""); if (blocknum != 0xFF) { - PrintAndLogEx(FAILED, "Dump failed"); + PrintAndLogEx(FAILED, "dump failed"); goto out; } From 7eadc900c19f0ba40f73c2985e5bbd7fefe751e0 Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Fri, 2 Oct 2020 19:42:19 +0200 Subject: [PATCH 23/28] pwr_oe2 is LF --- fpga/hi_flite.v | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/fpga/hi_flite.v b/fpga/hi_flite.v index 6cb87825e..c87a002cc 100644 --- a/fpga/hi_flite.v +++ b/fpga/hi_flite.v @@ -39,6 +39,7 @@ wire disabl = mod_type[0]; // Most off, oe4 for modulation; // Trying reader emulation (would presumably just require switching power on, but I am not sure) assign pwr_lo = 1'b0; +assign pwr_oe2 = 1'b0; // 512x64/fc -wait before ts0, 32768 ticks // tslot: 256*64/fc @@ -339,7 +340,6 @@ end //put modulation here to maintain the correct clock. Seems that some readers are sensitive to that reg pwr_hi; reg pwr_oe1; -reg pwr_oe2; reg pwr_oe3; reg pwr_oe4; @@ -351,7 +351,6 @@ begin begin pwr_hi <= ck_1356meg; pwr_oe1 <= 1'b0;//mod; - pwr_oe2 <= 1'b0;//mod; pwr_oe3 <= 1'b0;//mod; pwr_oe4 <= mod;//1'b0; end @@ -359,10 +358,12 @@ begin begin pwr_hi <= 1'b0; pwr_oe1 <= 1'b0; - pwr_oe2 <= 1'b0; pwr_oe3 <= 1'b0; pwr_oe4 <= mod; end end + + + endmodule From 8e5a2850997da79e2ac628c6fc8db7ec04e7e83c Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Fri, 2 Oct 2020 19:42:47 +0200 Subject: [PATCH 24/28] textual --- fpga/hi_iso14443a.v | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/fpga/hi_iso14443a.v b/fpga/hi_iso14443a.v index 958436e69..f339b14e6 100644 --- a/fpga/hi_iso14443a.v +++ b/fpga/hi_iso14443a.v @@ -540,16 +540,14 @@ begin bit_to_arm = sendbit; end - - - assign ssp_din = bit_to_arm; // Subcarrier (adc_clk/16, for FPGA_HF_ISO14443A_TAGSIM_MOD only). wire sub_carrier; assign sub_carrier = ~sub_carrier_cnt[3]; -// in FPGA_HF_ISO14443A_READER_MOD: drop carrier for mod_sig_coil==1 (pause); in FPGA_HF_ISO14443A_READER_LISTEN: carrier always on; in other modes: carrier always off +// in FPGA_HF_ISO14443A_READER_MOD: drop carrier for mod_sig_coil == 1 (pause); +// in FPGA_HF_ISO14443A_READER_LISTEN: carrier always on; in other modes: carrier always off assign pwr_hi = (ck_1356meg & (((mod_type == `FPGA_HF_ISO14443A_READER_MOD) & ~mod_sig_coil) || (mod_type == `FPGA_HF_ISO14443A_READER_LISTEN))); @@ -566,7 +564,6 @@ assign pwr_oe4 = mod_sig_coil & sub_carrier & (mod_type == `FPGA_HF_ISO14443A_TA assign pwr_oe2 = 1'b0; assign pwr_lo = 1'b0; - assign dbg = negedge_cnt[3]; endmodule From 40413c9b0cb5459fc4c39a18b70c1f4726c1b6ab Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Fri, 2 Oct 2020 20:19:58 +0200 Subject: [PATCH 25/28] zero padding --- client/src/cmdhf14b.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/cmdhf14b.c b/client/src/cmdhf14b.c index d4c31237d..5f3936cf6 100644 --- a/client/src/cmdhf14b.c +++ b/client/src/cmdhf14b.c @@ -597,7 +597,7 @@ static void print_ct_general_info(void *vcard) { uint32_t uid32 = (card.uid[0] |card.uid[1] << 8 |card.uid[2] << 16 | card.uid[3] << 24); PrintAndLogEx(SUCCESS, "ASK C-Ticket"); - PrintAndLogEx(SUCCESS, " UID: " _GREEN_("%s") " ( " _YELLOW_("%u") " )", sprint_hex(card.uid, sizeof(card.uid)), uid32); + PrintAndLogEx(SUCCESS, " UID: " _GREEN_("%s") " ( " _YELLOW_("%010u") " )", sprint_hex(card.uid, sizeof(card.uid)), uid32); PrintAndLogEx(SUCCESS, " Product Code: %02X", card.pc); PrintAndLogEx(SUCCESS, " Facility Code: %02X", card.fc); PrintAndLogEx(NORMAL, ""); From d612f17b13f760c98d5e3b10c8f5974a2a39de6e Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Sat, 3 Oct 2020 00:03:44 +0200 Subject: [PATCH 26/28] hf 14b sriread - uses cliparser --- client/src/cmdhf14b.c | 43 +++++++++++++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 14 deletions(-) diff --git a/client/src/cmdhf14b.c b/client/src/cmdhf14b.c index 5f3936cf6..87589f299 100644 --- a/client/src/cmdhf14b.c +++ b/client/src/cmdhf14b.c @@ -34,16 +34,6 @@ bool apdu_in_framing_enable = true; static int CmdHelp(const char *Cmd); -static int usage_hf_14b_read_srx(void) { - PrintAndLogEx(NORMAL, "Usage: hf 14b sriread [h] <1|2>"); - PrintAndLogEx(NORMAL, "Options:"); - PrintAndLogEx(NORMAL, " h this help"); - PrintAndLogEx(NORMAL, " <1|2> 1 = SRIX4K , 2 = SRI512"); - PrintAndLogEx(NORMAL, "Example:"); - PrintAndLogEx(NORMAL, _YELLOW_(" hf 14b sriread 1")); - PrintAndLogEx(NORMAL, _YELLOW_(" hf 14b sriread 2")); - return PM3_SUCCESS; -} static int usage_hf_14b_write_srx(void) { PrintAndLogEx(NORMAL, "Usage: hf 14b [h] sriwrite <1|2> "); PrintAndLogEx(NORMAL, "Options:"); @@ -932,11 +922,36 @@ static int CmdHF14BReader(const char *Cmd) { * this command just dumps the contents of the memory/ */ static int CmdHF14BReadSri(const char *Cmd) { - char cmdp = tolower(param_getchar(Cmd, 0)); - if (strlen(Cmd) < 1 || cmdp == 'h') return usage_hf_14b_read_srx(); + + CLIParserContext *ctx; + CLIParserInit(&ctx, "hf 14b sriread", + "Read contents of a SRI512 | SRIX4K tag", + "hf 14b sriread\n" + ); + + void *argtable[] = { + arg_param_begin, + arg_param_end + }; + CLIExecWithReturn(ctx, Cmd, argtable, true); + CLIParserFree(ctx); + + iso14b_card_select_t card; + if (get_14b_UID(&card) == false) { + PrintAndLogEx(WARNING, "no tag found"); + return PM3_SUCCESS; + } - uint8_t tagtype = param_get8(Cmd, 0); - uint8_t blocks = (tagtype == 1) ? 0x7F : 0x0F; + if (card.uidlen != 8) { + PrintAndLogEx(FAILED, "current dump command only work with SRI4K / SRI512 tags"); + return PM3_SUCCESS; + } + + // detect cardsize + // 1 = 4096 + // 2 = 512 + uint8_t cardtype = get_st_cardsize(card.uid); + uint8_t blocks = (cardtype == 1) ? 0x7F : 0x0F; clearCommandBuffer(); SendCommandMIX(CMD_HF_SRI_READ, blocks, 0, 0, NULL, 0); From 5e18463f8b343d507b11b361d62e0720fbb5a884 Mon Sep 17 00:00:00 2001 From: mwalker33 Date: Sat, 3 Oct 2020 11:34:33 +1000 Subject: [PATCH 27/28] Update cliparser.md Added 0 or 1 string option a little formatting. --- doc/cliparser.md | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/doc/cliparser.md b/doc/cliparser.md index 83002dda4..044f8f8e3 100644 --- a/doc/cliparser.md +++ b/doc/cliparser.md @@ -6,14 +6,15 @@ Note: the parser will format and color and layout as needed. -## common options -where possiable all options should be lowercase. -extended options preceeded with -- should be short -options provided directly (without an option identifier) should be avoided. --vv for extra verbos should be avoided; use of debug level is prefered. -whith --options the equle is not needed (will work with and without) so dont use '=' -e.g. cmd --cn 12345 +## design comments +* where possiable all options should be lowercase. +* extended options preceeded with -- should be short +* options provided directly (without an option identifier) should be avoided. +* -vv for extra verbos should be avoided; use of debug level is prefered. +* with --options the equal is not needed (will work with and without) so dont use '=' + e.g. cmd --cn 12345 +## common options -h --help : help --cn : card number --fn : facility number @@ -61,13 +62,21 @@ e.g. lf indala clone -r a0000000a0002021 -> this uses ..... }; **Notes:** -booleen : arg_lit0 ("\", "\", \["\",\] \<"description"\>); -optional integer : arg_int0 ("\", "\", \["\",\] \<"description"\>); -required integer : arg_int1 ("\", "\", \["\",\] \<"description"\>); -optional string : arg_strx0 ("\", "\", \["\",\] \<"description"\>); -required string : arg_strx1 ("\", "\", \["\",\] \<"description"\>); +booleen : arg_lit0 ("\", "\", \["\",\] \<"description"\>) -** if an option does not have a short or long option, use NULL in its place. ** +**integer** + optional integer : arg_int0 ("\", "\", \["\",\] \<"description"\>)\ + required integer : arg_int1 ("\", "\", \["\",\] \<"description"\>) + +**Strings 0 or 1** + optional string : arg_str0("\", "\", \["\",\] \<"description"\>)\ + required string : arg_str1("\", "\", \["\",\] \<"description"\>) + +**Strings x to 250** + optional string : arg_strx0 ("\", "\", \["\",\] \<"description"\>)\ + required string : arg_strx1 ("\", "\", \["\",\] \<"description"\>) + +**if an option does not have a short or long option, use NULL in its place** ### show the menu CLIExecWithReturn(\, \, \, \); From dff8848af2b839741e6508d199fe154772235dd8 Mon Sep 17 00:00:00 2001 From: Iceman Date: Sat, 3 Oct 2020 10:36:05 +0200 Subject: [PATCH 28/28] Update cliparser.md --- doc/cliparser.md | 40 +++++++++++++++++++++++++++++++++++----- 1 file changed, 35 insertions(+), 5 deletions(-) diff --git a/doc/cliparser.md b/doc/cliparser.md index 044f8f8e3..bbc6c6b42 100644 --- a/doc/cliparser.md +++ b/doc/cliparser.md @@ -1,12 +1,33 @@ -# cliparser - proxmark3-rrg +# Cliparser + +The old style with mixed custom commandline parsing of user parameters or options was messy and confusing. You can find all kinds in the Proxmark3 client. +Samples +``` +data xxxx h +script run x.lua -h +hf 14a raw -h +hf 14b raw -ss +lf search 1 +lf config h H +``` +In order to counter this and unify it, there was discussion over at the official repository a few years ago (link to issue) and there it became clear a change is needed. Among the different solutions suggested @merlokk's idea of using the lib cliparser was agreed upon. The lib was adapted and implemented for commands like +``` +emv +hf fido +``` +And then it fell into silence since it wasn't well documented how to use the cliparser. Looking at source code wasn't very efficient. However the need of a better cli parsing was still there. Fast forward today, where more commands has used the cliparser but it still wasn't the natural way when adding a new client command to the Proxmark3 client. After more discussions among @doegox, @iceman1001 and @mrwalker the concept became more clear on how to use the cliparser lib in the _preferred_ way. The aftermath was a design and layout specfied which lead to a simpler implemtentation of the cliparser in the client source code while still unfiy all helptexts with the new colours support and a defined layout. As seen below, the simplicity and clearness. + +![sample of new style helptext](http://www.icedev.se/proxmark3/helptext.png) + + ## cliparser setup and use -*** Draft notes - needs work *** - -Note: the parser will format and color and layout as needed. +The parser will format and color and layout as needed. +It will also add the `-h --help` option automatic. ## design comments + * where possiable all options should be lowercase. * extended options preceeded with -- should be short * options provided directly (without an option identifier) should be avoided. @@ -14,6 +35,8 @@ Note: the parser will format and color and layout as needed. * with --options the equal is not needed (will work with and without) so dont use '=' e.g. cmd --cn 12345 + + ## common options -h --help : help --cn : card number @@ -25,6 +48,10 @@ Note: the parser will format and color and layout as needed. -v --verbose : flag when output should provide more information, not conidered debug. -1 --buffer : use the sample buffer + + +## How to implement in source code + ### setup the parser data structure Header file to include @@ -60,7 +87,10 @@ e.g. lf indala clone -r a0000000a0002021 -> this uses ..... arg_int0(NULL, "cn", "", "Cardnumber (26 bit format)"), arg_param_end }; - + +_All options has a parameter index, since `-h --help` is added automatic, it will be assigned index 0. +Hence all options you add will start at index 1 and upwards._ + **Notes:** booleen : arg_lit0 ("\", "\", \["\",\] \<"description"\>)