mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2024-09-20 15:26:13 +08:00
make style
This commit is contained in:
parent
91af65353a
commit
2441b24124
|
@ -4758,7 +4758,7 @@ static int CmdHF14ADesChFileSettings(const char *Cmd) {
|
|||
CLIParserFree(ctx);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
uint8_t data[250] = {0};
|
||||
uint8_t *settings = &data[1];
|
||||
size_t datalen = 0;
|
||||
|
@ -4768,7 +4768,7 @@ static int CmdHF14ADesChFileSettings(const char *Cmd) {
|
|||
CLIParserFree(ctx);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
uint8_t sdata[250] = {0};
|
||||
int sdatalen = sizeof(sdata);
|
||||
CLIGetHexWithReturn(ctx, 13, sdata, &sdatalen);
|
||||
|
@ -4776,7 +4776,7 @@ static int CmdHF14ADesChFileSettings(const char *Cmd) {
|
|||
CLIParserFree(ctx);
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
|
||||
|
||||
if (sdatalen > 18) {
|
||||
PrintAndLogEx(ERR, "File settings length must be less than 18 instead of %d.", sdatalen);
|
||||
CLIParserFree(ctx);
|
||||
|
@ -4791,7 +4791,7 @@ static int CmdHF14ADesChFileSettings(const char *Cmd) {
|
|||
|
||||
SetAPDULogging(APDULogging);
|
||||
CLIParserFree(ctx);
|
||||
|
||||
|
||||
uint8_t fileid = data[0];
|
||||
|
||||
if (noauth) {
|
||||
|
@ -5752,14 +5752,14 @@ static int DesfileReadFileAndPrint(DesfireContext *dctx, uint8_t fnum, int filet
|
|||
// get file settings
|
||||
if (filetype == RFTAuto) {
|
||||
FileSettingsS fsettings;
|
||||
|
||||
|
||||
DesfireCommunicationMode commMode = dctx->commMode;
|
||||
DesfireSetCommMode(dctx, DCMPlain);
|
||||
res = DesfireGetFileSettingsStruct(dctx, fnum, &fsettings);
|
||||
DesfireSetCommMode(dctx, commMode);
|
||||
|
||||
DesfireSetCommMode(dctx, commMode);
|
||||
|
||||
if (res == PM3_SUCCESS) {
|
||||
switch(fsettings.fileType) {
|
||||
switch (fsettings.fileType) {
|
||||
case 0x00:
|
||||
case 0x01: {
|
||||
filetype = RFTData;
|
||||
|
@ -5785,15 +5785,15 @@ static int DesfileReadFileAndPrint(DesfireContext *dctx, uint8_t fnum, int filet
|
|||
}
|
||||
|
||||
DesfireSetCommMode(dctx, fsettings.commMode);
|
||||
|
||||
|
||||
if (fsettings.fileCommMode != 0 && noauth)
|
||||
PrintAndLogEx(WARNING, "File needs communication mode `%s` but there is no authentication", CLIGetOptionListStr(DesfireCommunicationModeOpts, fsettings.commMode));
|
||||
|
||||
if (verbose)
|
||||
PrintAndLogEx(INFO, "Got file type: %s. Option: %s. comm mode: %s",
|
||||
GetDesfireFileType(fsettings.fileType),
|
||||
CLIGetOptionListStr(DesfireReadFileTypeOpts, filetype),
|
||||
CLIGetOptionListStr(DesfireCommunicationModeOpts, fsettings.commMode));
|
||||
PrintAndLogEx(INFO, "Got file type: %s. Option: %s. comm mode: %s",
|
||||
GetDesfireFileType(fsettings.fileType),
|
||||
CLIGetOptionListStr(DesfireReadFileTypeOpts, filetype),
|
||||
CLIGetOptionListStr(DesfireCommunicationModeOpts, fsettings.commMode));
|
||||
} else {
|
||||
PrintAndLogEx(WARNING, "GetFileSettings error. Can't get file type.");
|
||||
}
|
||||
|
@ -5803,7 +5803,7 @@ static int DesfileReadFileAndPrint(DesfireContext *dctx, uint8_t fnum, int filet
|
|||
|
||||
uint8_t resp[2048] = {0};
|
||||
size_t resplen = 0;
|
||||
|
||||
|
||||
if (filetype == RFTData) {
|
||||
res = DesfireReadFile(dctx, fnum, offset, length, resp, &resplen);
|
||||
if (res != PM3_SUCCESS) {
|
||||
|
@ -5842,7 +5842,7 @@ static int DesfileReadFileAndPrint(DesfireContext *dctx, uint8_t fnum, int filet
|
|||
}
|
||||
reclen = resplen;
|
||||
}
|
||||
|
||||
|
||||
if (verbose)
|
||||
PrintAndLogEx(INFO, "Record length %zu", reclen);
|
||||
|
||||
|
@ -5892,7 +5892,7 @@ static int DesfileReadFileAndPrint(DesfireContext *dctx, uint8_t fnum, int filet
|
|||
PrintAndLogEx(SUCCESS, "Read operation returned no data from file %d", fnum);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -5990,9 +5990,9 @@ static int CmdHF14ADesReadData(const char *Cmd) {
|
|||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
res = DesfileReadFileAndPrint(&dctx, fnum, op, offset, length, noauth, verbose);
|
||||
|
||||
|
||||
DropField();
|
||||
return res;
|
||||
}
|
||||
|
@ -6111,14 +6111,14 @@ static int CmdHF14ADesWriteData(const char *Cmd) {
|
|||
// get file settings
|
||||
if (op == RFTAuto) {
|
||||
FileSettingsS fsettings;
|
||||
|
||||
|
||||
DesfireCommunicationMode commMode = dctx.commMode;
|
||||
DesfireSetCommMode(&dctx, DCMPlain);
|
||||
res = DesfireGetFileSettingsStruct(&dctx, fnum, &fsettings);
|
||||
DesfireSetCommMode(&dctx, commMode);
|
||||
|
||||
DesfireSetCommMode(&dctx, commMode);
|
||||
|
||||
if (res == PM3_SUCCESS) {
|
||||
switch(fsettings.fileType) {
|
||||
switch (fsettings.fileType) {
|
||||
case 0x00:
|
||||
case 0x01: {
|
||||
op = RFTData;
|
||||
|
@ -6149,15 +6149,15 @@ static int CmdHF14ADesWriteData(const char *Cmd) {
|
|||
}
|
||||
|
||||
DesfireSetCommMode(&dctx, fsettings.commMode);
|
||||
|
||||
|
||||
if (fsettings.fileCommMode != 0 && noauth)
|
||||
PrintAndLogEx(WARNING, "File needs communication mode `%s` but there is no authentication", CLIGetOptionListStr(DesfireCommunicationModeOpts, fsettings.commMode));
|
||||
|
||||
if (verbose)
|
||||
PrintAndLogEx(INFO, "Got file type: %s. Option: %s. comm mode: %s",
|
||||
GetDesfireFileType(fsettings.fileType),
|
||||
CLIGetOptionListStr(DesfireReadFileTypeOpts, op),
|
||||
CLIGetOptionListStr(DesfireCommunicationModeOpts, fsettings.commMode));
|
||||
PrintAndLogEx(INFO, "Got file type: %s. Option: %s. comm mode: %s",
|
||||
GetDesfireFileType(fsettings.fileType),
|
||||
CLIGetOptionListStr(DesfireReadFileTypeOpts, op),
|
||||
CLIGetOptionListStr(DesfireCommunicationModeOpts, fsettings.commMode));
|
||||
} else {
|
||||
PrintAndLogEx(WARNING, "GetFileSettings error. Can't get file type.");
|
||||
}
|
||||
|
@ -6238,9 +6238,9 @@ static int CmdHF14ADesWriteData(const char *Cmd) {
|
|||
if (verbose)
|
||||
PrintAndLogEx(INFO, "Commit " _GREEN_("OK"));
|
||||
}
|
||||
|
||||
|
||||
PrintAndLogEx(INFO, "Write %s file %02x " _GREEN_("success"), CLIGetOptionListStr(DesfireReadFileTypeOpts, op), fnum);
|
||||
|
||||
|
||||
DropField();
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
@ -6298,8 +6298,8 @@ static int CmdHF14ADesLsFiles(const char *Cmd) {
|
|||
DropField();
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
FileListS FileList = {0};
|
||||
size_t filescount = 0;
|
||||
bool isopresent = false;
|
||||
|
@ -6314,7 +6314,7 @@ static int CmdHF14ADesLsFiles(const char *Cmd) {
|
|||
DropField();
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
PrintAndLogEx(INFO, "---------------------------- " _CYAN_("File list") " -----------------------(r w rw ch)-----");
|
||||
for (int i = 0; i < filescount; i++) {
|
||||
PrintAndLogEx(SUCCESS, "ID: " _GREEN_("%02x ") NOLF, FileList[i].fileNum);
|
||||
|
@ -6324,7 +6324,7 @@ static int CmdHF14ADesLsFiles(const char *Cmd) {
|
|||
else
|
||||
PrintAndLogEx(NORMAL, "ISO ID: " _YELLOW_("n/a ") NOLF);
|
||||
}
|
||||
|
||||
|
||||
DesfirePrintFileSettingsOneLine(&FileList[i].fileSettings);
|
||||
}
|
||||
|
||||
|
@ -6371,7 +6371,7 @@ static int CmdHF14ADesDump(const char *Cmd) {
|
|||
|
||||
SetAPDULogging(APDULogging);
|
||||
CLIParserFree(ctx);
|
||||
|
||||
|
||||
res = DesfireSelectAndAuthenticateEx(&dctx, securechann, appid, noauth, verbose);
|
||||
if (res != PM3_SUCCESS) {
|
||||
DropField();
|
||||
|
@ -6417,7 +6417,7 @@ static int CmdHF14ADesDump(const char *Cmd) {
|
|||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(INFO, "--------------------------------- " _CYAN_("File %02x") " ----------------------------------", FileList[i].fileNum);
|
||||
PrintAndLogEx(SUCCESS, "File ID : " _GREEN_("%02x"), FileList[i].fileNum);
|
||||
|
@ -6428,14 +6428,14 @@ static int CmdHF14ADesDump(const char *Cmd) {
|
|||
PrintAndLogEx(SUCCESS, "File ISO ID : " _YELLOW_("n/a"));
|
||||
}
|
||||
DesfirePrintFileSettingsExtended(&FileList[i].fileSettings);
|
||||
|
||||
|
||||
res = DesfileReadFileAndPrint(&dctx, FileList[i].fileNum, RFTAuto, 0, 0, noauth, verbose);
|
||||
}
|
||||
|
||||
DropField();
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
static int CmdHF14ADesTest(const char *Cmd) {
|
||||
DesfireTest(true);
|
||||
return PM3_SUCCESS;
|
||||
|
|
|
@ -391,19 +391,19 @@ static int DesfireExchangeNative(bool activate_field, DesfireContext *ctx, uint8
|
|||
size_t len = 0;
|
||||
// tx chaining
|
||||
size_t sentdatalen = 0;
|
||||
while(cdatalen >= sentdatalen) {
|
||||
while (cdatalen >= sentdatalen) {
|
||||
if (cdatalen - sentdatalen > DESFIRE_TX_FRAME_MAX_LEN)
|
||||
len = DESFIRE_TX_FRAME_MAX_LEN;
|
||||
else
|
||||
len = cdatalen - sentdatalen;
|
||||
|
||||
|
||||
size_t sendindx = sentdatalen;
|
||||
size_t sendlen = len;
|
||||
if (sentdatalen > 0) {
|
||||
sendindx--;
|
||||
sendlen++;
|
||||
cdata[sendindx] = MFDES_ADDITIONAL_FRAME;
|
||||
}
|
||||
}
|
||||
|
||||
res = DESFIRESendRaw(activate_field, &cdata[sendindx], sendlen, buf, sizeof(buf), &buflen, &rcode);
|
||||
if (res != PM3_SUCCESS) {
|
||||
|
@ -411,7 +411,7 @@ static int DesfireExchangeNative(bool activate_field, DesfireContext *ctx, uint8
|
|||
PrintAndLogEx(DEBUG, "error DESFIRESendRaw %s", DesfireGetErrorString(res, &ssw));
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
sentdatalen += len;
|
||||
if (rcode != MFDES_ADDITIONAL_FRAME || buflen > 0) {
|
||||
if (sentdatalen != cdatalen)
|
||||
|
@ -498,22 +498,22 @@ static int DesfireExchangeISO(bool activate_field, DesfireContext *ctx, uint8_t
|
|||
int res = 0;
|
||||
// tx chaining
|
||||
size_t sentdatalen = 0;
|
||||
while(datalen >= sentdatalen) {
|
||||
while (datalen >= sentdatalen) {
|
||||
if (datalen - sentdatalen > DESFIRE_TX_FRAME_MAX_LEN)
|
||||
apdu.Lc = DESFIRE_TX_FRAME_MAX_LEN;
|
||||
else
|
||||
apdu.Lc = datalen - sentdatalen;
|
||||
apdu.data = &data[sentdatalen];
|
||||
|
||||
|
||||
if (sentdatalen > 0)
|
||||
apdu.INS = MFDES_ADDITIONAL_FRAME;
|
||||
apdu.INS = MFDES_ADDITIONAL_FRAME;
|
||||
|
||||
res = DESFIRESendApdu(activate_field, apdu, buf, sizeof(buf), &buflen, &sw);
|
||||
if (res != PM3_SUCCESS) {
|
||||
PrintAndLogEx(DEBUG, "error DESFIRESendApdu %s", DesfireGetErrorString(res, &sw));
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
sentdatalen += apdu.Lc;
|
||||
if (sw != DESFIRE_GET_ISO_STATUS(MFDES_ADDITIONAL_FRAME) || buflen > 0) {
|
||||
if (sentdatalen != datalen)
|
||||
|
@ -1134,7 +1134,7 @@ int DesfireGetFileSettingsStruct(DesfireContext *dctx, uint8_t fileid, FileSetti
|
|||
int DesfireFillFileList(DesfireContext *dctx, FileListS FileList, size_t *filescount, bool *isopresent) {
|
||||
uint8_t buf[APDU_RES_LEN] = {0};
|
||||
size_t buflen = 0;
|
||||
|
||||
|
||||
*filescount = 0;
|
||||
*isopresent = false;
|
||||
memset(FileList, 0, sizeof(FileListS));
|
||||
|
@ -1144,10 +1144,10 @@ int DesfireFillFileList(DesfireContext *dctx, FileListS FileList, size_t *filesc
|
|||
PrintAndLogEx(ERR, "Desfire GetFileIDList command " _RED_("error") ". Result: %d", res);
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
|
||||
if (buflen == 0)
|
||||
return PM3_SUCCESS;
|
||||
|
||||
|
||||
for (int i = 0; i < buflen; i++) {
|
||||
FileList[i].fileNum = buf[i];
|
||||
DesfireGetFileSettingsStruct(dctx, FileList[i].fileNum, &FileList[i].fileSettings);
|
||||
|
@ -1159,7 +1159,7 @@ int DesfireFillFileList(DesfireContext *dctx, FileListS FileList, size_t *filesc
|
|||
if (res != PM3_SUCCESS) {
|
||||
PrintAndLogEx(ERR, "Desfire GetFileISOIDList command " _RED_("error") ". Result: %d", res);
|
||||
}
|
||||
|
||||
|
||||
size_t isoindx = 0;
|
||||
if (buflen > 0) {
|
||||
for (int i = 0; i < *filescount; i++) {
|
||||
|
@ -1175,9 +1175,9 @@ int DesfireFillFileList(DesfireContext *dctx, FileListS FileList, size_t *filesc
|
|||
} else {
|
||||
PrintAndLogEx(WARNING, "ISO ID list returned no data");
|
||||
}
|
||||
|
||||
|
||||
*isopresent = (isoindx > 0);
|
||||
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
@ -1216,7 +1216,7 @@ int DesfireReadFile(DesfireContext *dctx, uint8_t fnum, uint32_t offset, uint32_
|
|||
data[0] = fnum;
|
||||
Uint3byteToMemLe(&data[1], offset);
|
||||
Uint3byteToMemLe(&data[4], len);
|
||||
|
||||
|
||||
return DesfireCommand(dctx, MFDES_READ_DATA, data, 7, resp, resplen, -1);
|
||||
}
|
||||
|
||||
|
@ -1226,7 +1226,7 @@ int DesfireWriteFile(DesfireContext *dctx, uint8_t fnum, uint32_t offset, uint32
|
|||
Uint3byteToMemLe(&xdata[1], offset);
|
||||
Uint3byteToMemLe(&xdata[4], len);
|
||||
memcpy(&xdata[7], data, len);
|
||||
|
||||
|
||||
return DesfireCommandTxData(dctx, MFDES_WRITE_DATA, xdata, 7 + len);
|
||||
}
|
||||
|
||||
|
@ -1252,7 +1252,7 @@ int DesfireReadRecords(DesfireContext *dctx, uint8_t fnum, uint32_t recnum, uint
|
|||
data[0] = fnum;
|
||||
Uint3byteToMemLe(&data[1], recnum);
|
||||
Uint3byteToMemLe(&data[4], reccount);
|
||||
|
||||
|
||||
return DesfireCommand(dctx, MFDES_READ_RECORDS, data, 7, resp, resplen, -1);
|
||||
}
|
||||
|
||||
|
@ -1262,7 +1262,7 @@ int DesfireWriteRecord(DesfireContext *dctx, uint8_t fnum, uint32_t offset, uint
|
|||
Uint3byteToMemLe(&xdata[1], offset);
|
||||
Uint3byteToMemLe(&xdata[4], len);
|
||||
memcpy(&xdata[7], data, len);
|
||||
|
||||
|
||||
return DesfireCommandTxData(dctx, MFDES_WRITE_RECORD, xdata, 7 + len);
|
||||
}
|
||||
|
||||
|
@ -1273,7 +1273,7 @@ int DesfireUpdateRecord(DesfireContext *dctx, uint8_t fnum, uint32_t recnum, uin
|
|||
Uint3byteToMemLe(&xdata[4], offset);
|
||||
Uint3byteToMemLe(&xdata[7], len);
|
||||
memcpy(&xdata[10], data, len);
|
||||
|
||||
|
||||
return DesfireCommandTxData(dctx, MFDES_UPDATE_RECORD, xdata, 10 + len);
|
||||
}
|
||||
|
||||
|
@ -1473,12 +1473,12 @@ void DesfirePrintAccessRight(uint8_t *data) {
|
|||
void DesfireFillFileSettings(uint8_t *data, size_t datalen, FileSettingsS *fsettings) {
|
||||
if (fsettings == NULL)
|
||||
return;
|
||||
|
||||
|
||||
memset(fsettings, 0, sizeof(FileSettingsS));
|
||||
|
||||
|
||||
if (datalen < 4)
|
||||
return;
|
||||
|
||||
|
||||
fsettings->fileType = data[0];
|
||||
fsettings->fileOption = data[1];
|
||||
fsettings->fileCommMode = data[1] & 0x03;
|
||||
|
@ -1523,7 +1523,7 @@ void DesfireFillFileSettings(uint8_t *data, size_t datalen, FileSettingsS *fsett
|
|||
|
||||
if (fsettings->additionalAccessRightsEn && reclen > 0 && datalen > reclen && datalen == reclen + data[reclen] * 2) {
|
||||
fsettings->additionalAccessRightsLength = data[reclen];
|
||||
|
||||
|
||||
for (int i = 0; i < fsettings->additionalAccessRightsLength; i++) {
|
||||
fsettings->additionalAccessRights[i] = MemLeToUint2byte(&data[reclen + 1 + i * 2]);
|
||||
}
|
||||
|
@ -1531,24 +1531,24 @@ void DesfireFillFileSettings(uint8_t *data, size_t datalen, FileSettingsS *fsett
|
|||
}
|
||||
|
||||
void DesfirePrintFileSettingsOneLine(FileSettingsS *fsettings) {
|
||||
PrintAndLogEx(NORMAL, "(%-5s) " NOLF, GetDesfireCommunicationMode(fsettings->fileCommMode));
|
||||
PrintAndLogEx(NORMAL, "(%-5s) " NOLF, GetDesfireCommunicationMode(fsettings->fileCommMode));
|
||||
PrintAndLogEx(NORMAL, "[0x%02x] " _CYAN_("%-13s ") NOLF, fsettings->fileType, GetDesfireFileType(fsettings->fileType));
|
||||
|
||||
switch (fsettings->fileType) {
|
||||
case 0x00:
|
||||
case 0x01: {
|
||||
PrintAndLogEx(NORMAL, "size: %d [0x%x] " NOLF, fsettings->fileSize, fsettings->fileSize);
|
||||
PrintAndLogEx(NORMAL, "size: %d [0x%x] " NOLF, fsettings->fileSize, fsettings->fileSize);
|
||||
break;
|
||||
}
|
||||
case 0x02: {
|
||||
PrintAndLogEx(NORMAL, "[%d .. %d] lim cred: 0x%02x (%d [0x%x]) " NOLF,
|
||||
fsettings->lowerLimit, fsettings->upperLimit, fsettings->limitedCredit, fsettings->value, fsettings->value);
|
||||
PrintAndLogEx(NORMAL, "[%d .. %d] lim cred: 0x%02x (%d [0x%x]) " NOLF,
|
||||
fsettings->lowerLimit, fsettings->upperLimit, fsettings->limitedCredit, fsettings->value, fsettings->value);
|
||||
break;
|
||||
}
|
||||
case 0x03:
|
||||
case 0x04: {
|
||||
PrintAndLogEx(NORMAL, "%d/%d record size: %d [0x%x]b " NOLF,
|
||||
fsettings->curRecordCount, fsettings->maxRecordCount, fsettings->recordSize, fsettings->recordSize);
|
||||
fsettings->curRecordCount, fsettings->maxRecordCount, fsettings->recordSize, fsettings->recordSize);
|
||||
break;
|
||||
}
|
||||
case 0x05: {
|
||||
|
@ -1559,22 +1559,22 @@ void DesfirePrintFileSettingsOneLine(FileSettingsS *fsettings) {
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
PrintAndLogEx(NORMAL, "(%s %s %s %s)",
|
||||
GetDesfireAccessRightStr(fsettings->rAccess),
|
||||
GetDesfireAccessRightStr(fsettings->wAccess),
|
||||
GetDesfireAccessRightStr(fsettings->rwAccess),
|
||||
GetDesfireAccessRightStr(fsettings->chAccess));
|
||||
|
||||
PrintAndLogEx(NORMAL, "(%s %s %s %s)",
|
||||
GetDesfireAccessRightStr(fsettings->rAccess),
|
||||
GetDesfireAccessRightStr(fsettings->wAccess),
|
||||
GetDesfireAccessRightStr(fsettings->rwAccess),
|
||||
GetDesfireAccessRightStr(fsettings->chAccess));
|
||||
}
|
||||
|
||||
void DesfirePrintFileSettingsExtended(FileSettingsS *fsettings) {
|
||||
PrintAndLogEx(SUCCESS, "File type : " _CYAN_("%s") " [0x%02x]", GetDesfireFileType(fsettings->fileType), fsettings->fileType);
|
||||
PrintAndLogEx(SUCCESS, "Comm mode : %s", GetDesfireCommunicationMode(fsettings->fileCommMode));
|
||||
PrintAndLogEx(SUCCESS, "Comm mode : %s", GetDesfireCommunicationMode(fsettings->fileCommMode));
|
||||
|
||||
switch (fsettings->fileType) {
|
||||
case 0x00:
|
||||
case 0x01: {
|
||||
PrintAndLogEx(SUCCESS, "File size : %d [0x%x] bytes", fsettings->fileSize, fsettings->fileSize);
|
||||
PrintAndLogEx(SUCCESS, "File size : %d [0x%x] bytes", fsettings->fileSize, fsettings->fileSize);
|
||||
break;
|
||||
}
|
||||
case 0x02: {
|
||||
|
@ -1601,13 +1601,13 @@ void DesfirePrintFileSettingsExtended(FileSettingsS *fsettings) {
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
PrintAndLogEx(SUCCESS, "Access rights : %04x (r: %s w: %s rw: %s change: %s)",
|
||||
fsettings->rawAccessRights,
|
||||
GetDesfireAccessRightStr(fsettings->rAccess),
|
||||
GetDesfireAccessRightStr(fsettings->wAccess),
|
||||
GetDesfireAccessRightStr(fsettings->rwAccess),
|
||||
GetDesfireAccessRightStr(fsettings->chAccess));
|
||||
|
||||
PrintAndLogEx(SUCCESS, "Access rights : %04x (r: %s w: %s rw: %s change: %s)",
|
||||
fsettings->rawAccessRights,
|
||||
GetDesfireAccessRightStr(fsettings->rAccess),
|
||||
GetDesfireAccessRightStr(fsettings->wAccess),
|
||||
GetDesfireAccessRightStr(fsettings->rwAccess),
|
||||
GetDesfireAccessRightStr(fsettings->chAccess));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -42,10 +42,10 @@ typedef struct {
|
|||
uint8_t wAccess;
|
||||
uint8_t rwAccess;
|
||||
uint8_t chAccess;
|
||||
|
||||
|
||||
// data
|
||||
uint32_t fileSize;
|
||||
|
||||
|
||||
//value
|
||||
uint32_t lowerLimit;
|
||||
uint32_t upperLimit;
|
||||
|
@ -56,12 +56,12 @@ typedef struct {
|
|||
uint32_t recordSize;
|
||||
uint32_t maxRecordCount;
|
||||
uint32_t curRecordCount;
|
||||
|
||||
|
||||
//mac
|
||||
uint8_t keyType;
|
||||
uint8_t key[16];
|
||||
uint8_t keyVersion;
|
||||
|
||||
|
||||
// additional rights
|
||||
uint8_t additionalAccessRightsLength;
|
||||
uint16_t additionalAccessRights[16];
|
||||
|
|
|
@ -383,7 +383,7 @@ uint8_t DesfireCommModeToFileCommMode(DesfireCommunicationMode comm_mode) {
|
|||
case DCMNone:
|
||||
break;
|
||||
}
|
||||
return fmode;
|
||||
return fmode;
|
||||
}
|
||||
|
||||
void desfire_crc32(const uint8_t *data, const size_t len, uint8_t *crc) {
|
||||
|
|
|
@ -26,9 +26,9 @@
|
|||
static const uint8_t CommandsCanUseAnyChannel[] = {
|
||||
MFDES_READ_DATA,
|
||||
MFDES_WRITE_DATA,
|
||||
MFDES_GET_VALUE,
|
||||
MFDES_READ_RECORDS,
|
||||
MFDES_WRITE_RECORD,
|
||||
MFDES_GET_VALUE,
|
||||
MFDES_READ_RECORDS,
|
||||
MFDES_WRITE_RECORD,
|
||||
MFDES_UPDATE_RECORD,
|
||||
};
|
||||
|
||||
|
@ -157,10 +157,10 @@ static void DesfireSecureChannelEncodeD40(DesfireContext *ctx, uint8_t cmd, uint
|
|||
return;
|
||||
|
||||
rlen = srcdatalen + DesfireGetMACLength(ctx);
|
||||
|
||||
|
||||
memcpy(data, &srcdata[hdrlen], srcdatalen - hdrlen);
|
||||
size_t srcmaclen = padded_data_length(srcdatalen - hdrlen, desfire_get_key_block_length(ctx->keyType));
|
||||
|
||||
|
||||
uint8_t mac[32] = {0};
|
||||
DesfireCryptoEncDecEx(ctx, true, data, srcmaclen, NULL, true, true, mac);
|
||||
|
||||
|
@ -274,9 +274,9 @@ static void DesfireSecureChannelDecodeD40(DesfireContext *ctx, uint8_t *srcdata,
|
|||
rlen = padded_data_length(srcdatalen - maclen, desfire_get_key_block_length(ctx->keyType));
|
||||
memcpy(data, srcdata, srcdatalen - maclen);
|
||||
DesfireCryptoEncDecEx(ctx, true, data, rlen, NULL, true, true, mac);
|
||||
|
||||
|
||||
if (memcmp(mac, &srcdata[srcdatalen - maclen], maclen) == 0) {
|
||||
*dstdatalen = srcdatalen - maclen;
|
||||
*dstdatalen = srcdatalen - maclen;
|
||||
} else {
|
||||
PrintAndLogEx(WARNING, "Received MAC is not match with calculated");
|
||||
//PrintAndLogEx(INFO, " received MAC: %s", sprint_hex(&srcdata[srcdatalen - maclen], maclen));
|
||||
|
@ -284,7 +284,7 @@ static void DesfireSecureChannelDecodeD40(DesfireContext *ctx, uint8_t *srcdata,
|
|||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
case DCMEncrypted:
|
||||
if (srcdatalen < desfire_get_key_block_length(ctx->keyType)) {
|
||||
memcpy(dstdata, srcdata, srcdatalen);
|
||||
|
|
|
@ -973,7 +973,7 @@
|
|||
},
|
||||
"help": {
|
||||
"command": "help",
|
||||
"description": "help use `<command> help` for details of a command prefs { edit client/device preferences... } -------- ----------------------- technology ----------------------- analyse { analyse utils... } data { plot window / data buffer manipulation... } emv { emv iso-14443 / iso-7816... } hf { high frequency commands... } hw { hardware commands... } lf { low frequency commands... } nfc { nfc commands... } reveng { crc calculations from reveng software... } smart { smart card iso-7816 commands... } script { scripting commands... } trace { trace manipulation... } wiegand { wiegand format manipulation... } -------- ----------------------- general ----------------------- clear clear screen hints turn hints on / off msleep add a pause in milliseconds rem add a text line in log file quit exit exit program [=] session log /home/iceman/.proxmark3/logs/log_20210729.txt --------------------------------------------------------------------------------------- auto available offline: no run lf search / hf search / data plot / data save",
|
||||
"description": "help use `<command> help` for details of a command prefs { edit client/device preferences... } -------- ----------------------- technology ----------------------- analyse { analyse utils... } data { plot window / data buffer manipulation... } emv { emv iso-14443 / iso-7816... } hf { high frequency commands... } hw { hardware commands... } lf { low frequency commands... } nfc { nfc commands... } reveng { crc calculations from reveng software... } smart { smart card iso-7816 commands... } script { scripting commands... } trace { trace manipulation... } wiegand { wiegand format manipulation... } -------- ----------------------- general ----------------------- clear clear screen hints turn hints on / off msleep add a pause in milliseconds rem add a text line in log file quit exit exit program [=] session log e:\\proxspace\\pm3/.proxmark3/logs/log_20210729.txt --------------------------------------------------------------------------------------- auto available offline: no run lf search / hf search / data plot / data save",
|
||||
"notes": [
|
||||
"auto"
|
||||
],
|
||||
|
@ -4390,15 +4390,27 @@
|
|||
},
|
||||
"hf mfdes dump": {
|
||||
"command": "hf mfdes dump",
|
||||
"description": "tries to dump all files on a desfire tag",
|
||||
"description": "for each application show fil list and then file content. key needs to be provided for authentication or flag --no-auth set (depend on cards settings).",
|
||||
"notes": [
|
||||
"hf mfdes dump"
|
||||
"hf mfdes dump --aid 123456 -> show file dump for: app=123456 with channel defaults from `default` command"
|
||||
],
|
||||
"offline": false,
|
||||
"options": [
|
||||
"-h, --help this help"
|
||||
"-h, --help this help",
|
||||
"-a, --apdu show apdu requests and responses",
|
||||
"-v, --verbose show technical data",
|
||||
"-n, --keyno <keyno> key number",
|
||||
"-t, --algo <des/2tdea/3tdea/aes> crypt algo: des, 2tdea, 3tdea, aes",
|
||||
"-k, --key <key> key for authenticate (hex 8(des), 16(2tdea or aes) or 24(3tdea) bytes)",
|
||||
"-f, --kdf <none/an10922/gallagher> key derivation function (kdf): none, an10922, gallagher",
|
||||
"-i, --kdfi <kdfi> kdf input (hex 1-31 bytes)",
|
||||
"-m, --cmode <plain/mac/encrypt> communicaton mode: plain/mac/encrypt",
|
||||
"-c, --ccset <native/niso/iso> communicaton command set: native/niso/iso",
|
||||
"-s, --schann <d40/ev1/ev2> secure channel: d40/ev1/ev2",
|
||||
"--aid <app id hex> application id (3 hex bytes, big endian)",
|
||||
"--no-auth execute without authentication"
|
||||
],
|
||||
"usage": "hf mfdes dump [-h]"
|
||||
"usage": "hf mfdes dump [-hav] [-n <keyno>] [-t <des/2tdea/3tdea/aes>] [-k <key>] [-f <none/an10922/gallagher>] [-i <kdfi>] [-m <plain/mac/encrypt>] [-c <native/niso/iso>] [-s <d40/ev1/ev2>] [--aid <app id hex>] [--no-auth]"
|
||||
},
|
||||
"hf mfdes enum": {
|
||||
"command": "hf mfdes enum",
|
||||
|
@ -5660,8 +5672,8 @@
|
|||
"command": "hw connect",
|
||||
"description": "connects to a proxmark3 device via specified serial port. baudrate here is only for physical uart or uart-bt, not for usb-cdc or blue shark add-on",
|
||||
"notes": [
|
||||
"hw connect -p /dev/ttyacm0",
|
||||
"hw connect -p /dev/ttyacm0 -b 115200"
|
||||
"hw connect -p com3",
|
||||
"hw connect -p com3 -b 115200"
|
||||
],
|
||||
"offline": true,
|
||||
"options": [
|
||||
|
@ -9814,6 +9826,6 @@
|
|||
"metadata": {
|
||||
"commands_extracted": 587,
|
||||
"extracted_by": "PM3Help2JSON v1.00",
|
||||
"extracted_on": "2021-07-29T12:40:22"
|
||||
"extracted_on": "2021-07-29T15:18:59"
|
||||
}
|
||||
}
|
|
@ -526,7 +526,7 @@ Check column "offline" for their availability.
|
|||
|`hf mfdes getfileids `|N |`[new]Get File IDs list`
|
||||
|`hf mfdes getfileisoids `|N |`[new]Get File ISO IDs list`
|
||||
|`hf mfdes lsfiles `|N |`[new]Show all files list`
|
||||
|`hf mfdes dump `|N |`Dump all files`
|
||||
|`hf mfdes dump `|N |`[new]Dump all files`
|
||||
|`hf mfdes createfile `|N |`[new]Create Standard/Backup File`
|
||||
|`hf mfdes createvaluefile`|N |`[new]Create Value File`
|
||||
|`hf mfdes createrecordfile`|N |`[new]Create Linear/Cyclic Record File`
|
||||
|
|
Loading…
Reference in a new issue