mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2024-09-22 08:16:16 +08:00
set config works
This commit is contained in:
parent
61ffdb5269
commit
b062ffa6cd
|
@ -4889,7 +4889,7 @@ static int CmdHF14ADesSetConfiguration(const char *Cmd) {
|
|||
CLIParserContext *ctx;
|
||||
CLIParserInit(&ctx, "hf mfdes setconfig",
|
||||
"Set card configuration. Danger zone! Needs to provide card's master key and works if not blocked by config.",
|
||||
"hf mfdes setconfig --param xxx --data yyy -> set parameter with data value");
|
||||
"hf mfdes setconfig --param 03 --data 0428 -> set parameter with data value");
|
||||
|
||||
void *argtable[] = {
|
||||
arg_param_begin,
|
||||
|
|
|
@ -1190,15 +1190,34 @@ int DesfireChangeKey(DesfireContext *dctx, bool change_master_key, uint8_t newke
|
|||
}
|
||||
|
||||
int DesfireSetConfiguration(DesfireContext *dctx, uint8_t paramid, uint8_t *param, size_t paramlen) {
|
||||
uint8_t data[200] = {0};
|
||||
uint8_t cdata[200] = {0};
|
||||
cdata[0] = MFDES_CHANGE_CONFIGURATION;
|
||||
uint8_t *data = &cdata[1];
|
||||
data[0] = paramid;
|
||||
memcpy(&data[1], param, paramlen);
|
||||
size_t datalen = 1 + paramlen;
|
||||
|
||||
|
||||
// add crc
|
||||
if (dctx->secureChannel == DACd40) {
|
||||
iso14443a_crc_append(&data[1], datalen - 1);
|
||||
datalen += 2;
|
||||
} else {
|
||||
desfire_crc32_append(cdata, datalen + 1);
|
||||
datalen += 4;
|
||||
}
|
||||
|
||||
// dynamic length
|
||||
if (paramid == 0x02) {
|
||||
data[datalen] = 0x80;
|
||||
datalen++;
|
||||
}
|
||||
|
||||
// send command
|
||||
uint8_t resp[257] = {0};
|
||||
size_t resplen = 0;
|
||||
int res = DesfireChangeKeyCmd(dctx, data, datalen, resp, &resplen);
|
||||
PrintAndLogEx(INFO, "plain data[%d]: %s", datalen, sprint_hex(data, datalen));
|
||||
int res = DesfireSetConfigurationCmd(dctx, data, datalen, resp, &resplen);
|
||||
|
||||
// check response
|
||||
if (res == 0 && resplen > 0)
|
||||
|
|
|
@ -126,6 +126,7 @@ static void DesfireSecureChannelEncodeD40(DesfireContext *ctx, uint8_t cmd, uint
|
|||
memcpy(dstdata, srcdata, hdrlen);
|
||||
DesfireCryptoEncDec(ctx, true, &data[hdrlen], rlen - hdrlen, &dstdata[hdrlen], true);
|
||||
*dstdatalen = rlen;
|
||||
ctx->commMode = DCMEncrypted;
|
||||
break;
|
||||
case DCMNone:
|
||||
;
|
||||
|
@ -172,6 +173,7 @@ static void DesfireSecureChannelEncodeEV1(DesfireContext *ctx, uint8_t cmd, uint
|
|||
rlen = padded_data_length(srcdatalen - hdrlen, desfire_get_key_block_length(ctx->keyType));
|
||||
DesfireCryptoEncDec(ctx, true, data, rlen, &dstdata[hdrlen], true);
|
||||
*dstdatalen = hdrlen + rlen;
|
||||
ctx->commMode = DCMEncrypted;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue