diff --git a/client/src/cmdhficlass.c b/client/src/cmdhficlass.c index 6ec4fd487..b4e096998 100644 --- a/client/src/cmdhficlass.c +++ b/client/src/cmdhficlass.c @@ -4594,6 +4594,7 @@ static int CmdHFiClassEncode(const char *Cmd) { arg_u64_0(NULL, "cn", "", "card number"), arg_u64_0(NULL, "issue", "", "issue level"), arg_str0("w", "wiegand", "", "see " _YELLOW_("`wiegand list`") " for available formats"), + arg_lit0(NULL, "emu", "Write to emulation memory instead of card"), arg_lit0(NULL, "shallow", "use shallow (ASK) reader modulation instead of OOK"), arg_lit0("v", NULL, "verbose (print encoded blocks)"), arg_param_end @@ -4640,10 +4641,12 @@ static int CmdHFiClassEncode(const char *Cmd) { char format[16] = {0}; int format_len = 0; + CLIParamStrToBuf(arg_get_str(ctx, 10), (uint8_t *)format, sizeof(format), &format_len); - bool shallow_mod = arg_get_lit(ctx, 11); - bool verbose = arg_get_lit(ctx, 12); + bool use_emulator_memory = arg_get_lit(ctx, 11); + bool shallow_mod = arg_get_lit(ctx, 12); + bool verbose = arg_get_lit(ctx, 13); CLIParserFree(ctx); @@ -4776,15 +4779,20 @@ static int CmdHFiClassEncode(const char *Cmd) { int isok = PM3_SUCCESS; // write - for (uint8_t i = 0; i < 4; i++) { - isok = iclass_write_block(6 + i, credential + (i * 8), NULL, key, use_credit_key, elite, rawkey, false, false, auth, shallow_mod); - switch (isok) { - case PM3_SUCCESS: - PrintAndLogEx(SUCCESS, "Write block %d/0x0%x ( " _GREEN_("ok") " ) --> " _YELLOW_("%s"), 6 + i, 6 + i, sprint_hex_inrow(credential + (i * 8), 8)); - break; - default: - PrintAndLogEx(INFO, "Write block %d/0x0%x ( " _RED_("fail") " )", 6 + i, 6 + i); - break; + if (use_emulator_memory) { + uint16_t bytes_sent = 0; + iclass_upload_emul(credential, sizeof(credential), 6 * PICOPASS_BLOCK_SIZE, &bytes_sent); + } else { + for (uint8_t i = 0; i < 4; i++) { + isok = iclass_write_block(6 + i, credential + (i * 8), NULL, key, use_credit_key, elite, rawkey, false, false, auth, shallow_mod); + switch (isok) { + case PM3_SUCCESS: + PrintAndLogEx(SUCCESS, "Write block %d/0x0%x ( " _GREEN_("ok") " ) --> " _YELLOW_("%s"), 6 + i, 6 + i, sprint_hex_inrow(credential + (i * 8), 8)); + break; + default: + PrintAndLogEx(INFO, "Write block %d/0x0%x ( " _RED_("fail") " )", 6 + i, 6 + i); + break; + } } } return isok;