mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-21 13:53:55 -07:00
lf keri - now supports continuous mode, EM (untested)
This commit is contained in:
parent
97b1562bad
commit
00f140683f
1 changed files with 69 additions and 65 deletions
|
@ -179,68 +179,56 @@ static int CmdKeriDemod(const char *Cmd) {
|
||||||
return demodKeri(true);
|
return demodKeri(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int CmdKeriRead(const char *Cmd) {
|
static int CmdKeriReader(const char *Cmd) {
|
||||||
(void)Cmd; // Cmd is not used so far
|
|
||||||
lf_read(false, 10000);
|
|
||||||
return demodKeri(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int CmdKeriClone(const char *Cmd) {
|
|
||||||
|
|
||||||
bool q5 = false, em = false;
|
|
||||||
|
|
||||||
uint8_t keritype[2] = {'i'}; // default to internalid
|
|
||||||
int typeLen = 0;
|
|
||||||
uint32_t fc = 0;
|
|
||||||
uint32_t cid = 0;
|
|
||||||
uint32_t internalid = 0;
|
|
||||||
uint32_t blocks[3] = {
|
|
||||||
T55x7_TESTMODE_DISABLED |
|
|
||||||
T55x7_X_MODE |
|
|
||||||
T55x7_MODULATION_PSK1 |
|
|
||||||
T55x7_PSKCF_RF_2 |
|
|
||||||
2 << T55x7_MAXBLOCK_SHIFT,
|
|
||||||
0,
|
|
||||||
0
|
|
||||||
};
|
|
||||||
|
|
||||||
// dynamic bitrate used
|
|
||||||
blocks[0] |= 0xF << 18;
|
|
||||||
|
|
||||||
CLIParserContext *ctx;
|
CLIParserContext *ctx;
|
||||||
CLIParserInit(&ctx, "lf keri clone",
|
CLIParserInit(&ctx, "lf keri reader",
|
||||||
"clone a KERI tag to a T55x7, Q5/T5555 or EM4305/4469 tag",
|
"read a keri tag",
|
||||||
"lf keri clone -t i --id 12345\n"
|
"lf keri reader -@ -> continuous reader mode"
|
||||||
"lf keri clone -t m --fc 6 --id 12345\n");
|
);
|
||||||
|
|
||||||
|
void *argtable[] = {
|
||||||
|
arg_param_begin,
|
||||||
|
arg_lit0("@", NULL, "optional - continuous reader mode"),
|
||||||
|
arg_param_end
|
||||||
|
};
|
||||||
|
CLIExecWithReturn(ctx, Cmd, argtable, true);
|
||||||
|
bool cm = arg_get_lit(ctx, 1);
|
||||||
|
CLIParserFree(ctx);
|
||||||
|
|
||||||
|
do {
|
||||||
|
lf_read(false, 10000);
|
||||||
|
demodKeri(!cm);
|
||||||
|
} while (cm && !kbd_enter_pressed());
|
||||||
|
|
||||||
|
return PM3_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int CmdKeriClone(const char *Cmd) {
|
||||||
|
CLIParserContext *ctx;
|
||||||
|
CLIParserInit(&ctx, "lf keri clone",
|
||||||
|
"clone a KERI tag to a T55x7, Q5/T5555 or EM4305/4469 tag",
|
||||||
|
"lf keri clone -t i --cn 12345 -> Internal ID\n"
|
||||||
|
"lf keri clone -t m --fc 6 --cn 12345 -> MS ID\n");
|
||||||
|
|
||||||
void *argtable[] = {
|
void *argtable[] = {
|
||||||
arg_param_begin,
|
arg_param_begin,
|
||||||
arg_lit0("q", "q5", "specify writing to Q5/T5555 tag"),
|
|
||||||
arg_str0("t", "type", "<m|i>", "Type m - MS, i - Internal ID"),
|
arg_str0("t", "type", "<m|i>", "Type m - MS, i - Internal ID"),
|
||||||
arg_int0(NULL, "fc", "<dec>", "Facility Code"),
|
arg_int0(NULL, "fc", "<dec>", "Facility Code"),
|
||||||
arg_int1(NULL, "id", "<dec>", "Keri ID"),
|
arg_int1(NULL, "cn", "<dec>", "KERI card ID"),
|
||||||
|
arg_lit0(NULL, "q5", "specify writing to Q5/T5555 tag"),
|
||||||
arg_lit0(NULL, "em", "specify writing to EM4305/4469 tag"),
|
arg_lit0(NULL, "em", "specify writing to EM4305/4469 tag"),
|
||||||
arg_param_end
|
arg_param_end
|
||||||
};
|
};
|
||||||
CLIExecWithReturn(ctx, Cmd, argtable, false);
|
CLIExecWithReturn(ctx, Cmd, argtable, false);
|
||||||
|
|
||||||
char cardtype[16] = {"T55x7"};
|
uint8_t keritype[2] = {'i'}; // default to internalid
|
||||||
if (arg_get_lit(ctx, 1)) {
|
int typeLen = sizeof(keritype);
|
||||||
blocks[0] = T5555_FIXED | T5555_MODULATION_PSK1 | T5555_SET_BITRATE(32) | T5555_PSK_RF_2 | 2 << T5555_MAXBLOCK_SHIFT;
|
CLIGetStrWithReturn(ctx, 1, keritype, &typeLen);
|
||||||
snprintf(cardtype, sizeof(cardtype), "Q5/T5555");
|
|
||||||
q5 = true;
|
|
||||||
}
|
|
||||||
if (arg_get_lit(ctx, 5)) {
|
|
||||||
blocks[0] = EM4305_KERI_CONFIG_BLOCK;
|
|
||||||
snprintf(cardtype, sizeof(cardtype), "EM4305/4469");
|
|
||||||
em = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
typeLen = sizeof(keritype);
|
uint32_t fc = arg_get_int_def(ctx, 2, 0);
|
||||||
CLIGetStrWithReturn(ctx, 2, keritype, &typeLen);
|
uint32_t cid = arg_get_int_def(ctx, 3, 0);
|
||||||
|
bool q5 = arg_get_lit(ctx, 4);
|
||||||
fc = arg_get_int_def(ctx, 3, 0);
|
bool em = arg_get_lit(ctx, 5);
|
||||||
cid = arg_get_int_def(ctx, 4, 0);
|
|
||||||
CLIParserFree(ctx);
|
CLIParserFree(ctx);
|
||||||
|
|
||||||
if (q5 && em) {
|
if (q5 && em) {
|
||||||
|
@ -249,6 +237,7 @@ static int CmdKeriClone(const char *Cmd) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Setup card data/build internal id
|
// Setup card data/build internal id
|
||||||
|
uint32_t internalid = 0;
|
||||||
switch (keritype[0]) {
|
switch (keritype[0]) {
|
||||||
case 'i' : // Internal ID
|
case 'i' : // Internal ID
|
||||||
// MSB is ONE
|
// MSB is ONE
|
||||||
|
@ -262,6 +251,24 @@ static int CmdKeriClone(const char *Cmd) {
|
||||||
return PM3_EINVARG;
|
return PM3_EINVARG;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32_t blocks[3];
|
||||||
|
blocks[0] = T55x7_TESTMODE_DISABLED | T55x7_X_MODE | T55x7_MODULATION_PSK1 | T55x7_PSKCF_RF_2 | 2 << T55x7_MAXBLOCK_SHIFT;
|
||||||
|
// dynamic bitrate used
|
||||||
|
blocks[0] |= 0xF << 18;
|
||||||
|
|
||||||
|
char cardtype[16] = {"T55x7"};
|
||||||
|
|
||||||
|
if (q5) {
|
||||||
|
blocks[0] = T5555_FIXED | T5555_MODULATION_PSK1 | T5555_SET_BITRATE(32) | T5555_PSK_RF_2 | 2 << T5555_MAXBLOCK_SHIFT;
|
||||||
|
snprintf(cardtype, sizeof(cardtype), "Q5/T5555");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (em) {
|
||||||
|
blocks[0] = EM4305_KERI_CONFIG_BLOCK;
|
||||||
|
snprintf(cardtype, sizeof(cardtype), "EM4305/4469");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Prepare and write to card
|
// Prepare and write to card
|
||||||
// 3 LSB is ONE
|
// 3 LSB is ONE
|
||||||
uint64_t data = ((uint64_t)internalid << 3) + 7;
|
uint64_t data = ((uint64_t)internalid << 3) + 7;
|
||||||
|
@ -288,19 +295,18 @@ static int CmdKeriSim(const char *Cmd) {
|
||||||
|
|
||||||
CLIParserContext *ctx;
|
CLIParserContext *ctx;
|
||||||
CLIParserInit(&ctx, "lf keri sim",
|
CLIParserInit(&ctx, "lf keri sim",
|
||||||
"Enables simulation of KERI card with card number.",
|
"Enables simulation of KERI card with internal ID.\n"
|
||||||
"lf keri sim --id 112233"
|
"You supply a KERI card id and it will converted to a KERI internal ID.",
|
||||||
|
"lf keri sim --cn 112233"
|
||||||
);
|
);
|
||||||
|
|
||||||
void *argtable[] = {
|
void *argtable[] = {
|
||||||
arg_param_begin,
|
arg_param_begin,
|
||||||
arg_int1(NULL, "id", "<dec>", "KERI Internal ID"),
|
arg_u64_1(NULL, "id", "<dec>", "KERI card ID"),
|
||||||
arg_param_end
|
arg_param_end
|
||||||
};
|
};
|
||||||
CLIExecWithReturn(ctx, Cmd, argtable, false);
|
CLIExecWithReturn(ctx, Cmd, argtable, false);
|
||||||
|
uint64_t internalid = arg_get_u64_def(ctx, 1, 0);
|
||||||
uint64_t internalid = arg_get_int_def(ctx, 1, 0);
|
|
||||||
|
|
||||||
CLIParserFree(ctx);
|
CLIParserFree(ctx);
|
||||||
|
|
||||||
internalid |= 0x80000000;
|
internalid |= 0x80000000;
|
||||||
|
@ -314,7 +320,7 @@ static int CmdKeriSim(const char *Cmd) {
|
||||||
bs[j++] = ((internalid >> i) & 1);
|
bs[j++] = ((internalid >> i) & 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
PrintAndLogEx(SUCCESS, "Simulating KERI - Internal Id: %" PRIu64, internalid);
|
PrintAndLogEx(SUCCESS, "Simulating KERI - Internal Id " _YELLOW_("%" PRIu64), internalid);
|
||||||
|
|
||||||
lf_psksim_t *payload = calloc(1, sizeof(lf_psksim_t) + sizeof(bs));
|
lf_psksim_t *payload = calloc(1, sizeof(lf_psksim_t) + sizeof(bs));
|
||||||
payload->carrier = 2;
|
payload->carrier = 2;
|
||||||
|
@ -322,8 +328,6 @@ static int CmdKeriSim(const char *Cmd) {
|
||||||
payload->clock = 32;
|
payload->clock = 32;
|
||||||
memcpy(payload->data, bs, sizeof(bs));
|
memcpy(payload->data, bs, sizeof(bs));
|
||||||
|
|
||||||
PrintAndLogEx(INFO, "Simulating");
|
|
||||||
|
|
||||||
clearCommandBuffer();
|
clearCommandBuffer();
|
||||||
SendCommandNG(CMD_LF_PSK_SIMULATE, (uint8_t *)payload, sizeof(lf_psksim_t) + sizeof(bs));
|
SendCommandNG(CMD_LF_PSK_SIMULATE, (uint8_t *)payload, sizeof(lf_psksim_t) + sizeof(bs));
|
||||||
free(payload);
|
free(payload);
|
||||||
|
@ -340,7 +344,7 @@ static int CmdKeriSim(const char *Cmd) {
|
||||||
static command_t CommandTable[] = {
|
static command_t CommandTable[] = {
|
||||||
{"help", CmdHelp, AlwaysAvailable, "This help"},
|
{"help", CmdHelp, AlwaysAvailable, "This help"},
|
||||||
{"demod", CmdKeriDemod, AlwaysAvailable, "Demodulate an KERI tag from the GraphBuffer"},
|
{"demod", CmdKeriDemod, AlwaysAvailable, "Demodulate an KERI tag from the GraphBuffer"},
|
||||||
{"read", CmdKeriRead, IfPm3Lf, "Attempt to read and extract tag data from the antenna"},
|
{"reader", CmdKeriReader, IfPm3Lf, "Attempt to read and extract tag data from the antenna"},
|
||||||
{"clone", CmdKeriClone, IfPm3Lf, "clone KERI tag to T55x7 or Q5/T5555"},
|
{"clone", CmdKeriClone, IfPm3Lf, "clone KERI tag to T55x7 or Q5/T5555"},
|
||||||
{"sim", CmdKeriSim, IfPm3Lf, "simulate KERI tag"},
|
{"sim", CmdKeriSim, IfPm3Lf, "simulate KERI tag"},
|
||||||
{NULL, NULL, NULL, NULL}
|
{NULL, NULL, NULL, NULL}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue