make style

This commit is contained in:
Philippe Teuwen 2022-01-05 18:56:56 +01:00
commit 5561466fe8
4 changed files with 44 additions and 44 deletions

View file

@ -1445,9 +1445,9 @@ void ReaderIClass(uint8_t flags) {
}; };
memcpy(&payload.header.hdr, &hdr, sizeof(picopass_hdr_t)); memcpy(&payload.header.hdr, &hdr, sizeof(picopass_hdr_t));
reply_ng(CMD_HF_ICLASS_READER, PM3_SUCCESS, (uint8_t*)&payload, sizeof(iclass_card_select_resp_t)); reply_ng(CMD_HF_ICLASS_READER, PM3_SUCCESS, (uint8_t *)&payload, sizeof(iclass_card_select_resp_t));
out: out:
switch_off(); switch_off();
} }

View file

@ -280,7 +280,7 @@ static int generate_config_card(const iclass_config_card_item_t *o, uint8_t *ke
HFiClassCalcDivKey(cc->csn, iClass_Key_Table[0], cc->key_d, false); HFiClassCalcDivKey(cc->csn, iClass_Key_Table[0], cc->key_d, false);
} else { } else {
PrintAndLogEx(FAILED, "failed to read a card"); PrintAndLogEx(FAILED, "failed to read a card");
PrintAndLogEx(INFO,"falling back to default config card"); PrintAndLogEx(INFO, "falling back to default config card");
} }
// generate dump file // generate dump file
@ -338,7 +338,7 @@ static int generate_config_card(const iclass_config_card_item_t *o, uint8_t *ke
if (Encrypt(ffs, ffs) == false) { if (Encrypt(ffs, ffs) == false) {
PrintAndLogEx(WARNING, "failed to encrypt FF"); PrintAndLogEx(WARNING, "failed to encrypt FF");
} else { } else {
PrintAndLogEx(NORMAL,"( " _GREEN_("ok") " )"); PrintAndLogEx(NORMAL, "( " _GREEN_("ok") " )");
} }
// local key copy // local key copy
@ -349,7 +349,7 @@ static int generate_config_card(const iclass_config_card_item_t *o, uint8_t *ke
if (Encrypt(lkey, enckey1) == false) { if (Encrypt(lkey, enckey1) == false) {
PrintAndLogEx(WARNING, "failed to encrypt key1"); PrintAndLogEx(WARNING, "failed to encrypt key1");
} else { } else {
PrintAndLogEx(NORMAL,"( " _GREEN_("ok") " )"); PrintAndLogEx(NORMAL, "( " _GREEN_("ok") " )");
} }
PrintAndLogEx(INFO, "Copy data... " NOLF); PrintAndLogEx(INFO, "Copy data... " NOLF);
@ -362,7 +362,7 @@ static int generate_config_card(const iclass_config_card_item_t *o, uint8_t *ke
for (uint8_t i = 0xD; i < 0x14; i++) { for (uint8_t i = 0xD; i < 0x14; i++) {
memcpy(data + (i * 8), ffs, sizeof(ffs)); memcpy(data + (i * 8), ffs, sizeof(ffs));
} }
PrintAndLogEx(NORMAL,"( " _GREEN_("ok") " )"); PrintAndLogEx(NORMAL, "( " _GREEN_("ok") " )");
// encrypted partial keyroll key 14 // encrypted partial keyroll key 14
PrintAndLogEx(INFO, "Setting encrypted partial key14... " NOLF); PrintAndLogEx(INFO, "Setting encrypted partial key14... " NOLF);
@ -373,7 +373,7 @@ static int generate_config_card(const iclass_config_card_item_t *o, uint8_t *ke
PrintAndLogEx(WARNING, "failed to encrypt partial 1"); PrintAndLogEx(WARNING, "failed to encrypt partial 1");
} }
memcpy(data + (0x14 * 8), enckey2, sizeof(enckey2)); memcpy(data + (0x14 * 8), enckey2, sizeof(enckey2));
PrintAndLogEx(NORMAL,"( " _GREEN_("ok") " )"); PrintAndLogEx(NORMAL, "( " _GREEN_("ok") " )");
// encrypted partial keyroll key 15 // encrypted partial keyroll key 15
@ -384,14 +384,14 @@ static int generate_config_card(const iclass_config_card_item_t *o, uint8_t *ke
PrintAndLogEx(WARNING, "failed to encrypt partial 2"); PrintAndLogEx(WARNING, "failed to encrypt partial 2");
} }
memcpy(data + (0x15 * 8), enckey2, sizeof(enckey2)); memcpy(data + (0x15 * 8), enckey2, sizeof(enckey2));
PrintAndLogEx(NORMAL,"( " _GREEN_("ok") " )"); PrintAndLogEx(NORMAL, "( " _GREEN_("ok") " )");
// encrypted 0xFF // encrypted 0xFF
PrintAndLogEx(INFO, "Setting 0xFF's... " NOLF); PrintAndLogEx(INFO, "Setting 0xFF's... " NOLF);
for (uint8_t i = 0x16; i <= app1_limit; i++) { for (uint8_t i = 0x16; i <= app1_limit; i++) {
memcpy(data + (i * 8), ffs, sizeof(ffs)); memcpy(data + (i * 8), ffs, sizeof(ffs));
} }
PrintAndLogEx(NORMAL,"( " _GREEN_("ok") " )"); PrintAndLogEx(NORMAL, "( " _GREEN_("ok") " )");
// revert potential modified app1_limit // revert potential modified app1_limit
cc->conf.app_limit = old_limit; cc->conf.app_limit = old_limit;
@ -541,7 +541,7 @@ static void mem_app_config(const picopass_hdr_t *hdr) {
uint8_t app_areas = 2; uint8_t app_areas = 2;
uint8_t books = 1; uint8_t books = 1;
uint8_t pages = 1; uint8_t pages = 1;
getMemConfig(mem, chip, &app_areas, &kb, &books, &pages); getMemConfig(mem, chip, &app_areas, &kb, &books, &pages);
uint8_t type = get_mem_config(hdr); uint8_t type = get_mem_config(hdr);
@ -558,25 +558,25 @@ static void mem_app_config(const picopass_hdr_t *hdr) {
} }
PrintAndLogEx(INFO, " %u KBits/%u App Areas ( " _YELLOW_("%u") " bytes )" PrintAndLogEx(INFO, " %u KBits/%u App Areas ( " _YELLOW_("%u") " bytes )"
, kb , kb
, app_areas , app_areas
, ((app2_limit + 1) * 8) * books * pages); , ((app2_limit + 1) * 8) * books * pages);
PrintAndLogEx(INFO, " %u books / %u pages" PrintAndLogEx(INFO, " %u books / %u pages"
, books , books
, pages , pages
); );
PrintAndLogEx(INFO, " First book / first page configuration"); PrintAndLogEx(INFO, " First book / first page configuration");
PrintAndLogEx(INFO, " Config | 0 - 5 ( 0x00 - 0x05 ) - 6 blocks "); PrintAndLogEx(INFO, " Config | 0 - 5 ( 0x00 - 0x05 ) - 6 blocks ");
PrintAndLogEx(INFO, " AA1 | 6 - %2d ( 0x06 - 0x%02X ) - %u blocks", app1_limit + 5, app1_limit + 5, app1_limit); PrintAndLogEx(INFO, " AA1 | 6 - %2d ( 0x06 - 0x%02X ) - %u blocks", app1_limit + 5, app1_limit + 5, app1_limit);
if (app1_limit + 5 < app2_limit ) { if (app1_limit + 5 < app2_limit) {
PrintAndLogEx(INFO, " AA2 | %2d - %2d ( 0x%02X - 0x%02X ) - %u blocks", app1_limit + 5 + 1, app2_limit, app1_limit + 5 + 1, app2_limit, app2_limit - app1_limit); PrintAndLogEx(INFO, " AA2 | %2d - %2d ( 0x%02X - 0x%02X ) - %u blocks", app1_limit + 5 + 1, app2_limit, app1_limit + 5 + 1, app2_limit, app2_limit - app1_limit);
} }
/* /*
[=] 32 KBits/3 App Areas ( 2048 bytes ) [=] 32 KBits/3 App Areas ( 2048 bytes )
[=] AA1 blocks 250 { 0x06 - 0xFF (06 - 255) } [=] AA1 blocks 250 { 0x06 - 0xFF (06 - 255) }
[=] AA2 blocks 5 { 0x100 - 0xFF (256 - 255) } [=] AA2 blocks 5 { 0x100 - 0xFF (256 - 255) }
*/ */
PrintAndLogEx(INFO, "------------------------- " _CYAN_("KeyAccess") " ------------------------"); PrintAndLogEx(INFO, "------------------------- " _CYAN_("KeyAccess") " ------------------------");
PrintAndLogEx(INFO, " * Kd, Debit key, AA1 Kc, Credit key, AA2 *"); PrintAndLogEx(INFO, " * Kd, Debit key, AA1 Kc, Credit key, AA2 *");
@ -898,7 +898,7 @@ static int CmdHFiClassInfo(const char *Cmd) {
int read_iclass_csn(bool loop, bool verbose) { int read_iclass_csn(bool loop, bool verbose) {
iclass_card_select_t payload = { iclass_card_select_t payload = {
.flags = (FLAG_ICLASS_READER_INIT | FLAG_ICLASS_READER_CLEARTRACE) .flags = (FLAG_ICLASS_READER_INIT | FLAG_ICLASS_READER_CLEARTRACE)
}; };
int res = PM3_SUCCESS; int res = PM3_SUCCESS;
@ -906,11 +906,11 @@ int read_iclass_csn(bool loop, bool verbose) {
do { do {
clearCommandBuffer(); clearCommandBuffer();
PacketResponseNG resp; PacketResponseNG resp;
SendCommandNG(CMD_HF_ICLASS_READER, (uint8_t*)&payload, sizeof(iclass_card_select_t)); SendCommandNG(CMD_HF_ICLASS_READER, (uint8_t *)&payload, sizeof(iclass_card_select_t));
if (WaitForResponseTimeout(CMD_HF_ICLASS_READER, &resp, 2000)) { if (WaitForResponseTimeout(CMD_HF_ICLASS_READER, &resp, 2000)) {
iclass_card_select_resp_t *r = (iclass_card_select_resp_t*)resp.data.asBytes; iclass_card_select_resp_t *r = (iclass_card_select_resp_t *)resp.data.asBytes;
if (loop) { if (loop) {
if (resp.status == PM3_ERFTRANS) { if (resp.status == PM3_ERFTRANS) {
continue; continue;
@ -1537,7 +1537,7 @@ static int CmdHFiClassEncryptBlk(const char *Cmd) {
} else { } else {
iclass_encrypt_block_data(blk_data, key); iclass_encrypt_block_data(blk_data, key);
} }
PrintAndLogEx(SUCCESS, "encrypted... " _YELLOW_("%s"), sprint_hex_inrow(blk_data, sizeof(blk_data))); PrintAndLogEx(SUCCESS, "encrypted... " _YELLOW_("%s"), sprint_hex_inrow(blk_data, sizeof(blk_data)));
return PM3_SUCCESS; return PM3_SUCCESS;
} }
@ -1545,19 +1545,19 @@ static int CmdHFiClassEncryptBlk(const char *Cmd) {
static bool select_only(uint8_t *CSN, uint8_t *CCNR, bool verbose) { static bool select_only(uint8_t *CSN, uint8_t *CCNR, bool verbose) {
iclass_card_select_t payload = { iclass_card_select_t payload = {
.flags = (FLAG_ICLASS_READER_INIT | FLAG_ICLASS_READER_CLEARTRACE) .flags = (FLAG_ICLASS_READER_INIT | FLAG_ICLASS_READER_CLEARTRACE)
}; };
clearCommandBuffer(); clearCommandBuffer();
PacketResponseNG resp; PacketResponseNG resp;
SendCommandNG(CMD_HF_ICLASS_READER, (uint8_t*)&payload, sizeof(iclass_card_select_t)); SendCommandNG(CMD_HF_ICLASS_READER, (uint8_t *)&payload, sizeof(iclass_card_select_t));
if (WaitForResponseTimeout(CMD_HF_ICLASS_READER, &resp, 2000) == false) { if (WaitForResponseTimeout(CMD_HF_ICLASS_READER, &resp, 2000) == false) {
PrintAndLogEx(WARNING, "command execute timeout"); PrintAndLogEx(WARNING, "command execute timeout");
return false; return false;
} }
iclass_card_select_resp_t *r = (iclass_card_select_resp_t*)resp.data.asBytes; iclass_card_select_resp_t *r = (iclass_card_select_resp_t *)resp.data.asBytes;
picopass_hdr_t *hdr = &r->header.hdr; picopass_hdr_t *hdr = &r->header.hdr;
// no tag found or button pressed // no tag found or button pressed
@ -1700,11 +1700,11 @@ static int CmdHFiClassDump(const char *Cmd) {
iclass_card_select_t payload_rdr = { iclass_card_select_t payload_rdr = {
.flags = (FLAG_ICLASS_READER_INIT | FLAG_ICLASS_READER_CLEARTRACE) .flags = (FLAG_ICLASS_READER_INIT | FLAG_ICLASS_READER_CLEARTRACE)
}; };
clearCommandBuffer(); clearCommandBuffer();
PacketResponseNG resp; PacketResponseNG resp;
SendCommandNG(CMD_HF_ICLASS_READER, (uint8_t*)&payload_rdr, sizeof(iclass_card_select_t)); SendCommandNG(CMD_HF_ICLASS_READER, (uint8_t *)&payload_rdr, sizeof(iclass_card_select_t));
if (WaitForResponseTimeout(CMD_HF_ICLASS_READER, &resp, 2000) == false) { if (WaitForResponseTimeout(CMD_HF_ICLASS_READER, &resp, 2000) == false) {
PrintAndLogEx(WARNING, "command execute timeout"); PrintAndLogEx(WARNING, "command execute timeout");
@ -1719,7 +1719,7 @@ static int CmdHFiClassDump(const char *Cmd) {
return PM3_ESOFT; return PM3_ESOFT;
} }
iclass_card_select_resp_t *r = (iclass_card_select_resp_t*)resp.data.asBytes; iclass_card_select_resp_t *r = (iclass_card_select_resp_t *)resp.data.asBytes;
if (r->status == FLAG_ICLASS_NULL) { if (r->status == FLAG_ICLASS_NULL) {
PrintAndLogEx(FAILED, "failed to read block 0,1,2"); PrintAndLogEx(FAILED, "failed to read block 0,1,2");
return PM3_ESOFT; return PM3_ESOFT;
@ -4038,11 +4038,11 @@ int CmdHFiClass(const char *Cmd) {
int info_iclass(void) { int info_iclass(void) {
iclass_card_select_t payload = { iclass_card_select_t payload = {
.flags = (FLAG_ICLASS_READER_INIT | FLAG_ICLASS_READER_CLEARTRACE) .flags = (FLAG_ICLASS_READER_INIT | FLAG_ICLASS_READER_CLEARTRACE)
}; };
clearCommandBuffer(); clearCommandBuffer();
PacketResponseNG resp; PacketResponseNG resp;
SendCommandNG(CMD_HF_ICLASS_READER, (uint8_t*)&payload, sizeof(iclass_card_select_t)); SendCommandNG(CMD_HF_ICLASS_READER, (uint8_t *)&payload, sizeof(iclass_card_select_t));
if (WaitForResponseTimeout(CMD_HF_ICLASS_READER, &resp, 2000) == false) { if (WaitForResponseTimeout(CMD_HF_ICLASS_READER, &resp, 2000) == false) {
DropField(); DropField();
@ -4050,7 +4050,7 @@ int info_iclass(void) {
} }
DropField(); DropField();
iclass_card_select_resp_t *r = (iclass_card_select_resp_t*)resp.data.asBytes; iclass_card_select_resp_t *r = (iclass_card_select_resp_t *)resp.data.asBytes;
// no tag found or button pressed // no tag found or button pressed
if (r->status == FLAG_ICLASS_NULL || resp.status == PM3_ERFTRANS) { if (r->status == FLAG_ICLASS_NULL || resp.status == PM3_ERFTRANS) {
@ -4093,7 +4093,7 @@ int info_iclass(void) {
} else { } else {
PrintAndLogEx(SUCCESS, " Kc: %s credit key ( hidden )", sprint_hex(hdr->key_c, sizeof(hdr->key_c))); PrintAndLogEx(SUCCESS, " Kc: %s credit key ( hidden )", sprint_hex(hdr->key_c, sizeof(hdr->key_c)));
} }
if ((r->status & FLAG_ICLASS_AIA) == FLAG_ICLASS_AIA) { if ((r->status & FLAG_ICLASS_AIA) == FLAG_ICLASS_AIA) {
PrintAndLogEx(SUCCESS, " AIA: %s application issuer area", sprint_hex(hdr->app_issuer_area, sizeof(hdr->app_issuer_area))); PrintAndLogEx(SUCCESS, " AIA: %s application issuer area", sprint_hex(hdr->app_issuer_area, sizeof(hdr->app_issuer_area)));

View file

@ -30,12 +30,12 @@ typedef enum {Scramble = 0, Descramble = 1} KeriMSScramble_t;
static int CmdKeriMSScramble(KeriMSScramble_t Action, uint32_t *FC, uint32_t *ID, uint32_t *CardID) { static int CmdKeriMSScramble(KeriMSScramble_t Action, uint32_t *FC, uint32_t *ID, uint32_t *CardID) {
// 255 = Not used/Unknown other values are the bit offset in the ID/FC values // 255 = Not used/Unknown other values are the bit offset in the ID/FC values
const uint8_t CardToID [] = { 255, 255, 255, 255, 13, 12, 20, 5, 16, 6, 21, 17, 8, 255, 0, 7, const uint8_t CardToID [] = { 255, 255, 255, 255, 13, 12, 20, 5, 16, 6, 21, 17, 8, 255, 0, 7,
10, 15, 255, 11, 4, 1, 255, 18, 255, 19, 2, 14, 3, 9, 255, 255 10, 15, 255, 11, 4, 1, 255, 18, 255, 19, 2, 14, 3, 9, 255, 255
}; };
const uint8_t CardToFC [] = { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, const uint8_t CardToFC [] = { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255,
255, 255, 2, 255, 255, 255, 3, 255, 4, 255, 255, 255, 255, 255, 1, 255 255, 255, 2, 255, 255, 255, 3, 255, 4, 255, 255, 255, 255, 255, 1, 255
}; };
uint8_t card_idx; // 0 - 31 uint8_t card_idx; // 0 - 31

View file

@ -142,12 +142,12 @@ typedef struct {
} PACKED picopass_ns_hdr_t; } PACKED picopass_ns_hdr_t;
// reader flags // reader flags
typedef struct { typedef struct {
uint8_t flags; uint8_t flags;
} PACKED iclass_card_select_t; } PACKED iclass_card_select_t;
// reader flags // reader flags
typedef struct { typedef struct {
uint8_t status; uint8_t status;
union { union {
picopass_hdr_t hdr; picopass_hdr_t hdr;
@ -156,4 +156,4 @@ typedef struct {
} PACKED iclass_card_select_resp_t; } PACKED iclass_card_select_resp_t;
#endif // _ICLASS_H_ #endif // _ICLASS_H_