mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2026-05-12 11:18:11 -07:00
fixes to hf iclass configcard mem setup, textual output, MIX->NG convertion
This commit is contained in:
+3
-1
@@ -23,6 +23,7 @@
|
||||
#include "printf.h"
|
||||
#include "legicrf.h"
|
||||
#include "BigBuf.h"
|
||||
#include "iclass_cmd.h"
|
||||
#include "iso14443a.h"
|
||||
#include "iso14443b.h"
|
||||
#include "iso15693.h"
|
||||
@@ -1685,7 +1686,8 @@ static void PacketReceived(PacketCommandNG *packet) {
|
||||
break;
|
||||
}
|
||||
case CMD_HF_ICLASS_READER: {
|
||||
ReaderIClass(packet->oldarg[0]);
|
||||
iclass_card_select_t *payload = (iclass_card_select_t *) packet->data.asBytes;
|
||||
ReaderIClass(payload->flags);
|
||||
break;
|
||||
}
|
||||
case CMD_HF_ICLASS_EML_MEMSET: {
|
||||
|
||||
+16
-35
@@ -34,6 +34,7 @@
|
||||
#include "protocols.h"
|
||||
#include "ticks.h"
|
||||
#include "iso15693.h"
|
||||
#include "iclass_cmd.h" /* iclass_card_select_t struct */
|
||||
|
||||
static uint8_t get_pagemap(const picopass_hdr_t *hdr) {
|
||||
return (hdr->conf.fuses & (FUSE_CRYPT0 | FUSE_CRYPT1)) >> 3;
|
||||
@@ -1402,13 +1403,8 @@ bool select_iclass_tag(picopass_hdr_t *hdr, bool use_credit_key, uint32_t *eof_t
|
||||
// turn off afterwards
|
||||
void ReaderIClass(uint8_t flags) {
|
||||
|
||||
picopass_hdr_t hdr = {0};
|
||||
// uint8_t last_csn[8] = {0, 0, 0, 0, 0, 0, 0, 0};
|
||||
uint8_t resp[ICLASS_BUFFER_SIZE] = {0};
|
||||
memset(resp, 0xFF, sizeof(resp));
|
||||
|
||||
// bool flag_readonce = flags & FLAG_ICLASS_READER_ONLY_ONCE; // flag to read until one tag is found successfully
|
||||
bool use_credit_key = flags & FLAG_ICLASS_READER_CREDITKEY; // flag to use credit key
|
||||
// flag to use credit key
|
||||
bool use_credit_key = ((flags & FLAG_ICLASS_READER_CREDITKEY) == FLAG_ICLASS_READER_CREDITKEY);
|
||||
|
||||
if ((flags & FLAG_ICLASS_READER_INIT) == FLAG_ICLASS_READER_INIT) {
|
||||
Iso15693InitReader();
|
||||
@@ -1418,13 +1414,14 @@ void ReaderIClass(uint8_t flags) {
|
||||
clear_trace();
|
||||
}
|
||||
|
||||
uint8_t result_status = 0;
|
||||
|
||||
uint8_t res = 0;
|
||||
uint32_t eof_time = 0;
|
||||
bool status = select_iclass_tag_ex(&hdr, use_credit_key, &eof_time, &result_status);
|
||||
if (status == false) {
|
||||
reply_mix(CMD_ACK, 0xFF, 0, 0, NULL, 0);
|
||||
switch_off();
|
||||
return;
|
||||
picopass_hdr_t hdr = {0};
|
||||
|
||||
if (select_iclass_tag_ex(&hdr, use_credit_key, &eof_time, &res) == false) {
|
||||
reply_ng(CMD_HF_ICLASS_READER, PM3_ERFTRANS, NULL, 0);
|
||||
goto out;
|
||||
}
|
||||
|
||||
// Page mapping for secure mode
|
||||
@@ -1443,30 +1440,14 @@ void ReaderIClass(uint8_t flags) {
|
||||
// Return to client, e 6 * 8 bytes of data.
|
||||
// with 0xFF:s in block 3 and 4.
|
||||
|
||||
LED_B_ON();
|
||||
reply_mix(CMD_ACK, result_status, 0, 0, (uint8_t *)&hdr, sizeof(hdr));
|
||||
iclass_card_select_resp_t payload = {
|
||||
.status = res
|
||||
};
|
||||
memcpy(&payload.header.hdr, &hdr, sizeof(picopass_hdr_t));
|
||||
|
||||
//Send back to client, but don't bother if we already sent this -
|
||||
// only useful if looping in arm (not try_once && not abort_after_read)
|
||||
/*
|
||||
if (memcmp(last_csn, card_data, 8) != 0) {
|
||||
|
||||
reply_mix(CMD_ACK, result_status, 0, 0, card_data, sizeof(card_data));
|
||||
if (flag_readonce) {
|
||||
LED_B_OFF();
|
||||
return;
|
||||
}
|
||||
LED_B_OFF();
|
||||
}
|
||||
*/
|
||||
|
||||
// if (userCancelled) {
|
||||
// reply_mix(CMD_ACK, 0xFF, 0, 0, card_data, 0);
|
||||
// switch_off();
|
||||
// } else {
|
||||
// reply_mix(CMD_ACK, result_status, 0, 0, card_data, 0);
|
||||
// }
|
||||
reply_ng(CMD_HF_ICLASS_READER, PM3_SUCCESS, (uint8_t*)&payload, sizeof(iclass_card_select_resp_t));
|
||||
|
||||
out:
|
||||
switch_off();
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@
|
||||
#define __ICLASS_H
|
||||
|
||||
#include "common.h"
|
||||
#include "pm3_cmd.h"
|
||||
#include "iclass_cmd.h"
|
||||
|
||||
void SniffIClass(uint8_t jam_search_len, uint8_t *jam_search_string);
|
||||
void ReaderIClass(uint8_t flags);
|
||||
|
||||
+228
-134
File diff suppressed because it is too large
Load Diff
@@ -13,21 +13,7 @@
|
||||
|
||||
#include "common.h"
|
||||
#include "fileutils.h"
|
||||
#include "pm3_cmd.h"
|
||||
|
||||
typedef struct iclass_block {
|
||||
uint8_t d[8];
|
||||
} iclass_block_t;
|
||||
|
||||
typedef struct iclass_prekey {
|
||||
uint8_t mac[4];
|
||||
uint8_t key[8];
|
||||
} iclass_prekey_t;
|
||||
|
||||
typedef struct {
|
||||
char desc[70];
|
||||
uint8_t data[16];
|
||||
} iclass_config_card_item_t;
|
||||
#include "iclass_cmd.h"
|
||||
|
||||
int CmdHFiClass(const char *Cmd);
|
||||
|
||||
|
||||
+5
-1
@@ -47,7 +47,7 @@ double g_PlotGridX = 0, g_PlotGridY = 0, g_PlotGridXdefault = 64, g_PlotGridYdef
|
||||
uint32_t g_CursorCPos = 0, g_CursorDPos = 0, g_GraphStop = 0;
|
||||
uint32_t g_GraphStart = 0; // Starting point/offset for the left side of the graph
|
||||
double g_GraphPixelsPerPoint = 1.f; // How many visual pixels are between each sample point (x axis)
|
||||
static bool flushAfterWrite = 0;
|
||||
static bool flushAfterWrite = false;
|
||||
double g_GridOffset = 0;
|
||||
bool g_GridLocked = false;
|
||||
|
||||
@@ -411,6 +411,10 @@ void SetFlushAfterWrite(bool value) {
|
||||
flushAfterWrite = value;
|
||||
}
|
||||
|
||||
bool GetFlushAfterWrite(void) {
|
||||
return flushAfterWrite;
|
||||
}
|
||||
|
||||
void memcpy_filter_rlmarkers(void *dest, const void *src, size_t n) {
|
||||
uint8_t *rdest = (uint8_t *)dest;
|
||||
uint8_t *rsrc = (uint8_t *)src;
|
||||
|
||||
@@ -63,6 +63,7 @@ extern session_arg_t g_session;
|
||||
void PrintAndLogOptions(const char *str[][2], size_t size, size_t space);
|
||||
void PrintAndLogEx(logLevel_t level, const char *fmt, ...);
|
||||
void SetFlushAfterWrite(bool value);
|
||||
bool GetFlushAfterWrite(void);
|
||||
void memcpy_filter_ansi(void *dest, const void *src, size_t n, bool filter);
|
||||
void memcpy_filter_rlmarkers(void *dest, const void *src, size_t n);
|
||||
void memcpy_filter_emoji(void *dest, const void *src, size_t n, emojiMode_t mode);
|
||||
|
||||
@@ -0,0 +1,159 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// (c) 2021 Iceman
|
||||
//
|
||||
// This code is licensed to you under the terms of the GNU GPL, version 2 or,
|
||||
// at your option, any later version. See the LICENSE.txt file for the text of
|
||||
// the license.
|
||||
//-----------------------------------------------------------------------------
|
||||
// iCLASS type prototyping
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef _ICLASS_CMD_H_
|
||||
#define _ICLASS_CMD_H_
|
||||
|
||||
#include "common.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// iCLASS / PICOPASS
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
// iCLASS reader flags
|
||||
#define FLAG_ICLASS_READER_INIT 0x01
|
||||
#define FLAG_ICLASS_READER_CLEARTRACE 0x02
|
||||
//#define FLAG_ICLASS_READER_ONLY_ONCE 0x04
|
||||
#define FLAG_ICLASS_READER_CREDITKEY 0x08
|
||||
#define FLAG_ICLASS_READER_AIA 0x10
|
||||
|
||||
// iCLASS reader status flags
|
||||
#define FLAG_ICLASS_NULL 0x00
|
||||
#define FLAG_ICLASS_CSN 0x01
|
||||
#define FLAG_ICLASS_CC 0x02
|
||||
#define FLAG_ICLASS_CONF 0x04
|
||||
#define FLAG_ICLASS_AIA 0x08
|
||||
|
||||
// iCLASS simulation modes
|
||||
#define ICLASS_SIM_MODE_CSN 0
|
||||
#define ICLASS_SIM_MODE_CSN_DEFAULT 1
|
||||
#define ICLASS_SIM_MODE_READER_ATTACK 2
|
||||
#define ICLASS_SIM_MODE_FULL 3
|
||||
#define ICLASS_SIM_MODE_READER_ATTACK_KEYROLL 4
|
||||
#define ICLASS_SIM_MODE_EXIT_AFTER_MAC 5 // note: device internal only
|
||||
#define ICLASS_SIM_MODE_CONFIG_CARD 6
|
||||
|
||||
|
||||
// iCLASS auth request data structure
|
||||
// used with read block, dump, write block
|
||||
typedef struct {
|
||||
uint8_t key[8];
|
||||
bool use_raw;
|
||||
bool use_elite;
|
||||
bool use_credit_key;
|
||||
bool use_replay;
|
||||
bool send_reply;
|
||||
bool do_auth;
|
||||
uint8_t blockno;
|
||||
} PACKED iclass_auth_req_t;
|
||||
|
||||
// iCLASS read block response data structure
|
||||
typedef struct {
|
||||
bool isOK;
|
||||
uint8_t div_key[8];
|
||||
uint8_t mac[4];
|
||||
uint8_t data[8];
|
||||
} PACKED iclass_readblock_resp_t;
|
||||
|
||||
// iCLASS dump data structure
|
||||
typedef struct {
|
||||
iclass_auth_req_t req;
|
||||
uint8_t start_block;
|
||||
uint8_t end_block;
|
||||
} PACKED iclass_dump_req_t;
|
||||
|
||||
// iCLASS write block request data structure
|
||||
typedef struct {
|
||||
iclass_auth_req_t req;
|
||||
uint8_t data[8];
|
||||
} PACKED iclass_writeblock_req_t;
|
||||
|
||||
// iCLASS dump data structure
|
||||
typedef struct {
|
||||
uint8_t blockno;
|
||||
uint8_t data[8];
|
||||
} PACKED iclass_restore_item_t;
|
||||
|
||||
typedef struct {
|
||||
iclass_auth_req_t req;
|
||||
uint8_t item_cnt;
|
||||
iclass_restore_item_t blocks[];
|
||||
} PACKED iclass_restore_req_t;
|
||||
|
||||
typedef struct iclass_premac {
|
||||
uint8_t mac[4];
|
||||
} PACKED iclass_premac_t;
|
||||
|
||||
typedef struct {
|
||||
bool use_credit_key;
|
||||
uint8_t count;
|
||||
iclass_premac_t items[];
|
||||
} PACKED iclass_chk_t;
|
||||
|
||||
typedef struct iclass_block {
|
||||
uint8_t d[8];
|
||||
} iclass_block_t;
|
||||
|
||||
typedef struct iclass_prekey {
|
||||
uint8_t mac[4];
|
||||
uint8_t key[8];
|
||||
} iclass_prekey_t;
|
||||
|
||||
typedef struct {
|
||||
char desc[70];
|
||||
uint8_t data[16];
|
||||
} iclass_config_card_item_t;
|
||||
|
||||
|
||||
// iclass / picopass chip config structures and shared routines
|
||||
typedef struct {
|
||||
uint8_t app_limit; //[8]
|
||||
uint8_t otp[2]; //[9-10]
|
||||
uint8_t block_writelock;//[11]
|
||||
uint8_t chip_config; //[12]
|
||||
uint8_t mem_config; //[13]
|
||||
uint8_t eas; //[14]
|
||||
uint8_t fuses; //[15]
|
||||
} PACKED picopass_conf_block_t;
|
||||
|
||||
// iCLASS secure mode memory mapping
|
||||
typedef struct {
|
||||
uint8_t csn[8];
|
||||
picopass_conf_block_t conf;
|
||||
uint8_t epurse[8];
|
||||
uint8_t key_d[8];
|
||||
uint8_t key_c[8];
|
||||
uint8_t app_issuer_area[8];
|
||||
} PACKED picopass_hdr_t;
|
||||
|
||||
// iCLASS non-secure mode memory mapping
|
||||
typedef struct {
|
||||
uint8_t csn[8];
|
||||
picopass_conf_block_t conf;
|
||||
uint8_t app_issuer_area[8];
|
||||
} PACKED picopass_ns_hdr_t;
|
||||
|
||||
// reader flags
|
||||
typedef struct {
|
||||
uint8_t flags;
|
||||
} PACKED iclass_card_select_t;
|
||||
|
||||
// reader flags
|
||||
typedef struct {
|
||||
uint8_t status;
|
||||
union {
|
||||
picopass_hdr_t hdr;
|
||||
picopass_ns_hdr_t ns_hdr;
|
||||
} header;
|
||||
} PACKED iclass_card_select_resp_t;
|
||||
|
||||
|
||||
#endif // _ICLASS_H_
|
||||
@@ -291,92 +291,6 @@ typedef struct {
|
||||
} PACKED ecdsa_publickey_t;
|
||||
|
||||
|
||||
// iCLASS auth request data structure
|
||||
// used with read block, dump, write block
|
||||
typedef struct {
|
||||
uint8_t key[8];
|
||||
bool use_raw;
|
||||
bool use_elite;
|
||||
bool use_credit_key;
|
||||
bool use_replay;
|
||||
bool send_reply;
|
||||
bool do_auth;
|
||||
uint8_t blockno;
|
||||
} PACKED iclass_auth_req_t;
|
||||
|
||||
// iCLASS read block response data structure
|
||||
typedef struct {
|
||||
bool isOK;
|
||||
uint8_t div_key[8];
|
||||
uint8_t mac[4];
|
||||
uint8_t data[8];
|
||||
} PACKED iclass_readblock_resp_t;
|
||||
|
||||
// iCLASS dump data structure
|
||||
typedef struct {
|
||||
iclass_auth_req_t req;
|
||||
uint8_t start_block;
|
||||
uint8_t end_block;
|
||||
} PACKED iclass_dump_req_t;
|
||||
|
||||
// iCLASS write block request data structure
|
||||
typedef struct {
|
||||
iclass_auth_req_t req;
|
||||
uint8_t data[8];
|
||||
} PACKED iclass_writeblock_req_t;
|
||||
|
||||
// iCLASS dump data structure
|
||||
typedef struct {
|
||||
uint8_t blockno;
|
||||
uint8_t data[8];
|
||||
} PACKED iclass_restore_item_t;
|
||||
|
||||
typedef struct {
|
||||
iclass_auth_req_t req;
|
||||
uint8_t item_cnt;
|
||||
iclass_restore_item_t blocks[];
|
||||
} PACKED iclass_restore_req_t;
|
||||
|
||||
typedef struct iclass_premac {
|
||||
uint8_t mac[4];
|
||||
} PACKED iclass_premac_t;
|
||||
|
||||
typedef struct {
|
||||
bool use_credit_key;
|
||||
uint8_t count;
|
||||
iclass_premac_t items[];
|
||||
} PACKED iclass_chk_t;
|
||||
|
||||
|
||||
// iclass / picopass chip config structures and shared routines
|
||||
typedef struct {
|
||||
uint8_t app_limit; //[8]
|
||||
uint8_t otp[2]; //[9-10]
|
||||
uint8_t block_writelock;//[11]
|
||||
uint8_t chip_config; //[12]
|
||||
uint8_t mem_config; //[13]
|
||||
uint8_t eas; //[14]
|
||||
uint8_t fuses; //[15]
|
||||
} PACKED picopass_conf_block_t;
|
||||
|
||||
// iCLASS secure mode memory mapping
|
||||
typedef struct {
|
||||
uint8_t csn[8];
|
||||
picopass_conf_block_t conf;
|
||||
uint8_t epurse[8];
|
||||
uint8_t key_d[8];
|
||||
uint8_t key_c[8];
|
||||
uint8_t app_issuer_area[8];
|
||||
} PACKED picopass_hdr_t;
|
||||
|
||||
// iCLASS non-secure mode memory mapping
|
||||
typedef struct {
|
||||
uint8_t csn[8];
|
||||
picopass_conf_block_t conf;
|
||||
uint8_t app_issuer_area[8];
|
||||
} PACKED picopass_ns_hdr_t;
|
||||
|
||||
|
||||
typedef struct {
|
||||
uint16_t delay_us;
|
||||
bool on;
|
||||
@@ -767,28 +681,6 @@ typedef struct {
|
||||
#define FLAG_CVE21_0430 0x2000
|
||||
|
||||
|
||||
// iCLASS reader flags
|
||||
#define FLAG_ICLASS_READER_INIT 0x01
|
||||
#define FLAG_ICLASS_READER_CLEARTRACE 0x02
|
||||
#define FLAG_ICLASS_READER_ONLY_ONCE 0x04
|
||||
#define FLAG_ICLASS_READER_CREDITKEY 0x08
|
||||
#define FLAG_ICLASS_READER_AIA 0x10
|
||||
|
||||
// iCLASS reader status flags
|
||||
#define FLAG_ICLASS_CSN 0x01
|
||||
#define FLAG_ICLASS_CC 0x02
|
||||
#define FLAG_ICLASS_CONF 0x04
|
||||
#define FLAG_ICLASS_AIA 0x08
|
||||
|
||||
// iCLASS simulation modes
|
||||
#define ICLASS_SIM_MODE_CSN 0
|
||||
#define ICLASS_SIM_MODE_CSN_DEFAULT 1
|
||||
#define ICLASS_SIM_MODE_READER_ATTACK 2
|
||||
#define ICLASS_SIM_MODE_FULL 3
|
||||
#define ICLASS_SIM_MODE_READER_ATTACK_KEYROLL 4
|
||||
#define ICLASS_SIM_MODE_EXIT_AFTER_MAC 5 // note: device internal only
|
||||
#define ICLASS_SIM_MODE_CONFIG_CARD 6
|
||||
|
||||
#define MODE_SIM_CSN 0
|
||||
#define MODE_EXIT_AFTER_MAC 1
|
||||
#define MODE_FULLSIM 2
|
||||
|
||||
Reference in New Issue
Block a user