Merge branch 'master' into fix-wiegand-formats
Signed-off-by: Iceman <iceman@iuse.se>
This commit is contained in:
7 files changed
+79
-30
No files matched your search
@@ -4,6 +4,10 @@ This project uses the changelog in accordance with [keepchangelog](http://keepac
|
||||
|
||||
## [unreleased][unreleased]
|
||||
- Fixed `wiegand` formats - HPP32, H10320 and S12906b encode as laid out, HGen37 decode checks the right parity bit, the limits of nine formats match their fields, `wiegand list -h` shows its own usage (@matrix)
|
||||
- Fixed `hf secc sim` - the ATQA codes the UID size, so readers that check it select a 7 or 10 byte UID, and a zero UID prints as taken from emulator memory (@matrix)
|
||||
- Fixed `lf keri clone` and `sim` - values the frame can't carry are refused instead of cut, `sim` prints the id and its raw, the help example and the clone hint name `--id` and `lf keri reader` (@matrix)
|
||||
- Fixed `lf paradox clone` and `sim` - FC above 255 and CN above 65535 are refused instead of cut, the clone hint names `lf paradox reader` (@matrix)
|
||||
- Fixed NDEF TLV decoding - a NULL TLV has no length, Lock and Memory Control sizes of 0 mean 256 and their page fields are powers of two (@matrix)
|
||||
- Fixed flashing with redirected output - the progress animation is drawn only when stdout is a terminal (@matrix)
|
||||
- Fixed `proxmark3 --flash`, `--dumpmem` and `--reboot-to-bootloader` exit status - a failure exits 1, a failed flash no longer ends with `All done` (@matrix)
|
||||
- Fixed `data rawdemod` - `--max`, `--samples` and the `--p2` clock no longer wrap above 255, `--fs` refuses values above 255 (@matrix)
|
||||
|
||||
@@ -475,6 +475,11 @@ static int CmdHFHIDConfigSim(const char *Cmd) {
|
||||
char uid_str[2 * sizeof(uid) + 1];
|
||||
strncpy(uid_str, sprint_hex_inrow(uid, uidlen), sizeof(uid_str) - 1);
|
||||
uid_str[sizeof(uid_str) - 1] = '\0';
|
||||
// an all-zero UID makes the device take a 4-byte UID from emulator memory
|
||||
bool uid_from_emul = (memcmp(uid, "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", sizeof(uid)) == 0);
|
||||
if (uid_from_emul) {
|
||||
snprintf(uid_str, sizeof(uid_str), "from emulator memory");
|
||||
}
|
||||
PrintAndLogEx(INFO, "HID Config Card sim:"
|
||||
" UID " _YELLOW_("%s")
|
||||
" AID " _YELLOW_("%s")
|
||||
@@ -490,7 +495,8 @@ static int CmdHFHIDConfigSim(const char *Cmd) {
|
||||
payload.tagtype = 4; // ISO14443-4 base type; ATQA/SAK/ATS overridden by ARM
|
||||
payload.flags = flags;
|
||||
payload.exitAfter = exitAfterNReads;
|
||||
payload.atqa[0] = 0x02; // HID Config Card ATQA high byte
|
||||
// HID Config Card ATQA high byte, b8 b7 code the UID size (ISO/IEC 14443-3)
|
||||
payload.atqa[0] = 0x02 | ((uid_from_emul || uidlen == 4) ? 0x00 : ((uidlen == 7) ? 0x40 : 0x80));
|
||||
payload.atqa[1] = 0x00; // HID Config Card ATQA low byte
|
||||
payload.sak = 0x38; // HID Config Card SAK
|
||||
payload.ats_len = (uint8_t)ats_len;
|
||||
|
||||
+26
-6
@@ -248,8 +248,8 @@ static int CmdKeriClone(const char *Cmd) {
|
||||
int typeLen = sizeof(keritype) - 1; // CLIGetStrWithReturn does not guarantee string to be null-terminated
|
||||
CLIGetStrWithReturn(ctx, 1, keritype, &typeLen);
|
||||
|
||||
uint32_t fc = arg_get_int_def(ctx, 2, 0);
|
||||
uint32_t cid = arg_get_int_def(ctx, 3, 0);
|
||||
int fc_arg = arg_get_int_def(ctx, 2, 0);
|
||||
int cn_arg = arg_get_int_def(ctx, 3, 0);
|
||||
bool q5 = arg_get_lit(ctx, 4);
|
||||
bool em = arg_get_lit(ctx, 5);
|
||||
CLIParserFree(ctx);
|
||||
@@ -259,6 +259,20 @@ static int CmdKeriClone(const char *Cmd) {
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
|
||||
if (fc_arg < 0 || cn_arg < 0) {
|
||||
PrintAndLogEx(FAILED, "FC and CN can't be negative");
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
|
||||
// the MS scramble carries 5 bits of fc and 22 of cn
|
||||
if (keritype[0] == 'm' && (fc_arg > 31 || cn_arg > 0x3FFFFF)) {
|
||||
PrintAndLogEx(FAILED, "MS FC has a max value of 31 and CN has a max value of 4194303");
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
|
||||
uint32_t fc = (uint32_t)fc_arg;
|
||||
uint32_t cid = (uint32_t)cn_arg;
|
||||
|
||||
// Setup card data/build internal id
|
||||
uint32_t internalid = 0;
|
||||
switch (keritype[0]) {
|
||||
@@ -310,7 +324,7 @@ static int CmdKeriClone(const char *Cmd) {
|
||||
}
|
||||
|
||||
PrintAndLogEx(SUCCESS, "Done!");
|
||||
PrintAndLogEx(HINT, "Hint: Try " _YELLOW_("`lf keri read`") " to verify");
|
||||
PrintAndLogEx(HINT, "Hint: Try " _YELLOW_("`lf keri reader`") " to verify");
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -320,7 +334,7 @@ static int CmdKeriSim(const char *Cmd) {
|
||||
CLIParserInit(&ctx, "lf keri sim",
|
||||
"Enables simulation of KERI card with internal ID.\n"
|
||||
"You supply a KERI card id and it will converted to a KERI internal ID.",
|
||||
"lf keri sim --cn 112233"
|
||||
"lf keri sim --id 112233"
|
||||
);
|
||||
|
||||
void *argtable[] = {
|
||||
@@ -332,6 +346,14 @@ static int CmdKeriSim(const char *Cmd) {
|
||||
uint64_t internalid = arg_get_u64_def(ctx, 1, 0);
|
||||
CLIParserFree(ctx);
|
||||
|
||||
// the frame carries 31 bits of internal id
|
||||
if (internalid > 0x7FFFFFFF) {
|
||||
PrintAndLogEx(FAILED, "Internal Id has a max value of 2147483647");
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
|
||||
PrintAndLogEx(SUCCESS, "Simulating KERI - Internal Id " _YELLOW_("%" PRIu64) ", Raw: E0000000%08" PRIX64, internalid, internalid | 0x80000000);
|
||||
|
||||
internalid |= 0x80000000;
|
||||
internalid <<= 3;
|
||||
internalid += 7;
|
||||
@@ -343,8 +365,6 @@ static int CmdKeriSim(const char *Cmd) {
|
||||
bs[j++] = ((internalid >> i) & 1);
|
||||
}
|
||||
|
||||
PrintAndLogEx(SUCCESS, "Simulating KERI - Internal Id " _YELLOW_("%" PRIu64), internalid);
|
||||
|
||||
lf_psksim_t *payload = calloc(1, sizeof(lf_psksim_t) + sizeof(bs));
|
||||
if (payload == NULL) {
|
||||
PrintAndLogEx(WARNING, "Failed to allocate memory");
|
||||
|
||||
@@ -333,8 +333,9 @@ static int CmdParadoxClone(const char *Cmd) {
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
|
||||
if (fc > 999 || cn > 99999) {
|
||||
PrintAndLogEx(FAILED, "FC has a max value of 999 and CN has a max value of 99999");
|
||||
// the frame carries 8 bits of fc and 16 of cn
|
||||
if (fc > 0xFF || cn > 0xFFFF) {
|
||||
PrintAndLogEx(FAILED, "FC has a max value of 255 and CN has a max value of 65535");
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
|
||||
@@ -384,7 +385,7 @@ static int CmdParadoxClone(const char *Cmd) {
|
||||
res = clone_t55xx_tag(blocks, ARRAYLEN(blocks));
|
||||
}
|
||||
PrintAndLogEx(SUCCESS, "Done!");
|
||||
PrintAndLogEx(HINT, "Hint: Try " _YELLOW_("`lf paradox read`") " to verify");
|
||||
PrintAndLogEx(HINT, "Hint: Try " _YELLOW_("`lf paradox reader`") " to verify");
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -421,8 +422,9 @@ static int CmdParadoxSim(const char *Cmd) {
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
|
||||
if (fc > 999 || cn > 99999) {
|
||||
PrintAndLogEx(FAILED, "FC has a max value of 999 and CN has a max value of 99999");
|
||||
// the frame carries 8 bits of fc and 16 of cn
|
||||
if (fc > 0xFF || cn > 0xFFFF) {
|
||||
PrintAndLogEx(FAILED, "FC has a max value of 255 and CN has a max value of 65535");
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
if (raw_len != 0) {
|
||||
|
||||
+29
-17
@@ -1440,12 +1440,17 @@ int NDEFDecodeAndPrint(uint8_t *ndef, size_t ndefLen, bool verbose) {
|
||||
|
||||
switch (ndef[indx]) {
|
||||
case 0x00: {
|
||||
indx++;
|
||||
uint16_t len = ndefTLVGetLength(&ndef[indx], &indx);
|
||||
PrintAndLogEx(SUCCESS, "--- " _CYAN_("NDEF NULL block") " ---");
|
||||
if (len)
|
||||
PrintAndLogEx(WARNING, "NDEF NULL block size must be 0, got %d bytes", len);
|
||||
indx += len;
|
||||
// a NULL TLV is the T byte alone, without length
|
||||
size_t run = 0;
|
||||
while ((indx < ndefLen) && (ndef[indx] == 0x00)) {
|
||||
indx++;
|
||||
run++;
|
||||
}
|
||||
if (run == 1) {
|
||||
PrintAndLogEx(SUCCESS, "--- " _CYAN_("NDEF NULL block") " ---");
|
||||
} else {
|
||||
PrintAndLogEx(SUCCESS, "--- " _CYAN_("NDEF NULL block") " --- x %zu", run);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 0x01: {
|
||||
@@ -1458,15 +1463,16 @@ int NDEFDecodeAndPrint(uint8_t *ndef, size_t ndefLen, bool verbose) {
|
||||
} else {
|
||||
uint8_t pages_addr = (ndef[indx] >> 4) & 0x0f;
|
||||
uint8_t byte_offset = ndef[indx] & 0x0f;
|
||||
uint8_t Size = ndef[indx + 1];
|
||||
uint8_t BytesLockedPerLockBit = (ndef[indx + 2] >> 4) & 0x0f;
|
||||
uint8_t bytes_per_page = ndef[indx + 2] & 0x0f;
|
||||
// Type 2 Tag spec: Size 0 is 256 lock bits, both nibbles are powers of two
|
||||
uint16_t Size = (ndef[indx + 1]) ? ndef[indx + 1] : 256;
|
||||
uint16_t BytesLockedPerLockBit = 1 << ((ndef[indx + 2] >> 4) & 0x0f);
|
||||
uint16_t bytes_per_page = 1 << (ndef[indx + 2] & 0x0f);
|
||||
PrintAndLogEx(SUCCESS, " Pages addr (number of pages).... %d", pages_addr);
|
||||
PrintAndLogEx(SUCCESS, " Byte offset (number of bytes)... %d", byte_offset);
|
||||
PrintAndLogEx(SUCCESS, " Lock Area size in bits.......... %d ( %d bytes )", Size, Size / 8);
|
||||
PrintAndLogEx(SUCCESS, " Number of bytes / page... %d", bytes_per_page);
|
||||
PrintAndLogEx(SUCCESS, " Lock Area size in bits.......... %u ( %u bytes )", Size, (Size + 7) / 8);
|
||||
PrintAndLogEx(SUCCESS, " Number of bytes / page... %u", bytes_per_page);
|
||||
PrintAndLogEx(SUCCESS, " Bytes Locked Per LockBit");
|
||||
PrintAndLogEx(SUCCESS, " number of bytes that each dynamic lock bit locks... %d", BytesLockedPerLockBit);
|
||||
PrintAndLogEx(SUCCESS, " number of bytes that each dynamic lock bit locks... %u", BytesLockedPerLockBit);
|
||||
}
|
||||
indx += len;
|
||||
break;
|
||||
@@ -1481,11 +1487,12 @@ int NDEFDecodeAndPrint(uint8_t *ndef, size_t ndefLen, bool verbose) {
|
||||
} else {
|
||||
uint8_t pages_addr = (ndef[indx] >> 4) & 0x0f;
|
||||
uint8_t byte_offset = ndef[indx] & 0x0f;
|
||||
uint8_t Size = ndef[indx + 1];
|
||||
uint8_t bytes_per_page = ndef[indx + 2] & 0x0f;
|
||||
// Type 2 Tag spec: Size is in bytes, 0 is 256, the page size is a power of two
|
||||
uint16_t Size = (ndef[indx + 1]) ? ndef[indx + 1] : 256;
|
||||
uint16_t bytes_per_page = 1 << (ndef[indx + 2] & 0x0f);
|
||||
PrintAndLogEx(SUCCESS, "Pages addr (number of pages).... %u", pages_addr);
|
||||
PrintAndLogEx(SUCCESS, "Byte offset (number of bytes)... %u", byte_offset);
|
||||
PrintAndLogEx(SUCCESS, "Reserved area size in bits...... %u ( %u bytes )", Size, Size / 8);
|
||||
PrintAndLogEx(SUCCESS, "Reserved area size in bytes..... %u", Size);
|
||||
PrintAndLogEx(SUCCESS, " Number of bytes / page... %u", bytes_per_page);
|
||||
}
|
||||
indx += len;
|
||||
@@ -1541,8 +1548,13 @@ int NDEFGetTotalLength(uint8_t *ndef, size_t ndeflen, size_t *outlen) {
|
||||
size_t idx = 0;
|
||||
while (idx < ndeflen) {
|
||||
|
||||
if (ndef[idx] == 0x00 ||
|
||||
ndef[idx] == 0x01 ||
|
||||
// a NULL TLV is the T byte alone, no length
|
||||
if (ndef[idx] == 0x00) {
|
||||
idx++;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ndef[idx] == 0x01 ||
|
||||
ndef[idx] == 0x02 ||
|
||||
ndef[idx] == 0x03 ||
|
||||
ndef[idx] == 0xFD) {
|
||||
|
||||
+1
-1
@@ -13773,7 +13773,7 @@
|
||||
"command": "lf keri sim",
|
||||
"description": "Enables simulation of KERI card with internal ID. You supply a KERI card id and it will converted to a KERI internal ID.",
|
||||
"notes": [
|
||||
"lf keri sim --cn 112233"
|
||||
"lf keri sim --id 112233"
|
||||
],
|
||||
"offline": false,
|
||||
"options": [
|
||||
|
||||
@@ -493,6 +493,10 @@ while true; do
|
||||
if ! CheckExecute "nfc decode test apple wallet" "$CLIENTBIN -c 'nfc decode -d 031AD10116550077616C6C65743A2F2F61637469766174652F6E6663FE'" "activate/nfc"; then break; fi
|
||||
if ! CheckExecute "nfc decode test signature" "$CLIENTBIN -c 'nfc decode -d 03FF010194113870696C65742E65653A656B616172743A3266195F26063132303832325904202020205F28033233335F2701316E1B5A13333038363439303039303030323636343030355304EBF2CE704103000000AC536967010200803A2448FCA7D354A654A81BD021150D1A152D1DF4D7A55D2B771F12F094EAB6E5E10F2617A2F8DAD4FD38AFF8EA39B71C19BD42618CDA86EE7E144636C8E0E7CFC4096E19C3680E09C78A0CDBC05DA2D698E551D5D709717655E56FE3676880B897D2C70DF5F06ECE07C71435255144F8EE41AF110E7B180DA0E6C22FB8FDEF61800025687474703A2F2F70696C65742E65652F6372742F33303836343930302D303030312E637274FE'" "30864900-0001.crt"; then break; fi
|
||||
if ! CheckExecute "nfc decode test openprinter tag" "$CLIENTBIN -c 'nfc decode -d 03FF012F91013A55046E756D616B6572732E636F6D2F70726F64756374732F6162732D66696C616D656E743F76617269616E743D3436393434323937333836323932521CD26170706C69636174696F6E2F766E642E6F70656E7072696E74746167A10218AFBF041B000007D0FCAB45F9080009020A70414253204C656D6F6E2059656C6C6F770B684E756D616B6572730E1A69094200101903E81119041A1218F01343F9A800181DF93C29182218F01823190104182418AA1825185A18261864FF00'" "application/vnd.openprinttag"; then break; fi
|
||||
if ! CheckExecute "nfc decode null tlv run" "$CLIENTBIN -c 'nfc decode -d 0000000300FE'" "NDEF NULL block --- x 3"; then break; fi
|
||||
if ! CheckExecute "nfc decode lock control" "$CLIENTBIN -c 'nfc decode -d 0103A01044FE'" "number of bytes that each dynamic lock bit locks\.\.\. 16"; then break; fi
|
||||
if ! CheckExecute "nfc decode lock control size 0" "$CLIENTBIN -c 'nfc decode -d 0103A00044FE'" "Lock Area size in bits\.{10} 256 \( 32 bytes \)"; then break; fi
|
||||
if ! CheckExecute "nfc decode memory control" "$CLIENTBIN -c 'nfc decode -d 0203A03044FE'" "Reserved area size in bytes\.{5} 48"; then break; fi
|
||||
|
||||
if ! CheckExecute "wiegand list usage" "$CLIENTBIN -c 'wiegand list -h'" "wiegand list \[-h\]"; then break; fi
|
||||
if ! CheckExecute "wiegand encode new" "$CLIENTBIN -c 'wiegand encode -w H10301 --fc 123 --cn 4567 --new'" "New PACS\\.{9} 0x 06BD88EB80"; then break; fi
|
||||
@@ -647,6 +651,7 @@ while true; do
|
||||
if ! CheckExecute "lf T55 keri_msid test" "$CLIENTBIN -c 'data load -f traces/lf_ATA5577_keri_msid.pm3; lf search -1'" "KERI ID found"; then break; fi
|
||||
if ! CheckExecute "lf T55 keri_msid test 2" "$CLIENTBIN -c 'data load -f traces/lf_ATA5577_keri_msid.pm3; lf keri demod'" \
|
||||
"Descrambled MS - FC: 6 Card: 12345"; then break; fi
|
||||
if ! CheckExecute "lf keri sim help example" "$CLIENTBIN -c 'lf keri sim -h'" "lf keri sim --id 112233"; then break; fi
|
||||
# if ! CheckExecute "lf T55 motorola test" "$CLIENTBIN -c 'data load -f traces/lf_ATA5577_motorola.pm3; lf search -1'" "Indala ID found"; then break; fi
|
||||
if ! CheckExecute "lf T55 motorola test 2" "$CLIENTBIN -c 'data load -f traces/lf_ATA5577_motorola.pm3; lf motorola demod'" \
|
||||
"Motorola - fmt: 26 FC: 258 Card: 2, Raw: A0000000A0002021"; then break; fi
|
||||
|
||||
Reference in new issue
Block a user