mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2026-05-12 11:18:11 -07:00
style
This commit is contained in:
@@ -8,8 +8,8 @@ author = 'Mosci'
|
||||
version = 'v1.0.3'
|
||||
desc =
|
||||
[[
|
||||
This is a script which writes value 0x01 to bytes from
|
||||
position 0x07 until 0xFF on a Legic Prime Tag (MIM256 or MIM1024)
|
||||
This is a script which writes value 0x01 to bytes from
|
||||
position 0x07 until 0xFF on a Legic Prime Tag (MIM256 or MIM1024)
|
||||
-- (created with 'hf legic dump -f my_dump.hex') --
|
||||
]]
|
||||
example = [[
|
||||
|
||||
@@ -14,7 +14,7 @@ copyright = ''
|
||||
author = '0xdrrb'
|
||||
version = 'v0.1.2'
|
||||
desc = [[
|
||||
This is a script that tries to dump and decrypt the data of a specific type of Mifare laundromat token.
|
||||
This is a script that tries to dump and decrypt the data of a specific type of Mifare laundromat token.
|
||||
OBS! Tag must be on the antenna.
|
||||
]]
|
||||
example = [[
|
||||
|
||||
+134
-134
File diff suppressed because it is too large
Load Diff
@@ -1151,7 +1151,7 @@ static int CmdHF14BWriteSri(const char *Cmd) {
|
||||
CLIExecWithReturn(ctx, Cmd, argtable, false);
|
||||
int blockno = arg_get_int_def(ctx, 1, -1);
|
||||
int dlen = 0;
|
||||
uint8_t data[4] = {0,0,0,0};
|
||||
uint8_t data[4] = {0, 0, 0, 0};
|
||||
int res = CLIParamHexToBuf(arg_get_str(ctx, 2), data, sizeof(data), &dlen);
|
||||
if (res) {
|
||||
CLIParserFree(ctx);
|
||||
@@ -1170,7 +1170,7 @@ static int CmdHF14BWriteSri(const char *Cmd) {
|
||||
|
||||
if (use_sri512 + use_srix4k > 1) {
|
||||
PrintAndLogEx(FAILED, "Select only one card type");
|
||||
return PM3_EINVARG;
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
|
||||
if (use_srix4k && blockno > 0x7F) {
|
||||
|
||||
+46
-46
@@ -442,7 +442,7 @@ static int getUID(bool loop, uint8_t *buf) {
|
||||
if (loop == false) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} while (loop && kbd_enter_pressed() == false);
|
||||
|
||||
@@ -470,7 +470,7 @@ static uint8_t arg_add_default(void *at[]) {
|
||||
at[5] = arg_lit0("o", "opt", "set OPTION Flag (needed for TI)");
|
||||
return 6;
|
||||
}
|
||||
static uint16_t arg_get_raw_flag(uint8_t uidlen, bool unaddressed, bool scan, bool add_option ) {
|
||||
static uint16_t arg_get_raw_flag(uint8_t uidlen, bool unaddressed, bool scan, bool add_option) {
|
||||
uint16_t flags = 0;
|
||||
if (unaddressed) {
|
||||
// unaddressed mode may not be supported by all vendors
|
||||
@@ -800,15 +800,15 @@ static int NxpSysInfo(uint8_t *uid) {
|
||||
*/
|
||||
static int CmdHF15Info(const char *Cmd) {
|
||||
|
||||
CLIParserContext *ctx;
|
||||
CLIParserContext *ctx;
|
||||
CLIParserInit(&ctx, "hf 15 info",
|
||||
"Uses the optional command `get_systeminfo` 0x2B to try and extract information",
|
||||
"hf 15 info\n"
|
||||
"hf 15 info -*\n"
|
||||
"hf 15 info -u E011223344556677"
|
||||
);
|
||||
);
|
||||
|
||||
void *argtable[6+1] = {};
|
||||
void *argtable[6 + 1] = {};
|
||||
uint8_t arglen = arg_add_default(argtable);
|
||||
argtable[arglen++] = arg_param_end;
|
||||
|
||||
@@ -844,7 +844,7 @@ static int CmdHF15Info(const char *Cmd) {
|
||||
if (getUID(false, uid) != PM3_SUCCESS) {
|
||||
PrintAndLogEx(WARNING, "no tag found");
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
}
|
||||
uidlen = 8;
|
||||
}
|
||||
|
||||
@@ -853,7 +853,7 @@ static int CmdHF15Info(const char *Cmd) {
|
||||
memcpy(req + reqlen, uid, sizeof(uid));
|
||||
reqlen += sizeof(uid);
|
||||
}
|
||||
PrintAndLogEx(SUCCESS, "Using UID... " _GREEN_("%s"), iso15693_sprintUID(NULL, uid));
|
||||
PrintAndLogEx(SUCCESS, "Using UID... " _GREEN_("%s"), iso15693_sprintUID(NULL, uid));
|
||||
|
||||
|
||||
AddCrc15(req, reqlen);
|
||||
@@ -1079,9 +1079,9 @@ static int CmdHF15WriteAfi(const char *Cmd) {
|
||||
"Write AFI on card",
|
||||
"hf 15 writeafi -* --afi 12\n"
|
||||
"hf 15 writeafi -u E011223344556677 --afi 12"
|
||||
);
|
||||
);
|
||||
|
||||
void *argtable[6+2] = {};
|
||||
void *argtable[6 + 2] = {};
|
||||
uint8_t arglen = arg_add_default(argtable);
|
||||
argtable[arglen++] = arg_int1(NULL, "afi", "<dec>", "AFI number (0-255)");
|
||||
argtable[arglen++] = arg_param_end;
|
||||
@@ -1124,7 +1124,7 @@ static int CmdHF15WriteAfi(const char *Cmd) {
|
||||
memcpy(req + reqlen, uid, sizeof(uid));
|
||||
reqlen += sizeof(uid);
|
||||
}
|
||||
PrintAndLogEx(SUCCESS, "Using UID... " _GREEN_("%s"), iso15693_sprintUID(NULL, uid));
|
||||
PrintAndLogEx(SUCCESS, "Using UID... " _GREEN_("%s"), iso15693_sprintUID(NULL, uid));
|
||||
}
|
||||
|
||||
// enforce, since we are writing
|
||||
@@ -1176,9 +1176,9 @@ static int CmdHF15WriteDsfid(const char *Cmd) {
|
||||
"Write DSFID on card",
|
||||
"hf 15 writedsfid -* --dsfid 12\n"
|
||||
"hf 15 writedsfid -u E011223344556677 --dsfid 12"
|
||||
);
|
||||
);
|
||||
|
||||
void *argtable[6+2] = {};
|
||||
void *argtable[6 + 2] = {};
|
||||
uint8_t arglen = arg_add_default(argtable);
|
||||
argtable[arglen++] = arg_int1(NULL, "dsfid", "<dec>", "DSFID number (0-255)");
|
||||
argtable[arglen++] = arg_param_end;
|
||||
@@ -1223,7 +1223,7 @@ static int CmdHF15WriteDsfid(const char *Cmd) {
|
||||
memcpy(req + reqlen, uid, sizeof(uid));
|
||||
reqlen += sizeof(uid);
|
||||
}
|
||||
PrintAndLogEx(SUCCESS, "Using UID... " _GREEN_("%s"), iso15693_sprintUID(NULL, uid));
|
||||
PrintAndLogEx(SUCCESS, "Using UID... " _GREEN_("%s"), iso15693_sprintUID(NULL, uid));
|
||||
}
|
||||
|
||||
// dsfid
|
||||
@@ -1239,7 +1239,7 @@ static int CmdHF15WriteDsfid(const char *Cmd) {
|
||||
// arg2 (recv == 1 == expect a response)
|
||||
uint8_t read_respone = 1;
|
||||
|
||||
PrintAndLogEx(DEBUG, "cmd %s", sprint_hex(req, reqlen) );
|
||||
PrintAndLogEx(DEBUG, "cmd %s", sprint_hex(req, reqlen));
|
||||
PacketResponseNG resp;
|
||||
clearCommandBuffer();
|
||||
SendCommandMIX(CMD_HF_ISO15693_COMMAND, reqlen, fast, read_respone, req, reqlen);
|
||||
@@ -1277,12 +1277,12 @@ static int CmdHF15Dump(const char *Cmd) {
|
||||
"hf 15 dump\n"
|
||||
"hf 15 dump -*\n"
|
||||
"hf 15 dump -u E011223344556677 -f hf-15-my-dump.bin"
|
||||
);
|
||||
);
|
||||
|
||||
void *argtable[6+2] = {};
|
||||
void *argtable[6 + 2] = {};
|
||||
uint8_t arglen = arg_add_default(argtable);
|
||||
argtable[arglen++] = arg_str0("f", "file", "<fn>", "filename of dump"),
|
||||
argtable[arglen++] = arg_param_end;
|
||||
argtable[arglen++] = arg_param_end;
|
||||
|
||||
CLIExecWithReturn(ctx, Cmd, argtable, true);
|
||||
|
||||
@@ -1321,7 +1321,7 @@ static int CmdHF15Dump(const char *Cmd) {
|
||||
if (getUID(false, uid) != PM3_SUCCESS) {
|
||||
PrintAndLogEx(WARNING, "no tag found");
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
}
|
||||
uidlen = 8;
|
||||
}
|
||||
|
||||
@@ -1330,7 +1330,7 @@ static int CmdHF15Dump(const char *Cmd) {
|
||||
memcpy(req + reqlen, uid, sizeof(uid));
|
||||
reqlen += sizeof(uid);
|
||||
}
|
||||
PrintAndLogEx(SUCCESS, "Using UID... " _GREEN_("%s"), iso15693_sprintUID(NULL, uid));
|
||||
PrintAndLogEx(SUCCESS, "Using UID... " _GREEN_("%s"), iso15693_sprintUID(NULL, uid));
|
||||
|
||||
// detect blocksize from card :)
|
||||
|
||||
@@ -1409,12 +1409,12 @@ static int CmdHF15Dump(const char *Cmd) {
|
||||
sprintf(lck, "%d", mem[i].lock);
|
||||
}
|
||||
PrintAndLogEx(INFO, "%3d/0x%02X | %s | %s | %s"
|
||||
, i
|
||||
, i
|
||||
, sprint_hex(mem[i].block, 4)
|
||||
, lck
|
||||
, sprint_ascii(mem[i].block, 4)
|
||||
);
|
||||
, i
|
||||
, i
|
||||
, sprint_hex(mem[i].block, 4)
|
||||
, lck
|
||||
, sprint_ascii(mem[i].block, 4)
|
||||
);
|
||||
}
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
|
||||
@@ -1449,7 +1449,7 @@ static int CmdHF15Raw(const char *Cmd) {
|
||||
"Sends raw bytes over ISO-15693 to card",
|
||||
"hf 15 raw -c -d 260100 --> add crc\n"
|
||||
"hf 15 raw -krc -d 260100 --> add crc, keep field on, skip response"
|
||||
);
|
||||
);
|
||||
|
||||
void *argtable[] = {
|
||||
arg_param_begin,
|
||||
@@ -1517,9 +1517,9 @@ static int CmdHF15Readmulti(const char *Cmd) {
|
||||
"Read multiple pages on a ISO-15693 tag ",
|
||||
"hf 15 rdmulti -* -b 1 --cnt 6 -> read 6 blocks\n"
|
||||
"hf 15 rdmulti -u E011223344556677 -b 12 --cnt 3 -> read three blocks"
|
||||
);
|
||||
);
|
||||
|
||||
void *argtable[6+3] = {};
|
||||
void *argtable[6 + 3] = {};
|
||||
uint8_t arglen = arg_add_default(argtable);
|
||||
argtable[arglen++] = arg_int1("b", NULL, "<dec>", "first page number (0-255)");
|
||||
argtable[arglen++] = arg_int1(NULL, "cnt", "<dec>", "number of pages (1-6)");
|
||||
@@ -1570,7 +1570,7 @@ static int CmdHF15Readmulti(const char *Cmd) {
|
||||
memcpy(req + reqlen, uid, sizeof(uid));
|
||||
reqlen += sizeof(uid);
|
||||
}
|
||||
PrintAndLogEx(SUCCESS, "Using UID... " _GREEN_("%s"), iso15693_sprintUID(NULL, uid));
|
||||
PrintAndLogEx(SUCCESS, "Using UID... " _GREEN_("%s"), iso15693_sprintUID(NULL, uid));
|
||||
}
|
||||
// add OPTION flag, in order to get lock-info
|
||||
req[0] |= ISO15_REQ_OPTION;
|
||||
@@ -1653,9 +1653,9 @@ static int CmdHF15Readblock(const char *Cmd) {
|
||||
"Read page on ISO-15693 tag",
|
||||
"hf 15 rdbl -* -b 12\n"
|
||||
"hf 15 rdbl -u E011223344556677 -b 12"
|
||||
);
|
||||
);
|
||||
|
||||
void *argtable[6+2] = {};
|
||||
void *argtable[6 + 2] = {};
|
||||
uint8_t arglen = arg_add_default(argtable);
|
||||
argtable[arglen++] = arg_int1("b", "blk", "<dec>", "page number (0-255)");
|
||||
argtable[arglen++] = arg_param_end;
|
||||
@@ -1679,7 +1679,7 @@ static int CmdHF15Readblock(const char *Cmd) {
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
|
||||
// default fallback to scan for tag.
|
||||
// default fallback to scan for tag.
|
||||
// overriding unaddress parameter :)
|
||||
if (uidlen != 8) {
|
||||
scan = true;
|
||||
@@ -1704,7 +1704,7 @@ static int CmdHF15Readblock(const char *Cmd) {
|
||||
memcpy(req + reqlen, uid, sizeof(uid));
|
||||
reqlen += sizeof(uid);
|
||||
}
|
||||
PrintAndLogEx(SUCCESS, "Using UID... " _GREEN_("%s"), iso15693_sprintUID(NULL, uid));
|
||||
PrintAndLogEx(SUCCESS, "Using UID... " _GREEN_("%s"), iso15693_sprintUID(NULL, uid));
|
||||
}
|
||||
// add OPTION flag, in order to get lock-info
|
||||
req[0] |= ISO15_REQ_OPTION;
|
||||
@@ -1819,9 +1819,9 @@ static int CmdHF15Write(const char *Cmd) {
|
||||
"Write block on ISO-15693 tag",
|
||||
"hf 15 wrbl -* -b 12 -d AABBCCDD\n"
|
||||
"hf 15 wrbl -u E011223344556677 -b 12 -d AABBCCDD"
|
||||
);
|
||||
);
|
||||
|
||||
void *argtable[6+4] = {};
|
||||
void *argtable[6 + 4] = {};
|
||||
uint8_t arglen = arg_add_default(argtable);
|
||||
argtable[arglen++] = arg_int1("b", "blk", "<dec>", "page number (0-255)");
|
||||
argtable[arglen++] = arg_str1("d", "data", "<hex>", "data, 4 bytes");
|
||||
@@ -1856,7 +1856,7 @@ static int CmdHF15Write(const char *Cmd) {
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
|
||||
// default fallback to scan for tag.
|
||||
// default fallback to scan for tag.
|
||||
// overriding unaddress parameter :)
|
||||
if (uidlen != 8) {
|
||||
scan = true;
|
||||
@@ -1884,7 +1884,7 @@ static int CmdHF15Write(const char *Cmd) {
|
||||
memcpy(req + reqlen, uid, sizeof(uid));
|
||||
reqlen += sizeof(uid);
|
||||
}
|
||||
PrintAndLogEx(SUCCESS, "Using UID... " _GREEN_("%s"), iso15693_sprintUID(NULL, uid));
|
||||
PrintAndLogEx(SUCCESS, "Using UID... " _GREEN_("%s"), iso15693_sprintUID(NULL, uid));
|
||||
}
|
||||
|
||||
|
||||
@@ -1913,14 +1913,14 @@ static int CmdHF15Restore(const char *Cmd) {
|
||||
"hf 15 restore\n"
|
||||
"hf 15 restore -*\n"
|
||||
"hf 15 restore -u E011223344556677 -f hf-15-my-dump.bin"
|
||||
);
|
||||
);
|
||||
|
||||
void *argtable[6+5] = {};
|
||||
void *argtable[6 + 5] = {};
|
||||
uint8_t arglen = arg_add_default(argtable);
|
||||
argtable[arglen++] = arg_str0("f", "file", "<fn>", "filename of dump"),
|
||||
argtable[arglen++] = arg_int0("r", "retry", "<dec>", "number of retries (def 3)"),
|
||||
argtable[arglen++] = arg_int0(NULL, "bs", "<dec>", "block size (def 4)"),
|
||||
argtable[arglen++] = arg_lit0("v", "verbose", "verbose output");
|
||||
argtable[arglen++] = arg_int0("r", "retry", "<dec>", "number of retries (def 3)"),
|
||||
argtable[arglen++] = arg_int0(NULL, "bs", "<dec>", "block size (def 4)"),
|
||||
argtable[arglen++] = arg_lit0("v", "verbose", "verbose output");
|
||||
argtable[arglen++] = arg_param_end;
|
||||
CLIExecWithReturn(ctx, Cmd, argtable, true);
|
||||
|
||||
@@ -1950,7 +1950,7 @@ static int CmdHF15Restore(const char *Cmd) {
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
|
||||
// default fallback to scan for tag.
|
||||
// default fallback to scan for tag.
|
||||
// overriding unaddress parameter :)
|
||||
if (uidlen != 8) {
|
||||
scan = true;
|
||||
@@ -1968,7 +1968,7 @@ static int CmdHF15Restore(const char *Cmd) {
|
||||
if (getUID(false, uid) != PM3_SUCCESS) {
|
||||
PrintAndLogEx(WARNING, "no tag found");
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
}
|
||||
uidlen = 8;
|
||||
}
|
||||
|
||||
@@ -1977,9 +1977,9 @@ static int CmdHF15Restore(const char *Cmd) {
|
||||
memcpy(req + reqlen, uid, sizeof(uid));
|
||||
reqlen += sizeof(uid);
|
||||
}
|
||||
PrintAndLogEx(SUCCESS, "Using UID... " _GREEN_("%s"), iso15693_sprintUID(NULL, uid));
|
||||
PrintAndLogEx(SUCCESS, "Using UID... " _GREEN_("%s"), iso15693_sprintUID(NULL, uid));
|
||||
} else {
|
||||
PrintAndLogEx(SUCCESS, "Using unaddressed mode");
|
||||
PrintAndLogEx(SUCCESS, "Using unaddressed mode");
|
||||
}
|
||||
PrintAndLogEx(INFO, "Using block size... %d", blocksize);
|
||||
|
||||
|
||||
+71
-71
@@ -39,10 +39,10 @@ static void print_status_flag1_interpretation(void) {
|
||||
PrintAndLogEx(INFO, "----+--------------------------------------------------------------------------------------------------------------------");
|
||||
PrintAndLogEx(INFO, " 00 | Indicates the successful completion of a command.");
|
||||
PrintAndLogEx(INFO, " FF | If an error occurs during the processing of a command that includes no list in the command packet, \n"
|
||||
" | or if an error occurs independently of any list, the card returns a response by setting FFh to Status Flag1.");
|
||||
" | or if an error occurs independently of any list, the card returns a response by setting FFh to Status Flag1.");
|
||||
PrintAndLogEx(INFO, " XX | If an error occurs while processing a command that includes Service Code List or Block List \n"
|
||||
" | in the command packet, the card returns a response by setting a number in the list to Status Flag1,\n"
|
||||
" | indicating the location of the error.");
|
||||
" | in the command packet, the card returns a response by setting a number in the list to Status Flag1,\n"
|
||||
" | indicating the location of the error.");
|
||||
PrintAndLogEx(INFO, "----+--------------------------------------------------------------------------------------------------------------------");
|
||||
}
|
||||
|
||||
@@ -51,28 +51,28 @@ static void print_status_flag2_interpration(void) {
|
||||
PrintAndLogEx(INFO, "----+--------------------------------------------------------------------------------------------------------------------");
|
||||
PrintAndLogEx(INFO, " 00 | Indicates the successful completion of a command.");
|
||||
PrintAndLogEx(INFO, " 01 | The calculated result is either less than zero when the purse data is decremented, or exceeds 4\n"
|
||||
" | Bytes when the purse data is incremented.");
|
||||
" | Bytes when the purse data is incremented.");
|
||||
PrintAndLogEx(INFO, " 02 | The specified data exceeds the value of cashback data at cashback of purse.");
|
||||
PrintAndLogEx(INFO, " 70 | Memory error (fatal error).");
|
||||
PrintAndLogEx(INFO, " 71 | The number of memory rewrites exceeds the upper limit (this is only a warning; data writing is performed as normal).\n"
|
||||
" | The maximum number of rewrites can differ, depending on the product being used.\n"
|
||||
" | In addition, Status Flag1 is either 00h or FFh depending on the product being used.");
|
||||
" | The maximum number of rewrites can differ, depending on the product being used.\n"
|
||||
" | In addition, Status Flag1 is either 00h or FFh depending on the product being used.");
|
||||
|
||||
PrintAndLogEx(INFO, " A1 | Illegal Number of Service| Number of Service or Number of Node specified by the command \n"
|
||||
" | falls outside the range of the prescribed value.");
|
||||
" | falls outside the range of the prescribed value.");
|
||||
PrintAndLogEx(INFO, " A2 | Illegal command packet (specified Number of Block) : Number of Block specified by the \n"
|
||||
" | command falls outside the range of the prescribed values for the product.");
|
||||
" | command falls outside the range of the prescribed values for the product.");
|
||||
PrintAndLogEx(INFO, " A3 | Illegal Block List (specified order of Service) : Service Code List Order specified by \n"
|
||||
" | Block List Element falls outside the Number of Service specified by the command \n"
|
||||
" | (or the Number of Service specified at the times of mutual authentication).");
|
||||
" | Block List Element falls outside the Number of Service specified by the command \n"
|
||||
" | (or the Number of Service specified at the times of mutual authentication).");
|
||||
PrintAndLogEx(INFO, " A4 | Illegal Service type : Area Attribute specified by the command or Service Attribute of Service Code is incorrect.");
|
||||
PrintAndLogEx(INFO, " A5 | Access is not allowed : Area or Service specified by the command cannot be accessed.\n"
|
||||
" | The parameter specified by the command does not satisfy the conditions for success.");
|
||||
" | The parameter specified by the command does not satisfy the conditions for success.");
|
||||
PrintAndLogEx(INFO, " A6 | Illegal Service Code List : Target to be accessed, identified by Service Code List Order, specified by Block\n"
|
||||
" | List Element does not exist. Or, Node specified by Node Code List does not exist.");
|
||||
" | List Element does not exist. Or, Node specified by Node Code List does not exist.");
|
||||
PrintAndLogEx(INFO, " A7 | Illegal Block List (Access Mode) : Access Mode specified by Block List Element is incorrect.");
|
||||
PrintAndLogEx(INFO, " A8 | Illegal Block Number Block Number (access to the specified data is inhibited) :\n"
|
||||
" | specified by Block List Element exceeds the number of Blocks assigned to Service.");
|
||||
" | specified by Block List Element exceeds the number of Blocks assigned to Service.");
|
||||
PrintAndLogEx(INFO, " A9 | Data write failure : This is the error that occurs in issuance commands.");
|
||||
PrintAndLogEx(INFO, " AA | Key-change failure : Key change failed.");
|
||||
PrintAndLogEx(INFO, " AB | Illegal Package Parity or illegal Package MAC : This is the error that occurs in issuance commands.");
|
||||
@@ -80,7 +80,7 @@ static void print_status_flag2_interpration(void) {
|
||||
PrintAndLogEx(INFO, " AD | Service exists already : This is the error that occurs in issuance commands.");
|
||||
PrintAndLogEx(INFO, " AE | Illegal System Code : This is the error that occurs in issuance commands.");
|
||||
PrintAndLogEx(INFO, " AF | Too many simultaneous cyclic write operations : Number of simultaneous write Blocks\n"
|
||||
" | specified by the command to Cyclic Service exceeds the number of Blocks assigned to Service.");
|
||||
" | specified by the command to Cyclic Service exceeds the number of Blocks assigned to Service.");
|
||||
PrintAndLogEx(INFO, " C0 | Illegal Package Identifier : This is the error that occurs in issuance commands.");
|
||||
PrintAndLogEx(INFO, " C1 | Discrepancy of parameters inside and outside Package : This is the error that occurs in issuance commands.");
|
||||
PrintAndLogEx(INFO, " C2 | Command is disabled already : This is the error that occurs in issuance commands.");
|
||||
@@ -111,9 +111,9 @@ static void print_number_of_block_constraints(void) {
|
||||
static void print_service_code_list_constraints(void) {
|
||||
PrintAndLogEx(INFO, " - Service Code List: For Service Code List, only Service Code existing in the product shall be specified:");
|
||||
PrintAndLogEx(INFO, " - Even when Service Code exists in the product, Service Code not referenced from Block List shall not \n"
|
||||
" be specified to Service Code List.");
|
||||
" be specified to Service Code List.");
|
||||
PrintAndLogEx(INFO, " - For existence or nonexistence of Service in a product, please check using the Request Service \n"
|
||||
" (or Request Service v2) command.");
|
||||
" (or Request Service v2) command.");
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -209,7 +209,7 @@ static bool add_last_IDm(uint8_t position, uint8_t *data) {
|
||||
if (last_known_card.IDm[0] != 0 && last_known_card.IDm[1] != 0) {
|
||||
memcpy(data + position, last_known_card.IDm, sizeof(last_known_card.IDm));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -447,7 +447,7 @@ static bool check_last_idm(uint8_t *data, uint16_t datalen) {
|
||||
PrintAndLogEx(WARNING, "No last known card! Use `" _YELLOW_("hf felica reader") "` first or set a custom IDm");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
PrintAndLogEx(INFO, "Using last known IDm... " _GREEN_("%s"), sprint_hex_inrow(data, datalen));
|
||||
return true;
|
||||
}
|
||||
@@ -467,7 +467,7 @@ static int send_wr_plain(uint8_t flags, uint16_t datalen, uint8_t *data, bool ve
|
||||
if (waitCmdFelica(0, &resp, verbose) == false) {
|
||||
PrintAndLogEx(ERR, "no response from card");
|
||||
return PM3_ERFTRANS;
|
||||
}
|
||||
}
|
||||
|
||||
memcpy(wr_noCry_resp, (felica_status_response_t *)resp.data.asBytes, sizeof(felica_status_response_t));
|
||||
return PM3_SUCCESS;
|
||||
@@ -493,13 +493,13 @@ static void reverse_3des_key(uint8_t *master_key, int length, uint8_t *reverse_m
|
||||
static int CmdHFFelicaAuthentication1(const char *Cmd) {
|
||||
CLIParserContext *ctx;
|
||||
CLIParserInit(&ctx, "hf felica auth1",
|
||||
"Initiate mutual authentication. This command must always be executed before Auth2 command\n"
|
||||
"and mutual authentication is achieve only after Auth2 command has succeeded.\n"
|
||||
_RED_("INCOMPLETE / EXPERIMENTAL COMMAND!!!"),
|
||||
"hf felica auth1 --an 01 --acl 0000 --sn 01 --scl 8B00 --key AAAAAAAAAAAAAAAABBBBBBBBBBBBBBBB\n"
|
||||
"hf felica auth1 --an 01 --acl 0000 --sn 01 --scl 8B00 --key AAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBAAAAAAAAAAAAAAAA\n"
|
||||
"hf felica auth1 -i 11100910C11BC407 --an 01 --acl 0000 --sn 01 ..scl 8B00 --key AAAAAAAAAAAAAAAABBBBBBBBBBBBBBBB\n"
|
||||
);
|
||||
"Initiate mutual authentication. This command must always be executed before Auth2 command\n"
|
||||
"and mutual authentication is achieve only after Auth2 command has succeeded.\n"
|
||||
_RED_("INCOMPLETE / EXPERIMENTAL COMMAND!!!"),
|
||||
"hf felica auth1 --an 01 --acl 0000 --sn 01 --scl 8B00 --key AAAAAAAAAAAAAAAABBBBBBBBBBBBBBBB\n"
|
||||
"hf felica auth1 --an 01 --acl 0000 --sn 01 --scl 8B00 --key AAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBAAAAAAAAAAAAAAAA\n"
|
||||
"hf felica auth1 -i 11100910C11BC407 --an 01 --acl 0000 --sn 01 ..scl 8B00 --key AAAAAAAAAAAAAAAABBBBBBBBBBBBBBBB\n"
|
||||
);
|
||||
void *argtable[] = {
|
||||
arg_param_begin,
|
||||
arg_str0(NULL, "an", "<hex>", "number of areas, 1 byte"),
|
||||
@@ -569,7 +569,7 @@ static int CmdHFFelicaAuthentication1(const char *Cmd) {
|
||||
}
|
||||
|
||||
uint8_t data[PM3_CMD_DATA_SIZE];
|
||||
memset(data, 0 , sizeof(data));
|
||||
memset(data, 0, sizeof(data));
|
||||
data[0] = 0x0C; // Static length
|
||||
data[1] = 0x3E; // Command ID
|
||||
|
||||
@@ -580,14 +580,14 @@ static int CmdHFFelicaAuthentication1(const char *Cmd) {
|
||||
memcpy(data + 2, idm, 8);
|
||||
}
|
||||
|
||||
// Length (1),
|
||||
// Command ID (1),
|
||||
// IDm (8),
|
||||
// Number of Area (1),
|
||||
// Area Code List (2),
|
||||
// Number of Service (1),
|
||||
// Service Code List (2),
|
||||
// M1c (16)
|
||||
// Length (1),
|
||||
// Command ID (1),
|
||||
// IDm (8),
|
||||
// Number of Area (1),
|
||||
// Area Code List (2),
|
||||
// Number of Service (1),
|
||||
// Service Code List (2),
|
||||
// M1c (16)
|
||||
uint16_t datalen = 32;
|
||||
data[0] = (datalen & 0xFF);
|
||||
data[1] = 0x10; // Command ID
|
||||
@@ -597,14 +597,14 @@ static int CmdHFFelicaAuthentication1(const char *Cmd) {
|
||||
}
|
||||
|
||||
if (anlen) {
|
||||
data[10] = an[0];
|
||||
data[10] = an[0];
|
||||
}
|
||||
if (acllen) {
|
||||
data[11] = acl[0];
|
||||
data[12] = acl[1];
|
||||
}
|
||||
if (snlen) {
|
||||
data[13] = sn[0];
|
||||
data[13] = sn[0];
|
||||
}
|
||||
if (scllen) {
|
||||
data[14] = scl[0];
|
||||
@@ -615,7 +615,7 @@ static int CmdHFFelicaAuthentication1(const char *Cmd) {
|
||||
}
|
||||
|
||||
// READER CHALLENGE - (RANDOM To Encrypt = Rac)
|
||||
uint8_t nonce[8] = {1,2,3,4,5,6,7,8};
|
||||
uint8_t nonce[8] = {1, 2, 3, 4, 5, 6, 7, 8};
|
||||
PrintAndLogEx(INFO, "Reader challenge (unencrypted): %s", sprint_hex(nonce, 8));
|
||||
|
||||
// Create M1c Challenge with 3DES (3 Keys = 24, 2 Keys = 16)
|
||||
@@ -624,7 +624,7 @@ static int CmdHFFelicaAuthentication1(const char *Cmd) {
|
||||
mbedtls_des3_init(&des3_ctx);
|
||||
|
||||
if (keylen == 24) {
|
||||
|
||||
|
||||
mbedtls_des3_set3key_enc(&des3_ctx, master_key);
|
||||
PrintAndLogEx(INFO, "3DES Master Secret: %s", sprint_hex(master_key, keylen));
|
||||
|
||||
@@ -659,8 +659,8 @@ static int CmdHFFelicaAuthentication1(const char *Cmd) {
|
||||
if (waitCmdFelica(0, &resp, 1) == false) {
|
||||
PrintAndLogEx(ERR, "no response from card");
|
||||
return PM3_ERFTRANS;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
felica_auth1_response_t auth1_response;
|
||||
memcpy(&auth1_response, (felica_auth1_response_t *)resp.data.asBytes, sizeof(felica_auth1_response_t));
|
||||
|
||||
@@ -710,12 +710,12 @@ static int CmdHFFelicaAuthentication2(const char *Cmd) {
|
||||
|
||||
CLIParserContext *ctx;
|
||||
CLIParserInit(&ctx, "hf felica auth2",
|
||||
"Complete mutual authentication. This command can only be executed subsquent to Auth1\n"
|
||||
_RED_("INCOMPLETE / EXPERIMENTAL COMMAND!!!\n")
|
||||
_RED_("EXPERIMENTAL COMMAND - M2c/P2c will be not checked"),
|
||||
"hf felica auth2 --cc 0102030405060708 --key AAAAAAAAAAAAAAAABBBBBBBBBBBBBBBB\n"
|
||||
"hf felica auth2 -i 11100910C11BC407 --cc 0102030405060708 --key AAAAAAAAAAAAAAAABBBBBBBBBBBBBBBB\n"
|
||||
);
|
||||
"Complete mutual authentication. This command can only be executed subsquent to Auth1\n"
|
||||
_RED_("INCOMPLETE / EXPERIMENTAL COMMAND!!!\n")
|
||||
_RED_("EXPERIMENTAL COMMAND - M2c/P2c will be not checked"),
|
||||
"hf felica auth2 --cc 0102030405060708 --key AAAAAAAAAAAAAAAABBBBBBBBBBBBBBBB\n"
|
||||
"hf felica auth2 -i 11100910C11BC407 --cc 0102030405060708 --key AAAAAAAAAAAAAAAABBBBBBBBBBBBBBBB\n"
|
||||
);
|
||||
void *argtable[] = {
|
||||
arg_param_begin,
|
||||
arg_str0("i", NULL, "<hex>", "set custom IDm"),
|
||||
@@ -758,7 +758,7 @@ static int CmdHFFelicaAuthentication2(const char *Cmd) {
|
||||
}
|
||||
|
||||
uint8_t data[PM3_CMD_DATA_SIZE];
|
||||
memset(data, 0 , sizeof(data));
|
||||
memset(data, 0, sizeof(data));
|
||||
|
||||
bool custom_IDm = false;
|
||||
|
||||
@@ -776,7 +776,7 @@ static int CmdHFFelicaAuthentication2(const char *Cmd) {
|
||||
}
|
||||
|
||||
if (cclen) {
|
||||
memcpy(data + 16, cc, cclen);
|
||||
memcpy(data + 16, cc, cclen);
|
||||
}
|
||||
|
||||
if (keylen) {
|
||||
@@ -791,7 +791,7 @@ static int CmdHFFelicaAuthentication2(const char *Cmd) {
|
||||
// M3c (8) == cc
|
||||
// unsigned char m3c[8]; == cc
|
||||
|
||||
|
||||
|
||||
mbedtls_des3_context des3_ctx_enc;
|
||||
mbedtls_des3_context des3_ctx_dec;
|
||||
|
||||
@@ -824,7 +824,7 @@ static int CmdHFFelicaAuthentication2(const char *Cmd) {
|
||||
unsigned char p3c[8];
|
||||
mbedtls_des3_crypt_ecb(&des3_ctx_dec, cc, p3c);
|
||||
PrintAndLogEx(INFO, "3DES decrypted M3c = P3c... %s", sprint_hex_inrow(p3c, sizeof(p3c)));
|
||||
|
||||
|
||||
// Encrypt p3c with master_key
|
||||
unsigned char m4c[8];
|
||||
mbedtls_des3_crypt_ecb(&des3_ctx_enc, p3c, m4c);
|
||||
@@ -848,7 +848,7 @@ static int CmdHFFelicaAuthentication2(const char *Cmd) {
|
||||
if (waitCmdFelica(0, &resp, 1) == false) {
|
||||
PrintAndLogEx(ERR, "no response from card");
|
||||
return PM3_ERFTRANS;
|
||||
}
|
||||
}
|
||||
|
||||
felica_auth2_response_t auth2_response;
|
||||
memcpy(&auth2_response, (felica_auth2_response_t *)resp.data.asBytes, sizeof(felica_auth2_response_t));
|
||||
@@ -954,7 +954,7 @@ static int CmdHFFelicaWritePlain(const char *Cmd) {
|
||||
}
|
||||
|
||||
uint8_t data[PM3_CMD_DATA_SIZE];
|
||||
memset(data, 0 , sizeof(data));
|
||||
memset(data, 0, sizeof(data));
|
||||
data[0] = 0x20; // Static length
|
||||
data[1] = 0x08; // Command ID
|
||||
|
||||
@@ -1115,7 +1115,7 @@ static int CmdHFFelicaReadPlain(const char *Cmd) {
|
||||
}
|
||||
|
||||
uint8_t data[PM3_CMD_DATA_SIZE];
|
||||
memset(data, 0 , sizeof(data));
|
||||
memset(data, 0, sizeof(data));
|
||||
data[0] = 0x10; // Static length
|
||||
data[1] = 0x06; // Command ID
|
||||
|
||||
@@ -1152,7 +1152,7 @@ static int CmdHFFelicaReadPlain(const char *Cmd) {
|
||||
|
||||
PrintAndLogEx(INFO, "block | data ");
|
||||
PrintAndLogEx(INFO, "------+----------------------------------------");
|
||||
|
||||
|
||||
// main loop block reads
|
||||
if (all_block_list_elements) {
|
||||
|
||||
@@ -1217,7 +1217,7 @@ static int CmdHFFelicaRequestResponse(const char *Cmd) {
|
||||
CLIParserFree(ctx);
|
||||
|
||||
uint8_t data[PM3_CMD_DATA_SIZE];
|
||||
memset(data, 0 , sizeof(data));
|
||||
memset(data, 0, sizeof(data));
|
||||
data[0] = 0x0A; // Static length
|
||||
data[1] = 0x04; // Command ID
|
||||
|
||||
@@ -1294,7 +1294,7 @@ static int CmdHFFelicaRequestSpecificationVersion(const char *Cmd) {
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
|
||||
uint8_t reserved[2] = {0,0};
|
||||
uint8_t reserved[2] = {0, 0};
|
||||
int rlen = 0;
|
||||
res = CLIParamHexToBuf(arg_get_str(ctx, 2), reserved, sizeof(reserved), &rlen);
|
||||
if (res) {
|
||||
@@ -1310,7 +1310,7 @@ static int CmdHFFelicaRequestSpecificationVersion(const char *Cmd) {
|
||||
CLIParserFree(ctx);
|
||||
|
||||
uint8_t data[PM3_CMD_DATA_SIZE];
|
||||
memset(data, 0 , sizeof(data));
|
||||
memset(data, 0, sizeof(data));
|
||||
data[0] = 0x0C; // Static length
|
||||
data[1] = 0x3C; // Command ID
|
||||
|
||||
@@ -1322,9 +1322,9 @@ static int CmdHFFelicaRequestSpecificationVersion(const char *Cmd) {
|
||||
memcpy(data + 2, idm, sizeof(idm));
|
||||
}
|
||||
|
||||
// add custom reserved
|
||||
if (rlen ) {
|
||||
memcpy(data +10, reserved, sizeof(reserved));
|
||||
// add custom reserved
|
||||
if (rlen) {
|
||||
memcpy(data + 10, reserved, sizeof(reserved));
|
||||
} else {
|
||||
data[10] = 0x00; // Reserved Value
|
||||
data[11] = 0x00; // Reserved Value
|
||||
@@ -1337,7 +1337,7 @@ static int CmdHFFelicaRequestSpecificationVersion(const char *Cmd) {
|
||||
|
||||
AddCrc(data, datalen);
|
||||
datalen += 2;
|
||||
uint8_t flags = (FELICA_APPEND_CRC |FELICA_RAW);
|
||||
uint8_t flags = (FELICA_APPEND_CRC | FELICA_RAW);
|
||||
|
||||
clear_and_send_command(flags, datalen, data, 0);
|
||||
|
||||
@@ -1346,7 +1346,7 @@ static int CmdHFFelicaRequestSpecificationVersion(const char *Cmd) {
|
||||
PrintAndLogEx(FAILED, "Got no response from card");
|
||||
return PM3_ERFTRANS;
|
||||
}
|
||||
|
||||
|
||||
felica_request_spec_response_t spec_response;
|
||||
memcpy(&spec_response, (felica_request_spec_response_t *)resp.data.asBytes, sizeof(felica_request_spec_response_t));
|
||||
|
||||
@@ -1401,7 +1401,7 @@ static int CmdHFFelicaResetMode(const char *Cmd) {
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
|
||||
uint8_t reserved[2] = {0,0};
|
||||
uint8_t reserved[2] = {0, 0};
|
||||
int rlen = 0;
|
||||
res = CLIParamHexToBuf(arg_get_str(ctx, 2), reserved, sizeof(reserved), &rlen);
|
||||
if (res) {
|
||||
@@ -1417,7 +1417,7 @@ static int CmdHFFelicaResetMode(const char *Cmd) {
|
||||
CLIParserFree(ctx);
|
||||
|
||||
uint8_t data[PM3_CMD_DATA_SIZE];
|
||||
memset(data, 0 , sizeof(data));
|
||||
memset(data, 0, sizeof(data));
|
||||
data[0] = 0x0C; // Static length
|
||||
data[1] = 0x3E; // Command ID
|
||||
|
||||
@@ -1495,7 +1495,7 @@ static int CmdHFFelicaRequestSystemCode(const char *Cmd) {
|
||||
|
||||
|
||||
uint8_t data[PM3_CMD_DATA_SIZE];
|
||||
memset(data, 0 , sizeof(data));
|
||||
memset(data, 0, sizeof(data));
|
||||
data[0] = 0x0A; // Static length
|
||||
data[1] = 0x0C; // Command ID
|
||||
|
||||
@@ -1578,7 +1578,7 @@ static int CmdHFFelicaRequestService(const char *Cmd) {
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
|
||||
uint8_t code[2] = {0,0};
|
||||
uint8_t code[2] = {0, 0};
|
||||
int clen = 0;
|
||||
res = CLIParamHexToBuf(arg_get_str(ctx, 3), code, sizeof(code), &clen);
|
||||
if (res) {
|
||||
@@ -1596,7 +1596,7 @@ static int CmdHFFelicaRequestService(const char *Cmd) {
|
||||
CLIParserFree(ctx);
|
||||
|
||||
uint8_t data[PM3_CMD_DATA_SIZE];
|
||||
memset(data, 0 , sizeof(data));
|
||||
memset(data, 0, sizeof(data));
|
||||
|
||||
bool custom_IDm = false;
|
||||
|
||||
@@ -1608,10 +1608,10 @@ static int CmdHFFelicaRequestService(const char *Cmd) {
|
||||
if (all_nodes == false) {
|
||||
// Node Number
|
||||
if (nlen == 1) {
|
||||
memcpy(data + 10, node, sizeof(node));
|
||||
memcpy(data + 10, node, sizeof(node));
|
||||
}
|
||||
|
||||
// code
|
||||
// code
|
||||
if (clen == 2) {
|
||||
memcpy(data + 11, code, sizeof(code));
|
||||
}
|
||||
@@ -2055,7 +2055,7 @@ static int CmdHFFelicaCmdRaw(const char *Cmd) {
|
||||
|
||||
int datalen = 0;
|
||||
uint8_t data[PM3_CMD_DATA_SIZE];
|
||||
memset(data, 0 , sizeof(data));
|
||||
memset(data, 0, sizeof(data));
|
||||
|
||||
CLIGetHexWithReturn(ctx, 7, data, &datalen);
|
||||
CLIParserFree(ctx);
|
||||
|
||||
@@ -181,7 +181,7 @@ static int cmd_hf_fido_register(const char *cmd) {
|
||||
"hf fido reg -> execute command with 2 parameters, filled 0x00\n"
|
||||
"hf fido reg -p s0 s1 -> execute command with plain parameters\n"
|
||||
"hf fido reg --cp 000102030405060708090a0b0c0d0e0f000102030405060708090a0b0c0d0e0f --ap 000102030405060708090a0b0c0d0e0f000102030405060708090a0b0c0d0e0f\n"
|
||||
);
|
||||
);
|
||||
|
||||
void *argtable[] = {
|
||||
arg_param_begin,
|
||||
@@ -693,7 +693,7 @@ static int cmd_hf_fido_2make_credential(const char *cmd) {
|
||||
"Sample file `fido2.json` in `client/resources/`.",
|
||||
"hf fido make -> default parameters file `fido2.json`\n"
|
||||
"hf fido make -f test.json -> use parameters file `text.json`"
|
||||
);
|
||||
);
|
||||
|
||||
void *argtable[] = {
|
||||
arg_param_begin,
|
||||
|
||||
+75
-75
File diff suppressed because it is too large
Load Diff
@@ -2203,7 +2203,7 @@ static void init_it_all(void) {
|
||||
known_target_key = 0;
|
||||
test_state[0] = 0;
|
||||
test_state[1] = 0;
|
||||
brute_force_per_second=0;
|
||||
brute_force_per_second = 0;
|
||||
init_book_of_work();
|
||||
real_sum_a8 = 0;
|
||||
|
||||
|
||||
@@ -460,13 +460,13 @@ static int CmdHFMFPWritePerso(const char *Cmd) {
|
||||
arg_param_end
|
||||
};
|
||||
CLIExecWithReturn(ctx, Cmd, argtable, true);
|
||||
|
||||
|
||||
bool verbose = arg_get_lit(ctx, 1);
|
||||
|
||||
uint8_t keyNum[64] = {0};
|
||||
int keyNumLen = 0;
|
||||
CLIGetHexWithReturn(ctx, 2, keyNum, &keyNumLen);
|
||||
|
||||
|
||||
uint8_t key[64] = {0};
|
||||
int keyLen = 0;
|
||||
CLIGetHexWithReturn(ctx, 3, key, &keyLen);
|
||||
@@ -546,7 +546,7 @@ static int CmdHFMFPInitPerso(const char *Cmd) {
|
||||
uint8_t data[250] = {0};
|
||||
int datalen = 0;
|
||||
int res;
|
||||
|
||||
|
||||
mfpSetVerboseMode(verbose2);
|
||||
for (uint16_t sn = 0x4000; sn < 0x4050; sn++) {
|
||||
keyNum[0] = sn >> 8;
|
||||
@@ -590,8 +590,8 @@ static int CmdHFMFPCommitPerso(const char *Cmd) {
|
||||
CLIParserInit(&ctx, "hf mfp commitp",
|
||||
"Executes Commit Perso command. Can be used in SL0 mode only.",
|
||||
"hf mfp commitp\n"
|
||||
// "hf mfp commitp --sl 1"
|
||||
);
|
||||
// "hf mfp commitp --sl 1"
|
||||
);
|
||||
|
||||
void *argtable[] = {
|
||||
arg_param_begin,
|
||||
@@ -601,7 +601,7 @@ static int CmdHFMFPCommitPerso(const char *Cmd) {
|
||||
};
|
||||
CLIExecWithReturn(ctx, Cmd, argtable, true);
|
||||
bool verbose = arg_get_lit(ctx, 1);
|
||||
// int slmode = arg_get_int(ctx, 2);
|
||||
// int slmode = arg_get_int(ctx, 2);
|
||||
CLIParserFree(ctx);
|
||||
|
||||
mfpSetVerboseMode(verbose);
|
||||
@@ -677,7 +677,7 @@ static int CmdHFMFPRdbl(const char *Cmd) {
|
||||
void *argtable[] = {
|
||||
arg_param_begin,
|
||||
arg_lit0("v", "verbose", "show internal data"),
|
||||
arg_int0("n", "count", "<dec>","blocks count (by default 1)"),
|
||||
arg_int0("n", "count", "<dec>", "blocks count (by default 1)"),
|
||||
arg_lit0("b", "keyb", "use key B (by default keyA)"),
|
||||
arg_lit0("p", "plain", "plain communication mode between reader and card"),
|
||||
arg_int1(NULL, "blk", "<dec>", "block number (0..255)"),
|
||||
@@ -882,7 +882,7 @@ static int CmdHFMFPWrbl(const char *Cmd) {
|
||||
"Writes one block to Mifare Plus card",
|
||||
"hf mfp wrbl --blk 1 -d ff0000000000000000000000000000ff --key 000102030405060708090a0b0c0d0e0f -> writes block 1 data\n"
|
||||
"hf mfp wrbl --blk 2 -d ff0000000000000000000000000000ff -v -> writes block 2 data with default key 0xFF..0xFF"
|
||||
);
|
||||
);
|
||||
|
||||
void *argtable[] = {
|
||||
arg_param_begin,
|
||||
|
||||
+28
-28
@@ -520,7 +520,7 @@ static int CmdLFHitagReader(const char *Cmd) {
|
||||
" lf hitag reader --22 --nrar 0102030411223344\n"
|
||||
" lf hitag reader --23 -k 4F4E4D494B52\n"
|
||||
" lf hitag reader --26\n"
|
||||
);
|
||||
);
|
||||
|
||||
void *argtable[] = {
|
||||
arg_param_begin,
|
||||
@@ -531,8 +531,8 @@ static int CmdLFHitagReader(const char *Cmd) {
|
||||
arg_lit0(NULL, "23", "Hitag2, read all pages, crypto mode. Key ISK high + ISK low. def 4F4E4D494B52 (ONMIKR)"),
|
||||
arg_lit0(NULL, "25", "Hitag2, test recorded authentications (replay?)"),
|
||||
arg_lit0(NULL, "26", "Hitag2, read UID"),
|
||||
arg_str0("k","key", "<hex>", "key, 4 or 6 hex bytes"),
|
||||
arg_str0(NULL,"nrar", "<hex>", "nonce / answer reader, 8 hex bytes"),
|
||||
arg_str0("k", "key", "<hex>", "key, 4 or 6 hex bytes"),
|
||||
arg_str0(NULL, "nrar", "<hex>", "nonce / answer reader, 8 hex bytes"),
|
||||
arg_param_end
|
||||
};
|
||||
CLIExecWithReturn(ctx, Cmd, argtable, false);
|
||||
@@ -592,7 +592,7 @@ static int CmdLFHitagReader(const char *Cmd) {
|
||||
htf = RHTSF_CHALLENGE;
|
||||
memcpy(htd.auth.NrAr, nrar, sizeof(nrar));
|
||||
}
|
||||
if (s02){
|
||||
if (s02) {
|
||||
cmd = CMD_LF_HITAGS_READ;
|
||||
htf = RHTSF_KEY;
|
||||
memcpy(htd.crypto.key, key, sizeof(key));
|
||||
@@ -615,7 +615,7 @@ static int CmdLFHitagReader(const char *Cmd) {
|
||||
if (h26) {
|
||||
htf = RHT2F_UID_ONLY;
|
||||
}
|
||||
|
||||
|
||||
clearCommandBuffer();
|
||||
SendCommandMIX(cmd, htf, 0, 0, &htd, sizeof(htd));
|
||||
PacketResponseNG resp;
|
||||
@@ -698,7 +698,7 @@ static int CmdLFHitagWriter(const char *Cmd) {
|
||||
"Hitag 2\n"
|
||||
" lf hitag writer --24 -k 4F4E4D494B52 -p 3 -d 01020304\n"
|
||||
" lf hitag writer --27 -k 4D494B52 -p 3 -d 01020304\n"
|
||||
);
|
||||
);
|
||||
|
||||
void *argtable[] = {
|
||||
arg_param_begin,
|
||||
@@ -708,8 +708,8 @@ static int CmdLFHitagWriter(const char *Cmd) {
|
||||
arg_lit0(NULL, "27", "Hitag2, write page, password mode"),
|
||||
arg_int1("p", "page", "<dec>", "page address to write to"),
|
||||
arg_str0("d", "data", "<hex>", "data, 4 hex bytes"),
|
||||
arg_str0("k","key", "<hex>", "key, 4 or 6 hex bytes"),
|
||||
arg_str0(NULL,"nrar", "<hex>", "nonce / answer writer, 8 hex bytes"),
|
||||
arg_str0("k", "key", "<hex>", "key, 4 or 6 hex bytes"),
|
||||
arg_str0(NULL, "nrar", "<hex>", "nonce / answer writer, 8 hex bytes"),
|
||||
arg_param_end
|
||||
};
|
||||
CLIExecWithReturn(ctx, Cmd, argtable, false);
|
||||
@@ -743,7 +743,7 @@ static int CmdLFHitagWriter(const char *Cmd) {
|
||||
uint8_t nrar[8];
|
||||
int nalen = 0;
|
||||
res = CLIParamHexToBuf(arg_get_str(ctx, 8), nrar, sizeof(nrar), &nalen);
|
||||
|
||||
|
||||
CLIParserFree(ctx);
|
||||
|
||||
if (res != 0) {
|
||||
@@ -782,7 +782,7 @@ static int CmdLFHitagWriter(const char *Cmd) {
|
||||
memcpy(htd.auth.NrAr, nrar, sizeof(nrar));
|
||||
memcpy(htd.auth.data, data, sizeof(data));
|
||||
}
|
||||
if (s04){
|
||||
if (s04) {
|
||||
htf = WHTSF_KEY;
|
||||
memcpy(htd.crypto.key, key, sizeof(key));
|
||||
memcpy(htd.crypto.data, data, sizeof(data));
|
||||
@@ -822,13 +822,13 @@ static int CmdLFHitag2Dump(const char *Cmd) {
|
||||
"In crypto mode the default key is 4F4E4D494B52 (ONMIKR) format: ISK high + ISK low.",
|
||||
"lf hitag dump -k 4F4E4D494B52\n"
|
||||
"lf hitag dump -k 4D494B52\n"
|
||||
);
|
||||
);
|
||||
|
||||
void *argtable[] = {
|
||||
arg_param_begin,
|
||||
arg_str0("f", "file", "<fn>", "file name"),
|
||||
arg_str0("k","key", "<hex>", "key, 4 or 6 hex bytes"),
|
||||
arg_str0(NULL,"nrar", "<hex>", "nonce / answer reader, 8 hex bytes"),
|
||||
arg_str0("k", "key", "<hex>", "key, 4 or 6 hex bytes"),
|
||||
arg_str0(NULL, "nrar", "<hex>", "nonce / answer reader, 8 hex bytes"),
|
||||
arg_param_end
|
||||
};
|
||||
CLIExecWithReturn(ctx, Cmd, argtable, false);
|
||||
@@ -858,23 +858,23 @@ static int CmdLFHitag2Dump(const char *Cmd) {
|
||||
|
||||
PrintAndLogEx(WARNING, "to be implememted...");
|
||||
|
||||
/*
|
||||
PrintAndLogEx(SUCCESS, "Dumping tag memory...");
|
||||
/*
|
||||
PrintAndLogEx(SUCCESS, "Dumping tag memory...");
|
||||
|
||||
clearCommandBuffer();
|
||||
//SendCommandNG(CMD_LF_HITAG_DUMP, &htd, sizeof(htd));
|
||||
PacketResponseNG resp;
|
||||
uint8_t *data = resp.data.asBytes;
|
||||
if (fnlen < 1) {
|
||||
char *fptr = filename;
|
||||
fptr += sprintf(fptr, "lf-hitag-");
|
||||
FillFileNameByUID(fptr, data, "-dump", 4);
|
||||
}
|
||||
clearCommandBuffer();
|
||||
//SendCommandNG(CMD_LF_HITAG_DUMP, &htd, sizeof(htd));
|
||||
PacketResponseNG resp;
|
||||
uint8_t *data = resp.data.asBytes;
|
||||
if (fnlen < 1) {
|
||||
char *fptr = filename;
|
||||
fptr += sprintf(fptr, "lf-hitag-");
|
||||
FillFileNameByUID(fptr, data, "-dump", 4);
|
||||
}
|
||||
|
||||
saveFile(filename, ".bin", data, 48);
|
||||
saveFileEML(filename, data, 48, 4);
|
||||
saveFileJSON(filename, jsfHitag, data, 48, NULL);
|
||||
*/
|
||||
saveFile(filename, ".bin", data, 48);
|
||||
saveFileEML(filename, data, 48, 4);
|
||||
saveFileJSON(filename, jsfHitag, data, 48, NULL);
|
||||
*/
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
@@ -2336,7 +2336,7 @@ static int CmdT55xxRestore(const char *Cmd) {
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
|
||||
size_t dlen = 0;
|
||||
size_t dlen = 0;
|
||||
uint8_t *dump = calloc(T55x7_BLOCK_COUNT * 4, sizeof(uint8_t));
|
||||
if (dump == NULL) {
|
||||
PrintAndLogEx(WARNING, "Fail, cannot allocate memory");
|
||||
@@ -2387,7 +2387,7 @@ static int CmdT55xxRestore(const char *Cmd) {
|
||||
if (usepwd)
|
||||
snprintf(pwdopt, sizeof(pwdopt), "-p %08X", password);
|
||||
|
||||
uint32_t *data = (uint32_t*) dump;
|
||||
uint32_t *data = (uint32_t *) dump;
|
||||
uint8_t idx;
|
||||
// Restore endien for writing to card
|
||||
for (idx = 0; idx < 12; idx++) {
|
||||
|
||||
@@ -137,7 +137,7 @@ int CmdWiegandDecode(const char *Cmd) {
|
||||
|
||||
uint32_t top = 0, mid = 0, bot = 0;
|
||||
|
||||
if (hlen) {
|
||||
if (hlen) {
|
||||
res = hexstring_to_u96(&top, &mid, &bot, hex);
|
||||
if (res != hlen) {
|
||||
PrintAndLogEx(ERR, "hex string contains none hex chars");
|
||||
|
||||
@@ -1083,7 +1083,7 @@ static int CmdEMVExec(const char *Cmd) {
|
||||
PrintAndLogEx(NORMAL, "AC: %s", sprint_hex(AC->value, AC->len));
|
||||
if (IAD) {
|
||||
PrintAndLogEx(NORMAL, "IAD: %s", sprint_hex(IAD->value, IAD->len));
|
||||
|
||||
|
||||
// https://mst-company.ru/blog/ekvajring-emv-tranzaktsiya-emv-transaction-flow-chast-4-pdol-i-beskontaktnye-karty-osobennosti-qvsdc-i-quics
|
||||
if (IAD->value[0] == 0x1f) {
|
||||
PrintAndLogEx(NORMAL, " Key index: 0x%02x", IAD->value[2]);
|
||||
@@ -1421,7 +1421,7 @@ static int CmdEMVScan(const char *Cmd) {
|
||||
"It executes EMV contactless transaction and saves result to a file which can be used for emulation\n",
|
||||
"emv scan -at -> scan MSD transaction mode and show APDU and TLV\n"
|
||||
"emv scan -c -> scan CDA transaction mode\n"
|
||||
);
|
||||
);
|
||||
|
||||
void *argtable[] = {
|
||||
arg_param_begin,
|
||||
@@ -1818,7 +1818,7 @@ static int CmdEMVTest(const char *Cmd) {
|
||||
"Executes tests\n",
|
||||
"emv test -i\n"
|
||||
"emv test --long"
|
||||
);
|
||||
);
|
||||
|
||||
void *argtable[] = {
|
||||
arg_param_begin,
|
||||
|
||||
+16
-16
@@ -45,25 +45,25 @@ const char *mfpGetErrorDescription(uint8_t errorCode) {
|
||||
}
|
||||
|
||||
AccessConditions_t MFAccessConditions[] = {
|
||||
{0x00, "read AB; write AB; increment AB; decrement transfer restore AB"},
|
||||
{0x01, "read AB; decrement transfer restore AB"},
|
||||
{0x02, "read AB"},
|
||||
{0x03, "read B; write B"},
|
||||
{0x04, "read AB; writeB"},
|
||||
{0x05, "read B"},
|
||||
{0x06, "read AB; write B; increment B; decrement transfer restore AB"},
|
||||
{0x07, "none"}
|
||||
{0x00, "read AB; write AB; increment AB; decrement transfer restore AB"},
|
||||
{0x01, "read AB; decrement transfer restore AB"},
|
||||
{0x02, "read AB"},
|
||||
{0x03, "read B; write B"},
|
||||
{0x04, "read AB; writeB"},
|
||||
{0x05, "read B"},
|
||||
{0x06, "read AB; write B; increment B; decrement transfer restore AB"},
|
||||
{0x07, "none"}
|
||||
};
|
||||
|
||||
AccessConditions_t MFAccessConditionsTrailer[] = {
|
||||
{0x00, "read A by A; read ACCESS by A; read B by A; write B by A"},
|
||||
{0x01, "write A by A; read ACCESS by A write ACCESS by A; read B by A; write B by A"},
|
||||
{0x02, "read ACCESS by A; read B by A"},
|
||||
{0x03, "write A by B; read ACCESS by AB; write ACCESS by B; write B by B"},
|
||||
{0x04, "write A by B; read ACCESS by AB; write B by B"},
|
||||
{0x05, "read ACCESS by AB; write ACCESS by B"},
|
||||
{0x06, "read ACCESS by AB"},
|
||||
{0x07, "read ACCESS by AB"}
|
||||
{0x00, "read A by A; read ACCESS by A; read B by A; write B by A"},
|
||||
{0x01, "write A by A; read ACCESS by A write ACCESS by A; read B by A; write B by A"},
|
||||
{0x02, "read ACCESS by A; read B by A"},
|
||||
{0x03, "write A by B; read ACCESS by AB; write ACCESS by B; write B by B"},
|
||||
{0x04, "write A by B; read ACCESS by AB; write B by B"},
|
||||
{0x05, "read ACCESS by AB; write ACCESS by B"},
|
||||
{0x06, "read ACCESS by AB"},
|
||||
{0x07, "read ACCESS by AB"}
|
||||
};
|
||||
|
||||
const char *mfGetAccessConditionsDesc(uint8_t blockn, uint8_t *data) {
|
||||
|
||||
@@ -58,7 +58,7 @@ typedef struct thread_key_args {
|
||||
uint32_t nt_enc;
|
||||
uint32_t nr_enc;
|
||||
uint16_t enc_len;
|
||||
uint8_t enc[ENC_LEN]; // next encrypted command + a full read/write
|
||||
uint8_t enc[ENC_LEN]; // next encrypted command + a full read/write
|
||||
} targs_key;
|
||||
|
||||
//------------------------------------------------------------------
|
||||
@@ -155,7 +155,7 @@ static int param_gethex_to_eol(const char *line, int paramnum, uint8_t *data, in
|
||||
}
|
||||
|
||||
static void hex_to_buffer(const uint8_t *buf, const uint8_t *hex_data, const size_t hex_len, const size_t hex_max_len,
|
||||
const size_t min_str_len, const size_t spaces_between, bool uppercase) {
|
||||
const size_t min_str_len, const size_t spaces_between, bool uppercase) {
|
||||
|
||||
if (buf == NULL) return;
|
||||
|
||||
@@ -444,13 +444,13 @@ static void *brute_thread(void *arguments) {
|
||||
|
||||
if (args->ev1) {
|
||||
// if it was EV1, we know for sure xxxAAAAAAAA recovery
|
||||
printf("\nKey candidate [ " _YELLOW_("....%08" PRIx64 )" ]\n\n", key & 0xFFFFFFFF);
|
||||
printf("\nKey candidate [ " _YELLOW_("....%08" PRIx64)" ]\n\n", key & 0xFFFFFFFF);
|
||||
__sync_fetch_and_add(&global_found_candidate, 1);
|
||||
} else {
|
||||
printf("\nKey candidate [ " _GREEN_("....%08" PRIx64) " ]\n\n", key & 0xFFFFFFFF);
|
||||
__sync_fetch_and_add(&global_found, 1);
|
||||
}
|
||||
__sync_fetch_and_add(&global_candiate_key, key);
|
||||
__sync_fetch_and_add(&global_candiate_key, key);
|
||||
//release lock
|
||||
pthread_mutex_unlock(&print_lock);
|
||||
break;
|
||||
@@ -493,14 +493,14 @@ static void *brute_key_thread(void *arguments) {
|
||||
|
||||
// check if cmd exists
|
||||
uint8_t isOK = checkValidCmdByte(dec, args->enc_len);
|
||||
if (isOK == false) {
|
||||
if (isOK == false) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// lock this section to avoid interlacing prints from different threats
|
||||
pthread_mutex_lock(&print_lock);
|
||||
printf("\nenc: %s\n", sprint_hex_inrow_ex(local_enc, args->enc_len, 0));
|
||||
printf("dec: %s\n", sprint_hex_inrow_ex(dec, args->enc_len, 0));
|
||||
printf("dec: %s\n", sprint_hex_inrow_ex(dec, args->enc_len, 0));
|
||||
printf("\nValid Key found [ " _GREEN_("%012" PRIx64) " ]\n\n", key);
|
||||
pthread_mutex_unlock(&print_lock);
|
||||
__sync_fetch_and_add(&global_found, 1);
|
||||
@@ -547,7 +547,7 @@ int main(int argc, char *argv[]) {
|
||||
sscanf(argv[8], "%x", &at_par_err);
|
||||
|
||||
int enc_len = 0;
|
||||
uint8_t enc[ENC_LEN] = {0}; // next encrypted command + a full read/write
|
||||
uint8_t enc[ENC_LEN] = {0}; // next encrypted command + a full read/write
|
||||
if (argc > 9) {
|
||||
// sscanf(argv[9], "%x", &cmd_enc);
|
||||
param_gethex_to_eol(argv[9], 0, enc, sizeof(enc), &enc_len);
|
||||
@@ -565,7 +565,7 @@ int main(int argc, char *argv[]) {
|
||||
printf("at parity err........ %04x\n", at_par_err);
|
||||
|
||||
if (argc > 9) {
|
||||
printf("next encrypted cmd... %s\n", sprint_hex_inrow_ex(enc, enc_len ,0));
|
||||
printf("next encrypted cmd... %s\n", sprint_hex_inrow_ex(enc, enc_len, 0));
|
||||
}
|
||||
|
||||
clock_t t1 = clock();
|
||||
@@ -615,11 +615,11 @@ int main(int argc, char *argv[]) {
|
||||
t1 = clock() - t1;
|
||||
printf("execution time %.2f sec\n", (float)t1 / 1000000.0);
|
||||
|
||||
|
||||
|
||||
if (!global_found && !global_found_candidate) {
|
||||
printf("\nFailed to find a key\n\n");
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
if (enc_len < 4) {
|
||||
printf("Too few next cmd bytes, skipping phase 2\n");
|
||||
@@ -635,7 +635,7 @@ int main(int argc, char *argv[]) {
|
||||
printf("partial key.. %08x\n", (uint32_t)(global_candiate_key & 0xFFFFFFFF));
|
||||
printf("nt enc....... %08x\n", nt_enc);
|
||||
printf("nr enc....... %08x\n", nr_enc);
|
||||
printf("next encrypted cmd: %s\n", sprint_hex_inrow_ex(enc, enc_len ,0));
|
||||
printf("next encrypted cmd: %s\n", sprint_hex_inrow_ex(enc, enc_len, 0));
|
||||
printf("\nlooking for the upper 16 bits of key\n");
|
||||
fflush(stdout);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user