mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-24 15:15:39 -07:00
file settings refactoring and fix bug in get file ids
This commit is contained in:
parent
dcd018f3aa
commit
bbf7b1a26d
3 changed files with 35 additions and 9 deletions
|
@ -5970,7 +5970,7 @@ static int CmdHF14ADesGetFileIDs(const char *Cmd) {
|
|||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
if (buflen >= 3) {
|
||||
if (buflen > 0) {
|
||||
PrintAndLogEx(INFO, "---- " _CYAN_("File ID list") " ----");
|
||||
for (int i = 0; i < buflen; i++)
|
||||
PrintAndLogEx(INFO, "File ID: %02x", buf[i]);
|
||||
|
@ -6048,7 +6048,7 @@ static int CmdHF14ADesGetFileISOIDs(const char *Cmd) {
|
|||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
if (buflen >= 3) {
|
||||
if (buflen > 1) {
|
||||
PrintAndLogEx(INFO, "---- " _CYAN_("File ISO ID list") " ----");
|
||||
for (int i = 0; i < buflen; i += 2)
|
||||
PrintAndLogEx(INFO, "File ID: %02x%02x", buf[i], buf[i + 1]);
|
||||
|
@ -6236,9 +6236,8 @@ static int CmdHF14ADesChFileSettings(const char *Cmd) {
|
|||
int ch_mode = 0x0e;
|
||||
if (CLIGetOptionList(arg_get_str(ctx, 18), DesfireFileAccessModeOpts, &ch_mode))
|
||||
return PM3_ESOFT;
|
||||
|
||||
settings[1] = ((rw_mode & 0x0f) << 4) | (ch_mode & 0x0f);
|
||||
settings[2] = ((r_mode & 0x0f) << 4) | (w_mode & 0x0f);
|
||||
|
||||
DesfireEncodeFileAcessMode(&settings[1], r_mode, w_mode, rw_mode, ch_mode) ;
|
||||
}
|
||||
|
||||
SetAPDULogging(APDULogging);
|
||||
|
|
|
@ -1239,11 +1239,36 @@ const char *GetDesfireAccessRightStr(uint8_t right) {
|
|||
return DesfireUnknownStr;
|
||||
}
|
||||
|
||||
void DesfireEncodeFileAcessMode(uint8_t *mode, uint8_t r, uint8_t w, uint8_t rw, uint8_t ch) {
|
||||
mode[0] = (ch & 0x0f) | ((rw << 4) & 0xf0);
|
||||
mode[1] = (w & 0x0f) | ((r << 4) & 0xf0);
|
||||
}
|
||||
|
||||
void DesfireDecodeFileAcessMode(uint8_t *mode, uint8_t *r, uint8_t *w, uint8_t *rw, uint8_t *ch) {
|
||||
// read
|
||||
if (r)
|
||||
*r = (mode[1] >> 4) & 0x0f; // hi 2b
|
||||
// write
|
||||
if (w)
|
||||
*w = mode[1] & 0x0f;
|
||||
// read/write
|
||||
if (rw)
|
||||
*rw = (mode[0] >> 4) & 0x0f; // low 2b
|
||||
// change
|
||||
if (ch)
|
||||
*ch = mode[0] & 0x0f;
|
||||
}
|
||||
|
||||
void DesfirePrintAccessRight(uint8_t *data) {
|
||||
PrintAndLogEx(SUCCESS, "read : %s", GetDesfireAccessRightStr((data[1] >> 4) & 0x0f)); // hi 2b
|
||||
PrintAndLogEx(SUCCESS, "write : %s", GetDesfireAccessRightStr(data[1] & 0x0f));
|
||||
PrintAndLogEx(SUCCESS, "readwrite: %s", GetDesfireAccessRightStr((data[0] >> 4) & 0x0f)); // low 2b
|
||||
PrintAndLogEx(SUCCESS, "change : %s", GetDesfireAccessRightStr(data[0] & 0x0f));
|
||||
uint8_t r = 0;
|
||||
uint8_t w = 0;
|
||||
uint8_t rw = 0;
|
||||
uint8_t ch = 0;
|
||||
DesfireDecodeFileAcessMode(data, &r, &w, &rw, &ch);
|
||||
PrintAndLogEx(SUCCESS, "read : %s", GetDesfireAccessRightStr(r));
|
||||
PrintAndLogEx(SUCCESS, "write : %s", GetDesfireAccessRightStr(w));
|
||||
PrintAndLogEx(SUCCESS, "readwrite: %s", GetDesfireAccessRightStr(rw));
|
||||
PrintAndLogEx(SUCCESS, "change : %s", GetDesfireAccessRightStr(ch));
|
||||
}
|
||||
|
||||
void DesfirePrintFileSettings(uint8_t *data, size_t len) {
|
||||
|
|
|
@ -78,6 +78,8 @@ int DesfireChangeFileSettings(DesfireContext *dctx, uint8_t *data, size_t datale
|
|||
|
||||
const DesfireCreateFileCommandsS *GetDesfireFileCmdRec(uint8_t type);
|
||||
const char *GetDesfireAccessRightStr(uint8_t right);
|
||||
void DesfireEncodeFileAcessMode(uint8_t *mode, uint8_t r, uint8_t w, uint8_t rw, uint8_t ch);
|
||||
void DesfireDecodeFileAcessMode(uint8_t *mode, uint8_t *r, uint8_t *w, uint8_t *rw, uint8_t *ch);
|
||||
void DesfirePrintAccessRight(uint8_t *data);
|
||||
void DesfirePrintFileSettings(uint8_t *data, size_t len);
|
||||
void DesfirePrintSetFileSettings(uint8_t *data, size_t len);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue