mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-03-14 00:53:12 +08:00
chg: return codes etc
This commit is contained in:
parent
56c4343081
commit
535298820b
1 changed files with 32 additions and 32 deletions
|
@ -445,7 +445,7 @@ static int ul_ev1_pwdgen_selftest() {
|
|||
uint8_t uid4[] = {0x04, 0xC5, 0xDF, 0x4A, 0x6D, 0x51, 0x80};
|
||||
uint32_t pwd4 = ul_ev1_pwdgenD(uid4);
|
||||
PrintAndLogEx(NORMAL, "UID | %s | %08X | %s", sprint_hex(uid4, 7), pwd4, (pwd4 == 0x72B1EC61) ? "OK" : "->72B1EC61<--");
|
||||
return 0;
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
//------------------------------------
|
||||
|
@ -565,7 +565,7 @@ static int ulc_requestAuthentication(uint8_t *nonce, uint16_t nonceLength) {
|
|||
static int ulc_authentication(uint8_t *key, bool switch_off_field) {
|
||||
|
||||
clearCommandBuffer();
|
||||
SendCommandOLD(CMD_HF_MIFAREUC_AUTH, switch_off_field, 0, 0, key, 16);
|
||||
SendCommandMIX(CMD_HF_MIFAREUC_AUTH, switch_off_field, 0, 0, key, 16);
|
||||
PacketResponseNG resp;
|
||||
if (!WaitForResponseTimeout(CMD_ACK, &resp, 1500)) return 0;
|
||||
if (resp.oldarg[0] == 1) return 1;
|
||||
|
@ -2262,7 +2262,7 @@ static int CmdHF14AMfURestore(const char *Cmd) {
|
|||
|
||||
PrintAndLogEx(NORMAL, "special PWD block written 0x%X - %s\n", MFU_NTAG_SPECIAL_PWD, sprint_hex(data, 4));
|
||||
clearCommandBuffer();
|
||||
SendCommandOLD(CMD_HF_MIFAREU_WRITEBL, MFU_NTAG_SPECIAL_PWD, keytype, 0, data, sizeof(data));
|
||||
SendCommandMIX(CMD_HF_MIFAREU_WRITEBL, MFU_NTAG_SPECIAL_PWD, keytype, 0, data, sizeof(data));
|
||||
|
||||
wait4response(MFU_NTAG_SPECIAL_PWD);
|
||||
|
||||
|
@ -2278,7 +2278,7 @@ static int CmdHF14AMfURestore(const char *Cmd) {
|
|||
data[3] = 0;
|
||||
PrintAndLogEx(NORMAL, "special PACK block written 0x%X - %s\n", MFU_NTAG_SPECIAL_PACK, sprint_hex(data, 4));
|
||||
clearCommandBuffer();
|
||||
SendCommandOLD(CMD_HF_MIFAREU_WRITEBL, MFU_NTAG_SPECIAL_PACK, keytype, 0, data, sizeof(data));
|
||||
SendCommandMIX(CMD_HF_MIFAREU_WRITEBL, MFU_NTAG_SPECIAL_PACK, keytype, 0, data, sizeof(data));
|
||||
wait4response(MFU_NTAG_SPECIAL_PACK);
|
||||
|
||||
// Signature
|
||||
|
@ -2286,7 +2286,7 @@ static int CmdHF14AMfURestore(const char *Cmd) {
|
|||
memcpy(data, mem->signature + i, 4);
|
||||
PrintAndLogEx(NORMAL, "special SIG block written 0x%X - %s\n", s, sprint_hex(data, 4));
|
||||
clearCommandBuffer();
|
||||
SendCommandOLD(CMD_HF_MIFAREU_WRITEBL, s, keytype, 0, data, sizeof(data));
|
||||
SendCommandMIX(CMD_HF_MIFAREU_WRITEBL, s, keytype, 0, data, sizeof(data));
|
||||
wait4response(s);
|
||||
}
|
||||
|
||||
|
@ -2295,7 +2295,7 @@ static int CmdHF14AMfURestore(const char *Cmd) {
|
|||
memcpy(data, mem->version + i, 4);
|
||||
PrintAndLogEx(NORMAL, "special VERSION block written 0x%X - %s\n", s, sprint_hex(data, 4));
|
||||
clearCommandBuffer();
|
||||
SendCommandOLD(CMD_HF_MIFAREU_WRITEBL, s, keytype, 0, data, sizeof(data));
|
||||
SendCommandMIX(CMD_HF_MIFAREU_WRITEBL, s, keytype, 0, data, sizeof(data));
|
||||
wait4response(s);
|
||||
}
|
||||
}
|
||||
|
@ -2309,7 +2309,7 @@ static int CmdHF14AMfURestore(const char *Cmd) {
|
|||
//Send write Block
|
||||
memcpy(data, mem->data + (b * 4), 4);
|
||||
clearCommandBuffer();
|
||||
SendCommandOLD(CMD_HF_MIFAREU_WRITEBL, b, keytype, 0, data, sizeof(data));
|
||||
SendCommandMIX(CMD_HF_MIFAREU_WRITEBL, b, keytype, 0, data, sizeof(data));
|
||||
wait4response(b);
|
||||
printf(".");
|
||||
fflush(stdout);
|
||||
|
@ -2329,7 +2329,7 @@ static int CmdHF14AMfURestore(const char *Cmd) {
|
|||
uint8_t b = blocks[i];
|
||||
memcpy(data, mem->data + (b * 4), 4);
|
||||
clearCommandBuffer();
|
||||
SendCommandOLD(CMD_HF_MIFAREU_WRITEBL, b, keytype, 0, data, sizeof(data));
|
||||
SendCommandMIX(CMD_HF_MIFAREU_WRITEBL, b, keytype, 0, data, sizeof(data));
|
||||
wait4response(b);
|
||||
PrintAndLogEx(NORMAL, "special block written %u - %s\n", b, sprint_hex(data, 4));
|
||||
}
|
||||
|
@ -2338,7 +2338,7 @@ static int CmdHF14AMfURestore(const char *Cmd) {
|
|||
DropField();
|
||||
free(dump);
|
||||
PrintAndLogEx(INFO, "Finish restore");
|
||||
return 0;
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
//
|
||||
// Load emulator with dump file
|
||||
|
@ -2388,7 +2388,7 @@ static int CmdHF14AMfUCAuth(const char *Cmd) {
|
|||
else
|
||||
PrintAndLogEx(WARNING, "Authentication failed");
|
||||
|
||||
return 0;
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2500,11 +2500,11 @@ static int CmdHF14AMfUCSetPwd(const char *Cmd) {
|
|||
|
||||
if (param_gethex(Cmd, 0, pwd, 32)) {
|
||||
PrintAndLogEx(WARNING, "Password must include 32 HEX symbols");
|
||||
return 1;
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
|
||||
clearCommandBuffer();
|
||||
SendCommandOLD(CMD_HF_MIFAREUC_SETPWD, 0, 0, 0, pwd, 16);
|
||||
SendCommandMIX(CMD_HF_MIFAREUC_SETPWD, 0, 0, 0, pwd, 16);
|
||||
|
||||
PacketResponseNG resp;
|
||||
if (WaitForResponseTimeout(CMD_ACK, &resp, 1500)) {
|
||||
|
@ -2512,13 +2512,13 @@ static int CmdHF14AMfUCSetPwd(const char *Cmd) {
|
|||
PrintAndLogEx(INFO, "Ultralight-C new password: %s", sprint_hex(pwd, 16));
|
||||
} else {
|
||||
PrintAndLogEx(WARNING, "Failed writing at block %u", (uint8_t)(resp.oldarg[1] & 0xff));
|
||||
return 1;
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
} else {
|
||||
PrintAndLogEx(WARNING, "command execution time out");
|
||||
return 1;
|
||||
return PM3_ETIMEOUT;
|
||||
}
|
||||
return 0;
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -2556,7 +2556,7 @@ static int CmdHF14AMfUCSetUid(const char *Cmd) {
|
|||
data[2] = uid[2];
|
||||
data[3] = 0x88 ^ uid[0] ^ uid[1] ^ uid[2];
|
||||
clearCommandBuffer();
|
||||
SendCommandOLD(CMD_HF_MIFAREU_WRITEBL, 0, 0, 0, data, sizeof(data));
|
||||
SendCommandMIX(CMD_HF_MIFAREU_WRITEBL, 0, 0, 0, data, sizeof(data));
|
||||
if (!WaitForResponseTimeout(CMD_ACK, &resp, 1500)) {
|
||||
PrintAndLogEx(WARNING, "Command execute timeout");
|
||||
return PM3_ETIMEOUT;
|
||||
|
@ -2568,7 +2568,7 @@ static int CmdHF14AMfUCSetUid(const char *Cmd) {
|
|||
data[2] = uid[5];
|
||||
data[3] = uid[6];
|
||||
clearCommandBuffer();
|
||||
SendCommandOLD(CMD_HF_MIFAREU_WRITEBL, 1, 0, 0, data, sizeof(data));
|
||||
SendCommandMIX(CMD_HF_MIFAREU_WRITEBL, 1, 0, 0, data, sizeof(data));
|
||||
if (!WaitForResponseTimeout(CMD_ACK, &resp, 1500)) {
|
||||
PrintAndLogEx(WARNING, "Command execute timeout");
|
||||
return PM3_ETIMEOUT;
|
||||
|
@ -2580,7 +2580,7 @@ static int CmdHF14AMfUCSetUid(const char *Cmd) {
|
|||
data[2] = oldblock2[2];
|
||||
data[3] = oldblock2[3];
|
||||
clearCommandBuffer();
|
||||
SendCommandOLD(CMD_HF_MIFAREU_WRITEBL, 2, 0, 0, data, sizeof(data));
|
||||
SendCommandMIX(CMD_HF_MIFAREU_WRITEBL, 2, 0, 0, data, sizeof(data));
|
||||
if (!WaitForResponseTimeout(CMD_ACK, &resp, 1500)) {
|
||||
PrintAndLogEx(WARNING, "Command execute timeout");
|
||||
return PM3_ETIMEOUT;
|
||||
|
@ -2611,11 +2611,11 @@ static int CmdHF14AMfUGenDiverseKeys(const char *Cmd) {
|
|||
|
||||
if (select_status == 0) {
|
||||
PrintAndLogEx(WARNING, "iso14443a card select failed");
|
||||
return 1;
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
if (card.uidlen != 4) {
|
||||
PrintAndLogEx(WARNING, "Wrong sized UID, expected 4bytes got %d", card.uidlen);
|
||||
return 1;
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
memcpy(uid, card.uid, sizeof(uid));
|
||||
} else {
|
||||
|
@ -2654,13 +2654,13 @@ static int CmdHF14AMfUGenDiverseKeys(const char *Cmd) {
|
|||
, divkey // output
|
||||
);
|
||||
|
||||
PrintAndLogEx(NORMAL, "-- 3DES version");
|
||||
PrintAndLogEx(NORMAL, "Masterkey :\t %s", sprint_hex(masterkey, sizeof(masterkey)));
|
||||
PrintAndLogEx(NORMAL, "UID :\t %s", sprint_hex(uid, sizeof(uid)));
|
||||
PrintAndLogEx(NORMAL, "block :\t %0d", block);
|
||||
PrintAndLogEx(NORMAL, "Mifare key :\t %s", sprint_hex(mifarekeyA, sizeof(mifarekeyA)));
|
||||
PrintAndLogEx(NORMAL, "Message :\t %s", sprint_hex(mix, sizeof(mix)));
|
||||
PrintAndLogEx(NORMAL, "Diversified key: %s", sprint_hex(divkey + 1, 6));
|
||||
PrintAndLogEx(SUCCESS, "-- 3DES version");
|
||||
PrintAndLogEx(SUCCESS, "Masterkey :\t %s", sprint_hex(masterkey, sizeof(masterkey)));
|
||||
PrintAndLogEx(SUCCESS, "UID :\t %s", sprint_hex(uid, sizeof(uid)));
|
||||
PrintAndLogEx(SUCCESS, "block :\t %0d", block);
|
||||
PrintAndLogEx(SUCCESS, "Mifare key :\t %s", sprint_hex(mifarekeyA, sizeof(mifarekeyA)));
|
||||
PrintAndLogEx(SUCCESS, "Message :\t %s", sprint_hex(mix, sizeof(mix)));
|
||||
PrintAndLogEx(SUCCESS, "Diversified key: %s", sprint_hex(divkey + 1, 6));
|
||||
|
||||
for (int i = 0; i < ARRAYLEN(mifarekeyA); ++i) {
|
||||
dkeyA[i] = (mifarekeyA[i] << 1) & 0xff;
|
||||
|
@ -2690,11 +2690,11 @@ static int CmdHF14AMfUGenDiverseKeys(const char *Cmd) {
|
|||
, newpwd // output
|
||||
);
|
||||
|
||||
PrintAndLogEx(NORMAL, "\n-- DES version");
|
||||
PrintAndLogEx(NORMAL, "Mifare dkeyA :\t %s", sprint_hex(dkeyA, sizeof(dkeyA)));
|
||||
PrintAndLogEx(NORMAL, "Mifare dkeyB :\t %s", sprint_hex(dkeyB, sizeof(dkeyB)));
|
||||
PrintAndLogEx(NORMAL, "Mifare ABA :\t %s", sprint_hex(dmkey, sizeof(dmkey)));
|
||||
PrintAndLogEx(NORMAL, "Mifare Pwd :\t %s", sprint_hex(newpwd, sizeof(newpwd)));
|
||||
PrintAndLogEx(SUCCESS, "\n-- DES version");
|
||||
PrintAndLogEx(SUCCESS, "Mifare dkeyA :\t %s", sprint_hex(dkeyA, sizeof(dkeyA)));
|
||||
PrintAndLogEx(SUCCESS, "Mifare dkeyB :\t %s", sprint_hex(dkeyB, sizeof(dkeyB)));
|
||||
PrintAndLogEx(SUCCESS, "Mifare ABA :\t %s", sprint_hex(dmkey, sizeof(dmkey)));
|
||||
PrintAndLogEx(SUCCESS, "Mifare Pwd :\t %s", sprint_hex(newpwd, sizeof(newpwd)));
|
||||
|
||||
mbedtls_des3_free(&ctx);
|
||||
// next. from the diversify_key method.
|
||||
|
|
Loading…
Reference in a new issue