mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-21 22:03:42 -07:00
Merge pull request #1393 from bettse/iclass_encode_fccn
fc/cn support for iclass encode
This commit is contained in:
commit
1e4057883d
2 changed files with 44 additions and 3 deletions
|
@ -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 `--wiegand/--fc/--cn` to `hf iclass encode` (@bettse)
|
||||
- Fic `lf t55xx detect` - to unset lf config decimation if value is not one (@iceman1001)
|
||||
- Fix `hf 15 sample` - data collection works again (@iceman1001)
|
||||
- Changed `data plot -h` - removed line (@doegox)
|
||||
|
|
|
@ -3582,19 +3582,24 @@ static int CmdHFiClassEncode(const char *Cmd) {
|
|||
|
||||
CLIParserContext *ctx;
|
||||
CLIParserInit(&ctx, "hf iclass encode",
|
||||
"Encode binary wiegand to block 7",
|
||||
"Encode binary wiegand to block 7\n"
|
||||
"Use either --bin or --wiegand/--fc/--cn",
|
||||
"hf iclass encode --bin 10001111100000001010100011 --ki 0 -> FC 31 CN 337\n"
|
||||
"hf iclass encode --fc 31 --cn 337 --ki 0 -> FC 31 CN 337\n"
|
||||
"hf iclass encode --bin 10001111100000001010100011 --ki 0 --elite -> FC 31 CN 337, writing w elite key"
|
||||
);
|
||||
|
||||
void *argtable[] = {
|
||||
arg_param_begin,
|
||||
arg_str1(NULL, "bin", "<bin>", "Binary string i.e 0001001001"),
|
||||
arg_str0(NULL, "bin", "<bin>", "Binary string i.e 0001001001"),
|
||||
arg_int1(NULL, "ki", "<dec>", "Key index to select key from memory 'hf iclass managekeys'"),
|
||||
arg_lit0(NULL, "credit", "key is assumed to be the credit key"),
|
||||
arg_lit0(NULL, "elite", "elite computations applied to key"),
|
||||
arg_lit0(NULL, "raw", "no computations applied to key"),
|
||||
arg_str0(NULL, "enckey", "<hex>", "3DES transport key, 16 hex bytes"),
|
||||
arg_u64_0(NULL, "fc", "<dec>", "facility code"),
|
||||
arg_u64_0(NULL, "cn", "<dec>", "card number"),
|
||||
arg_str0("w", "wiegand", "<format>", "see " _YELLOW_("`wiegand list`") " for available formats"),
|
||||
arg_param_end
|
||||
};
|
||||
CLIExecWithReturn(ctx, Cmd, argtable, false);
|
||||
|
@ -3630,6 +3635,15 @@ static int CmdHFiClassEncode(const char *Cmd) {
|
|||
bool use_sc = false;
|
||||
CLIGetHexWithReturn(ctx, 6, enc_key, &enc_key_len);
|
||||
|
||||
wiegand_card_t card;
|
||||
memset(&card, 0, sizeof(wiegand_card_t));
|
||||
card.FacilityCode = arg_get_u32_def(ctx, 7, 0);
|
||||
card.CardNumber = arg_get_u32_def(ctx, 8, 0);
|
||||
|
||||
char format[16] = {0};
|
||||
int format_len = 0;
|
||||
CLIParamStrToBuf(arg_get_str(ctx, 9), (uint8_t *)format, sizeof(format), &format_len);
|
||||
|
||||
CLIParserFree(ctx);
|
||||
|
||||
if ((rawkey + elite) > 1) {
|
||||
|
@ -3650,6 +3664,11 @@ static int CmdHFiClassEncode(const char *Cmd) {
|
|||
return PM3_EINVARG;
|
||||
}
|
||||
|
||||
if (bin_len == 0 && card.FacilityCode == 0 && card.CardNumber == 0) {
|
||||
PrintAndLogEx(ERR, "Must provide either --cn/--fc or --bin");
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
|
||||
if (have_enc_key == false) {
|
||||
use_sc = IsCardHelperPresent(false);
|
||||
if (use_sc == false) {
|
||||
|
@ -3697,7 +3716,28 @@ static int CmdHFiClassEncode(const char *Cmd) {
|
|||
PrintAndLogEx(WARNING, "Ignoring '%c'", c);
|
||||
}
|
||||
}
|
||||
memcpy(credential + 8, data, sizeof(data));
|
||||
|
||||
if (bin_len) {
|
||||
memcpy(credential + 8, data, sizeof(data));
|
||||
} else {
|
||||
wiegand_message_t packed;
|
||||
memset(&packed, 0, sizeof(wiegand_message_t));
|
||||
|
||||
int format_idx = HIDFindCardFormat((char *)format);
|
||||
if (format_idx == -1) {
|
||||
PrintAndLogEx(WARNING, "Unknown format: " _YELLOW_("%s"), format);
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
|
||||
if (HIDPack(format_idx, &card, &packed, false) == false) {
|
||||
PrintAndLogEx(WARNING, "The card data could not be encoded in the selected format.");
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
add_HID_header(&packed);
|
||||
|
||||
packed.Bot = BSWAP_32(packed.Bot);
|
||||
memcpy(credential + 12, &packed.Bot, sizeof(packed.Bot));
|
||||
}
|
||||
|
||||
// encrypt with transport key
|
||||
if (use_sc) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue