mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-02-13 10:43:01 +08:00
chg: textual
This commit is contained in:
parent
fff8edd815
commit
07d7b9424c
1 changed files with 48 additions and 52 deletions
100
client/cmdhfmf.c
100
client/cmdhfmf.c
|
@ -2062,8 +2062,7 @@ int CmdHF14AMfEGet(const char *Cmd) {
|
|||
uint8_t data[16] = {0x00};
|
||||
char c = param_getchar(Cmd, 0);
|
||||
|
||||
if (strlen(Cmd) < 1 || c == 'h' || c == 'H')
|
||||
return usage_hf14_eget();
|
||||
if (strlen(Cmd) < 1 || c == 'h' || c == 'H') return usage_hf14_eget();
|
||||
|
||||
blockNo = param_get8(Cmd, 0);
|
||||
|
||||
|
@ -2071,17 +2070,15 @@ int CmdHF14AMfEGet(const char *Cmd) {
|
|||
if (!mfEmlGetMem(data, blockNo, 1)) {
|
||||
PrintAndLog("data[%3d]:%s", blockNo, sprint_hex(data, 16));
|
||||
} else {
|
||||
PrintAndLog("Command execute timeout");
|
||||
PrintAndLog("[!] Command execute timeout");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CmdHF14AMfEClear(const char *Cmd) {
|
||||
char c = param_getchar(Cmd, 0);
|
||||
|
||||
if (c == 'h' || c == 'H')
|
||||
return usage_hf14_eclr();
|
||||
|
||||
if (c == 'h' || c == 'H') return usage_hf14_eclr();
|
||||
|
||||
UsbCommand cmd = {CMD_MIFARE_EML_MEMCLR, {0, 0, 0}};
|
||||
clearCommandBuffer();
|
||||
SendCommand(&cmd);
|
||||
|
@ -2100,7 +2097,7 @@ int CmdHF14AMfESet(const char *Cmd) {
|
|||
blockNo = param_get8(Cmd, 0);
|
||||
|
||||
if (param_gethex(Cmd, 1, memBlock, 32)) {
|
||||
PrintAndLog("block data must include 32 HEX symbols");
|
||||
PrintAndLog("[!] block data must include 32 HEX symbols");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -2150,7 +2147,7 @@ int CmdHF14AMfELoad(const char *Cmd) {
|
|||
// open file
|
||||
f = fopen(filename, "r");
|
||||
if (f == NULL) {
|
||||
PrintAndLog("File %s not found or locked", filename);
|
||||
PrintAndLog("[!] File %s not found or locked", filename);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -2162,7 +2159,7 @@ int CmdHF14AMfELoad(const char *Cmd) {
|
|||
|
||||
if (blockNum >= numBlocks) break;
|
||||
|
||||
PrintAndLog("File reading error.");
|
||||
PrintAndLog("[!] File reading error.");
|
||||
fclose(f);
|
||||
return 2;
|
||||
}
|
||||
|
@ -2170,7 +2167,7 @@ int CmdHF14AMfELoad(const char *Cmd) {
|
|||
if (strlen(buf) < blockWidth){
|
||||
if(strlen(buf) && feof(f))
|
||||
break;
|
||||
PrintAndLog("File content error. Block data must include %d HEX symbols", blockWidth);
|
||||
PrintAndLog("[!] File content error. Block data must include %d HEX symbols", blockWidth);
|
||||
fclose(f);
|
||||
return 2;
|
||||
}
|
||||
|
@ -2180,7 +2177,7 @@ int CmdHF14AMfELoad(const char *Cmd) {
|
|||
buf8[i / 2] = tmp & 0xFF;
|
||||
}
|
||||
if (mfEmlSetMem_xt(buf8, blockNum, 1, blockWidth/2)) {
|
||||
PrintAndLog("Cant set emul block: %3d", blockNum);
|
||||
PrintAndLog("[!] Cant set emul block: %3d", blockNum);
|
||||
fclose(f);
|
||||
return 3;
|
||||
}
|
||||
|
@ -2195,16 +2192,16 @@ int CmdHF14AMfELoad(const char *Cmd) {
|
|||
// Ultralight /Ntag
|
||||
if ( blockWidth == 8 ) {
|
||||
if ((blockNum != numBlocks)) {
|
||||
PrintAndLog("Warning, Ultralight/Ntag file content, Loaded %d blocks into emulator memory", blockNum);
|
||||
PrintAndLog("[-] Warning, Ultralight/Ntag file content, Loaded %d blocks into emulator memory", blockNum);
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
if ((blockNum != numBlocks)) {
|
||||
PrintAndLog("Error, file content, Only loaded %d blocks, must be %d blocks into emulator memory", blockNum, numBlocks);
|
||||
PrintAndLog("[-] Error, file content, Only loaded %d blocks, must be %d blocks into emulator memory", blockNum, numBlocks);
|
||||
return 4;
|
||||
}
|
||||
}
|
||||
PrintAndLog("Loaded %d blocks from file: %s", blockNum, filename);
|
||||
PrintAndLog("[+] Loaded %d blocks from file: %s", blockNum, filename);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -2221,8 +2218,7 @@ int CmdHF14AMfESave(const char *Cmd) {
|
|||
|
||||
char c = param_getchar(Cmd, 0);
|
||||
|
||||
if ( c == 'h' || c == 'H')
|
||||
return usage_hf14_esave();
|
||||
if ( c == 'h' || c == 'H') return usage_hf14_esave();
|
||||
|
||||
switch (c) {
|
||||
case '0' : numBlocks = 5*4; break;
|
||||
|
@ -2244,7 +2240,7 @@ int CmdHF14AMfESave(const char *Cmd) {
|
|||
if (len < 1) {
|
||||
// get filename (UID from memory)
|
||||
if (mfEmlGetMem(buf, 0, 1)) {
|
||||
PrintAndLog("Can\'t get UID from block: %d", 0);
|
||||
PrintAndLog("[!] Can\'t get UID from block: %d", 0);
|
||||
len = sprintf(fnameptr, "dump");
|
||||
fnameptr += len;
|
||||
}
|
||||
|
@ -2263,14 +2259,14 @@ int CmdHF14AMfESave(const char *Cmd) {
|
|||
f = fopen(filename, "w+");
|
||||
|
||||
if ( !f ) {
|
||||
PrintAndLog("Can't open file %s ", filename);
|
||||
PrintAndLog("[!] Can't open file %s ", filename);
|
||||
return 1;
|
||||
}
|
||||
|
||||
// put hex
|
||||
for (i = 0; i < numBlocks; i++) {
|
||||
if (mfEmlGetMem(buf, i, 1)) {
|
||||
PrintAndLog("Cant get block: %d", i);
|
||||
PrintAndLog("[!] Cant get block: %d", i);
|
||||
break;
|
||||
}
|
||||
for (j = 0; j < 16; j++)
|
||||
|
@ -2280,7 +2276,7 @@ int CmdHF14AMfESave(const char *Cmd) {
|
|||
}
|
||||
printf("\n");
|
||||
fclose(f);
|
||||
PrintAndLog("Saved %d blocks to file: %s", numBlocks, filename);
|
||||
PrintAndLog("[+] Saved %d blocks to file: %s", numBlocks, filename);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -2293,7 +2289,7 @@ int CmdHF14AMfECFill(const char *Cmd) {
|
|||
return usage_hf14_ecfill();
|
||||
|
||||
if (c != 'a' && c != 'A' && c != 'b' && c != 'B') {
|
||||
PrintAndLog("Key type must be A or B");
|
||||
PrintAndLog("[!] Key type must be A or B");
|
||||
return 1;
|
||||
}
|
||||
if (c != 'A' && c != 'a') keyType = 1;
|
||||
|
@ -2326,7 +2322,7 @@ int CmdHF14AMfEKeyPrn(const char *Cmd) {
|
|||
PrintAndLog("|---|----------------|----------------|");
|
||||
for (i = 0; i < numSectors; i++) {
|
||||
if (mfEmlGetMem(data, FirstBlockOfSector(i) + NumBlocksPerSector(i) - 1, 1)) {
|
||||
PrintAndLog("error get block %d", FirstBlockOfSector(i) + NumBlocksPerSector(i) - 1);
|
||||
PrintAndLog("[!] error get block %d", FirstBlockOfSector(i) + NumBlocksPerSector(i) - 1);
|
||||
break;
|
||||
}
|
||||
keyA = bytes_to_num(data, 6);
|
||||
|
@ -2366,12 +2362,12 @@ int CmdHF14AMfCSetUID(const char *Cmd) {
|
|||
if (atqaPresent) {
|
||||
if (param_getchar(Cmd, argi)) {
|
||||
if (param_gethex(Cmd, argi, atqa, 4)) {
|
||||
PrintAndLog("ATQA must include 4 HEX symbols");
|
||||
PrintAndLog("[!] ATQA must include 4 HEX symbols");
|
||||
return 1;
|
||||
}
|
||||
argi++;
|
||||
if (!param_getchar(Cmd, argi) || param_gethex(Cmd, argi, sak, 2)) {
|
||||
PrintAndLog("SAK must include 2 HEX symbols");
|
||||
PrintAndLog("[!] SAK must include 2 HEX symbols");
|
||||
return 1;
|
||||
}
|
||||
argi++;
|
||||
|
@ -2390,12 +2386,12 @@ int CmdHF14AMfCSetUID(const char *Cmd) {
|
|||
|
||||
res = mfCSetUID(uid, (atqaPresent) ? atqa : NULL, (atqaPresent) ? sak : NULL, oldUid, wipeCard);
|
||||
if (res) {
|
||||
PrintAndLog("Can't set UID. error=%d", res);
|
||||
PrintAndLog("[!] Can't set UID. error=%d", res);
|
||||
return 1;
|
||||
}
|
||||
|
||||
PrintAndLog("old UID:%s", sprint_hex(oldUid, 4));
|
||||
PrintAndLog("new UID:%s", sprint_hex(uid, 4));
|
||||
PrintAndLog("[+] old UID:%s", sprint_hex(oldUid, 4));
|
||||
PrintAndLog("[+] new UID:%s", sprint_hex(uid, 4));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -2420,7 +2416,7 @@ int CmdHF14AMfCSetBlk(const char *Cmd) {
|
|||
|
||||
res = mfCSetBlock(blockNo, block, NULL, params);
|
||||
if (res) {
|
||||
PrintAndLog("Can't write block. error=%d", res);
|
||||
PrintAndLog("[!] Can't write block. error=%d", res);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
|
@ -2446,7 +2442,7 @@ int CmdHF14AMfCLoad(const char *Cmd) {
|
|||
if (fillFromEmulator) {
|
||||
for (blockNum = 0; blockNum < 16 * 4; blockNum += 1) {
|
||||
if (mfEmlGetMem(buf8, blockNum, 1)) {
|
||||
PrintAndLog("Cant get block: %d", blockNum);
|
||||
PrintAndLog("[!] Cant get block: %d", blockNum);
|
||||
return 2;
|
||||
}
|
||||
if (blockNum == 0) flags = MAGIC_INIT + MAGIC_WUPC; // switch on field and send magic sequence
|
||||
|
@ -2454,7 +2450,7 @@ int CmdHF14AMfCLoad(const char *Cmd) {
|
|||
if (blockNum == 16 * 4 - 1) flags = MAGIC_HALT + MAGIC_OFF; // Done. Magic Halt and switch off field.
|
||||
|
||||
if (mfCSetBlock(blockNum, buf8, NULL, flags)) {
|
||||
PrintAndLog("Cant set magic card block: %d", blockNum);
|
||||
PrintAndLog("[!] Cant set magic card block: %d", blockNum);
|
||||
return 3;
|
||||
}
|
||||
printf("."); fflush(stdout);
|
||||
|
@ -2474,7 +2470,7 @@ int CmdHF14AMfCLoad(const char *Cmd) {
|
|||
// open file
|
||||
f = fopen(filename, "r");
|
||||
if (f == NULL) {
|
||||
PrintAndLog("File not found or locked.");
|
||||
PrintAndLog("[!] File not found or locked.");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -2485,14 +2481,14 @@ int CmdHF14AMfCLoad(const char *Cmd) {
|
|||
|
||||
if (fgets(buf, sizeof(buf), f) == NULL) {
|
||||
fclose(f);
|
||||
PrintAndLog("File reading error.");
|
||||
PrintAndLog("[!] File reading error.");
|
||||
return 2;
|
||||
}
|
||||
|
||||
if (strlen(buf) < 32) {
|
||||
if(strlen(buf) && feof(f))
|
||||
break;
|
||||
PrintAndLog("File content error. Block data must include 32 HEX symbols");
|
||||
PrintAndLog("[!] File content error. Block data must include 32 HEX symbols");
|
||||
fclose(f);
|
||||
return 2;
|
||||
}
|
||||
|
@ -2506,7 +2502,7 @@ int CmdHF14AMfCLoad(const char *Cmd) {
|
|||
if (blockNum == 16 * 4 - 1) flags = MAGIC_HALT + MAGIC_OFF; // Done. Switch off field.
|
||||
|
||||
if (mfCSetBlock(blockNum, buf8, NULL, flags)) {
|
||||
PrintAndLog("Can't set magic card block: %d", blockNum);
|
||||
PrintAndLog("[!] Can't set magic card block: %d", blockNum);
|
||||
fclose(f);
|
||||
return 3;
|
||||
}
|
||||
|
@ -2520,10 +2516,10 @@ int CmdHF14AMfCLoad(const char *Cmd) {
|
|||
|
||||
// 64 or 256blocks.
|
||||
if (blockNum != 16 * 4 && blockNum != 32 * 4 + 8 * 16){
|
||||
PrintAndLog("File content error. There must be 64 blocks");
|
||||
PrintAndLog("[!] File content error. There must be 64 blocks");
|
||||
return 4;
|
||||
}
|
||||
PrintAndLog("Loaded %d blocks from file: %s", blockNum, filename);
|
||||
PrintAndLog("[+] Loaded %d blocks from file: %s", blockNum, filename);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -2542,7 +2538,7 @@ int CmdHF14AMfCGetBlk(const char *Cmd) {
|
|||
|
||||
res = mfCGetBlock(blockNo, data, MAGIC_SINGLE);
|
||||
if (res) {
|
||||
PrintAndLog("Can't read block. error=%d", res);
|
||||
PrintAndLog("[!] Can't read block. error=%d", res);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -2560,7 +2556,7 @@ int CmdHF14AMfCGetSc(const char *Cmd) {
|
|||
|
||||
sector = param_get8(Cmd, 0);
|
||||
if (sector > 39) {
|
||||
PrintAndLog("Sector number must be less then 40");
|
||||
PrintAndLog("[!] Sector number must be less then 40");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -2581,7 +2577,7 @@ int CmdHF14AMfCGetSc(const char *Cmd) {
|
|||
|
||||
res = mfCGetBlock( start + i, data, flags);
|
||||
if (res) {
|
||||
PrintAndLog("Can't read block. %d error=%d", start + i, res);
|
||||
PrintAndLog("[!] Can't read block. %d error=%d", start + i, res);
|
||||
return 1;
|
||||
}
|
||||
PrintAndLog("%3d | %s", start + i, sprint_hex(data, 16));
|
||||
|
@ -2624,14 +2620,14 @@ int CmdHF14AMfCSave(const char *Cmd) {
|
|||
case '2':
|
||||
case '4':
|
||||
numblocks = NumOfBlocks(ctmp);
|
||||
PrintAndLog("Saving magic mifare %cK", ctmp);
|
||||
PrintAndLog("[+] Saving magic mifare %cK", ctmp);
|
||||
cmdp++;
|
||||
break;
|
||||
case 'u':
|
||||
case 'U':
|
||||
// get filename based on UID
|
||||
if (mfCGetBlock(0, buf, MAGIC_SINGLE)) {
|
||||
PrintAndLog("Cant get block: %d", 0);
|
||||
PrintAndLog("[-] Cant get block: %d", 0);
|
||||
femlptr += sprintf(femlptr, "dump");
|
||||
fbinptr += sprintf(fbinptr, "dump");
|
||||
} else {
|
||||
|
@ -2663,7 +2659,7 @@ int CmdHF14AMfCSave(const char *Cmd) {
|
|||
cmdp += 2;
|
||||
break;
|
||||
default:
|
||||
PrintAndLog("Unknown parameter '%c'", param_getchar(Cmd, cmdp));
|
||||
PrintAndLog("[!] Unknown parameter '%c'", param_getchar(Cmd, cmdp));
|
||||
errors = true;
|
||||
break;
|
||||
}
|
||||
|
@ -2683,12 +2679,12 @@ int CmdHF14AMfCSave(const char *Cmd) {
|
|||
if (i == numblocks - 1) flags = MAGIC_HALT + MAGIC_OFF;
|
||||
|
||||
if (mfCGetBlock(i, buf, flags)) {
|
||||
PrintAndLog("Cant get block: %d", i);
|
||||
PrintAndLog("[!] Cant get block: %d", i);
|
||||
return 3;
|
||||
}
|
||||
|
||||
if (mfEmlSetMem(buf, i, 1)) {
|
||||
PrintAndLog("Cant set emul block: %d", i);
|
||||
PrintAndLog("[!] Cant set emul block: %d", i);
|
||||
return 3;
|
||||
}
|
||||
printf("."); fflush(stdout);
|
||||
|
@ -2701,12 +2697,12 @@ int CmdHF14AMfCSave(const char *Cmd) {
|
|||
sprintf(fbinptr, ".bin");
|
||||
|
||||
if ((feml = fopen(filename[0], "w+")) == NULL ) {
|
||||
PrintAndLog("File not found or locked");
|
||||
PrintAndLog("[!] File not found or locked");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if ((fbin = fopen(filename[1], "wb")) == NULL) {
|
||||
PrintAndLog("File not found or locked");
|
||||
PrintAndLog("[!] File not found or locked");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -2717,7 +2713,7 @@ int CmdHF14AMfCSave(const char *Cmd) {
|
|||
if (i == numblocks - 1) flags = MAGIC_HALT + MAGIC_OFF;
|
||||
|
||||
if (mfCGetBlock(i, buf, flags)) {
|
||||
PrintAndLog("Cant get block: %d", i);
|
||||
PrintAndLog("[!] Cant get block: %d", i);
|
||||
break;
|
||||
}
|
||||
// eml
|
||||
|
@ -2734,7 +2730,7 @@ int CmdHF14AMfCSave(const char *Cmd) {
|
|||
fclose(feml); fclose(fbin);
|
||||
|
||||
for (uint8_t i=0; i<2; ++i)
|
||||
PrintAndLog("Saved %d blocks to file: %s", numblocks, filename[i]);
|
||||
PrintAndLog("[+] Saved %d blocks to file: %s", numblocks, filename[i]);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -2751,7 +2747,7 @@ int CmdHf14AMfDecryptBytes(const char *Cmd){
|
|||
|
||||
int len = param_getlength(Cmd, 3);
|
||||
if (len & 1 ) {
|
||||
PrintAndLog("Uneven hex string length. LEN=%d", len);
|
||||
PrintAndLog("[!] Uneven hex string length. LEN=%d", len);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -2796,9 +2792,9 @@ int CmdHf14AMfSetMod(const char *Cmd) {
|
|||
uint8_t ok = resp.arg[0] & 0xff;
|
||||
PrintAndLog("isOk:%02x", ok);
|
||||
if (!ok)
|
||||
PrintAndLog("Failed.");
|
||||
PrintAndLog("[-] Failed.");
|
||||
} else {
|
||||
PrintAndLog("Command execute timeout");
|
||||
PrintAndLog("[!] Command execute timeout");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue